PageSourceSearch

https://zedastro.lovable.app/assets/PhotoPointsNearby-Y150Q677.js

js zedastro.lovable.app collected 2026-10-03 03:47:11 UTC 202,637 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/enhancedReverseGeocoding-C3sKkwIS.js","assets/vendor-framework-B2PzffdG.js","assets/index-H_Ttc-JF.js","assets/vendor-supabase-doSO1MX1.js","assets/vendor-ui-primitives-CFWWya1M.js","assets/vendor-utils-DC8M5gYj.js","assets/vendor-ui-motion-Cv12dV9o.js","assets/vendor-forms-BUMX7aPz.js","assets/index-Dn6aVUmx.css","assets/providerPreference-BS7T_2tE.js","assets/nearestTownCalculator-Kx9oaLMr.js","assets/locationDatabase-MleriTcW.js","assets/geoUtils-8Agboysf.js","assets/chinaCityLocations-DBM4CF2U.js","assets/locationFinder-Dfl7v1uy.js","assets/bortleScaleUtils-CoQoybhV.js","assets/locationWaterCheck-DOmiwUyx.js","assets/chinaBortleData-BgRdfXBp.js","assets/astroSpots-CZ76xRmE.js","assets/forecast-B6KNVlvE.js"])))=>i.map(i=>d[i]);
2var e=Object.defineProperty,t=(t,a,n)=>((t,a,n)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[a]=n)(t,"symbol"!=typeof a?a+"":a,n);import{j as a,R as n,r as i,t as o,_ as r,y as s,L as l}from"./vendor-framework-B2PzffdG.js";import{u as c,H as d,N as u,a as m,L as h,T as g,b as f,c as p,d as y,D as x,e as S,f as k,g as b,o as w,h as v,B as N,j as D,I as C,s as j,k as L,l as M,m as R,p as I,q as A,r as $,t as E,P as T}from"./index-H_Ttc-JF.js";import{m as F,ak as O,j as q,_ as P,aO as _,aP as z,aL as V,w as B,aQ as U,a8 as H,aR as G,aS as W,aT as Z,aU as Q,aV as J,ap as Y,a5 as K,A as X,i as ee,aW as te,aX as ae,F as ne,aY as ie,aZ as oe,R as re,S as se,a_ as le,a$ as ce,y as de,b0 as ue,B as me,b1 as he,b2 as ge,b3 as fe,b4 as pe,g as ye,b5 as xe}from"./vendor-ui-motion-Cv12dV9o.js";import{H as Se}from"./hoth-slider-BOeyXQec.js";import{p as ke,P as be,u as we,L as ve,C as Ne}from"./PhotoLocationCard-B9NwLy-X.js";import{c as De,a as Ce,b as je,n as Le,l as Me}from"./siqsCalculator-DYugX_R-.js";import"./suncalc-83nwNwsX.js";import{u as Re}from"./vendor-ui-primitives-CFWWya1M.js";import{L as Ie,P as Ae,M as $e,u as Ee,l as Te,a as Fe,T as Oe,C as qe}from"./vendor-maps-BclC1Gt6.js";import{g as Pe,c as _e}from"./MapMarkerUtils-BDKvDimi.js";import{c as ze,f as Ve}from"./geoUtils-8Agboysf.js";import{i as Be,g as Ue}from"./astroSpots-CZ76xRmE.js";import{g as He,a as Ge,b as We,c as Ze,d as Qe,R as Je,i as Ye,s as Ke,e as Xe,f as et,n as tt}from"./RealTimeSiqsProvider-DmCvnrza.js";import{u as at,L as nt,U as it,b as ot,A as rt,c as st,a as lt,d as ct,e as dt,T as ut,f as mt,M as ht,g as gt,h as ft,i as pt,v as yt,j as xt,p as St,k as kt}from"./LocationNameService-CR_gU7GF.js";import{U as bt,L as wt}from"./LocationCard-C8rHgdkn.js";import{g as vt,f as Nt}from"./unifiedBortleService-BeTEY11m.js";import"./TileConverter-BszUHU33.js";import{S as Dt}from"./slider-znad8psd.js";import{C as Ct,u as jt}from"./CreateAstroSpotDialog-BLupcBgS.js";import{L as Lt}from"./lightPollutionConfig-l0MnJuLk.js";import{S as Mt}from"./skeleton-CcG16koJ.js";import Rt from"./AdBanner-DwREyNap.js";import{u as It}from"./useGeolocation-Duv6bWEE.js";import{getEnhancedLocationDetails as At}from"./enhancedReverseGeocoding-C3sKkwIS.js";import{a as $t,b as Et,v as Tt}from"./vendor-utils-DC8M5gYj.js";import{u as Ft}from"./useGeocodedAddress-BaNYeuOQ.js";import{f as Ot}from"./clearSkyRate-BxEOP5ZY.js";import{g as qt,s as Pt}from"./locationStorage-C0urCfSW.js";import{searchLocations as _t}from"./searchLocations-De5T7xjo.js";import{P as zt}from"./progress-BHAQWESz.js";import{t as Vt}from"./use-toast-DEowTB2y.js";import{g as Bt,a as Ut,b as Ht,c as Gt}from"./naturalWondersService-NA0npYAd.js";import{S as Wt,a as Zt,b as Qt,c as Jt,d as Yt}from"./select-DsBAWzxS.js";import"./vendor-supabase-doSO1MX1.js";import"./vendor-forms-BUMX7aPz.js";import"./nearestTownCalculator-Kx9oaLMr.js";import"./locationDatabase-MleriTcW.js";import"./chinaCityLocations-DBM4CF2U.js";import"./locationFinder-Dfl7v1uy.js";import"./bortleScaleUtils-CoQoybhV.js";import"./SiqsScoreBadge-gue8glvM.js";import"./forecast-B6KNVlvE.js";import"./locationWaterCheck-DOmiwUyx.js";import"./useCreatorProfile-CNoIqiY2.js";import"./VerificationBadge-CEbaX9UR.js";import"./upload-progress-DpS1Yej_.js";import"./enhancedCache-CD2jHVCB.js";import"./useAdvertisements-CCmFSK87.js";import"./providerPreference-BS7T_2tE.js";import"./chinaBortleData-BgRdfXBp.js";const Kt=({children:e,pageTitle:t})=>{const{t:n}=c(),i=t||n("Photo Points Nearby | Sky Viewer","附近拍摄点 | 天空观测");return a.jsxs("div",{className:"relative min-h-screen overflow-x-hidden",children:[a.jsx(d,{children:a.jsx("title",{children:i})}),a.jsx(u,{}),a.jsx("div",{className:"relative pt-16 sm:pt-20 md:pt-28 pb-12 sm:pb-20 will-change-transform z-10",children:a.jsx("div",{className:"w-full max-w-none px-[1px] sm:mx-auto sm:px-4",children:e})})]})},Xt=({children:e,onClick:t,onDoubleClick:n,tooltip:i,ariaLabel:o})=>{const r=a.jsxs(F.button,{onClick:t,onDoubleClick:n,"aria-label":o,className:"group relative flex items-center justify-center w-12 h-12 md:w-14 md:h-14 roun
2ded-xl bg-cosmic-900/60 hover:bg-cosmic-800/80 backdrop-blur-md shadow-[0_0_12px_rgba(103,232,249,0.15),inset_0_0_20px_rgba(103,232,249,0.05)] hover:shadow-[0_0_24px_rgba(103,232,249,0.35),inset_0_0_30px_rgba(103,232,249,0.12)] transition-all duration-300",whileHover:{scale:1.06},whileTap:{scale:.94},children:[a.jsx("span",{className:"absolute inset-0 rounded-xl opacity-20 pointer-events-none",style:{backgroundImage:"linear-gradient(90deg, hsl(var(--primary)) 1px, transparent 1px), linear-gradient(0deg, hsl(var(--primary)) 1px, transparent 1px)",backgroundSize:"8px 8px",maskImage:"radial-gradient(circle, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%)",WebkitMaskImage:"radial-gradient(circle, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%)"}}),a.jsx("span",{className:"absolute inset-0 rounded-xl overflow-hidden pointer-events-none opacity-40",children:a.jsx("span",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-primary/20 to-transparent -translate-y-full group-hover:translate-y-full transition-transform duration-700 ease-in-out"})}),e]});return i?a.jsx(g,{children:a.jsxs(f,{children:[a.jsx(p,{asChild:!0,children:r}),a.jsx(y,{side:"bottom",className:"max-w-xs",children:a.jsx("p",{className:"text-xs",children:i})})]})}):r},ea=({userLocation:e,locationLoading:t,getPosition:n,showMapToggle:i=!1,showMap:o=!0,toggleMapView:r,refreshMarkers:s,viewToggle:l,action:d,title:u,description:g})=>{const{t:f}=c(),p=m();return a.jsx(F.div,{initial:"hidden",animate:"visible",variants:{hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{duration:.5}}},children:a.jsxs("div",{className:"group flex flex-col items-center text-center mb-8",children:[a.jsxs("div",{className:"flex flex-col items-center cursor-default mb-3",children:[a.jsx(F.h1,{className:`relative ${p?"text-3xl":"text-4xl md:text-5xl"} font-bold uppercase tracking-[0.22em] leading-none text-cyan-100 drop-shadow-[0_0_14px_rgba(34,211,238,0.55)] transition-all duration-300 group-hover:drop-shadow-[0_0_22px_rgba(34,211,238,0.85)]`,variants:{hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{delay:.3,duration:.5}}},children:a.jsx("span",{className:"bg-clip-text text-transparent bg-gradient-to-b from-cyan-50 via-cyan-200 to-cyan-400",children:u??f("Dark Mapper","暗图")})}),a.jsx(F.div,{className:"h-px bg-gradient-to-r from-transparent via-cyan-200 to-transparent shadow-[0_0_10px_rgba(34,211,238,0.9)] mx-auto mt-4 rounded-full",initial:{width:0,opacity:0},animate:{width:120,opacity:1},transition:{delay:.4,duration:.6}})]}),t&&a.jsxs("div",{className:"flex items-center text-sm text-cyan-200/70 mb-3",children:[a.jsx(h,{className:"w-3 h-3 mr-1 animate-spin"}),f("Getting location...","正在获取位置...")]}),a.jsxs("div",{className:"hidden md:flex items-center gap-1.5 text-[0.7rem] font-medium uppercase tracking-[0.2em] text-cyan-200/50 mt-3 transition-opacity duration-300 group-hover:opacity-0",children:[a.jsx("span",{className:"h-1 w-1 rotate-45 bg-cyan-300/70"}),f("Hover for details","悬停查看详情"),a.jsx("span",{className:"h-1 w-1 rotate-45 bg-cyan-300/70"})]}),a.jsx("div",{className:"grid transition-all duration-500 ease-out md:grid-rows-[0fr] md:opacity-0 md:mt-0 md:group-hover:grid-rows-[1fr] md:group-hover:opacity-100 md:group-hover:mt-3 grid-rows-[1fr] opacity-100 mt-3",children:a.jsx("div",{className:"overflow-hidden",children:a.jsx("p",{className:"text-cyan-100/70 max-w-xl mx-auto",children:g??f("Discover extraordinary locations for night sky photography near you. Switch between categories to explore certified dark sky preserves, calculated optimal spots, mountain peaks, and unique wonders.","发现您附近非凡的夜空摄影地点。在类别之间切换,探索认证暗夜保护区、计算的最佳地点、山峰和独特奇观。")})})})]})})},ta=({activeView:e,onViewChange:t,loading:n=!1})=>{const{t:i}=c(),o=[{value:"certified",label:i("Dark Sky Locations","暗夜天空位置"),icon:O},{value:"calculated",label:i("Recommended Near Me","附近推荐"),icon:q},{value:"obscura",label:i("Obscura Locations","奇观位置"),icon:P},{value:"mountains",label:i("Natural Locations","自然位置"),icon:_},{value:"darksky",label:i("Dark Sky Reserves","暗夜保护区"),icon:z},{value:"natural-wonders",label:i("Natural Wonders","自然奇观"),icon:V},{value:"astrospots",label:i("Astrospots","观星点"),icon:B}];return a.jsx(g,{children:a.jsxs(x,{children:[a.jsxs(f,{children:[a.jsx(p,{asChild:!0,children:a.jsx(S,{asChild:!0,disabled:n,children:a.jsxs(F.button,{className:"group relative flex items-center justify-center w-12 h-12 md:w-14 md:h-14 roun
2ded-xl bg-cosmic-900/60 hover:bg-cosmic-800/80 backdrop-blur-md shadow-[0_0_12px_rgba(103,232,249,0.15),inset_0_0_20px_rgba(103,232,249,0.05)] hover:shadow-[0_0_24px_rgba(103,232,249,0.35),inset_0_0_30px_rgba(103,232,249,0.12)] transition-all duration-300",whileHover:{scale:1.06},whileTap:{scale:.94},children:[a.jsx("span",{className:"absolute inset-0 rounded-xl opacity-20 pointer-events-none",style:{backgroundImage:"linear-gradient(90deg, hsl(var(--primary)) 1px, transparent 1px), linear-gradient(0deg, hsl(var(--primary)) 1px, transparent 1px)",backgroundSize:"8px 8px",maskImage:"radial-gradient(circle, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%)",WebkitMaskImage:"radial-gradient(circle, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 70%)"}}),a.jsx("span",{className:"absolute inset-0 rounded-xl overflow-hidden pointer-events-none opacity-40",children:a.jsx("span",{className:"absolute inset-0 bg-gradient-to-b from-transparent via-primary/20 to-transparent -translate-y-full group-hover:translate-y-full transition-transform duration-700 ease-in-out"})}),a.jsx(U,{className:"h-5 w-5 md:h-6 md:w-6 relative z-10 rotate-90 text-emerald-400",strokeWidth:2.5})]})})}),a.jsx(y,{side:"bottom",className:"max-w-xs",children:a.jsx("p",{className:"text-xs",children:i("Select map filter here","在此选择地图过滤器")})})]}),a.jsx(k,{align:"start",className:"w-56 bg-cosmic-900/95 backdrop-blur-md border-cosmic-700/50 z-[9999]",children:o.map(({value:n,label:i,icon:o})=>a.jsxs(b,{onClick:()=>{var a;(a=n)!==e&&t(a)},disabled:e===n,className:"cursor-pointer",children:[a.jsx(o,{className:"mr-2 h-4 w-4"}),a.jsx("span",{className:e===n?"font-medium text-primary":"",children:i})]},n))})]})})},aa=n.memo(({currentValue:e,onValueChange:t,minValue:i=100,maxValue:o=1e3,stepValue:r=100,loading:s=!1,loadingComplete:l=!1})=>{const{t:d}=c(),u=e=>`${e.toFixed(0)}${d("km","公里")}`,m=n.useCallback(e=>{t(e[0])},[t]),h=(e-i)/(o-i)*100;return a.jsxs(F.div,{className:"glassmorphism backdrop-blur-md bg-cosmic-900/40 border border-cosmic-700/40 p-4 rounded-lg relative overflow-hidden",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.2},children:[a.jsx("div",{className:"absolute top-0 left-0 w-full h-0.5 bg-gradient-to-r from-transparent via-primary/30 to-transparent"}),a.jsx("div",{className:"absolute bottom-0 left-0 w-full h-0.5 bg-gradient-to-r from-transparent via-primary/30 to-transparent"}),a.jsx("div",{className:"absolute left-0 top-0 w-0.5 h-full bg-gradient-to-b from-transparent via-primary/30 to-transparent"}),a.jsx("div",{className:"absolute right-0 top-0 w-0.5 h-full bg-gradient-to-b from-transparent via-primary/30 to-transparent"}),a.jsxs("div",{className:"flex justify-between items-center mb-2",children:[a.jsxs("div",{className:"text-sm text-muted-foreground flex items-center",children:[s?a.jsx(H,{className:"h-3.5 w-3.5 mr-1.5 animate-spin text-primary"}):l?a.jsx(G,{className:"h-3.5 w-3.5 mr-1.5 text-green-500 transition-colors duration-300"}):a.jsx(H,{className:"h-3.5 w-3.5 mr-1.5 text-primary/80"}),d("Move the slider to expand your search radius and discover more photo spots!","移动滑块以扩大搜索半径并发现更多摄影点!")]}),a.jsxs(F.div,{className:"flex items-center gap-1.5 text-primary font-medium bg-background/20 px-2 py-0.5 rounded-md border border-primary/20",whileHover:{scale:1.05},transition:{type:"spring",stiffness:400,damping:10},children:[a.jsx(q,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"text-sm",children:u(e)})]})]}),a.jsxs("div",{className:"relative mt-2",children:[a.jsx(Se,{value:[e],min:i,max:o,step:r,onValueChange:m,className:"mt-2 z-10 relative transition-all duration-200 ease-out"}),a.jsx(F.div,{className:"absolute top-2.5 left-0 h-2 rounded-full transition-all duration-200 ease-out\n            "+(s?"bg-gradient-to-r from-primary/60 to-transparent":l?"bg-gradient-to-r from-green-500/60 to-transparent":"bg-gradient-to-r from-primary/60 to-transparent"),style:{width:`${h}%`,transition:"width 200ms ease-out, opacity 300ms ease-in-out, box-shadow 300ms ease-in-out"},animate:{opacity:s?[.3,1,.3]:l?[.6,1]:[.6,1,.6],boxShadow:s?["0 0 2px rgba(139, 92, 246, 0.2)","0 0 12px rgba(139, 92, 246, 0.8)","0 0 2px rgba(139, 92, 246, 0.2)"]:l?["0 0 2px rgba(34, 197, 94, 0.3)","0 0 8px rgba(34, 197, 94, 0.6)"]:["0 0 2px rgba(139, 92, 246, 0.3)","0 0 8px rgba(139, 92, 246, 0.6)","0 0 2px rgba(139, 92, 246, 0.3)"]},transition:{duration:s?1:l?.5:2,repeat:s||!l?1/0:0,ease:"easeInOut"}})]}),a.jsxs("div",{className:"flex justify-between mt-1.5",children:[a.jsx(F.div,{className:"text-xs text-muted-foreground",whileHover:{color:"rgba(139, 92, 246, 0.8)"},children:u(i)}),a.jsx(F.div,{className:"text-xs text-muted-foreground",whileHover:{color:"rgba(139, 92, 246, 0.8)"},children:u(o)})]}),a.jsx("div",{className:"relative h-1 mt-1",children:Array.from({length:(o-i)/r+1}).map((t,n)=>a.jsx("div",{className:"absolute h-1 w-0.5 transition-all duration-200 ease-out "+(n*r+i<=e?"bg-primary/60":"bg-muted/40"),style:{left:n*r/(o-i)*100+"%",transition:"background-color 200ms ease-out"}},n))})]})}),na=new Map;function ia(e){e&&e.id&&na.set(e.id,e)}let oa=null,ra=0;async function sa(){try{const t=localStorage.getItem("cachedCertifiedLocations");
2if(t)try{const e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return oa=e,setTimeout(()=>la(),2e3),e}catch(e){}return la()}catch(e){return[]}}async function la(){try{const{findCertifiedLocations:t}=await r(async()=>{const{findCertifiedLocations:e}=await Promise.resolve().then(()=>jn);return{findCertifiedLocations:e}},void 0),a=[{latitude:39.9042,longitude:116.4074},{latitude:51.5074,longitude:-.1278},{latitude:40.7128,longitude:-74.006},{latitude:-33.8688,longitude:151.2093},{latitude:-1.2921,longitude:36.8219}].map(e=>t(e.latitude,e.longitude,2e4,500)),n=await Promise.all(a),i=new Map;n.forEach(e=>{e.forEach(e=>{if(e.latitude&&e.longitude){const t=`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;i.set(t,e)}})});const o=function(e){const t=new Map;return e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.set(a,e)}),[{id:"castle-baroness-scoppa",name:"Castle of Baroness Scoppa",chineseName:"斯科帕女男爵城堡",latitude:38.6009,longitude:16.4028,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:5,siqs:6.5},{id:"butterflies-maj",name:"Butterflies on Máj",chineseName:"马耶的蝴蝶",latitude:50.0822,longitude:14.4199,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:6,siqs:5.2},{id:"suicide-cemetery",name:"The Suicide Cemetery",chineseName:"自杀者墓地",latitude:52.4967,longitude:13.2032,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:6,siqs:5},{id:"church-our-lady",name:"Church of Our Lady",chineseName:"圣母教堂",latitude:55.6804,longitude:11.0808,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:5,siqs:6.8},{id:"fu-lu-shou-complex",name:"Fu Lu Shou Complex",chineseName:"福禄寿综合体",latitude:1.3017,longitude:103.8546,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:7,siqs:4.5},{id:"trojan-horse",name:"Çanakkale Trojan Horse",chineseName:"恰纳卡莱特洛伊木马",latitude:40.1519,longitude:26.4051,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:5,siqs:6},{id:"wied-il-ghasri",name:"Wied il-Għasri",chineseName:"维埃德伊尔加斯里",latitude:36.0787,longitude:14.2284,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:4,siqs:7.5},{id:"marjuns-lifting-stone",name:"Marjun's Lifting Stone",chineseName:"马容举石",latitude:62.3352,longitude:-6.7654,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:4,siqs:8},{id:"mingo-gc30",name:"Mingo GC30",chineseName:"明戈GC30",latitude:39.278,longitude:-100.9437,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:3,siqs:8.5},{id:"pere-cheney-cemetery",name:"Pere Cheney Cemetery",chineseName:"佩雷切尼墓地",latitude:44.5434,longitude:-84.7221,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:4,siqs:7.8},{id:"tianzi-hotel",name:"Tianzi Hotel",chineseName:"天子大酒店",latitude:30.7642,longitude:114.9431,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:7,siqs:4.2},{id:"forbidden-city",name:"The Forbidden City",chineseName:"故宫",latitude:39.9163,longitude:116.3972,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:8,siqs:3.5},{id:"jiuzhaigou-valley",name:"Jiuzhaigou Valley",chineseName:"九寨沟",latitude:33.26,longitude:103.92,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:3,siqs:8.8},{id:"park-street-station",name:"Park Street Station Mural",chineseName:"公园街站壁画",latitude:42.3564,longitude:-71.0625,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:8,siqs:3},{id:"willie-whale",name:"Willie the Whale",chineseName:"鲸鱼威利",latitude:40.485,longitude:-86.139,isDarkSkyReserve:!1,certification:"Atlas Obscura Location",timestamp:(new Date).toISOString(),bortleScale:6,siqs:5.5}
2].forEach(e=>{const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.has(a)||t.set(a,e)}),Array.from(t.values())}(function(e){const t=new Map;return e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.set(a,e)}),[{id:"aoraki-mackenzie-reserve",name:"Aoraki Mackenzie International Dark Sky Reserve",chineseName:"奥拉基麦肯齐国际暗夜天空保护区",latitude:-43.9856,longitude:170.4639,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"brecon-beacons-reserve",name:"Brecon Beacons National Park International Dark Sky Reserve",chineseName:"布雷肯比肯斯国家公园国际暗夜天空保护区",latitude:51.8828,longitude:-3.4322,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"central-idaho-reserve",name:"Central Idaho Dark Sky Reserve",chineseName:"爱达荷中部暗夜天空保护区",latitude:44.221,longitude:-114.9318,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"cranborne-chase-reserve",name:"Cranborne Chase International Dark Sky Reserve",chineseName:"克兰伯恩蔡斯国际暗夜天空保护区",latitude:51.029,longitude:-2.137,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"exmoor-reserve",name:"Exmoor National Park International Dark Sky Reserve",chineseName:"埃克斯穆尔国家公园国际暗夜天空保护区",latitude:51.1407,longitude:-3.6118,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"kerry-reserve",name:"Kerry International Dark Sky Reserve",chineseName:"克里国际暗夜天空保护区",latitude:51.948,longitude:-10.2293,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"mont-megantic-reserve",name:"Mont-Mégantic International Dark Sky Reserve",chineseName:"梅甘蒂克山国际暗夜天空保护区",latitude:45.4555,longitude:-71.1522,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"moore-reserve",name:"Moore's Reserve (South Downs)",chineseName:"摩尔暗夜天空保护区(南唐斯)",latitude:50.916,longitude:-.6067,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"namib-rand-reserve",name:"NamibRand International Dark Sky Reserve",chineseName:"纳米布兰德国际暗夜天空保护区",latitude:-24.94,longitude:16.06,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"pic-du-midi-reserve",name:"Pic du Midi International Dark Sky Reserve",chineseName:"米迪峰国际暗夜天空保护区",latitude:42.9372,longitude:.1413,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"rhon-reserve",name:"Rhön International Dark Sky Reserve",chineseName:"伦国际暗夜天空保护区",latitude:50.3492,longitude:9.9675,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"river-murray-reserve",name:"River Murray International Dark Sky Reserve",chineseName:"墨累河国际暗夜天空保护区",latitude:-34.4048,longitude:139.2851,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"snowdonia-reserve",name:"Snowdonia National Park International Dark Sky Reserve",chineseName:"斯诺多尼亚国家公园国际暗夜天空保护区",latitude:52.9493,longitude:-3.8872,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"wairarapa-reserve",name:"Wairarapa International Dark Sky Reserve",chineseName:"怀拉拉帕国际暗夜天空保护区",latitude:-41.3446,longitude:175.544,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"westhavelland-reserve",name:"Westhavelland International Dark Sky Reserve",chineseName:"西哈弗尔兰国际暗夜天空保护区",latitude:52.6967,longitude:12.3086,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"winlaton-reserve",name:"Northumberland International Dark Sky Park",chineseName:"诺森伯兰国际暗夜天空公园",latitude:55.3,longitude:-2.33,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"aotea-sanctuary",name:"Aotea / Great Barrier Island International Dark Sky Sanctuary",chineseName:"奥特亚/å¤
2§å ¡ç¤å²›å›½é™…暗夜天空保护区",latitude:-36.2058,longitude:175.4831,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"boundary-waters-sanctuary",name:"Boundary Waters Canoe Area Wilderness",chineseName:"边界水域皮划艇区域荒野",latitude:47.8297,longitude:-91.4884,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"cosmic-campground-sanctuary",name:"Cosmic Campground International Dark Sky Sanctuary",chineseName:"宇宙营地国际暗夜天空保护区",latitude:33.4733,longitude:-108.9225,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"gabriela-mistral-sanctuary",name:"Gabriela Mistral Dark Sky Sanctuary",chineseName:"加布里埃拉·米斯特拉尔暗夜天空保护区",latitude:-30.2451,longitude:-70.7342,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"massacre-rim-sanctuary",name:"Massacre Rim Dark Sky Sanctuary",chineseName:"大屠杀边缘暗夜天空保护区",latitude:41.5683,longitude:-119.7522,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"pitcairn-islands-sanctuary",name:"Pitcairn Islands Dark Sky Sanctuary",chineseName:"皮特凯恩群岛暗夜天空保护区",latitude:-25.0667,longitude:-130.1,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"rainbow-bridge-sanctuary",name:"Rainbow Bridge National Monument Dark Sky Sanctuary",chineseName:"彩虹桥国家纪念碑暗夜天空保护区",latitude:37.0772,longitude:-110.9639,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"stewarts-point-sanctuary",name:"The Jump-Off Dark Sky Sanctuary",chineseName:"跳跃点暗夜天空保护区",latitude:34.7666,longitude:-92.4813,isDarkSkyReserve:!0,certification:"Dark Sky Sanctuary - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"anza-borrego-park",name:"Anza-Borrego Desert State Park",chineseName:"安扎-博雷戈沙漠州立公园",latitude:33.255,longitude:-116.3763,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"arches-park",name:"Arches National Park",chineseName:"拱门国家公园",latitude:38.7331,longitude:-109.5925,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"big-bend-park",name:"Big Bend National Park",chineseName:"大弯国家公园",latitude:29.2498,longitude:-103.2502,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"black-canyon-park",name:"Black Canyon of the Gunnison National Park",chineseName:"甘尼森峡谷国家公园",latitude:38.5754,longitude:-107.7416,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"bryce-canyon-park",name:"Bryce Canyon National Park",chineseName:"布莱斯峡谷国家公园",latitude:37.6283,longitude:-112.1677,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"canyonlands-park",name:"Canyonlands National Park",chineseName:"峡谷地国家公园",latitude:38.2136,longitude:-109.9025,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"capitol-reef-park",name:"Capitol Reef National Park",chineseName:"圆顶礁国家公园",latitude:38.2821,longitude:-111.2471,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"chaco-culture-park",name:"Chaco Culture National Historical Park",chineseName:"查科文化国家历史公园",latitude:36.0319,longitude:-107.9698,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"death-valley-park",name:"Death Valley National Park",chineseName:"死亡谷国家公园",latitude:36.5323,longitude:-116.9325,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"dinosaur-park",name:"Dinosaur National Monument",chineseName:"恐龙国家纪念碑",latitude:40.5435,longitude:-108.9986,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"grand-canyon-park",name:"Grand Canyon National Park",chineseName:"大峡谷国家公园",latitude:36.1069,longitude:-112.1129,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"great-basin-park",name:"Great Basin National Park",chineseName:"大盆地国家公园",latitude:38.95,longitude:-114.26,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:1},{id:"joshua-tree-park",name:"Joshua Tree National Park",chineseName:"约书亚树国家公园",latitude:33.8734,longitude:-115.901,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"mesa-verde-park",name:"Mesa Verde National Park",chineseName:"梅萨维德国家公园",latitude:37.2308,longitude:-108.4618,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"natural-bridges-park",name:"Natural Bridges National Monument",chineseName:"天然桥国家纪念碑",latitude:37.6087,longitude:-109.9753,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"petrified-forest-park",name:"Petrified Forest National Park",chineseName:"石化森林国家公园",latitude:35.0865,longitude:-109.782,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"salinas-pueblo-park",name:"Salinas Pueblo Missions National Monument",chineseName:"萨莱纳斯普韦布洛使团国家纪念碑",latitude:34.2598,longitude:-106.0907,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"sark-park",name:"Sark International Dark Sky Community",chineseName:"萨克国际暗夜天空社区",latitude:49.4327,longitude:-2.3641,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"stelvio-park",name:"Stelvio National Park",chineseName:"斯泰尔维奥国家公园",latitude:46.4983,longitude:10.5415,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"waterton-glacier-park",name:"Waterton-Glacier International Peace Park",chineseName:"沃特顿-冰川国际和平公园",latitude:48.7596,longitude:-113.787,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"zselic-park",name:"Zselic National Landscape Protection Area",chineseName:"泽利茨国家景观保护区",latitude:46.2368,longitude:17.766,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2}
2].forEach(e=>{const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.has(a)||t.set(a,e)}),Array.from(t.values())}(function(e){const t=new Map;return e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.set(a,e)}),[{id:"under-canvas-mt",name:"Under Canvas Mount Rushmore",chineseName:"拉什莫尔山露营地暗夜天空点",latitude:43.8791,longitude:-103.4591,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:3,type:"lodging"},{id:"gateway-canyons",name:"Gateway Canyons Resort",chineseName:"峡谷之门度假村暗夜天空点",latitude:38.6825,longitude:-108.9653,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:2,type:"lodging"},{id:"amangiri",name:"Amangiri Resort",chineseName:"安缦圭丽度假村暗夜天空点",latitude:37.0153,longitude:-111.6258,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:1,type:"lodging"},{id:"finnich-cottages",name:"Finnich Cottages",chineseName:"芬尼奇小屋暗夜天空点",latitude:56.0486,longitude:-4.4681,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:3,type:"lodging"},{id:"hotel-rangá",name:"Hotel Rangá",chineseName:"朗加��店暗夜天空点",latitude:63.8366,longitude:-20.3561,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:2,type:"lodging"}
2,{id:"crystal-creek-rainforest",name:"Crystal Creek Rainforest Retreat",chineseName:"水晶溪雨林度假村暗夜天空点",latitude:-28.3922,longitude:153.1689,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:3,type:"lodging"},{id:"hoshinoya-karuizawa",name:"Hoshinoya Karuizawa",chineseName:"星野轻井泽暗夜天空点",latitude:36.3339,longitude:138.5928,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:3,type:"lodging"},{id:"kakslauttanen-arctic-resort",name:"Kakslauttanen Arctic Resort",chineseName:"卡克斯劳塔宁北极度假村暗夜天空点",latitude:68.3352,longitude:27.335,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:2,type:"lodging"},{id:"explora-atacama",name:"Explora Atacama",chineseName:"阿塔卡马探索酒店暗夜天空点",latitude:-22.9083,longitude:-68.2025,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:1,type:"lodging"},{id:"exclusive-namibia",name:"AndBeyond Sossusvlei Desert Lodge",chineseName:"AndBeyond 索苏斯维利沙漠小屋暗夜天空点",latitude:-24.7887,longitude:15.3854,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:1,type:"lodging"},{id:"baines-camp",name:"Sanctuary Baines Camp",chineseName:"贝恩斯营地",latitude:-19.5482,longitude:22.9982,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:2,type:"lodging"},{id:"little-kulala",name:"Little Kulala",chineseName:"小库拉拉营地",latitude:-24.3751,longitude:15.685,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:1,type:"lodging"},{id:"ali-starlightcamp",name:"Ali & Reza's StarLightCamp",chineseName:"阿里和雷扎的星光营地",latitude:34.9482,longitude:53.551,isDarkSkyReserve:!1,certification:"Dark Sky Lodging - IDA Approved",timestamp:(new Date).toISOString(),bortleScale:2,type:"lodging"}].forEach(e=>{const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.has(a)||t.set(a,e)}),Array.from(t.values())}(function(e){const t=new Map;return e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.set(a,e)}),[{id:"flagstaff-urban",name:"Flagstaff Urban Night Sky Place",chineseName:"弗拉格斯塔夫城市暗夜天空区",latitude:35.1983,longitude:-111.6513,isDarkSkyReserve:!1,certification:"Urban Night Sky Place - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:4},{id:"montreal-urban",name:"Mont-Mégantic Urban Night Sky Reserve",chineseName:"梅甘蒂克山城市暗夜天空保护区",latitude:45.4555,longitude:-71.1522,isDarkSkyReserve:!1,certification:"Urban Night Sky Place - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:4},{id:"tucson-urban",name:"Tucson Urban Night Sky District",chineseName:"图森城市暗夜天空区",latitude:32.2226,longitude:-110.9747,isDarkSkyReserve:!1,certification:"Urban Night Sky Place - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:5},{id:"sedona-urban",name:"Sedona Urban Night Sky Community",chineseName:"塞多纳城市暗夜天空社区",latitude:34.8697,longitude:-111.761,isDarkSkyReserve:!1,certification:"Urban Night Sky Place - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:4}].forEach(e=>{const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.has(a)||t.set(a,e)}),Array.from(t.values())}(function(e){const t=new Map;return e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.set(a,e)}),[{id:"westcliffe-community",name:"Westcliffe & Silver Cliff Dark Sky Community",chineseName:"韦斯特克利夫和银崖暗夜天空社区",latitude:38.1315,longitude:-105.464,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3}
2,{id:"fountain-hills-community",name:"Fountain Hills Dark Sky Community",chineseName:"喷泉山暗夜天空社区",latitude:33.6045,longitude:-111.725,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:4},{id:"borrego-springs-community",name:"Borrego Springs Dark Sky Community",chineseName:"博雷戈温泉暗夜天空社区",latitude:33.255,longitude:-116.3763,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"dripping-springs-community",name:"Dripping Springs Dark Sky Community",chineseName:"滴泉暗夜天空社区",latitude:30.1902,longitude:-98.0867,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:4},{id:"xichong-shenzhen-community",name:"Shenzhen Xichong Dark Sky Community",chineseName:"深圳西冲暗夜社区",latitude:22.5808,longitude:114.5034,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"torrance-barrens-community",name:"Torrance Barrens Dark Sky Preserve",chineseName:"托伦斯荒地暗夜天空保护区",latitude:44.9272,longitude:-79.5131,isDarkSkyReserve:!1,certification:"Dark Sky Preserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"headlands-community",name:"Headlands International Dark Sky Park",chineseName:"海德兰国际暗夜天空公园",latitude:45.7842,longitude:-84.8466,isDarkSkyReserve:!1,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"homer-glen-community",name:"Homer Glen Dark Sky Community",chineseName:"荷马格伦暗夜天空社区",latitude:41.6012,longitude:-87.9381,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:4}].forEach(e=>{const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.has(a)||t.set(a,e)}),Array.from(t.values())}(function(e){const t=new Map;return e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;t.set(a,e)}),[{id:"shenzhen-xichong",name:"Shenzhen Xichong Dark Sky Community",chineseName:"深圳西冲暗夜社区",latitude:22.5808,longitude:114.5034,isDarkSkyReserve:!1,certification:"Dark Sky Community - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"yeongyang-firefly",name:"Yeongyang Firefly Eco Park Dark Sky Park",chineseName:"英阳萤火虫生态公园暗夜天空公园",latitude:36.6552,longitude:129.1122,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"jindo-dark-sky",name:"Jindo Dark Sky Park",chineseName:"珍岛暗夜天空公园",latitude:34.4763,longitude:126.2631,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"yaeyama-dark-sky",name:"Yaeyama Islands International Dark Sky Reserve",chineseName:"八重山群岛国际暗夜天空保护区",latitude:24.4667,longitude:124.2167,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"iriomote-ishigaki",name:"Iriomote-Ishigaki National Park Dark Sky Reserve",chineseName:"西表石垣国家公园暗夜天空保护区",latitude:24.3423,longitude:124.1546,isDarkSkyReserve:!0,certification:"Dark Sky Reserve - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"himawari-farm",name:"Himawari Farm Dark Sky Park",chineseName:"向日葵农场暗夜天空公园",latitude:42.9824,longitude:140.9946,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"yangmingshan-dark-sky",name:"Yangmingshan National Park Dark Sky Park",chineseName:"阳明山国家公园暗夜公园",latitude:25.1637,longitude:121.5619,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:3},{id:"alishan-dark-sky",name:"Alishan Dark Sky Park",chineseName:"阿里山暗夜公园",latitude:23.5105,longitude:120.8053,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2},{id:"hehuanshan-dark-sky",name:"Hehuanshan Dark Sky Park",chineseName:"合欢山暗夜公园",latitude:24.1384,longitude:121.2822,isDarkSkyReserve:!0,certification:"Dark Sky Park - International Dark Sky Association",timestamp:(new Date).toISOString(),bortleScale:2}
2].forEach(e=>{const a=`${e.latitude.toFixed(4)}-${e.longitude.toFixed(4)}`;if(t.has(a)){const n=t.get(a);n.id===e.id&&t.set(a,{...n,isDarkSkyReserve:e.isDarkSkyReserve,certification:e.certification})}else t.set(a,e)}),Array.from(t.values())}(Array.from(i.values()))))))).sort((e,t)=>{const a="number"==typeof e.siqs?e.siqs:e.siqs?.score||0;return("number"==typeof t.siqs?t.siqs:t.siqs?.score||0)-a});oa=o,ra=Date.now();try{localStorage.setItem("cachedCertifiedLocations",JSON.stringify(o))}catch(e){}return o}catch(e){return oa||[]}}function ca(e=!0){const[t,a]=i.useState([]),[n,o]=i.useState(!0),[r,s]=i.useState(!1),[l,c]=i.useState(0);i.useEffect(()=>{if(!e)return void o(!1);let t=!0;o(!0),s(!1);try{const e=JSON.parse(localStorage.getItem("cachedCertifiedLocations")||"[]");e.length>0&&t&&(a(e),c(50))}catch(i){}const n=setInterval(()=>{c(e=>e>=90?(clearInterval(n),e):Math.min(90,e+10))},300);return(async()=>{try{0===l&&c(10);const e=await sa();if(t){a(e),c(100),o(!1);try{localStorage.setItem("cachedCertifiedLocations",JSON.stringify(e))}catch(i){}}}catch(e){if(t){s(!0),o(!1);try{const e=JSON.parse(localStorage.getItem("cachedCertifiedLocations")||"[]");e.length>0&&a(e)}catch(i){}}}})(),()=>{t=!1,clearInterval(n)}},[e]);const d=i.useCallback(async()=>{if(e){o(!0),c(10);try{const e=await async function(){oa=null,ra=0;try{localStorage.removeItem("cachedCertifiedLocations")}catch(e){}return sa()}();a(e),c(100),o(!1);try{localStorage.setItem("cachedCertifiedLocations",JSON.stringify(e))}catch(t){}}catch(n){s(!0),o(!1)}}},[e]);return{certifiedLocations:t,isLoading:n,isError:r,loadingProgress:l,refreshLocations:d}}const da=({userLocation:e,locations:t,certifiedLocations:a,calculatedLocations:n,activeView:r,searchRadius:s,onLocationClick:l,onLocationUpdate:d})=>{const[u,h]=i.useState(!1),{mapContainerHeight:g,legendOpen:f,handleLegendToggle:p,isMobile:y}=function(){const[e,t]=i.useState("450px"),[a,n]=i.useState(!1),[o,r]=i.useState(!1),s=m();return{mapContainerHeight:e,legendOpen:a,isUpdatingLocation:o,setIsUpdatingLocation:r,handleLegendToggle:i.useCallback(e=>{n(e)},[]),isMobile:s}}(),{handleMapClick:x,handleGetLocation:S}=function(e){const{t:t}=c();return{handleMapClick:i.useCallback((t,a)=>{e&&e(t,a)},[e]),handleGetLocation:i.useCallback(()=>{if(!e)return;const a=Re.loading(t("Getting your location...","正在获取您的位置..."));navigator.geolocation.getCurrentPosition(n=>{Re.dismiss(a);const{latitude:i,longitude:o}=n.coords;e(i,o),Re.success(t("Location updated successfully","位置更新成功"));try{const e=window.leafletMap;e&&e.setView([i,o],12,{animate:!0,duration:1.5})}catch(r){}},e=>{Re.dismiss(a);let n=t("Could not get your location","无法获取您的位置");1===e.code?n=t("Location permission denied","位置权限被拒绝"):2===e.code?n=t("Location unavailable","位置不可用"):3===e.code&&(n=t("Location request timed out","位置请求超时")),Re.error(n)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:0})},[e,t])}}(d),{hoveredLocationId:k,handleHover:b,handleTouchStart:w,handleTouchEnd:v,handleTouchMove:N}=(()=>{const[e,t]=i.useState(null),a=m(),n=i.useRef(null),o=i.useRef(null),r=i.useRef(0),s=i.useRef(null),l=i.useRef(!1);i.useEffect(()=>()=>{n.current&&clearTimeout(n.current)},[]);const c=i.useCallback(e=>{if(e!==o.current)if(n.current&&(clearTimeout(n.current),n.current=null),null!==e){const i=a?50:0;i>0?n.current=setTimeout(()=>{t(e),o.current=e},i):(t(e),o.current=e)}else{const e=a?100:25;n.current=setTimeout(()=>{t(null),o.current=null},e)}},[a]),d=i.useCallback((e,t)=>{a&&(r.current=Date.now(),l.current=!1,e.touches&&e.touches[0]&&(s.current={x:e.touches[0].clientX,y:e.touches[0].clientY}),c(t))},[a,c]),u=i.useCallback((e,t)=>{a&&(Date.now()-r.current<500&&!l.current?setTimeout(()=>{c(null)},3e3):c(null),s.current=null,r.current=0,l.current=!1)},[a,c]),h=i.useCallback(e=>{if(a&&s.current&&e.touches&&e.touches[0]){const t=Math.abs(e.touches[0].clientX-s.current.x),a=Math.abs(e.touches[0].clientY-s.current.y);(t>15||a>15)&&(l.current=!0,c(null))}},[a,c]);return{hoveredLocationId:e,handleHover:c,handleTouchStart:d,handleTouchEnd:u,handleTouchMove:h}})(),{mapReady:D,handleMapReady:C,validLocations:j,mapCenter:L,initialZoom:M,certifiedLocationsLoaded:R,certifiedLocationsLoading:I}
2=(({userLocation:e,locations:t,searchRadius:a,activeView:n})=>{const[r,s]=i.useState(!1),[l,c]=i.useState(null),{certifiedLocations:d,isLoading:u,loadingProgress:m}=ca(!0),[h,g]=i.useState(!1);i.useEffect(()=>{if(d.length>0){try{localStorage.setItem("cachedCertifiedLocations",JSON.stringify(d)),g(!0)}catch(e){}d.forEach(e=>{(e.isDarkSkyReserve||e.certification)&&ia(e)})}},[d]);const{handleLocationClick:f}=(()=>{const e=o();return{getZoomLevel:i.useCallback(e=>e<=10?12:e<=50?10:e<=100?9:e<=300?8:e<=500?7:6,[]),handleLocationClick:i.useCallback(t=>{if(t)try{const a=ke(t);a&&e(`/location/${a.locationId}`,{state:a.locationState})}catch(a){}},[e])}})(),p=i.useCallback(()=>{const e=new Map;return"certified"===n?d.forEach(t=>{if(t.latitude&&t.longitude&&(t.isDarkSkyReserve||t.certification)&&!t.certification?.toLowerCase().includes("atlas obscura")&&!t.certification?.toLowerCase().includes("natural mountain")){const a=`${t.latitude.toFixed(6)}-${t.longitude.toFixed(6)}`;e.set(a,t)}}):"obscura"===n||"darksky"===n||"natural-wonders"===n||"astrospots"===n?Array.isArray(t)&&t.forEach(t=>{if(t.latitude&&t.longitude){const a=`${t.latitude.toFixed(6)}-${t.longitude.toFixed(6)}`;e.set(a,t)}}):"mountains"===n?Array.isArray(t)&&t.forEach(t=>{if(t.latitude&&t.longitude){const a=`${t.latitude.toFixed(6)}-${t.longitude.toFixed(6)}`;e.set(a,t)}}):"calculated"===n&&Array.isArray(t)&&t.forEach(t=>{if(t.latitude&&t.longitude&&!t.isDarkSkyReserve&&!t.certification){const a=`${t.latitude.toFixed(6)}-${t.longitude.toFixed(6)}`;e.set(a,t)}}),Array.from(e.values())},[t,d,n]),{processedLocations:y}=(({userLocation:e,locations:t,searchRadius:a,activeView:n,mapReady:i})=>{const o=Array.isArray(t)?t:[];return o.filter(e=>Boolean(e?.isDarkSkyReserve||e?.certification)).length,o.length,{processedLocations:o.filter(e=>e&&"number"==typeof e.latitude&&"number"==typeof e.longitude)}})({userLocation:e,locations:p(),searchRadius:a,activeView:n,mapReady:r}),x=e?[e.latitude,e.longitude]:[35.8617,104.1954];return{mapReady:r,handleMapReady:i.useCallback(()=>{s(!0)},[]),selectedLocation:l,handleLocationClick:f,validLocations:y,mapCenter:x,initialZoom:4,certifiedLocationsLoaded:h,certifiedLocationsLoading:u,loadingProgress:m,allCertifiedLocationsCount:d.length}})({userLocation:e,locations:t,searchRadius:s,activeView:r});return function(e,t){i.useEffect(()=>{if(e&&e.length>0)try{const n="certified"===t?"persistent_certified_locations":"obscura"===t?"persistent_obscura_locations":"mountains"===t?"persistent_mountains_locations":"persistent_calculated_locations",i=sessionStorage.getItem(n),o=e.map(e=>({id:e.id||`loc-${e.latitude?.toFixed(6)}-${e.longitude?.toFixed(6)}`,name:e.name||"Unknown Location",latitude:e.latitude,longitude:e.longitude,siqs:e.siqs,isDarkSkyReserve:e.isDarkSkyReserve,certification:e.certification,distance:e.distance}));let r=o;if(i)try{const e=JSON.parse(i),t=new Map;Array.isArray(e)&&e.forEach(e=>{if(e?.latitude&&e?.longitude){const a=`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;t.set(a,e)}}),o.forEach(e=>{if(e?.latitude&&e?.longitude){const a=`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;t.set(a,e)}}),r=Array.from(t.values())}catch(a){}sessionStorage.setItem(n,JSON.stringify(r))}catch(a){}},[e,t])}(t,r),{mapContainerHeight:g,legendOpen:f,mapReady:D,handleMapReady:C,optimizedLocations:j,mapCenter:L,initialZoom:M,hoveredLocationId:k,handleHover:b,handleTouchStart:w,handleTouchEnd:v,handleTouchMove:N,handleMapClick:x,handleLocationClicked:i.useCallback(e=>{l&&l(e)},[l]),handleGetLocation:S,handleLegendToggle:p,isMobile:y,certifiedLocationsLoaded:R,certifiedLocationsLoading:I}},ua=({marker:e,eventMap:t})=>(i.useEffect(()=>{if(!e)return;const a=e.getElement();return a?(Object.entries(t).forEach(([e,t])=>{t&&a.addEventListener(e,t)}),()=>{Object.entries(t).forEach(([e,t])=>{t&&a.removeEventListener(e,t)})}):void 0},[e,t]),null),ma=e=>He(e),ha=n.memo(({location:e,siqsScore:t,siqsLoading:n,displayName:o,isCertified:r,onViewDetails:s})=>{const{t:l,language:d}=c(),u=m(),[h,g]=i.useState(null);i.useEffect(()=>{null!==t&&t>0&&g(t)},[t]);const f=h??t??Qe(e.siqs),p=null==(y=f)||y<=0?"":y>=7.5?"siqs-excellent":y>=5.5?"siqs-good":"siqs-poor";var y;const x=f&&f>0?f.toFixed(1):"N/A",S="zh"===d?"Calculated Location"===e.name?"推算观星点":e.chineseName||o:o,k="zh"===d?e.chineseName&&"Calculated Location"!==e.name?o:null:e.chineseName||null,{bortle:b}=at(e.latitude,e.longitude),w=b??e.bortleScale;return a.jsx(Ae,{closeOnClick:!1,autoClose:!1,offset:[0,10],direction:"bottom",children:a.jsxs("div",{className:`py-3 px-3 min-w-[200px] max-w-[260px] leaflet-popup-custom-compact marker-popup-gradient ${p}`,style:{background:"linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 
20.95) 100%)",borderLeft:`4px solid ${He(f)}`,borderRadius:"8px",color:"white",boxShadow:"0 4px 12px rgba(0,0,0,0.4)"},children:[r&&e.certification&&a.jsxs("div",{className:"text-xs font-medium text-yellow-400 flex items-center mb-1.5",children:[a.jsx(z,{className:"h-3.5 w-3.5 mr-1 fill-yellow-400 text-yellow-400"}),e.certification]}),a.jsxs("div",{className:"font-semibold text-sm mb-0.5",style:{color:"#f1f5f9"},children:[r&&!e.certification&&a.jsx(z,{className:"h-3.5 w-3.5 mr-1 text-primary fill-primary inline"}),S]}),k&&a.jsx("div",{className:"text-xs mb-1.5",style:{color:"#cbd5e1"},children:k}),a.jsxs("div",{className:"flex items-center justify-between text-[11px] mb-2",style:{color:"#94a3b8"},children:[a.jsxs("span",{children:[e.latitude.toFixed(4),", ",e.longitude.toFixed(4)]}),"number"==typeof e.distance&&isFinite(e.distance)&&a.jsx("span",{style:{color:"#cbd5e1"},children:Ve(e.distance)})]}),a.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[r&&a.jsx(z,{className:"h-3.5 w-3.5 fill-yellow-400 text-yellow-400 mr-0.5"}),a.jsxs("span",{className:`font-semibold text-base ${Ge(f)}`,children:["zh"===d?"观星指数":"SIQS",": ",n&&!h?"...":x]})]}),null!=w&&w>=1&&w<=9&&a.jsxs("div",{className:"flex items-center",children:[a.jsx("span",{className:"text-xs mr-1",style:{color:"#94a3b8"},children:"zh"===d?"光害:":"Bortle:"}),a.jsx("span",{className:"font-semibold text-sm "+(v=w,null==v?"text-muted-foreground":v<=3?"text-cyan-400":v<=5?"text-green-400":v<=7?"text-yellow-400":"text-red-400"),children:Nt(w)})]}),e.user_id&&a.jsx(bt,{userId:e.user_id,size:"sm",className:"ml-auto"})]}),a.jsxs("button",{onClick:t=>{t.stopPropagation(),s(e)},className:`text-xs flex items-center justify-center w-full ${u?"py-3":"py-2"} px-3 rounded-md transition-all font-medium`,style:{background:"rgba(59, 130, 246, 0.2)",color:"#dbeafe",border:"none",cursor:"pointer"},onMouseOver:e=>e.currentTarget.style.background="rgba(59, 130, 246, 0.3)",onMouseOut:e=>e.currentTarget.style.background="rgba(59, 130, 246, 0.2)",children:[a.jsx(W,{className:"h-3.5 w-3.5 mr-1.5"}),"zh"===d?"查看详情":"View Details"]})]})});var v}),ga=({location:e,onClick:t,isHovered:n,onHover:r,locationId:s,isCertified:l,activeView:d,handleTouchStart:u,handleTouchEnd:h,handleTouchMove:g})=>{const[f,p]=i.useState(null),[y,x]=i.useState(l),[S,k]=i.useState(7),[b,v]=i.useState(!1),N=e.certification?.toLowerCase().includes("natural mountain"),{siqsScore:D,displayName:C,icon:j}=function({location:e,realTimeSiqs:t,isCertified:a,isHovered:n}){const{language:o,t:r}=c(),s=m(),l=i.useMemo(()=>{if("zh"===o){if("Calculated Location"===e.name)return"推算观星点";if(e.chineseName)return e.chineseName}return e.name||r("Unnamed Location","未命名位置")},[o,e.chineseName,e.name,r]),d=i.useMemo(()=>{if(null!==t)return We(t);const a=We(e.siqs);return a>0?a:null},[e,t]),u=i.useMemo(()=>null!==t?{...e,siqs:We(t)}:e,[e,t]);return{displayName:l,siqsScore:d,icon:i.useMemo(()=>((e,t,a,n)=>{const i=(e=>{if("observatory"===e.spot_type)return"verified"===e.verification_status?"rgba(34, 211, 238, 0.95)":"rgba(245, 158, 11, 0.9)";const t=We(e),a=e.certification?.toLowerCase().includes("natural mountain");return t>0||a?ma(t||0):"number"==typeof e.bortleScale&&e.bortleScale>0?ma(Ze(e.bortleScale)):e.isDarkSkyReserve||e.certification?(e=>{if(!e.isDarkSkyReserve&&!e.certification&&!e.isUNESCO)return"rgba(74, 222, 128, 0.85)";const t=(e.certification||"").toLowerCase();return e.isUNESCO||t.includes("unesco")?"rgba(139, 92, 246, 0.85)":t.includes("atlas obscura")?"rgba(6, 182, 212, 0.85)":t.includes("community")?"rgba(255, 215, 0, 0.85)":t.includes("reserve")||t.includes("sanctuary")||e.isDarkSkyReserve?"rgba(155, 135, 245, 0.85)":t.includes("park")?"rgba(74, 222, 128, 0.85)":t.includes("urban")||t.includes("night sky place")?"rgba(30, 174, 219, 0.85)":t.includes("lodging")?"rgba(0, 0, 128, 0.85)":"rgba(155, 135, 245, 0.85)"})(e):"#4ADE80"})(e),o=e.isUNESCO||e.certification?.toLowerCase().includes("unesco"),r=e.certification?.toLowerCase().includes("atlas obscura"),s=e.certification?.toLowerCase().includes("natural mountain"),l="observatory"===e.spot_type,c=l&&"verified"===e.verification_status,d=n?a?22:c?20:16:a||c?28:24;let u="";return c?u=`<svg xmlns="http://www.w3.org/2000/svg" width="${.7*d}" height="${.7*d}" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n      <path d="m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44"/>\n      <path d="m13.56 11.747 4.332-.924"/>\n      <path d="m16 21-3.105-6.21"/>
2\n      <path d="M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z"/>\n      <path d="m6.158 8.633 1.114 4.456"/>\n      <path d="m8 21 3.105-6.21"/>\n      <circle cx="12" cy="13" r="2" fill="white"/>\n    </svg>`:l?u=`<svg xmlns="http://www.w3.org/2000/svg" width="${.66*d}" height="${.66*d}" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n      <path d="M3 21h18"/>\n      <path d="M8 21V9l4-4 4 4v12"/>\n      <path d="M10 13h4"/>\n      <path d="M12 5V2"/>\n      <path d="M7 7 5 5"/>\n      <path d="m17 7 2-2"/>\n    </svg>`:o?u=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*d}" height="${.6*d}" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n      <circle cx="12" cy="12" r="10"/>\n      <path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/>\n      <path d="M2 12h20"/>\n    </svg>`:s?u=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*d}" height="${.6*d}" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="2">\n      <path d="m8 3 4 8 5-5 5 15H2L8 3z"/>\n    </svg>`:r?u=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*d}" height="${.6*d}" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n      <path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/>\n      <circle cx="12" cy="12" r="3"/>\n    </svg>`:t&&(u=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*d}" height="${.6*d}" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="2">\n      <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>\n    </svg>`),Ie.divIcon({className:"custom-div-icon",html:`\n      <div \n        style="\n          background-color: ${i}; \n          width: ${d}px; \n          height: ${d}px; \n          border-radius: 50%;\n          border: ${l?"3px":"2px"} solid ${c?"#ecfeff":"white"};\n          box-shadow: ${l?"0 0 0 3px rgba(34,211,238,0.2), 0 0 12px rgba(34,211,238,0.65)":"0 0 4px rgba(0,0,0,0.5)"};\n          display: flex;\n          align-items: center;\n          justify-content: center;\n        "\n      >\n        ${u}\n      </div>\n    `,iconSize:[d,d],iconAnchor:[d/2,d/2]})})(u,a,n,s),[u,a,n,s])}}({location:e,realTimeSiqs:f,isCertified:l,isHovered:n}),L=o();i.useEffect(()=>{if(l){v(!0),x(!0);const e=setTimeout(()=>v(!1),100);return()=>clearTimeout(e)}},[l]),i.useEffect(()=>{v(!0),x(!0);const e=setTimeout(()=>v(!1),100);return()=>clearTimeout(e)},[d]);const M=i.useCallback((e,t,a)=>{p(e),x(t),a&&k(a),l&&(null===e||e<=0)&&!t&&(x(!0),setTimeout(()=>v(!0),2e3),setTimeout(()=>v(!1),2100))},[s,l]),R=i.useCallback(()=>{l&&(v(!0),setTimeout(()=>v(!1),100),x(!0)),t(e)},[e,t,l]),I=i.useCallback(()=>{r(s)},[s,r]),A=i.useCallback(()=>{r(null)},[r]),$=i.useCallback(e=>{l&&(v(!0),setTimeout(()=>v(!1),100),x(!0)),u&&u(e,s)},[u,s,l]),E=i.useCallback(e=>{h&&h(e,s)},[h,s]),T=i.useCallback(e=>{g&&g(e)},[g]),F=i.useCallback(e=>{try{if(e.id&&e.user_id)w(e.id);else{const t=ke(e);t&&L(`/location/${t.locationId}`,{state:t.locationState})}}catch(t){}},[L]);return a.jsxs(a.Fragment,{children:[a.jsx(Je,{isVisible:!0,latitude:e.latitude,longitude:e.longitude,bortleScale:e.bortleScale,isCertified:!N&&l,isDarkSkyReserve:e.isDarkSkyReserve,existingSiqs:e.siqs,onSiqsCalculated:M,forceUpdate:b||l&&!f||N,priorityLevel:N?"high":void 0}),a.jsxs($e,{position:[e.latitude,e.longitude],icon:j,onClick:R,children:[a.jsx(ua,{marker:null,eventMap:{mouseover:I,mouseout:A,touchstart:$,touchend:E,touchmove:T}}),a.jsx(ha,{location:e,siqsScore:D,siqsLoading:y,displayName:C,isCertified:l,onViewDetails:F})]})]})},fa=n.memo(e=>{const{latitude:t,longitude:n}=e.location;return!Number.isFinite(t)||!Number.isFinite(n)||Math.abs(t)>90||Math.abs(n)>180?null:a.jsx(ga,{...e})}),pa=({effects:e=[],userLocation:t,activeView:a,searchRadius:i})=>{const o=Ee();return n.useEffect(()=>(e.includes("zoom-controls")&&(o.zoomControl||o.addControl(Te.control.zoom({position:"bottomright"}
2))),()=>{}),[o,e,t,a,i]),null},ya=({userLocation:e,searchRadius:t,onMapClick:a})=>{const n=Ee();return i.useEffect(()=>{if(!n||!a)return;const e=e=>{a&&a(e.latlng.lat,e.latlng.lng)};return n.on("click",e),()=>{n.off("click",e)}},[n,a]),null},xa=()=>{const e=Ee(),t=m();return i.useEffect(()=>{if(!e||!t)return;const a=()=>{if(e._panes)try{const t=e._panes.markerPane;t&&(t.style.willChange="transform",t.style.transform="translate3d(0,0,0)",requestAnimationFrame(()=>{if(t){const e=parseInt(t.style.zIndex||"600");t.style.zIndex=String(e+1),setTimeout(()=>{t&&(t.style.zIndex="600")},16)}}))}catch(t){}},n=()=>{try{requestAnimationFrame(()=>{e.invalidateSize({animate:!1,pan:!1});const t=e.getContainer();!t||0!==t.clientWidth&&0!==t.clientHeight||setTimeout(()=>{e.invalidateSize({animate:!1,pan:!1})},100)})}catch(t){}};(()=>{try{e.eachLayer(e=>{e instanceof Ie.TileLayer&&(e.options.updateWhenIdle=!0,e.options.updateWhenZooming=!1,e.options.keepBuffer=1)}),e.doubleClickZoom.disable(),e.touchZoom&&(e.touchZoom.disable(),e.touchZoom.enable({pinch:!0})),e.dragging&&(e.dragging.disable(),e.dragging.enable())}catch(t){}})(),n(),(()=>{if(/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream)try{const t=e._panes.tilePane;t&&(t.style.webkitBackfaceVisibility="hidden",t.style.webkitTransform="translate3d(0,0,0)"),e.on("zoom",()=>{try{if(e._panes&&e._panes.markerPane){const t=e._panes.markerPane;t.style.display="none",requestAnimationFrame(()=>{t&&(t.style.display="")})}}catch(t){}})}catch(t){}})(),a(),e.on("zoomanim",a),e.on("zoomend",a),e.on("moveend",a),e.on("resize",n);const i=setInterval(()=>{n()},2e3);return()=>{e.off("zoomanim",a),e.off("zoomend",a),e.off("moveend",a),e.off("resize",n),e.off("zoom"),clearInterval(i)}},[e,t]),null},Sa=256,ka=1050,ba=1050,wa=180,va="1_1",Na="brightness(2.5) saturate(0.15) contrast(1.5) opacity(0.9)",Da="brightness(1.8) saturate(0.08) contrast(1.4) opacity(0.88)",Ca=(e,t,a,n,i,o="radar")=>"satellite"===o?((e,t,a,n,i)=>`${e}${t}/256/${a}/${n}/${i}/0/0.png`)(e,t,a,n,i):((e,t,a,n,i)=>`${e}${t}/256/${a}/${n}/${i}/2/${va}.png`)(e,t,a,n,i);function ja(e,t=.75){const{latitudes:a,longitudes:n,values:i}=e;if(!a?.length||!n?.length||!i?.length)return null;const o=320,r=256,s=a[0],l=a[a.length-1],c=n[0],d=n[n.length-1];if(l<=s||d<=c)return null;const u=document.createElement("canvas");u.width=o,u.height=r;const m=u.getContext("2d");if(!m)return null;const h=m.createImageData(o,r),g=h.data,f=Math.round(255*Math.min(1,t));for(let x=0;x<r;x++){const e=l-x/255*(l-s);for(let t=0;t<o;t++){const r=La(e,c+t/319*(d-c),a,n,i);if(r<6)continue;const s=Math.round(r/100*f),l=4*(x*o+t);g[l]=g[l+1]=g[l+2]=255,g[l+3]=s}}m.putImageData(h,0,0);const p=document.createElement("canvas");p.width=o,p.height=r;const y=p.getContext("2d");return y?(y.filter="blur(2px)",y.drawImage(u,0,0),p.toDataURL("image/png")):u.toDataURL("image/png")}function La(e,t,a,n,i){const o=a.length,r=n.length;if(!o||!r)return 0;const s=Math.max(a[0],Math.min(a[o-1],e)),l=Math.max(n[0],Math.min(n[r-1],t));let c=0;for(let f=0;f<o-1;f++){if(s>=a[f]&&s<=a[f+1]){c=f;break}f===o-2&&(c=f)}let d=0;for(let f=0;f<r-1;f++){if(l>=n[f]&&l<=n[f+1]){d=f;break}f===r-2&&(d=f)}const u=Math.min(c+1,o-1),m=Math.min(d+1,r-1),h=(s-a[c])/(a[u]-a[c]||1),g=(l-n[d])/(n[m]-n[d]||1);return(1-h)*(1-g)*(i[c]?.[d]??0)+(1-h)*g*(i[c]?.[m]??0)+h*(1-g)*(i[u]?.[d]??0)+h*g*(i[u]?.[m]??0)}const Ma=({visible:e=!0,opacity:t=.85,host:a,frame:n,onBoundsChange:o})=>{const r=Ee(),s=i.useRef(null),l=i.useRef(null),c=i.useRef(null),d=i.useRef(null),u=i.useRef(!1),m=i.useRef(0),h=i.useRef(""),[g,f]=i.useState(null);return i.useEffect(()=>{if(r&&!u.current){if(!r.getPane("cloudCoverPane")){const e=r.createPane("cloudCoverPane");e.style.zIndex=String(ka),e.style.pointerEvents="none",e.style.filter=Na}u.current=!0}},[r]),i.useEffect(()=>{if(!r)return;const e=r.getPane("cloudCoverPane");e&&(e.style.filter="satellite"===n?.type?Da:Na)},[r,n?.type]),i.useEffect(()=>{if(!r||!o)return;const e=()=>{const e=r.getBounds();o({latMin:e.getSouth(),latMax:e.getNorth(),lngMin:e.getWest(),lngMax:e.getEast()})};return e(),r.on("moveend",e),r.on("zoomend",e),()=>{r.off("moveend",e),r.off("zoomend",e)}},[r,o]),i.useEffect(()=>{if("forecast"!==n?.type||!n?.forecastData)return void f(null);if(n.precomputedDataUrl)return void f(n.precomputedDataUrl);f(null);const e=n,a=()=>{const a=ja(e.forecastData,.9*t);a&&(e.precomputedDataUrl=a,f(a))};let i;return i="requestIdleCallback"in window?window.requestIdleCallback(a,{timeout:800}):setTimeout(a,4),()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(i):clearTimeout(i)}},[n?.time,n?.type,n?.forecastData,n?.precomputedDataUrl,t]),i.useEffect(()=>{if(!r)return;const i=`${e}-${n?.path}-${n?.time}-${n?.type}`;if(i===h.current)return;if(h.current=i,!e||!n||"radar"!==n.type&&"satellite"!==n.type||!a||!n.path){if(s.current){try{r.removeLayer(s.current)}catch{}s.current=null}if(l.current){try{r.removeLayer(l.current)}catch{}l.current=null}return}const o="satellite"===n.type?0:2,c="satellite"===n.type?"0":va,d=`${a}${n.path}/256/{z}/{x}/{y}/${o}/${c}.png`,u=Ie.tileLayer(d,{opacity:0,maxZoom:18,maxNativeZoom:7,tileSize:Sa,pane:"cloudCoverPane",zIndex:ka,attribution:'© <a href="https://rainviewer.com">RainViewer</a>',crossOrigin:"anonymous",interactive:!1});u.addTo(r);const g=s.current,f=performance.now();m.current&&cancelAnimationFrame(m.current);const p=e=>{const a=Math.min((e-f)/180,1);if(u.setOpacity(a*t),g&&g.setOpacity((1-a)*t),a<1)m.current=requestAnimationFrame(p);else{if(g&&r)try{r.removeLayer(g)}catch{}l.current=s.current,s.current=u}}
2;return m.current=requestAnimationFrame(p),()=>{m.current&&cancelAnimationFrame(m.current)}},[r,a,n?.path,n?.type,n?.time,e,t]),i.useEffect(()=>{if(!r)return;if(!e||!n||"forecast"!==n.type||!g){if(c.current){try{r.removeLayer(c.current)}catch{}c.current=null}if(d.current){try{r.removeLayer(d.current)}catch{}d.current=null}return}const a=n.forecastData,i=a.latitudes[0],o=a.latitudes[a.latitudes.length-1],s=a.longitudes[0],l=a.longitudes[a.longitudes.length-1],u=Ie.latLngBounds(Ie.latLng(i,s),Ie.latLng(o,l)),h=Ie.imageOverlay(g,u,{opacity:0,pane:"cloudCoverPane",interactive:!1,zIndex:ka});h.addTo(r);const f=c.current,p=performance.now();m.current&&cancelAnimationFrame(m.current);const y=e=>{const a=Math.min((e-p)/180,1);if(h.setOpacity(a*t),f&&f.setOpacity((1-a)*t),a<1)m.current=requestAnimationFrame(y);else{if(f&&r)try{r.removeLayer(f)}catch{}d.current=c.current,c.current=h}};return m.current=requestAnimationFrame(y),()=>{m.current&&cancelAnimationFrame(m.current)}},[r,e,g,n?.type,t]),i.useEffect(()=>()=>{m.current&&cancelAnimationFrame(m.current),[s,l,c,d].forEach(e=>{if(e.current&&r)try{r.removeLayer(e.current)}catch{}e.current=null})},[r]),null},Ra=({map:e,visible:t=!0,opacity:a=.85,host:n,frame:o,onBoundsChange:r})=>{const s=i.useRef(null),l=i.useRef(null),c=i.useRef(null),d=i.useRef(null),u=i.useRef(!1),m=i.useRef(0),h=i.useRef(""),g=i.useRef(""),[f,p]=i.useState(null);return i.useEffect(()=>{if(u.current)return;const e=document.createElement("style");return e.id="amap-cloud-filter",e.textContent=`\n      .amap-layer img[src*="rainviewer"] {\n        filter: ${Na} !important;\n      }\n    `,document.head.appendChild(e),u.current=!0,()=>{const e=document.getElementById("amap-cloud-filter");e&&e.remove(),u.current=!1}},[]),i.useEffect(()=>{const e=document.getElementById("amap-cloud-filter");if(!e)return;const t="satellite"===o?.type?Da:Na;e.textContent=`.amap-layer img[src*="rainviewer"] { filter: ${t} !important; }`},[o?.type]),i.useEffect(()=>{if("forecast"!==o?.type||!o?.forecastData)return void p(null);if(o.precomputedDataUrl)return void p(o.precomputedDataUrl);p(null);const e=o,t=()=>{const t=ja(e.forecastData,.8*a);t&&(e.precomputedDataUrl=t,p(t))};let n;return n="requestIdleCallback"in window?window.requestIdleCallback(t,{timeout:800}):setTimeout(t,4),()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(n):clearTimeout(n)}},[o?.time,o?.type,o?.forecastData,o?.precomputedDataUrl,a]),i.useEffect(()=>{if(!e||!r)return;const t=()=>{try{const t=e.getBounds();if(!t)return;
2const a=t.getSouthWest(),n=t.getNorthEast();r({latMin:a.getLat(),latMax:n.getLat(),lngMin:a.getLng(),lngMax:n.getLng()})}catch{}};return t(),e.on("moveend",t),e.on("zoomend",t),()=>{e.off("moveend",t),e.off("zoomend",t)}},[e,r]),i.useEffect(()=>{const i=`${t}-${o?.path}-${o?.time}-${o?.type}`;if(i===h.current)return;if(h.current=i,!e||!n||!o||"radar"!==o.type&&"satellite"!==o.type||!o.path||!t){if(s.current){try{e?.remove(s.current)}catch{}s.current=null}if(l.current){try{e?.remove(l.current)}catch{}l.current=null}return}const r=window.AMap;if(!r)return;const c=new r.TileLayer({getTileUrl:(e,t,a)=>{const i=Math.min(a,7);return Ca(n,o.path,i,e,t,o.type)},opacity:0,zIndex:ba,tileSize:256,zooms:[2,18]});e.add(c);const d=s.current,u=a,g=performance.now();m.current&&cancelAnimationFrame(m.current);const f=t=>{const a=t-g,n=Math.min(a/180,1);try{c.setOpacity(n*u),d&&d.setOpacity&&d.setOpacity((1-n)*u)}catch{}if(n<1)m.current=requestAnimationFrame(f);else{if(d)try{e.remove(d)}catch{}l.current=s.current,s.current=c}};return m.current=requestAnimationFrame(f),()=>{m.current&&cancelAnimationFrame(m.current)}},[e,n,o?.path,o?.type,t,a]),i.useEffect(()=>{const n=`${t}-${o?.time}-forecast-${f?"r":"n"}`;if(n===g.current)return;if(g.current=n,!(e&&t&&o&&"forecast"===o.type&&f)){if(c.current){try{c.current.setMap?c.current.setMap(null):c.current.parentElement?c.current.parentElement.removeChild(c.current):e?.remove(c.current)}catch{}c.current=null}if(d.current){try{d.current.setMap?d.current.setMap(null):d.current.parentElement?d.current.parentElement.removeChild(d.current):e?.remove(d.current)}catch{}d.current=null}return}const i=window.AMap;if(!i)return;const r=o.forecastData,s=f;if(!s||!r)return;const l=r.latitudes[0],u=r.latitudes[r.latitudes.length-1],h=r.longitudes[0],p=r.longitudes[r.longitudes.length-1];try{(t=>{e.add(t);const n=c.current,i=performance.now();m.current&&cancelAnimationFrame(m.current);const o=r=>{const s=r-i,l=Math.min(s/180,1);try{t.setOpacity(l*a),n&&n.setOpacity&&n.setOpacity((1-l)*a)}catch{}if(l<1)m.current=requestAnimationFrame(o);else{if(n)try{n.setMap?n.setMap(null):e.remove(n)}catch{}d.current=c.current,c.current=t}};m.current=requestAnimationFrame(o)})(new i.ImageLayer({url:s,bounds:new i.Bounds(new i.LngLat(h,l),new i.LngLat(p,u)),zIndex:ba,opacity:0,zooms:[2,18]}))}catch{}return()=>{m.current&&cancelAnimationFrame(m.current)}},[e,t,f,o?.type,a]),i.useEffect(()=>()=>{m.current&&cancelAnimationFrame(m.current),[s,l,c,d].forEach(t=>{if(t.current&&e)try{t.current.setMap?t.current.setMap(null):e.remove(t.current)}catch{}t.current=null})},[e]),null};function Ia(e,t){return Math.floor((e+180)/360*Math.pow(2,t))}function Aa(e,t){const a=e*Math.PI/180;return Math.floor((1-Math.log(Math.tan(a)+1/Math.cos(a))/Math.PI)/2*Math.pow(2,t))}function $a(e,t){return e/Math.pow(2,t)*360-180}function Ea(e,t){const a=Math.PI-2*Math.PI*e/Math.pow(2,t);return 180/Math.PI*Math.atan(.5*(Math.exp(a)-Math.exp(-a)))}const Ta=({map:e,visible:t=!0,opacity:a=.85,host:n,frame:o,onBoundsChange:r})=>{const s=i.useRef(new Map),l=i.useRef(null),c=i.useRef(null),d=i.useRef(0),u=i.useRef(!0),m=i.useRef(0),h=i.useRef(null),g=i.useRef(""),[f,p]=i.useState(null),y=i.useRef(e);y.current=e;const x=i.useRef(t);x.current=t;const S=i.useRef(a);S.current=a;const k=i.useRef(n);k.current=n;const b=i.useRef(o);b.current=o;const w=i.useCallback(()=>{for(const[,e]of s.current)try{e.setMap(null)}catch{}s.current.clear(),g.current=""},[]),v=i.useCallback(()=>{const e=y.current,t=b.current,a=k.current;if(!u.current||!e)return;const n=window.TMap;if(n?.ImageGroundLayer&&n?.LatLng&&n?.LatLngBounds)if(x.current&&t&&("radar"===t.type||"satellite"===t.type)&&t.path&&a)try{const o=e.getBounds();if(!o)return;
2const r=o.getSouthWest(),l=o.getNorthEast(),c=e.getZoom(),d=100;let u=Math.max(0,Math.min(Math.floor(c),7));for(let e=0;e<8;e++){const e=Math.pow(2,u)-1,t=u<=2?2:1;if((Math.min(e,Ia(l.getLng(),u)+t)-Math.max(0,Ia(r.getLng(),u)-t)+1)*(Math.min(e,Aa(r.getLat(),u)+t)-Math.max(0,Aa(l.getLat(),u)-t)+1)<=d||u<=0)break;u--}const m=Math.pow(2,u)-1,h=u<=2?2:1,f=Math.max(0,Ia(r.getLng(),u)-h),p=Math.min(m,Ia(l.getLng(),u)+h),y=Math.max(0,Aa(l.getLat(),u)-h),x=Math.min(m,Aa(r.getLat(),u)+h),k=new Set;for(let e=f;e<=p;e++)for(let t=y;t<=x;t++)k.add(`${u}_${e}_${t}`);const b=Array.from(k).sort().join(",");if(b===g.current)return;g.current=b;for(const[e,t]of s.current)if(!k.has(e)){try{t.setMap(null)}catch{}s.current.delete(e)}const w=.7*S.current;for(const g of k){if(s.current.has(g))continue;const[o,r,l]=g.split("_").map(Number),c=Ca(a,t.path,o,r,l,t.type),d=$a(r,o),u=$a(r+1,o),m=Ea(l,o),h=Ea(l+1,o);try{const t=new n.ImageGroundLayer({map:e,src:c,bounds:new n.LatLngBounds(new n.LatLng(h,d),new n.LatLng(m,u)),zIndex:ba,opacity:w,minZoom:0,maxZoom:20,visible:!0});s.current.set(g,t)}catch(i){}}}catch(i){}else w()},[w]),N=i.useRef(v);N.current=v;const D=i.useMemo(()=>()=>{cancelAnimationFrame(m.current),null!==h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{h.current=null,m.current=requestAnimationFrame(()=>{u.current&&N.current()})},250)},[e]),C=i.useCallback(()=>{g.current="",D()},[D]);return i.useEffect(()=>{if(e)return u.current=!0,e.on("panend",D),e.on("zoom_changed",C),C(),()=>{e.off("panend",D),e.off("zoom_changed",C)}},[e,D,C]),i.useEffect(()=>{w(),C()},[o?.path,o?.type,t,a,n]),i.useEffect(()=>{if(!e||!r)return;const t=()=>{try{const t=e.getBounds();if(!t)return;
2const a=t.getSouthWest(),n=t.getNorthEast();r({latMin:a.getLat(),latMax:n.getLat(),lngMin:a.getLng(),lngMax:n.getLng()})}catch{}};return t(),e.on("panend",t),e.on("zoom_changed",t),()=>{e.off("panend",t),e.off("zoom_changed",t)}},[e,r]),i.useEffect(()=>{if("forecast"!==o?.type||!o?.forecastData)return void p(null);if(o.precomputedDataUrl)return void p(o.precomputedDataUrl);p(null);const e=o,t=()=>{const t=ja(e.forecastData,.8*a);t&&(e.precomputedDataUrl=t,p(t))};let n;return n="requestIdleCallback"in window?window.requestIdleCallback(t,{timeout:800}):setTimeout(t,4),()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(n):clearTimeout(n)}},[o?.time,o?.type,o?.forecastData,o?.precomputedDataUrl,a]),i.useEffect(()=>{if(l.current){try{l.current.setMap(null)}catch{}l.current=null}if(!(e&&t&&o&&"forecast"===o.type&&f)){if(c.current){try{c.current.setMap(null)}catch{}c.current=null}return}const n=window.TMap;if(!n?.ImageGroundLayer||!n?.LatLng||!n?.LatLngBounds)return;const i=o.forecastData,r=f;if(!r||!i)return;const s=i.latitudes[0],u=i.latitudes[i.latitudes.length-1],m=i.longitudes[0],h=i.longitudes[i.longitudes.length-1];try{const t=new n.ImageGroundLayer({map:e,src:r,bounds:new n.LatLngBounds(new n.LatLng(s,m),new n.LatLng(u,h)),zIndex:ba,opacity:0,minZoom:0,maxZoom:20,visible:!0}),i=l.current,o=a,g=performance.now(),f=wa;d.current&&cancelAnimationFrame(d.current);const p=e=>{const a=e-g,n=Math.min(a/f,1);try{t.setOpacity(n*o),i&&i.setOpacity&&i.setOpacity((1-n)*o)}catch{}if(n<1)d.current=requestAnimationFrame(p);else{if(i)try{i.setMap(null)}catch{}c.current=l.current,l.current=t}};d.current=requestAnimationFrame(p)}catch(g){}return()=>{d.current&&cancelAnimationFrame(d.current)}},[e,t,f,o?.type,o?.forecastData,a]),i.useEffect(()=>(u.current=!0,()=>{if(u.current=!1,d.current&&cancelAnimationFrame(d.current),w(),l.current){try{l.current.setMap(null)}catch{}l.current=null}if(c.current){try{c.current.setMap(null)}catch{}c.current=null}}),[w]),null},Fa=(e,t)=>new Date(1e3*e).toLocaleTimeString("en"===t?"en-US":"zh-CN",{hour:"2-digit",minute:"2-digit",hour12:!1}),Oa=(e,t)=>new Date(1e3*e).toLocaleDateString("en"===t?"en-US":"zh-CN",{month:"short",day:"numeric"}),qa=({isVisible:e,onToggle:t,className:n=""})=>a.jsx("div",{className:`flex items-center ${n}`,children:a.jsx("button",{onClick:t,className:"w-9 h-9 flex items-center justify-center rounded-full shadow-lg backdrop-blur-sm transition-all duration-200 "+(e?"bg-blue-500/90 text-white border border-blue-400/50 shadow-blue-500/30":"bg-black/60 text-white/60 border border-white/10 hover:border-white/20"),title:e?"Hide cloud cover":"Show cloud cover",children:e?a.jsx(Z,{className:"h-4 w-4",strokeWidth:2}):a.jsx(Q,{className:"h-4 w-4",strokeWidth:2})})}),Pa=({frames:e,currentIndex:t,onIndexChange:n,isPlaying:i,onTogglePlay:o,nowIndex:r=0})=>{const{t:s,language:l}=c();if(0===e.length)return null;const d=e[t],u="forecast"===d?.type,m="satellite"===d?.type,h=e.length>1?r/(e.length-1)*100:0,g=u?"bg-amber-500/20 text-amber-400":m?"bg-teal-500/20 text-teal-400":"bg-blue-500/20 text-blue-400",f=u?s("Forecast","预报"):m?s("Satellite","卫星"):s("Radar","雷达");return a.jsx(F.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},className:"absolute bottom-2 left-2 right-2 z-[1000] pointer-events-auto",children:a.jsxs("div",{className:"bg-black/80 backdrop-blur-md rounded-lg px-3 py-2 shadow-xl border border-white/10",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{onClick:o,className:"flex-shrink-0 w-7 h-7 flex items-center justify-center rounded-full bg-blue-500/20 hover:bg-blue-500/30 transition-colors",children:i?a.jsx(J,{className:"h-3.5 w-3.5 text-blue-400"}):a.jsx(Y,{className:"h-3.5 w-3.5 text-blue-400 ml-0.5"})}),a.jsxs("div",{className:"flex-1 min-w-0 relative",children:[a.jsx(Dt,{value:[t],min:0,max:Math.max(0,e.length-1),step:1,onValueChange:e=>n(e[0]),className:"w-full"}),e.length>1&&a.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-0.5 h-4 bg-yellow-400 rounded-full pointer-events-none",style:{left:`${h}%`},title:"Now"})]}),a.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 min-w-[120px] justify-end",children:[a.jsx("span",{className:`text-[9px] font-semibold px-1.5 py-0.5 rounded-full ${g}`,children:f}),a.jsx("div",{className:"text-[10px] text-white/80 font-mono text-right",children:d&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-white/40",children:Oa(d.time,l)})," ",a.jsx("span",{children:Fa(d.time,l)})]})})]})]}),a.jsxs("div",{className:"flex items-center justify-between mt-1",children:[a.jsxs("span",{className:"text-[9px] text-white/40 flex items-center gap-1",children:[a.jsx(Z,{className:"h-2.5 w-2.5"}),s("Cloud Cover · Satellite + 3-Day Forecast","云量 · 卫星 + 3天预报")]}),a.jsx("span",{className:"text-[9px] text-white/30",children:"© RainViewer + Open-Meteo"})]})]})})},_a=n.memo(({center:e,userLocation:t,zoom:o,displayLocations:r,isMobile:s,activeView:l,searchR
2adius:c,showRadiusCircles:d,onMapClick:u,onLocationClick:m,hoveredLocationId:h,onMarkerHover:g,handleTouchStart:f,handleTouchEnd:p,handleTouchMove:y,useMobileMapFixer:x,mapRef:S,onMapReady:k,currentSiqs:b,showLightPollution:w=!0,showCloudCover:N=!1,cloudCoverHost:D="",cloudCoverFrame:C=null,onCloudBoundsChange:j,onAstroSpotCreated:L})=>{const{provider:M}=v(),R=Pe(Boolean(s),M),[I,A]=i.useState(!1);i.useEffect(()=>{const e=setTimeout(()=>A(!0),1200);return()=>clearTimeout(e)},[]);const $=n.useCallback(e=>{m&&m(e)},[m]),E=n.useCallback((e,t)=>{u&&u(e,t)},[u]);return a.jsxs(Fe,{center:e,zoom:"calculated"===l?s?4:5:s?o-1:o,style:{height:"100%",width:"100%"},scrollWheelZoom:!s,ref:S,className:"map-container "+(s?"mobile-optimized":""),whenReady:k,attributionControl:!1,worldCopyJump:!1,children:[a.jsx(Oe,{...R,maxZoom:s?R.maxZoom-2:R.maxZoom}),R.annotationUrl&&a.jsx(Oe,{url:R.annotationUrl,attribution:R.annotationAttribution,subdomains:R.annotationSubdomains,maxZoom:s?R.maxZoom-2:R.maxZoom}),a.jsx(nt,{visible:w&&I,opacity:.55}),N&&D&&C&&a.jsx(Ma,{visible:N,opacity:.9,host:D,frame:C,onBoundsChange:j}),d&&t&&!s&&a.jsx(qe,{center:[t.latitude,t.longitude],pathOptions:{color:"rgb(99, 102, 241)",fillColor:"rgb(99, 102, 241)",fillOpacity:.05,weight:1,dashArray:"5, 5"},radius:1e3*c}),a.jsx(pa,{userLocation:t,activeView:l,searchRadius:c,effects:["zoom-controls"]}),u&&a.jsx(ya,{userLocation:t,searchRadius:c,onMapClick:E}),t&&a.jsx(it,{position:[t.latitude,t.longitude],currentSiqs:b,onAstroSpotCreated:L}),r.map(e=>{if(!e||!e.latitude||!e.longitude)return null;const t=Boolean(e.isDarkSkyReserve||e.certification),n=e.id||`loc-${e.latitude?.toFixed(6)}-${e.longitude?.toFixed(6)}`,i=n,o=h===n;return a.jsx(fa,{location:e,onClick:$,isHovered:o,onHover:g||(()=>{}),locationId:n,isCertified:t,activeView:l,handleTouchStart:f,handleTouchEnd:p,handleTouchMove:y},i)}),x&&s&&a.jsx(xa,{})]})});_e();const za=n.memo(({center:e,userLocation:t,locations:n,searchRadius:o,activeView:r,onMapReady:s,onLocationClick:l,onMapClick:c,zoom:d=10,hoveredLocationId:u,onMarkerHover:m,handleTouchStart:h,handleTouchEnd:g,handleTouchMove:f,isMobile:p,useMobileMapFixer:y=!1,showRadiusCircles:x=!1,showLightPollution:S=!0,showCloudCover:k=!1,cloudCoverHost:b="",cloudCoverFrame:w=null,onCloudBoundsChange:v,onAstroSpotCreated:N})=>{const[D,C]=i.useState(!1),[j,L]=i.useState(null),M=i.useRef(null),R=i.useRef(null),I=i.useRef(!0),A=i.useCallback((e,t)=>{t||null===e||L(e)},[]);i.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const $=i.useCallback(()=>{const e=((e,t,a,n)=>{if(!e||0===e.length)return[];const i=e.filter(e=>e.isDarkSkyReserve||e.certification);let o=e.filter(e=>!e.isDarkSkyReserve&&!e.certification);return"calculated"===n&&t&&(o=o.filter(e=>!(!e.latitude||!e.longitude)&&ze(t.latitude,t.longitude,e.latitude,e.longitude)<=a&&!Be(e.latitude,e.longitude,!1))),"certified"===n?i:"obscura"===n||"mountains"===n||"darksky"===n||"natural-wonders"===n||"astrospots"===n?e:[...i,...o]})(n||[],t,o,r);return((e,t,a)=>!t||e.length<=30||"calculated"!==a?e:[...e.filter(e=>e.isDarkSkyReserve||e.certification),...e.filter(e=>!e.isDarkSkyReserve&&!e.certification).filter((e,t)=>t%2==0).slice(0,50)])(e,Boolean(p),r)},[n,t,o,r,p]);i.useEffect(()=>{if(!M.current)return;const e=M.current;let t=null;const a=()=>{t&&window.clearTimeout(t),t=window.setTimeout(()=>{e&&e.invalidateSize(),t=null},300)};window.addEventListener("resize",a);const n=setTimeout(()=>{e&&e.invalidateSize()},300);return()=>{window.removeEventListener("resize",a),t&&window.clearTimeout(t),clearTimeout(n)}},[]),i.useEffect(()=>{if(M.current)return window.leafletMap=M.current,()=>{delete window.leafletMap}},[M.current]);const E=$(),T=i.useCallback(()=>{C(!0),s&&s()},[s]);return a.jsxs("div",{ref:R,className:"relative w-full h-full",children:[t&&a.jsx(Je,{isVisible:!0,latitude:t.latitude,longitude:t.longitude,bortleScale:4,forceUpdate:!0,priorityLevel:"high",onSiqsCalculated:A},`user-location-${t.latitude.toFixed(4)}-${t.longitude.toFixed(4)}`),a.jsx(_a,{center:e,userLocation:t,zoom:d,displayLocations:E,isMobile:Boolean(p),activeView:r,searchR
2adius:o,showRadiusCircles:x,onMapClick:c,onLocationClick:l,hoveredLocationId:u,onMarkerHover:m,handleTouchStart:h,handleTouchEnd:g,handleTouchMove:f,useMobileMapFixer:y,mapRef:M,onMapReady:T,currentSiqs:j,showLightPollution:S,showCloudCover:k,cloudCoverHost:b,cloudCoverFrame:w,onCloudBoundsChange:v,onAstroSpotCreated:N})]})}),Va=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),Ba=(e,t,a,n,i)=>{const o=((e,t)=>{if("observatory"===e.spot_type)return"verified"===e.verification_status?"rgba(34, 211, 238, 0.95)":"rgba(245, 158, 11, 0.9)";const a=void 0!==t?t:We(e),n=e.certification?.toLowerCase().includes("natural mountain");return a&&a>0||n?ma(a||0):"number"==typeof e.bortleScale&&e.bortleScale>0?ma(Ze(e.bortleScale)):e.isDarkSkyReserve||e.certification?(e=>{if(!e.isDarkSkyReserve&&!e.certification&&!e.isUNESCO)return"rgba(74, 222, 128, 0.85)";const t=(e.certification||"").toLowerCase();return e.isUNESCO||t.includes("unesco")?"rgba(139, 92, 246, 0.85)":t.includes("atlas obscura")?"rgba(6, 182, 212, 0.85)":t.includes("community")?"rgba(255, 215, 0, 0.85)":t.includes("reserve")||t.includes("sanctuary")||e.isDarkSkyReserve?"rgba(155, 135, 245, 0.85)":t.includes("park")?"rgba(74, 222, 128, 0.85)":t.includes("urban")||t.includes("night sky place")?"rgba(30, 174, 219, 0.85)":t.includes("lodging")?"rgba(0, 0, 128, 0.85)":"rgba(155, 135, 245, 0.85)"})(e):"#4ADE80"})(e,i),r=e.isUNESCO||e.certification?.toLowerCase().includes("unesco"),s=e.certification?.toLowerCase().includes("atlas obscura"),l=e.certification?.toLowerCase().includes("natural mountain"),c="observatory"===e.spot_type,d=c&&"verified"===e.verification_status,u=n?a?24:d?20:18:a?32:d?28:24;let m="";return d?m=`<svg xmlns="http://www.w3.org/2000/svg" width="${.7*u}" height="${.7*u}" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n      <path d="m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44"/>\n      <path d="m13.56 11.747 4.332-.924"/>\n      <path d="m16 21-3.105-6.21"/>\n      <path d="M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z"/>\n      <path d="m6.158 8.633 1.114 4.456"/>\n      <path d="m8 21 3.105-6.21"/>\n      <circle cx="12" cy="13" r="2" fill="white"/>\n    </svg>`:c?m=`<svg xmlns="http://www.w3.org/2000/svg" width="${.66*u}" height="${.66*u}" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n      <path d="M3 21h18"/>\n      <path d="M8 21V9l4-4 4 4v12"/>\n      <path d="M10 13h4"/>\n      <path d="M12 5V2"/>\n      <path d="M7 7 5 5"/>\n      <path d="m17 7 2-2"/>\n    </svg>`:r?m=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*u}" height="${.6*u}" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="2">\n      <circle cx="12" cy="12" r="10"/>\n      <path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/>\n      <path d="M2 12h20"/>\n    </svg>`:l?m=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*u}" height="${.6*u}" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="2">\n      <path d="m8 3 4 8 5-5 5 15H2L8 3z"/>\n    </svg>`:s?m=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*u}" height="${.6*u}" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2">\n      <path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/>\n      <circle cx="12" cy="12" r="3"/>\n    </svg>`:t&&(m=`<svg xmlns="http://www.w3.org/2000/svg" width="${.6*u}" height="${.6*u}" viewBox="0 0 24 24" fill="white" stroke="white" stroke-width="2">\n      <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>\n    </svg>`),{content:`\n    <div style="\n      background-color: ${o}; \n      width: ${u}px; \n      height: ${u}px; \n      border-radius: 50%;\n      border: ${c?"3px":"2px"} solid ${d?"#ecfeff":"white"};\n      box-shadow: ${c?"0 0 0 3px rgba(34,211,238,0.2), 0 0 12px rgba(34,211,238,0.65)":"0 0 4px rgba(0,0,0,0.5)"};\n      display: flex;\n      align-items: center;\n      justify-content: center;\n      cursor: pointer;\n    ">\n      ${m}\n    </div>\n  `,size:[u,u],offset:[-u/2,-u/2]}},Ua=(e,t,a)=>{const n=e.certification?.toLowerCase().includes("atlas obscura"),i=e.certification?.toLowerCase().includes("natural mountain");
2return"certified"===a?t&&!n&&!i:"obscura"===a?n:"mountains"===a?i:"calculated"===a?!t&&!n&&!i:"darksky"===a||"natural-wonders"===a||"astrospots"===a||!(!t&&Be(e.latitude,e.longitude,Boolean(e.isDarkSkyReserve||e.certification)))},Ha=e=>{const{location:t,siqsScore:a,displayName:n,isCertified:i,isMobile:o=!1,userAvatarUrl:r,distance:s,locationType:l,chineseLocationName:c,bortleScale:d,language:u="en"}=e,m=d??t.bortleScale,h=a||We(t)||0,g=h>10?h/10:h,f=g>0?Math.min(10,g).toFixed(1):"N/A";let p="#94a3b8";g>=8?p="#10b981":g>=6?p="#fbbf24":g>=4?p="#f59e0b":g>=2?p="#f97316":g>0&&(p="#ef4444");const y=g>0?p:"rgba(148, 163, 184, 0.5)",x=Va(n);Va(t.name);const S=Va(t.chineseName||""),k=Va(c||""),b=Va(l||""),w=Va(JSON.stringify(t.id));let v="";i&&t.certification&&(v=`<div style="font-size: 12px; color: #fbbf24; margin-bottom: 6px; display: flex; align-items: center; font-weight: 500;">\n      <svg width="14" height="14" viewBox="0 0 24 24" fill="#fbbf24" stroke="#fbbf24" stroke-width="2" style="display: inline-block; vertical-align: middle; margin-right: 4px;">\n      <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>\n    </svg>${Va(t.certification)}\n    </div>`);let N="";l&&(N=`<div style="font-size: 11px; color: ${"Atlas Obscura"===l?"#d97706":"#8b5cf6"}; margin-bottom: 4px; display: flex; align-items: center;">\n      ${"Atlas Obscura"===l?'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#d97706" stroke-width="2" style="display: inline-block; margin-right: 3px;">\n          <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>\n        </svg>':'<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#8b5cf6" stroke-width="2" style="display: inline-block; margin-right: 3px;">\n          <path d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"></path>\n        </svg>'}${b}\n    </div>`);let D="";const C=(e=>{if(!e)return"";try{const t=new URL(e);if("https:"===t.protocol||"http:"===t.protocol)return Va(t.toString())}catch{return""}return""})(r);C&&(D=`<img \n      src="${C}"\n      style="\n        width: 24px;\n        height: 24px;\n        border-radius: 50%;\n        border: 1.5px solid rgba(100, 116, 139, 0.5);\n        margin-left: 8px;\n        object-fit: cover;\n      " \n      onerror="this.style.display='none'"\n    />`);const j=k?`<div style="font-size: 12px; color: #cbd5e1; margin-bottom: 6px;">\n    ${k}\n  </div>`:"",L=void 0!==s&&isFinite(s)?s<1?`${Math.round(1e3*s)}m`:`${s.toFixed(1)}km`:"",M=`<div style="font-size: 11px; color: #94a3b8; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center;">\n    <span>${t.latitude.toFixed(4)}, ${t.longitude.toFixed(4)}</span>\n    ${L?`<span style="color: #cbd5e1;">${L}</span>`:""}\n  </div>`;return`\n    <div class="amap-popup-wrapper" style="\n      background: linear-gradient(135deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 
20.95) 100%);\n      border-left: 4px solid ${y};\n      border-radius: 8px;\n      padding: 12px;\n      min-width: ${o?"200px":"220px"};\n      max-width: 280px;\n      color: white;\n      box-shadow: 0 4px 12px rgba(0,0,0,0.4);\n    ">\n      ${v}\n      ${N}\n      \n      <div style="font-size: 14px; font-weight: 600; margin-bottom: 4px; color: #f1f5f9;">\n        ${"zh"===u?"Calculated Location"===t.name?"推算观星点":S||x:x}\n      </div>\n      \n      ${j}\n      \n      ${M}\n      \n      <div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">\n        <div style="display: flex; align-items: center; gap: 12px;">\n          <div style="display: flex; align-items: center;">\n            ${i?'<svg width="14" height="14" viewBox="0 0 24 24" fill="#fbbf24" stroke="none" style="margin-right: 4px;">\n              <polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"></polygon>\n            </svg>':""}\n            <div style="color: ${p}; font-weight: 600; font-size: 16px;">\n              ${"zh"===u?"观星指数":"SIQS"}: ${f}\n            </div>\n          </div>\n      ${m&&m>=1&&m<=9?`\n          <div style="display: flex; align-items: center;">\n            <span style="color: #94a3b8; font-size: 12px; margin-right: 4px;">${"zh"===u?"光害:":"Bortle:"}</span>\n            <span style="color: ${m<=3?"#22d3ee":m<=5?"#4ade80":m<=7?"#facc15":"#f87171"}; font-weight: 600; font-size: 14px;">${"number"==typeof m?m.toFixed(2):m}</span>\n          </div>\n          `:""}\n          ${D}\n        </div>\n      </div>\n      \n      <button \n        onclick="viewAMapSpotDetails(${w})"\n        style="\n          width: 100%;\n          padding: ${o?"12px":"8px"} 12px;\n          background: rgba(59, 130, 246, 0.2);\n          color: #dbeafe;\n          border: none;\n          border-radius: 6px;\n          cursor: pointer;\n          font-size: 13px;\n          font-weight: 500;\n          transition: all 0.2s;\n          display: flex;\n          align-items: center;\n          justify-content: center;\n          gap: 6px;\n        "\n        onmouseover="this.style.background='rgba(59, 130, 246, 0.3)'"\n        onmouseout="this.style.background='rgba(59, 130, 246, 0.2)'"\n      >\n        <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">\n          <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>\n          <polyline points="15 3 21 3 21 9"></polyline>\n          <line x1="10" y1="14" x2="21" y2="3"></line>\n        </svg>\n        ${"zh"===u?"查看详情":"View Details"}\n      </button>\n    </div>\n  `},Ga=({center:e,userLocation:t,locations:n,searchRadius:s,activeView:l,zoom:d=10,onMapClick:u,onLocationClick:m,onMapReady:h,showRadiusCircles:g,isMobile:f=!1,hoveredLocationId:p,showLightPollution:y=!0,showCloudCover:x=!1,cloudCoverHost:S="",cloudCoverFrame:k=null,onCloudBoundsChange:b,onAstroSpotCreated:w})=>{const{language:v}=c(),N=o(),D=i.useRef(null),C=i.useRef(null),j=i.useRef(new Map),L=i.useRef(new Map),M=i.useRef(null),R=i.useRef(null),[I,A]=i.useState(new Map),$=i.useRef(new Map),E=i.useRef(new Map),T=i.useRef(!0),[F,O]=i.useState(null),[q,P]=i.useState(!0),[_,z]=i.useState(new Map),[V,B]=i.useState(!1),[U,H]=i.useState(null),[G,W]=i.useState(!1),[Z,Q]=i.useState(0),[J,Y]=i.useState(null),[K,X]=i.useState(new Map),ee=i.useCallback(e=>e.id||`loc-${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`,[]);i.useEffect(()=>{const e=e=>{const{path:t,state:a}=e.detail;t&&N(t,{state:a})};return window.addEventListener("navigate-to-location",e),()=>{window.removeEventListener("navigate-to-location",e)}},[N]),i.useEffect(()=>(window.viewAMapSpotDetails=e=>{const t=n.find(t=>ee(t)===e);t&&m&&m(t)},window.openAMapCreateSpotDialog=async(e,t)=>{try{const{getEnhancedLocationDetails:a}=await r(async()=>{const{getEnhancedLocationDetails:e}=await(import("./enhancedReverseGeocoding-C3sKkwIS.js"));return{getEnhancedLocationDetails:e}}
2,__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),n=(await a(e,t,"en")).formattedName||"My Spot";H({lat:e,lng:t,name:n}),B(!0)}catch(a){H({lat:e,lng:t,name:"My Spot"}),B(!0)}},()=>{delete window.viewAMapSpotDetails,delete window.openAMapCreateSpotDialog}),[n,m,ee]),i.useEffect(()=>{if(!D.current)return;if(C.current)return;const t=window.AMap;if(!t)return;const a=D.current.getBoundingClientRect();if(0===a.width||0===a.height){const e=setTimeout(()=>{Q(e=>e+1)},200);return()=>clearTimeout(e)}try{const a=new t.Map(D.current,{center:[e[1],e[0]],zoom:d,viewMode:"2D",layers:[new t.TileLayer],features:["bg","road","building","point"],showLabel:!0,labelzIndex:130,showIndoorMap:!1});C.current=a,u&&a.on("click",e=>{u(e.lnglat.lat,e.lnglat.lng)}),a.on("tileevent",e=>{e.type}),a.on("complete",()=>{W(!0);try{a.resize()}catch{}h&&h()});const n={current:!1};a.on("complete",()=>{n.current=!0});const i=setTimeout(()=>{if(!n.current){W(!0);try{a.resize()}catch{}}},3e3);return()=>{if(clearTimeout(i),C.current){try{C.current.destroy()}catch(e){}C.current=null}W(!1)}}catch(n){}},[]),i.useEffect(()=>{if(0===Z)return;if(!D.current||C.current)return;const t=window.AMap;if(!t)return;const a=D.current.getBoundingClientRect();if(0!==a.width&&0!==a.height)try{const a=new t.Map(D.current,{center:[e[1],e[0]],zoom:d,viewMode:"2D",layers:[new t.TileLayer],features:["bg","road","building","point"],showLabel:!0,labelzIndex:130,showIndoorMap:!1});C.current=a,u&&a.on("click",e=>{u(e.lnglat.lat,e.lnglat.lng)}),a.on("tileevent",e=>{e.type}),a.on("complete",()=>{W(!0);try{a.resize()}catch{}h&&h()}),setTimeout(()=>{if(!G){W(!0);try{a.resize()}catch{}}},3e3)}catch(n){}else if(Z<15){const e=setTimeout(()=>Q(e=>e+1),300);return()=>clearTimeout(e)}},[Z]),i.useEffect(()=>{C.current&&C.current.setCenter([e[1],e[0]])},[e]);const te=i.useCallback((e,t)=>{if($.current.set(e,t),A(a=>{const n=new Map(a);return n.set(e,t),n}),"user-location"===e)return void(T.current=!1);const a=j.current.get(e),i=n.find(t=>ee(t)===e);if(a&&i){const e=Boolean(i.isDarkSkyReserve||i.certification),n=Ba(i,e,!1,f,t);a.setContent(n.content)}const o=L.current.get(e);if(o&&i){const e=Boolean(i.isDarkSkyReserve||i.certification),a=_.get(i.user_id||"");let n="";"Atlas Obscura"===i.certification?n="Atlas Obscura":i.certification?.toLowerCase().includes("mountain")&&(n="Mountain"),o.setContent(Ha({location:i,siqsScore:t,displayName:"zh"===v?"Calculated Location"===i.name?"推算观星点":i.chineseName||i.name:i.name,isCertified:e,userId:i.user_id,isMobile:f,userAvatarUrl:a?.avatar_url,distance:i.distance,locationType:n,chineseLocationName:"",language:v}))}},[n,_,f,ee,v]),ae=i.useCallback((e,t)=>{O(e),P(t),T.current=t,t||null===e||te("user-location",e)},[te]),ne=i.useRef(null),ie=i.useRef({en:"Your Location"});i.useEffect(()=>{t&&(async()=>{try{const e=await vt(t.latitude,t.longitude);e.bortle>=1&&e.bortle<=9&&Y(e.bortle)}catch(e){}})()},[t?.latitude,t?.longitude]);const oe=i.useCallback((e,a=!1)=>{const{en:n,zh:i}=ie.current,o=t?.latitude||0,r=t?.longitude||0;return ot({title:"zh"===v?"您的位置":"Your Location",locationName:"zh"===v&&i||n,latitude:o,longitude:r,siqs:e>0?e:null,siqsLoading:a,bortleScale:J,showViewDetails:!0,showCreateSpot:!0,viewDetailsAction:"viewUserLocationDetails()",createSpotAction:`window.openAMapCreateSpotDialog(${o}, ${r})`,language:v})},[t,J,v]);return i.useEffect(()=>{if(!ne.current||!t)return;const e=F??0;try{ne.current.setContent(oe(e,q))}catch(a){}},[F,q,oe,t]),i.useEffect(()=>{if(!C.current||!t)return;T.current=!0,P(!0),M.current&&C.current&&(C.current.remove(M.current),M.current=null),R.current&&C.current&&(C.current.remove(R.current),R.current=null),ie.current={en:"Loading..."};const e=new window.AMap.Marker({position:[t.longitude,t.latitude],icon:new window.AMap.Icon({size:new window.AMap.Size(32,42),image:"data:image/svg+xml;base64,"+btoa('\n          <svg xmlns="http://www.w3.org/2000/svg" width="32" height="42" viewBox="0 0 32 42">\n            <path d="M16 0C7.2 0 0 7.2 0 16c0 11 16 26 16 26s16-15 16-26c0-8.8-7.2-16-16-16z" fill="#e11d48"/>\n            <circle cx="16" cy="16" r="6" fill="white"/>\n          </svg>\n        '),imageSize:new window.AMap.Size(32,42)}),title:"Your Location",anchor:"bottom-center",zIndex:1100});C.current.add(e),M.current=e;const a=`loc-${t.latitude.toFixed(6)}-${t.longitude.toFixed(6)}`;
2window.viewUserLocationDetails=()=>{window.dispatchEvent(new CustomEvent("navigate-to-location",{detail:{path:`/location/${a}`,state:{id:a,latitude:t.latitude,longitude:t.longitude,name:ie.current?.en||"Your Location",timestamp:Date.now()}}}))};const n=$.current.get("user-location")||0,i=new window.AMap.InfoWindow({content:oe(n),offset:new window.AMap.Pixel(0,-42),closeWhenClickMap:!0});if(ne.current=i,e.on("click",()=>{i.open(C.current,e.getPosition())}),(async()=>{try{const{getEnhancedLocationDetails:e}=await r(async()=>{const{getEnhancedLocationDetails:e}=await(import("./enhancedReverseGeocoding-C3sKkwIS.js"));return{getEnhancedLocationDetails:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),a=(await e(t.latitude,t.longitude,"en")).formattedName||"Your Location";window.AMap.plugin("AMap.Geocoder",function(){new window.AMap.Geocoder({city:"全国",radius:1e3}).getAddress([t.longitude,t.latitude],(e,t)=>{"complete"===e&&t.regeocode?ie.current={en:a,zh:t.regeocode.formattedAddress}:ie.current={en:a};const n=$.current.get("user-location")||0;i.setContent(oe(n))})})}catch(e){ie.current={en:"Your Location"}}})(),g&&s>0){const e=new window.AMap.Circle({center:[t.longitude,t.latitude],radius:1e3*s,strokeColor:"#3b82f6",strokeWeight:2,fillColor:"#3b82f6",fillOpacity:.1});C.current.add(e),R.current=e}return()=>{delete window.viewUserLocationDetails,ne.current=null,M.current&&C.current&&(C.current.remove(M.current),M.current=null),R.current&&C.current&&(C.current.remove(R.current),R.current=null)}},[t,s,g,oe]),i.useEffect(()=>{n.length>0&&(async()=>{const e=[...new Set(n.map(e=>e.user_id).filter(Boolean))],t=new Map(_);for(const n of e)if(n&&!t.has(n))try{const{supabase:e}=await r(async()=>{const{supabase:e}=await import("./index-H_Ttc-JF.js").then(e=>e.d1);return{supabase:e}},__vite__mapDeps([2,1,3,4,5,6,7,8])),{data:a}=await e.from("profiles").select("avatar_url, username").eq("id",n).single();a&&t.set(n,a)}catch(a){}z(t)})()},[n]),i.useEffect(()=>{if(C.current&&n)return j.current.forEach(e=>{e&&C.current&&C.current.remove(e)}),j.current.clear(),L.current.clear(),n.forEach(e=>{const t=ee(e),a=Boolean(e.isDarkSkyReserve||e.certification);if(!Ua(e,a,l))return;const n=p===t,i=$.current.get(t)||We(e),o=E.current.get(t)||e.bortleScale,r=Ba(e,a,n,f,i),s=new window.AMap.Marker({position:[e.longitude,e.latitude],title:e.name,content:r.content,offset:new window.AMap.Pixel(...r.offset),zIndex:1100}),c=_.get(e.user_id||"");let d="";"Atlas Obscura"===e.certification?d="Atlas Obscura":e.certification?.toLowerCase().includes("mountain")&&(d="Mountain");let u="";const m=new window.AMap.InfoWindow({content:Ha({location:e,siqsScore:i,displayName:"zh"===v?"Calculated Location"===e.name?"推算观星点":e.chineseName||e.name:e.name,isCertified:a,userId:e.user_id,isMobile:f,userAvatarUrl:c?.avatar_url,distance:e.distance,locationType:d,chineseLocationName:u,bortleScale:o,language:v}),offset:new window.AMap.Pixel(0,-r.size[1]/2)});window.AMap.plugin("AMap.Geocoder",function(){new window.AMap.Geocoder({city:"全国",radius:1e3}).getAddress([e.longitude,e.latitude],(n,i)=>{if("complete"===n&&i.regeocode){u=i.regeocode.formattedAddress;const n=$.current.get(t)||We(e),o=E.current.get(t)||e.bortleScale;m.setContent(Ha({location:e,siqsScore:n,displayName:"zh"===v?"Calculated Location"===e.name?"推算观星点":e.chineseName||e.name:e.name,isCertified:a,userId:e.user_id,isMobile:f,userAvatarUrl:c?.avatar_url,distance:e.distance,locationType:d,chineseLocationName:u,bortleScale:o,language:v}))}})}),s.on("click",()=>{m.open(C.current,s.getPosition())}),C.current.add(s),j.current.set(t,s),L.current.set(t,m)}),()=>{j.current.forEach(e=>{e&&C.current&&C.current.remove(e)}),j.current.clear(),L.current.clear()}},[n,l,p,f,_,ee]),i.useEffect(()=>{G&&0!==n.length&&(async()=>{const e=new Map(K);for(const a of n.slice(0,50)){const n=ee(a);if(!e.has(n))try{const t=await vt(a.latitude,a.longitude,a.bortleScale);t.bortle>=1&&t.bortle<=9&&(e.set(n,t.bortle),E.current.set(n,t.bortle))}catch(t){}}X(e)})()},[G,n,ee]),i.useEffect(()=>{if(!p)return;const e=j.current.get(p);if(e){const t=n.find(e=>ee(e)===p);if(t){const a=Boolean(t.isDarkSkyReserve||t.certification),n=$.current.get(ee(t))||We(t),i=Ba(t,a,!0,f,n);e.setContent(i.content)}}},[p,n,f,ee]),a.jsxs("div",{className:"relative w-full h-full",children:[t&&a.jsx(Je,{isVisible:!0,latitude:t.latitude,longitude:t.longitude,bortleScale:4,forceUpdate:!0,priorityLevel:"high",onSiqsCalculated:(e,t)=>{ae(e,t)}},`user-location-${t.latitude.toFixed(4)}-${t.longitude.toFixed(4)}`),n.map(e=>{const t=ee(e),n=Boolean(e.isDarkSkyReserve||e.certification);return Ua(e,n,l)?a.jsx(Je,{isVisible:!0,latitude:e.latitude,longitude:e.longitude,bortleScale:e.bortleScale||4,existingSiqs:e.siqs,onSiqsCalculated:e=>{null!==e&&te(t,e)}},t):null}),a.jsx("div",{ref:D,className:"w-full h-full"}),G&&C.current&&a.jsx(rt,{map:C.current,visible:y,opacity:.55}),G&&C.current&&x&&S&&k&&a.jsx(Ra,{map:C.current,visible:x,opacity:.9,host:S,frame:k,onBoundsChange:b}),V&&U&&a.jsx(Ct,{latitude:U.lat,longitude:U.lng,defaultName:U.name,stayOnPage:Boolean(w),onCreated:w,onClose:()=>{B(!1),H(null)}})]})},Wa=({center:e,userLocation:t,locations:n,searchRadius:s,activeView:l,zoom:d=10,onMapClick:u,onLocationClick:m,onMapReady:h,showRadiusCircles:g,isMobile:f=!1,hoveredLocationId:p,showLightPollution:y=!0,showCloudCover:x=!1,cloudCoverHost:S="",cloudCoverFrame:k=null,onCloudBoundsChange:b,onAstroSpotCreated:w})=>{const{language:v}=c(),N=o(),D=i.useRef(null),C=i.useRef(null),j=i.useRef(new Map),L=i.useRef(new Map),M=i.useRef(null),R=i.useRef(null),I=i.useRef(!0),A=i.useRef(null),[$,E]=i.useState(new Map),[T,F]=i.useState(null),[O,q]=i.useState(!0),[P,_]=i.useState(new Map),[z,V]=i.useState(!1),[B,U]=i.useState(null),[H,G]=i.useState(!1),[W,Z]=i.useState(0),[Q,J]=i.useState(null),[Y,K]=i.useState(new Map),X=i.useCallback(e=>e.id||`loc-${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`,[]);i.useEffect(()=>{const e=e=>{const{path:t,state:a}=e.detail;t&&N(t,{state:a})};return window.addEventListener("navigate-to-location",e),()=>window.removeEventListener("navigate-to-location",e)},[N]),i.useEffect(()=>(window.viewTMapSpotDetails=e=>{const t=n.find(t=>X(t)===e);t&&m&&m(t)},window.openTMapCreateSpotDialog=async(e,t)=>
2{try{const{getEnhancedLocationDetails:a}=await r(async()=>{const{getEnhancedLocationDetails:e}=await(import("./enhancedReverseGeocoding-C3sKkwIS.js"));return{getEnhancedLocationDetails:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),n=await a(e,t,"en");U({lat:e,lng:t,name:n.formattedName||"My Spot"}),V(!0)}catch{U({lat:e,lng:t,name:"My Spot"}),V(!0)}},()=>{delete window.viewTMapSpotDetails,delete window.openTMapCreateSpotDialog}),[n,m,X]),i.useEffect(()=>{if(!D.current||C.current)return;const t=window.TMap;if(!t)return;const a=D.current.getBoundingClientRect();if(0!==a.width&&0!==a.height)try{const a=new t.Map(D.current,{center:new t.LatLng(e[0],e[1]),zoom:d,baseMap:{type:"vector"},viewMode:"2D",showControl:!1}),n="tmap-hide-controls";if(!document.getElementById(n)){const e=document.createElement("style");e.id=n,e.textContent='\n          .tmap-ctrl, .tmap-controls, [class*="tmap-control"],\n          .tmap-logo, .tmap-copyright, .tencent-map-logo,\n          [class*="logo-text"], [class*="smnoprint"],\n          .tmap-scale-control, .tmap-zoom-control, .tmap-rotate-control {\n            display: none !important;\n            visibility: hidden !important;\n          }\n        ',document.head.appendChild(e)}C.current=a,a.on("click",e=>{if(st(L.current),R.current)try{R.current.close()}catch{}const t=e.latLng;t&&u&&u(t.getLat(),t.getLng())}),a.on("tilesloaded",()=>{G(!0),h&&h()});const i=setTimeout(()=>{H||(G(!0),h&&h())},3e3);return()=>{if(clearTimeout(i),C.current){try{C.current.destroy()}catch{}C.current=null}G(!1)}}catch(n){}else if(W<15){const e=setTimeout(()=>Z(e=>e+1),200);return()=>clearTimeout(e)}},[W]),i.useEffect(()=>{if(C.current)try{const t=window.TMap;C.current.setCenter(new t.LatLng(e[0],e[1]))}catch{}},[e]);const ee=i.useCallback((e,t,a)=>{const n=Boolean(e.isDarkSkyReserve||e.certification),i=P.get(e.user_id||"");let o="";return"Atlas Obscura"===e.certification?o="Atlas Obscura":e.certification?.toLowerCase().includes("mountain")&&(o="Mountain"),Ha({location:e,siqsScore:t,displayName:"zh"===v?"Calculated Location"===e.name?"推算观星点":e.chineseName||e.name:e.name,isCertified:n,userId:e.user_id,isMobile:f,userAvatarUrl:i?.avatar_url,distance:e.distance,locationType:o,chineseLocationName:"",bortleScale:a??e.bortleScale,language:v}).replace(/viewAMapSpotDetails/g,"viewTMapSpotDetails")},[P,f,v]),te=i.useCallback((e,t)=>{E(a=>{const n=new Map(a);return n.set(e,t),n});const a=L.current.get(e),i=n.find(t=>X(t)===e);if(a&&i){const n=Y.get(e)??i.bortleScale;a.setContent(ee(i,t,n))}"user-location"===e&&(I.current=!1,q(!1))},[n,Y,X]);i.useEffect(()=>{t&&vt(t.latitude,t.longitude).then(e=>{e.bortle>=1&&e.bortle<=9&&J(e.bortle)}).catch(()=>{})},[t?.latitude,t?.longitude]);const ae=i.useRef({en:"Your Location"}),ne=i.useCallback((e,a=I.current)=>ot({title:"zh"===v?"您的位置":"Your Location",locationName:"zh"===v&&ae.current.zh||ae.current.en,latitude:t?.latitude||0,longitude:t?.longitude||0,siqs:e>0?e:null,siqsLoading:a,bortleScale:Q,showViewDetails:!0,showCreateSpot:!0,viewDetailsAction:"viewTMapUserLocationDetails()",createSpotAction:`window.openTMapCreateSpotDialog(${t?.latitude}, ${t?.longitude})`,language:v}),[t,Q,v]);return i.useEffect(()=>{if(R.current&&t){const e=T??0;R.current.setContent(ne(e,O))}},[$,ne,t,Q]),i.useEffect(()=>{if(!C.current||!t)return;if(I.current=!0,q(!0),M.current){try{M.current.setMap(null)}catch{}M.current=null}if(R.current){try{R.current.setMap(null)}catch{}R.current=null}if(A.current){try{A.current.setMap(null)}catch{}A.current=null}const e=window.TMap;if(!e)return;const a=lt(e,C.current,t.latitude,t.longitude,'\n      <svg xmlns="http://www.w3.org/2000/svg" width="32" height="42" viewBox="0 0 32 42">\n        <path d="M16 0C7.2 0 0 7.2 0 16c0 11 16 26 16 26s16-15 16-26c0-8.8-7.2-16-16-16z" fill="#e11d48"/>\n        <circle cx="16" cy="16" r="6" fill="white"/>\n      </svg>');M.current=a,window.viewTMapUserLocationDetails=()=>{const e=`loc-${t.latitude.toFixed(6)}-${t.longitude.toFixed(6)}`;window.dispatchEvent(new CustomEvent("navigate-to-location",{detail:{path:`/location/${e}`,state:{id:e,latitude:t.latitude,longitude:t.longitude,name:ae.current.en,timestamp:Date.now()}}}))};const n=T??0,i=ct(e,C.current,t.latitude,t.longitude,ne(n,O));R.current=i,i.close();const o=()=>{const e=a.getEl();e?e.addEventListener("click",e=>{e.stopPropagation(),st(L.current),i.open()}):setTimeout(o,100)};if(o(),(async()=>
2{try{const{getEnhancedLocationDetails:e}=await r(async()=>{const{getEnhancedLocationDetails:e}=await(import("./enhancedReverseGeocoding-C3sKkwIS.js"));return{getEnhancedLocationDetails:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17])),a=await e(t.latitude,t.longitude,"en");ae.current={en:a.formattedName||"Your Location"};const n=$.get("user-location")||0;i.setContent(ne(n))}catch{}})(),g&&s>0&&e.Circle){const a=new e.LatLng(t.latitude,t.longitude),n=new e.Circle({map:C.current,center:a,radius:1e3*s,styles:{default:new e.CircleStyle({color:"rgba(59,130,246,0.1)",showBorder:!0,borderColor:"rgba(59,130,246,0.8)",borderWidth:2})}});A.current=n}return()=>{if(delete window.viewTMapUserLocationDetails,R.current){try{R.current.setMap(null)}catch{}R.current=null}if(M.current){try{M.current.setMap(null)}catch{}M.current=null}if(A.current){try{A.current.setMap(null)}catch{}A.current=null}}},[t,s,g,ne]),i.useEffect(()=>{if(!R.current||!t)return;const e=T??0;try{R.current.setContent(ne(e,O))}catch(a){}},[T,O,ne,t]),i.useEffect(()=>{n.length>0&&(async()=>{const e=[...new Set(n.map(e=>e.user_id).filter(Boolean))],t=new Map(P);for(const a of e)if(a&&!t.has(a))try{const{supabase:e}=await r(async()=>{const{supabase:e}=await import("./index-H_Ttc-JF.js").then(e=>e.d1);return{supabase:e}},__vite__mapDeps([2,1,3,4,5,6,7,8])),{data:n}=await e.from("profiles").select("avatar_url, username").eq("id",a).single();n&&t.set(a,n)}catch{}_(t)})()},[n]),i.useEffect(()=>{if(!C.current||!n)return;const e=window.TMap;return e?(j.current.forEach(e=>{try{e.setMap(null)}catch{}}),L.current.forEach(e=>{try{e.close(),e.setMap(null)}catch{}}),j.current.clear(),L.current.clear(),n.forEach(t=>{const a=X(t),n=Boolean(t.isDarkSkyReserve||t.certification);if(!Ua(t,n,l))return;const i=$.get(a)||We(t),o=Y.get(a)||t.bortleScale,r=Ba(t,n,p===a,f,i),s=lt(e,C.current,t.latitude,t.longitude,r.content),c=ee(t,i,o),d=ct(e,C.current,t.latitude,t.longitude,c);d.close(),dt(s,L.current,a,d),j.current.set(a,s),L.current.set(a,d)}),()=>{j.current.forEach(e=>{try{e.setMap(null)}catch{}}),L.current.forEach(e=>{try{e.close(),e.setMap(null)}catch{}}),j.current.clear(),L.current.clear()}):void 0},[n,l,p,f,$,P,Y,v,X]),i.useEffect(()=>{H&&0!==n.length&&(async()=>{const e=new Map(Y);for(const t of n.slice(0,50)){const a=X(t);if(!e.has(a))try{const n=await vt(t.latitude,t.longitude,t.bortleScale);n.bortle>=1&&n.bortle<=9&&e.set(a,n.bortle)}catch{}}K(e)})()},[H,n,X]),i.useEffect(()=>{if(!p)return;const e=j.current.get(p);if(e){const t=n.find(e=>X(e)===p);if(t){const a=Boolean(t.isDarkSkyReserve||t.certification),n=$.get(X(t))||We(t),i=Ba(t,a,!0,f,n);e.setHTML?.(i.content)}}},[p,n,f,$,X]),a.jsxs("div",{className:"relative w-full h-full",style:{zIndex:0,isolation:"isolate"},children:[t&&a.jsx(Je,{isVisible:!0,latitude:t.latitude,longitude:t.longitude,bortleScale:Q??4,forceUpdate:!0,priorityLevel:"high",onSiqsCalculated:(e,t)=>{F(e),q(t),I.current=t,t||null===e||te("user-location",e)}},`user-tmap-${t.latitude.toFixed(4)}-${t.longitude.toFixed(4)}`),n.map(e=>{const t=X(e),n=Boolean(e.isDarkSkyReserve||e.certification);return Ua(e,n,l)?a.jsx(Je,{isVisible:!0,latitude:e.latitude,longitude:e.longitude,bortleScale:Y.get(t)??e.bortleScale??4,onSiqsCalculated:e=>{null!==e&&te(t,e)}},t):null}),a.jsx("div",{ref:D,className:"w-full h-full"}),H&&C.current&&a.jsx(ut,{map:C.current,visible:y,opacity:.55}),H&&C.current&&x&&S&&k&&a.jsx(Ta,{map:C.current,visible:x,opacity:.9,host:S,frame:k,onBoundsChange:b}),z&&B&&a.jsx(Ct,{latitude:B.lat,longitude:B.lng,defaultName:B.name,stayOnPage:Boolean(w),onCreated:w,onClose:()=>{V(!1),U(null)}})]})},Za=e=>{const{provider:t,isAMapReady:n,isTMapReady:i}=v();return"amap"===t?n?a.jsx(Ga,{...e}):a.jsx(za,{...e}):"tmap"===t&&i?a.jsx(Wa,{...e}):a.jsx(za,{...e})},Qa=({showStarLegend:e=!0,showCircleLegend:t=!0,className:n="",activeView:o="calculated",onToggle:r})=>{const{t:s}=c(),[l,d]=i.useState(!1),[u,m]=i.useState("lorenz"),h=e||"certified"===o,g=t||"calculated"===o,f="obscura"===o,p=e=>{e.stopPropagation(),e.preventDefault()};return i.useEffect(()=>{r&&r(l)},[l,r]),i.useEffect(()=>{const e=e=>{const t=e.detail;"china-standard"!==t?.mapStyle&&"lorenz"!==t?.mapStyle||m(t.mapStyle)};return(()=>{try{const e=localStorage.getItem("light-pollution-runtime-config");if(!e)return;const t=JSON.parse(e);"china-standard"!==t?.mapStyle&&"lorenz"!==t?.mapStyle||m(t.mapStyle)}catch{}})(),window.addEventListener(Lt,e),()=>window.removeEventListener(Lt,e)},[]),a.jsxs("div",{className:`${n}`,onClick:p,onTouchStart:p,children:[!l&&a.jsx("button",{onClick:()=>d(!0),className:"w-9 h-9 flex items-center justify-center rounded-full shadow-lg backdrop-blur-sm bg-black/60 text-white/80 border border-white/10 hover:border-white/20 transition-all duration-200",title:s("Map Legend","地图图例"),children:a.jsx(K,{className:"h-4 w-4",strokeWidth:2})}),a.jsx(X,{children:l&&a.jsxs(F.div,{initial:{opacity:0,scale:.9,y:-8}
2,animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.9,y:-8},transition:{duration:.2},className:"bg-black/80 backdrop-blur-md rounded-lg shadow-xl border border-white/10 w-[180px] overflow-hidden",onClick:p,children:[a.jsxs("button",{onClick:()=>d(!1),className:"w-full flex items-center justify-between px-2.5 py-2 hover:bg-white/5 transition-colors",children:[a.jsxs("span",{className:"text-[10px] font-semibold text-white/90 tracking-wide uppercase flex items-center gap-1.5",children:[a.jsx(K,{className:"h-3 w-3 text-white/60"}),s("Map Legend","地图图例")]}),a.jsx(ee,{className:"h-3 w-3 text-white/40"})]}),a.jsxs("div",{className:"px-2.5 pb-2.5 space-y-2",children:[h&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("h4",{className:"text-[9px] font-medium text-white/50 uppercase tracking-wider",children:s("Certified Locations","认证地点")}),a.jsx(Ja,{color:"hsl(var(--primary))",label:s("Reserve/Sanctuary","保护区/庇护所"),type:"star"}),a.jsx(Ja,{color:"#4ADE80",label:s("Dark Sky Park","暗夜公园"),type:"star"}),a.jsx(Ja,{color:"#FFA500",label:s("Community","暗夜社区"),type:"star"}),a.jsx(Ja,{color:"#0EA5E9",label:s("Urban Night Sky","城市夜空"),type:"star"}),a.jsx(Ja,{color:"#1e3a8a",label:s("Dark Sky Lodging","暗夜住宿"),type:"hotel"}),a.jsx(Ja,{color:"#8b5cf6",label:s("UNESCO Place","教科文组织地点"),type:"unesco"})]}),g&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("h4",{className:"text-[9px] font-medium text-white/50 uppercase tracking-wider",children:s("SIQS Score","SIQS评分")}),a.jsx(Ja,{color:"#22c55e",label:s("Excellent (7.5-10)","极佳 (7.5-10)"),type:"circle"}),a.jsx(Ja,{color:"#eab308",label:s("Good (5.5-7.4)","良好 (5.5-7.4)"),type:"circle"}),a.jsx(Ja,{color:"#f97316",label:s("Average (4.0-5.4)","一般 (4.0-5.4)"),type:"circle"}),a.jsx(Ja,{color:"#ef4444",label:s("Below Avg (<4.0)","较差 (<4.0)"),type:"circle"})]}),f&&a.jsxs("div",{className:"space-y-1",children:[a.jsx("h4",{className:"text-[9px] font-medium text-white/50 uppercase tracking-wider",children:s("Atlas Obscura","奇观")}),a.jsx(Ja,{color:"#06b6d4",label:s("Obscura Location","奇观位置"),type:"eye"})]}),a.jsxs("div",{className:"pt-1 border-t border-white/5",children:[a.jsx("h4",{className:"text-[9px] font-medium text-white/50 uppercase tracking-wider mb-1",children:s("LP Map Version","光污染地图版本")}),a.jsx("p",{className:"text-[9px] text-white/70",children:"china-standard"===u?s("China Q/GT 001-2025","中国 Q/GT 001-2025"):s("Lorenz Original","洛伦兹原图")})]}),a.jsx("p",{className:"text-[8px] text-white/30 pt-1 border-t border-white/5",children:s("Tap markers for details","点击标记查看详情")})]})]})})]})},Ja=({color:e,label:t,type:n})=>{const i="star"===n?a.jsx(z,{className:"h-2.5 w-2.5",style:{color:e,fill:e}}):"hotel"===n?a.jsx(te,{className:"h-2.5 w-2.5",style:{color:e,fill:e}}):"eye"===n?a.jsx(P,{className:"h-2.5 w-2.5",style:{color:e}}):"unesco"===n?a.jsx(ae,{className:"h-2.5 w-2.5",style:{color:e,fill:e}}):a.jsx(ne,{className:"h-2.5 w-2.5",style:{color:e,fill:`${e}40`}}
2);return a.jsxs("div",{className:"flex items-center gap-1.5 py-px",children:[a.jsx("div",{className:"w-4 flex items-center justify-center flex-shrink-0",children:i}),a.jsx("span",{className:"text-[9px] text-white/70 leading-tight",children:t})]})},Ya=({onGetLocation:e,className:t="",shouldCenter:n=!0,hasLocation:o=!1})=>{const{t:r}=c(),[s,l]=i.useState(!1),d=e=>{e.stopPropagation(),e.preventDefault()},u=i.useCallback(t=>{if(d(t),l(!0),e(),n)try{const e=window.leafletMap;e&&setTimeout(()=>{e.setView([e.getCenter().lat,e.getCenter().lng],12,{animate:!0,duration:1})},300)}catch(a){Re.error(r("Could not center map","无法将地图居中"))}setTimeout(()=>l(!1),1e3)},[e,n,r]);return a.jsx("div",{className:t,onClick:d,onTouchStart:d,children:a.jsx("button",{onClick:u,className:"w-9 h-9 flex items-center justify-center rounded-full shadow-lg backdrop-blur-sm transition-all duration-200 "+(o?"bg-primary/90 text-white border border-primary/50 shadow-primary/30":"bg-black/60 text-white/70 border border-white/10 hover:border-white/20"),title:r("My Location","我的位置"),children:a.jsx(q,{className:"h-4 w-4",strokeWidth:2})})})};function Ka(e,t,a,n,i){if(!e||!t||!i)return;const o=Math.max(0,Math.min(n,7)),r=Math.pow(2,o),s=r-1,l=e=>Math.floor((e+180)/360*r),c=e=>{const t=e*Math.PI/180;return Math.floor((1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2*r)},d=Math.max(0,l(i.lngMin)),u=Math.min(s,l(i.lngMax)),m=Math.max(0,c(i.latMax)),h=Math.min(s,c(i.latMin)),g="satellite"===a?0:2,f="satellite"===a?"0":va;for(let p=d;p<=u;p++)for(let a=m;a<=h;a++)(new Image).src=`${e}${t}/256/${o}/${p}/${a}/${g}/${f}.png`}const Xa=({userLocation:e,locations:t,searchRadius:n,activeView:o,mapReady:r,handleMapReady:s,handleLocationClicked:l,handleMapClick:d,mapCenter:u,initialZoom:m,mapContainerHeight:g,isMobile:f,hoveredLocationId:p,handleHover:y,handleTouchStart:x,handleTouchEnd:S,handleTouchMove:k,handleGetLocation:b,onLegendToggle:w,onAstroSpotCreated:v})=>{const{t:N}=c(),[D,C]=i.useState(!0),[j,L]=i.useState(!1),M=(()=>{const[e,t]=i.useState([]),[a,n]=i.useState(""),[o,r]=i.useState(0),[s,l]=i.useState(!1),[c,d]=i.useState(!0),[u,m]=i.useState(null),[h,g]=i.useState(0),[f,p]=i.useState(null),y=i.useRef(0),x=i.useRef([]),S=i.useRef(!1),k=i.useRef(null),b=i.useRef(null),w=i.useRef(null),v=i.useRef(null),N=i.useRef(null),D=i.useRef(!0),C=i.useRef([]),j=i.useRef([]),L=i.useRef(""),M=i.useCallback(e=>{y.current=e,r(e)},[]),R=i.useCallback((e,a,i,o,r)=>{const s=e.length>0?e[e.length-1].time:a.length>0?a[a.length-1].time:0,l=[...a.length>0?a:e,...i.filter(e=>e.time>s)].sort((e,t)=>e.time-t.time);x.current=l,n(o),t(l);const c=Math.floor(Date.now()/1e3);let d=0,u=1/0;if(l.forEach((e,t)=>{const a=Math.abs(e.time-c);a<u&&(u=a,d=t)}),g(d),r)M(d);else{const e=Math.min(y.current,Math.max(0,l.length-1));e!==y.current&&M(e)}},[M]),I=i.useCallback(async()=>{try{const e=await fetch("https://api.rainviewer.com/public/weather-maps.json");if(!e.ok)return;const t=await e.json();L.current=t.host,C.current=[...(t.radar?.past||[]).map(e=>({time:e.time,path:e.path,type:"radar"})),...(t.radar?.nowcast||[]).map(e=>({time:e.time,path:e.path,type:"radar"}))],j.current=(t.satellite?.infrared||[]).map(e=>({time:e.time,path:e.path,type:"satellite"}))}catch(e){}},[]),A=i.useCallback(async(e,t)=>{N.current&&N.current.abort();const a=new AbortController;N.current=a;try{d(!0),m(null);const{frames:n,fetchedBounds:i}=await async function(e,t){const a=10,n=.2*(e.latMax-e.latMin),i=.2*(e.lngMax-e.lngMin),o=Math.max(-85,e.latMin-n),r=Math.min(85,e.latMax+n),s=Math.max(-180,e.lngMin-i),l=Math.min(180,e.lngMax+i),c=(r-o)/7,d=(l-s)/9,u=Array.from({length:8},(e,t)=>+(o+t*c).toFixed(2)),m=Array.from({length:a},(e,t)=>+(s+t*d).toFixed(2)),h=[],g=[];for(const y of u)for(const e of m)h.push(String(y)),g.push(String(e));const f={latMin:o,latMax:r,lngMin:s,lngMax:l};try{const e=`https://api.open-meteo.com/v1/forecast?latitude=${h.join(",")}&longitude=${g.join(",")}&hourly=cloud_cover,wind_speed_10m,wind_direction_10m&forecast_days=3&timezone=UTC`,n=await fetch(e,{signal:t});if(!n.ok)return{frames:[],fetchedBounds:f};const i=await n.json(),o=Array.isArray(i)?i:[i];if(!o.length)return{frames:[],fetchedBounds:f};const r=o[0]?.hourly?.time||[];if(!r.length)return{frames:[],fetchedBounds:f};const s=3,l=[];for(let t=0;t<r.length;t+=s){const e=Math.floor(new Date(r[t]+"Z").getTime()/1e3),n=Array.from({length:8},()=>new Array(a).fill(0)),i=Array.from({length:8},()=>new Array(a).fill(0)),s=Array.from({length:8},()=>new Array(a).fill(0));for(let r=0;r<8;r++)for(let e=0;e<a;e++){const l=o[r*a+e];n[r][e]=l?.hourly?.cloud_cover?.[t]??0;const c=l?.hourly?.wind_speed_10m?.[t]??0,d=(l?.hourly?.wind_direction_10m?.[t]??0)*Math.PI/180;i[r][e]=c*Math.sin(d),s[r][e]=c*Math.cos(d)}const c={latitudes:u,longitudes:m,values:n,windU:i,windV:s};l.push({time:e,path:"",type:"forecast",forecastData:c})}return{frames:l,fetchedBounds:f}}catch(p){if("AbortError"===p?.name)throw p;return{frames:[],fetchedBounds:f}}}(e,a.signal);w.current=i,p(i),R(C.current,j.current,n,L.current,t)}catch(n){"AbortError"!==n?.name&&m(String(n?.message||n))}finally{d(!1)}},[R]);i.useEffect(()=>{(async()=>{d(!0),await I(),await A(b.current||{latMin:-60,latMax:70,lngMin:-180,lngMax:180},!0),D.current=!1})();const e=setInterval(async()=>{await I(),b.current&&await A(b.current,!1)},3e5);return()=>{clearInterval(e),N.current&&N.current.abort()}},[I,A]),i.useEffect(()=>{const e=x.current,t=b.current,a=L.current;if(e.length&&t&&a)for(let n=1;n<=3;n++){const i=e[(o+n)%e.length];!i||"radar"!==i.type&&"satellite"!==i.type||Ka(a,i.path,i.type,7,t)}},[o]);const $=i.useCallback(e=>{b.current=e,function(e,t){if(!e)return!0;const a=e.lngMax-e.lngMin,n=e.latMax-e.latMin,i=t.lngMax-t.lngMin,o=t.latMax-t.latMin;if(Math.max(i/(a||1),o/(n||1),a/(i||1),n/(o||1))>1.5)return!0;const r=Math.abs((t.latMin+t.latMax)/2-(e.latMin+e.latMax)/2),s=Math.abs((t.lngMin+t.lngMax)/2-(e.lngMin+e.lngMax)/2);return r>.35*n||s>.35*a}(w.current,e)&&(v.current&&clearTimeout(v.current),v.current=window.setTimeout(()=>{A(e,!1)},1500))},[A]);i.useEffect(()=>{if(S.current=s,!s)return void(k.current&&(clearTimeout(k.current),k.current=null));if(0===x.current.length)return;const e=()=>{S.current&&(M((y.current+1)%Math.max(1,x.current.length)),k.current=window.setTimeout(e,400))};return k.current=window.setTimeout(e,400),()=>{k.current&&clearTimeout(k.current)}},[s,M]);const E=i.useCallback(()=>l(e=>!e),[]);return{frames:e,host:a,currentIndex:o,setCurrentIndex:M,isPlaying:s,togglePlay:E,isLoading:c,error:u,nowIndex:h,setMapBounds:$,forecastBounds:f}}
2)();return a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{height:g},className:"relative mb-3 mt-2 w-full max-w-none overflow-hidden rounded-none transition-all duration-300 sm:mb-4 sm:rounded-md",children:[!r&&a.jsx("div",{className:"absolute inset-0 z-20",children:a.jsx("div",{className:"flex h-full items-center justify-center bg-background/80",children:a.jsx(h,{className:"animate-spin h-10 w-10 text-primary"})})}),a.jsx(Za,{center:u,userLocation:e,locations:t,searchRadius:n,activeView:o,onMapReady:s,onLocationClick:l,onMapClick:d,zoom:m,hoveredLocationId:p,onMarkerHover:y,handleTouchStart:x,handleTouchEnd:S,handleTouchMove:k,isMobile:f,useMobileMapFixer:!1,showRadiusCircles:"calculated"===o&&!f,showLightPollution:D,showCloudCover:j,cloudCoverHost:M.host,cloudCoverFrame:M.frames[M.currentIndex]||null,onCloudBoundsChange:M.setMapBounds,onAstroSpotCreated:v}),a.jsx("div",{className:"absolute left-3 bottom-3 z-[999]",children:a.jsx(mt,{isVisible:D,onToggle:()=>C(!D)})}),a.jsx(Qa,{activeView:o,showStarLegend:"certified"===o,showCircleLegend:"calculated"===o,onToggle:w,className:"absolute top-3 right-3 z-[999]"}),a.jsxs("div",{className:"absolute right-3 bottom-3 flex flex-col gap-2 z-[999]",children:[a.jsx(qa,{isVisible:j,onToggle:()=>L(!j),frames:M.frames,currentIndex:M.currentIndex,onIndexChange:M.setCurrentIndex,isPlaying:M.isPlaying,onTogglePlay:M.togglePlay}),a.jsx(Ya,{onGetLocation:b,shouldCenter:!1,hasLocation:null!==e})]}),a.jsx(X,{children:j&&M.frames.length>0&&a.jsx(Pa,{frames:M.frames,currentIndex:M.currentIndex,onIndexChange:M.setCurrentIndex,isPlaying:M.isPlaying,onTogglePlay:M.togglePlay,nowIndex:M.nowIndex})})]}),a.jsx(ht,{})]})},en=n.memo(({userLocation:e,locations:t,onLocationClick:n,onLocationUpdate:i,searchRadius:o,activeView:r,onAstroSpotCreated:s})=>{const{mapContainerHeight:l,mapReady:c,mapCenter:d,initialZoom:u,hoveredLocationId:m,handleMapReady:h,handleLocationClicked:g,handleMapClick:f,handleGetLocation:p,handleHover:y,handleTouchStart:x,handleTouchEnd:S,handleTouchMove:k,handleLegendToggle:b,isMobile:w,optimizedLocations:v}=da({userLocation:e,locations:t,certifiedLocations:t,calculatedLocations:t,searchRadius:o,activeView:r,onLocationClick:n,onLocationUpdate:i});return a.jsx(Xa,{userLocation:e,locations:v,searchRadius:o,activeView:r,mapReady:c,handleMapReady:h,handleLocationClicked:g,handleMapClick:f,mapCenter:d,initialZoom:u,mapContainerHeight:l,isMobile:w,hoveredLocationId:m,handleHover:y,handleTouchStart:x,handleTouchEnd:S,handleTouchMove:k,handleGetLocation:p,onLegendToggle:b,onAstroSpotCreated:s})}),tn=({locations:e,initialLoad:t,onViewDetails:n})=>{const{t:i}=c(),o=m(),r=o?"grid grid-cols-1 gap-3":"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",s={hidden:{opacity:0},visible:{opacity:1,transition:{duration:o?.15:.2}}},l={hidden:{opacity:0,y:o?10:20},visible:{opacity:1,y:0,transition:{duration:o?.15:.25,ease:"easeOut"}}};return e.length?a.jsx(F.div,{className:r,variants:s,initial:"hidden",animate:"visible",children:e.map((e,t)=>a.jsx(F.div,{variants:l,whileHover:o?void 0:{scale:1.02,boxShadow:"0 4px 20px rgba(139, 92, 246, 0.15)"},className:"transition-all duration-300",children:a.jsx(gt,{padding:o?"sm":"md",spacing:"none",className:"h-full hover:bg-cosmic-800/30 border-0",children:a.jsx(be,{location:e,index:t,onViewDetails:()=>n(e),showRealTimeSiqs:!0})})},e.id||`${e.latitude}-${e.longitude}`))}):null}
2,an=({searchRadius:e=0,onRefresh:t})=>{const{t:n}=c();return a.jsxs("div",{className:"text-center py-12 glassmorphism rounded-xl bg-cosmic-800/30 border border-cosmic-600/30",children:[a.jsx(ie,{className:"h-12 w-12 text-yellow-400 mx-auto mb-4"}),a.jsx("h2",{className:"text-xl font-semibold mb-2",children:n("No Recommended Locations Found","未找到推荐地点")}),a.jsx("p",{className:"text-muted-foreground max-w-lg mx-auto mb-2 text-sm",children:n("We couldn't find any locations with good viewing conditions within your search radius.","在您的搜索半径内,我们未能找到具有良好观测条件的地点。")}),a.jsxs("div",{className:"flex items-center justify-center gap-2 mt-4",children:[a.jsx(oe,{className:"h-4 w-4 text-primary"}),a.jsx("p",{className:"text-sm text-primary",children:e>0?n(`Try increasing your search radius beyond ${e}km.`,`尝试将搜索半径增加到${e}公里以上。`):n("Try adjusting your search radius to find better viewing spots.","尝试调整搜索半径以找到更好的观测地点。")})]}),t&&a.jsxs("div",{className:"mt-6 flex flex-col gap-3 items-center",children:[a.jsxs(N,{variant:"outline",onClick:t,className:"group border-primary/40 hover:bg-cosmic-800/50",children:[a.jsx(re,{className:"mr-2 h-4 w-4 group-hover:animate-spin"}),n("Refresh Recommendations","刷新推荐")]}),e<1e4&&a.jsxs(N,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>{const t=Math.min(1e4,e+1e3);document.dispatchEvent(new CustomEvent("expand-search-radius",{detail:{radius:t}}))},children:[a.jsx(se,{className:"mr-1.5 h-3 w-3"}),n("Try wider search area","尝试更广的搜索范围")]})]})]})},nn=({hasMore:e,onLoadMore:t,canLoadMoreCalculated:n=!1,onLoadMoreCalculated:o,loadMoreClickCount:r=0,maxLoadMoreClicks:s=2})=>{const{t:l}=c(),[d,u]=i.useState(!1),[m,g]=i.useState(!1);return i.useEffect(()=>{u(!!(o&&n&&r<s))},[o,n,r,s]),a.jsxs("div",{className:"mt-8 space-y-4",children:[d&&a.jsx("div",{className:"flex justify-center",children:a.jsx(N,{variant:"default",onClick:async()=>{if(o){g(!0);try{await o();const e=s-r-1;e>0?Re.info(l(`Loading more locations... (${e} more loads available)`,`正在加载更多位置...(还可以加载${e}次)`)):Re.info(l("Loading final batch of locations...","正在加载最后一批位置..."))}finally{g(!1)}}},disabled:m,className:"group sci-fi-btn bg-cosmic-700/80 hover:bg-cosmic-600/90 transition-all duration-300 py-2.5",size:"lg",children:m?a.jsxs(a.Fragment,{children:[l("Finding Locations...","正在查找位置..."),a.jsx(h,{className:"ml-2.5 h-5 w-5 animate-spin"})]}):a.jsxs(a.Fragment,{children:[l("Find More Locations","查找更多位置"),a.jsx(ie,{className:"ml-2.5 h-5 w-5 transition-transform group-hover:translate-x-1"})]})})}),e&&a.jsx("div",{className:"flex justify-center",children:a.jsxs(N,{variant:"outline",onClick:t,className:"group sci-fi-btn border-primary/40 hover:bg-cosmic-800/50 hover:opacity-90 transition-all duration-300",children:[l("Load More Locations","加载更多位置"),a.jsx(ie,{className:"ml-2 h-4 w-4 transition-transform group-hover:translate-x-1"})]})})]})},on=({locations:e,loading:t,hasMore:n,onLoadMore:r,onRefresh:s,searchRadius:l=0,initialLoad:d=!1,onLoadMoreCalculated:u,canLoadMoreCalculated:m=!1,loadMoreClickCount:g=0,maxLoadMoreClicks:f=2})=>{const{t:p}=c(),y=o();!function({onRefresh:e}){i.useEffect(()=>{const t=t=>{e&&(document.dispatchEvent(new CustomEvent("set-search-radius",{detail:{radius:t.detail.radius}})),setTimeout(e,100))};return document.addEventListener("expand-search-radius",t),()=>{document.removeEventListener("expand-search-radius",t)}},[e])}({onRefresh:s});const x=e.filter(e=>void 0!==e.siqs&&Ye(e.siqs,0)),S=Ke(x);return t&&0===S.length?a.jsx("div",{className:"flex justify-center items-center py-12",children:a.jsx(h,{className:"h-8 w-8 animate-spin text-primary/60"})}):0===S.length?a.jsx(an,{searchRadius:l,onRefresh:s}):a.jsxs(a.Fragment,{children:[a.jsx(tn,{locations:S,initialLoad:d,onViewDetails:e=>{const t=`loc-${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;y(`/location/${t}`,{state:{...e,id:t,timestamp:(new Date).toISOString()}}),Re.info(p("Opening location details","正在打开位置详情"))}}),a.jsx(nn,{hasMore:n,onLoadMore:r,canLoadMoreCalculated:m,onLoadMoreCalculated:u,loadMoreClickCount:g,maxLoadMoreClicks:f})]})},rn=({selectedType:e,onTypeChange:t})=>{const{t:n}=c(),i=[{id:"all",label:n("All Types","全部类型"),icon:q,color:"text-muted-foreground border-border bg-background/50 hover:bg-background/80"},{id:"reserve",label:n("Dark Sky Reserve","暗夜保护区"),icon:V,color:"text-primary border-primary/30 bg-primary/10 hover:bg-primary/20"},{id:"park",label:n("Dark Sky Park","暗夜公园"),icon:le,color:"text-primary border-primary/30 bg-primary/10 hover:bg-primary/20"},{id:"community",label:n("Dark Sky Community","暗夜社区"),icon:ce,color:"text-primary border-primary/30 bg-primary/10 hover:bg-primary/20"},{id:"urban",label:n("Urban Night Sky","城市夜空"),icon:ce,color:"text-primary border-primary/30 bg-primary/10 hover:bg-primary/20"}
2,{id:"lodging",label:n("Dark Sky Lodging","暗夜住宿"),icon:te,color:"text-primary border-primary/30 bg-primary/10 hover:bg-primary/20"},{id:"unesco",label:n("UNESCO Dark Sky","联合国教科文组织暗夜"),icon:ae,color:"text-primary border-primary/30 bg-primary/10 hover:bg-primary/20"}];return a.jsxs("div",{className:"mb-4 px-2",children:[a.jsxs("div",{className:"text-sm text-muted-foreground mb-2",children:[n("Filter by certification type","按认证类型筛选"),":"]}),a.jsx("div",{className:"flex flex-wrap gap-2",children:i.map(n=>a.jsxs(D,{variant:"outline",className:`\n              ${n.color}\n              px-2.5 py-1.5 \n              rounded-full \n              flex items-center\n              cursor-pointer\n              transition-all\n              ${e===n.id?"ring-2 ring-primary ring-offset-1":""}\n            `,onClick:()=>t(n.id),children:[a.jsx(n.icon,{className:"h-3.5 w-3.5 mr-1.5"}),a.jsx("span",{className:"text-sm",children:n.label})]},n.id))})]})},sn=({value:e,onChange:t,className:n=""})=>{const{t:i}=c();return a.jsxs("div",{className:`relative ${n}`,children:[a.jsx(C,{type:"text",placeholder:i("Search dark sky locations...","搜索暗夜地点..."),value:e,onChange:e=>t(e.target.value),className:"pr-8 focus:ring-2 focus:ring-primary/30"}),a.jsx(se,{className:"absolute right-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"})]})},ln=({locations:e,loading:t,hasMore:o,onLoadMore:r,onViewDetails:s,initialLoad:l})=>{const{t:d}=c(),[u,m]=i.useState("all"),[g,f]=i.useState(""),[p,y]=i.useState(5),{certifiedLocations:x,isLoading:S,refreshLocations:k}=ca(!0),b=n.useMemo(()=>{const t=new Map;return e&&e.length>0&&e.forEach(e=>{if(e.latitude&&e.longitude){const a=`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;t.set(a,e)}}),x&&x.length>0&&x.forEach(e=>{if(e.latitude&&e.longitude){const a=`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;t.set(a,e)}}),Array.from(t.values())},[e,x]);i.useEffect(()=>{b.length},[b]),i.useEffect(()=>{b.length>0&&p<5&&y(5)},[b.length]);const w=n.useMemo(()=>b.filter(e=>{if("all"!==u){const t=(e.certification||"").toLowerCase();switch(u){case"reserve":return t.includes("reserve")||e.isDarkSkyReserve;case"park":return t.includes("park");case"community":return t.includes("community");case"urban":return t.includes("urban");case"lodging":return t.includes("lodging");default:return!0}}if(g){const t=g.toLowerCase();return e.name?.toLowerCase().includes(t)||e.chineseName?.toLowerCase().includes(t)||e.certification?.toLowerCase().includes(t)}return!0}),[b,u,g]),v=w.slice(0,p),D=p<w.length;i.useEffect(()=>{},[b.length,w.length,v.length]);const C=l&&(t||S);return C?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(h,{className:"h-8 w-8 animate-spin text-primary/70"})}):0!==w.length||C?a.jsxs("div",{children:[a.jsxs("div",{className:"space-y-4 mb-6",children:[a.jsx(rn,{selectedType:u,onTypeChange:m}),a.jsx("div",{className:"flex w-full max-w-none gap-2 px-[1px] sm:max-w-xl sm:mx-auto sm:px-0",children:a.jsx(sn,{value:g,onChange:f,className:"flex-1"})})]}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:v.map((e,t)=>a.jsx(be,{location:e,index:t,onViewDetails:()=>s(e),showRealTimeSiqs:!0},e.id||`${e.latitude}-${e.longitude}-${t}`))}),D&&a.jsx("div",{className:"mt-6 flex justify-center",children:a.jsx(N,{variant:"outline",onClick:()=>{y(e=>e+5)},disabled:C,className:"min-w-[120px]",children:C?a.jsxs(a.Fragment,{children:[a.jsx(h,{className:"mr-2 h-4 w-4 animate-spin"}),d("Loading...","加载中...")]}):d("Load More","加载更多")})})]}):a.jsxs("div",{className:"text-center py-8",children:[a.jsx("p",{className:"text-muted-foreground",children:g||"all"!==u?d("No matching certified locations found.","未找到匹配的认证地点。"):d("No certified dark sky locations found in this area.","在此区域中未找到认证的暗空地点。")}),a.jsx(N,{variant:"outline",className:"mt-4",onClick:k,children:d("Refresh Locations","刷新位置")})]})},cn=({locations:e,loading:t,onViewDetails:i,initialLoad:o=!1,userLocation:r})=>{const{t:s}=c(),l=n.useMemo(()=>Ke(e),[e]);return t&&o?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[a.jsx(h,{className:"h-8 w-8 animate-spin text-cyan-500 mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:s("Loading Atlas Obscura locations...","正在加载奇观位置...")})]}):l&&0!==l.length?a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-4 px-2",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-cyan-500 to-teal-600",children:s("Atlas Obscura Locations","奇观位置")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s(`${l.length} fascinating places from around the world`,`来自世界各地的 ${l.length} 个迷人地点`)})]})}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:l.map((e,t)=>a.jsx(F.div,{initial:{opacity:0,y:20}
2,animate:{opacity:1,y:0},transition:{delay:.05*t,duration:.3},children:a.jsx(be,{location:e,index:t,onViewDetails:i,showRealTimeSiqs:!0,userLocation:r})},e.id||`${e.latitude}-${e.longitude}`))})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(P,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-50"}),a.jsx("p",{className:"text-lg font-medium text-foreground",children:s("No Atlas Obscura locations available","暂无奇观位置")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:s("Atlas Obscura locations are being loaded","奇观位置正在加载中")})]})},dn=({locations:e,loading:t,onViewDetails:i,initialLoad:o=!1,userLocation:r})=>{const{t:s}=c(),l=n.useMemo(()=>Ke(e),[e]);return t&&o?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[a.jsx(h,{className:"h-8 w-8 animate-spin text-amber-500 mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:s("Loading mountain locations...","正在加载山峰位置...")})]}):l&&0!==l.length?a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-4 px-2",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-amber-500 to-orange-600",children:s("Famous Mountains","著名山峰")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s(`${l.length} iconic peaks from around the world`,`来自世界各地的 ${l.length} 座标志性山峰`)})]})}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:l.map((e,t)=>a.jsx(F.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.05*t,duration:.3},children:a.jsx(be,{location:e,index:t,onViewDetails:i,showRealTimeSiqs:!0,userLocation:r})},e.id||`${e.latitude}-${e.longitude}`))})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(_,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-50"}),a.jsx("p",{className:"text-lg font-medium text-foreground",children:s("No mountain locations available","暂无山峰位置")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:s("Mountain locations are being loaded","山峰位置正在加载中")})]})},un=({locations:e,loading:t,initialLoad:n,onViewDetails:o,userLocation:r})=>{const{t:s}=c(),[l,d]=i.useState(""),u=i.useMemo(()=>{if(!l)return e;const t=l.toLowerCase();return e.filter(e=>e.name?.toLowerCase().includes(t)||e.chineseName?.toLowerCase().includes(t))},[e,l]),m=i.useMemo(()=>Ke(u),[u]);return t&&n?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[a.jsx(h,{className:"h-8 w-8 animate-spin text-indigo-500 mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:s("Loading dark sky reserves...","正在加载暗夜保护区...")})]}):m&&0!==m.length?a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-4 px-2",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-indigo-500 to-purple-600",children:s("Dark Sky Reserves","暗夜保护区")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s(`${m.length} internationally designated dark sky reserves`,`来自全球的 ${m.length} 个国际认证暗夜保护区`)})]})}),a.jsx("div",{className:"mb-4 w-full max-w-none px-[1px] sm:max-w-xl sm:px-0",children:a.jsx(sn,{value:l,onChange:d})}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:m.map((e,t)=>a.jsx(F.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:.05*t,duration:.3},children:a.jsx(be,{location:e,index:t,onViewDetails:o||(()=>{}),showRealTimeSiqs:!0,userLocation:r})},e.id||`${e.latitude}-${e.longitude}`))})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(z,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-50"}),a.jsx("p",{className:"text-lg font-medium text-foreground",children:l?s("No matching dark sky reserves found","未找到匹配的暗夜保护区"):s("No dark sky reserves available","暂无暗夜保护区")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:s("Dark sky reserves are being loaded","暗夜保护区正在加载中")})]})},mn=({locations:e,loading:t,onViewDetails:i,initialLoad:o=!1,userLocation:r})=>{const{t:s}=c(),l=n.useMemo(()=>Ke(e),[e]);return t&&o?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[a.jsx(h,{className:"h-8 w-8 animate-spin text-emerald-500 mb-4"}),a.jsx("p",{className:"text-muted-foreground",children:s("Loading natural wonders...","正在加载自然奇观...")})]}):l&&0!==l.length?a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"flex items-center justify-between mb-4 px-2",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-emerald-500 to-teal-600",children:s("Natural Wonders","自然奇观")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s(`${l.length} spectacular natural wonders from around the world`,`来自世界各地的 ${l.length} 处绝美自然奇观`)})]})}),a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4",children:l.map((e,t)=>a.jsx(F.div,{initial:{opacity:0,y:20}
2,animate:{opacity:1,y:0},transition:{delay:.05*t,duration:.3},children:a.jsx(be,{location:e,index:t,onViewDetails:i,showRealTimeSiqs:!0,userLocation:r})},e.id||`${e.latitude}-${e.longitude}`))})]}):a.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[a.jsx(V,{className:"h-12 w-12 text-muted-foreground mb-4 opacity-50"}),a.jsx("p",{className:"text-lg font-medium text-foreground",children:s("No natural wonders available","暂无自然奇观")}),a.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:s("Natural wonder locations are being loaded","自然奇观位置正在加载中")})]})},hn=()=>a.jsx("div",{className:"space-y-6",children:[...Array(3)].map((e,t)=>a.jsx("div",{className:"p-4 rounded-lg border border-cosmic-700/20 bg-cosmic-900/50 backdrop-blur-sm animate-in fade-in-50 duration-500",style:{animationDelay:150*t+"ms"},children:a.jsxs("div",{className:"space-y-3",children:[a.jsx(Mt,{className:"h-6 w-2/3 bg-cosmic-800/50"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Mt,{className:"h-4 w-20 bg-cosmic-800/50"}),a.jsx(Mt,{className:"h-4 w-20 bg-cosmic-800/50"})]}),a.jsxs("div",{className:"flex gap-2 items-center",children:[a.jsx(Mt,{className:"h-4 w-4 rounded-full bg-cosmic-800/50"}),a.jsx(Mt,{className:"h-4 w-32 bg-cosmic-800/50"})]})]})},t))}),gn=async e=>{try{const{data:t,error:a}=await j.from("astro_spot_timeslots").select("\n        id,\n        start_time,\n        end_time,\n        max_capacity,\n        astro_spot_reservations (\n          id,\n          status\n        )\n      ").eq("spot_id",e).gte("start_time",(new Date).toISOString()).order("start_time",{ascending:!0});if(a)return{hasAvailableSlots:!1,totalSlots:0,availableSlots:0,bookedSlots:0};if(!t||0===t.length)return{hasAvailableSlots:!1,totalSlots:0,availableSlots:0,bookedSlots:0};let n=0,i=0;const o=t.length;for(const e of t){const t=(e.astro_spot_reservations?.filter(e=>"confirmed"===e.status)||[]).length;e.max_capacity-t>0?n++:i++}return{hasAvailableSlots:n>0,totalSlots:o,availableSlots:n,bookedSlots:i}}catch(t){return{hasAvailableSlots:!1,totalSlots:0,availableSlots:0,bookedSlots:0}}},fn=n.memo(({isLoading:e,sortedAstroSpots:t,isMobile:n,onCardClick:o,realTimeSiqs:r,stabilizedSiqs:s,loadingSiqs:l,onSiqsCalculated:d})=>{const{t:u}=c(),m=t?.map(e=>e.id)||[],{availabilities:h}=(e=>{const[t,a]=i.useState({}),[n,o]=i.useState(!1);return i.useEffect(()=>{(async()=>{if(e.length){o(!0);try{const t=await(async e=>{const t={};for(let a=0;a<e.length;a+=10){const n=e.slice(a,a+10).map(async e=>({spotId:e,data:await gn(e)}));(await Promise.all(n)).forEach(({spotId:e,data:a})=>{t[e]=a})}return t})(e);a(t)}catch(t){}finally{o(!1)}}})()},[e.join(",")]),{availabilities:t,loading:n}})(m);if(e)return a.jsx(hn,{});if(!t||0===t.length)return a.jsx(F.div,{className:"w-full text-muted-foreground/70 text-center py-16",initial:{opacity:0}
2,animate:{opacity:1},transition:{duration:.5},children:u("No Astrospots yet. Be the first to share!","还没有观星点,快来分享吧!")});const g=e=>{o(e)};return a.jsxs(F.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.5},children:[a.jsxs("h2",{className:"font-bold text-xl mt-12 mb-5 flex items-center gap-2 text-gradient-blue",children:[a.jsx(ne,{className:"h-4 w-4 text-primary"}),a.jsx("span",{children:u("All Astrospots","全部观星点")}),a.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-2",children:["(",u("Booking available spots first","优先显示可预订地点"),")"]})]}),a.jsx("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3",children:t.map((e,t)=>a.jsx(F.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:Math.min(.05*t,.5),ease:"easeOut"},children:a.jsx("button",{className:"relative text-left w-full group focus:outline-none rounded-xl transition duration-150 ease-in-out hover:shadow-2xl hover:border-primary border-2 border-transparent",tabIndex:0,onClick:()=>g(e.id),onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||g(e.id)},"aria-label":e.name,style:{background:"none",padding:0},children:a.jsxs("div",{className:"w-full h-full",children:[a.jsx(Je,{isVisible:l[e.id]||!r[e.id]&&!s[e.id],latitude:e.latitude,longitude:e.longitude,bortleScale:e.bortleScale,existingSiqs:e.siqs,onSiqsCalculated:(t,a,n)=>d(e.id,t,a,n),priorityLevel:n?"low":"medium",debugLabel:`astrospot-card-${e.id.substring(0,6)}`,source:"astrospots",spotId:e.id}),a.jsx("div",{className:"transition-shadow group-hover:shadow-xl group-hover:ring-2 group-hover:ring-primary rounded-xl",children:a.jsx(wt,{id:e.id,name:e.name,latitude:e.latitude,longitude:e.longitude,siqs:s[e.id]??r[e.id]??e.siqs,timestamp:e.timestamp,isCertified:!1,siqsLoading:l[e.id]&&!s[e.id],userId:e.user_id,availableBookings:h[e.id]?.availableSlots||0,verificationStatus:e.verification_status})}),a.jsx("span",{className:"absolute inset-0 rounded-xl z-10 transition bg-black/0 group-hover:bg-primary/5"})]})})},e.id))})]})});fn.displayName="AstroSpotsList";const pn=n.memo(({showMap:e,activeView:t,initialLoad:o,effectiveLocation:r,certifiedLocations:s,calculatedLocations:l,obscuraLocations:c=[],mountainsLocations:d=[],darkSkyLocations:u=[],naturalWondersLocations:m=[],astroSpotLocations:h=[],searchRadius:g,calculatedSearchRadius:f,loading:p,hasMore:y,loadMore:x,refreshSiqs:S,onLocationClick:k,onLocationUpdate:b,canLoadMoreCalculated:w=!1,loadMoreCalculated:v,loadMoreClickCount:N=0,maxLoadMoreClicks:D=2,adSlot:C,isMobile:j=!1,onAstroSpotCardClick:L,onAstroSpotMarkerClick:M,astroSpotRealTimeSiqs:R={},astroSpotStabilizedSiqs:I={},astroSpotLoadingSiqs:A={},onAstroSpotSiqsCalculated:$,onAstroSpotCreated:E})=>{const T=i.useCallback((e,t)=>{b(e,t)},[b]),F=n.useMemo(()=>Ke(s),[s]),O=n.useMemo(()=>Ke(l),[l]),q=n.useMemo(()=>Ke(c),[c]),P=n.useMemo(()=>Ke(d),[d]),_=n.useMemo(()=>Ke(u),[u]),z=n.useMemo(()=>Ke(m),[m]),V=n.useMemo(()=>h,[h]),B=n.useMemo(()=>({certified:F,obscura:q,mountains:P,darksky:_,"natural-wonders":z,astrospots:V,calculated:O}[t]||O),[t,F,q,P,_,z,V,O]),U=n.useCallback(e=>{"astrospots"===t&&M?M(e):k(e)},[t,M,k]);return a.jsxs("div",{className:"mt-4",children:[e&&a.jsx("div",{className:"relative mb-6 w-full max-w-none px-[1px] sm:max-w-xl sm:mx-auto sm:px-0",children:a.jsx(en,{userLocation:r,locations:B,onLocationClick:U,onLocationUpdate:T,searchRadius:"calculated"===t?f:g,certifiedLocations:F,calculatedLocations:O,activeView:t,onAstroSpotCreated:"astrospots"===t?E:void 0})}),C&&a.jsx("div",{className:"mb-6 w-full max-w-none px-[1px] sm:max-w-xl sm:mx-auto sm:px-0",children:C}),!e&&"certified"===t&&a.jsx(ln,{locations:F,loading:p,hasMore:y,onLoadMore:x,onViewDetails:k,onRefresh:S,initialLoad:o}),!e&&"calculated"===t&&a.jsx(on,{locations:O,loading:p,hasMore:y,onLoadMore:x,onRefresh:S,searchRadius:f,initialLoad:o,canLoadMoreCalculated:w,onLoadMoreCalculated:v,loadMoreClickCount:N,maxLoadMoreClicks:D}),!e&&"obscura"===t&&a.jsx(cn,{locations:q,loading:p,onViewDetails:k,onRefresh:S,initialLoad:o,userLocation:r}),!e&&"mountains"===t&&a.jsx(dn,{locations:P,loading:p,onViewDetails:k,onRefresh:S,initialLoad:o,userLocation:r}),!e&&"darksky"===t&&a.jsx(un,{locations:_,loading:p,initialLoad:o,onViewDetails:k,userLocation:r}),!e&&"natural-wonders"===t&&a.jsx(mn,{locations:z,loading:p,onViewDetails:k,initialLoad:o,userLocation:r}),!e&&"astrospots"===t&&a.jsx("div",{className:"w-full max-w-none px-[1px] sm:max-w-5xl sm:mx-auto sm:px-0",children:a.jsx(fn,{isLoading:p,sortedAstroSpots:V,isMobile:j,onCardClick:L??(()=>{}),realTimeSiqs:R,stabilizedSiqs:I,loadingSiqs:A,onSiqsCalculated:$??(()=>{})})})]})}),yn=["certified","calculated","obscura","mountains","darksky","natural-wonders","astrospots"],xn=e=>{const t=new URLSearchParams(e).get("view");return yn.includes(t)?t:"calculated"},Sn=(e,t,a)=>
2{const n=a*Math.sqrt(Math.random()),i=2*Math.random()*Math.PI,o=n*Math.cos(i),r=n*Math.sin(i),s=e*(Math.PI/180),l=e+r/111.32,c=t+o/(111.32*Math.cos(s));return{latitude:l,longitude:c,distance:ze(e,t,l,c)}},kn=new Map,bn=async(e,t=5)=>{try{if(Be(e.latitude,e.longitude))return null;if((await At(e.latitude,e.longitude)).isWater)return null;const a=function(){const e=Intl.DateTimeFormat().resolvedOptions().timeZone,t=$t(new Date,e),a=t.getHours(),n=new Date(t);n.setHours(18,0,0,0);const i=Et(new Date(t),1);i.setHours(7,0,0,0);const o=a>=18||a<7;let r,s;if(o)if(a>=18)s=Math.round((i.getTime()-t.getTime())/6e4);else{const e=new Date(t);e.setHours(7,0,0,0),s=Math.round((e.getTime()-t.getTime())/6e4)}else r=Math.round((n.getTime()-t.getTime())/6e4);return{start:n,end:i,isNighttime:o,timeUntilNight:r,timeUntilDaylight:s}}(e.latitude,e.longitude),n=4,i={useSingleHourSampling:!0,targetHour:1,cacheDurationMins:30},o=await De(e.latitude,e.longitude,n,i);return o&&o.siqs>=t?{id:`calc-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,name:"Calculated Location",chineseName:"推算观星点",latitude:e.latitude,longitude:e.longitude,bortleScale:n,siqs:o.siqs,isViable:o.isViable,distance:e.distance,timestamp:(new Date).toISOString(),timeInfo:{isNighttime:a.isNighttime,timeUntilNight:a.timeUntilNight,timeUntilDaylight:a.timeUntilDaylight}}:null}catch(a){return null}};async function wn(e,t,a,n=10,i=5){const o=((e,t,a,n)=>{const i=`spots-${e.toFixed(2)}-${t.toFixed(2)}-${a}-${n}`,o=kn.get(i);return o&&Date.now()-o.timestamp<18e5?o.spots:null})(e,t,a,n);if(o)return o;try{const o=((e,t,a,n=20)=>{const i=[];for(let r=0;r<2*n;r++)i.push(Sn(e,t,a));const o=[];for(i.length>0&&o.push(i[0]);o.length<n&&i.length>o.length;){let e=null,t=-1;for(const a of i){if(o.some(e=>e===a))continue;let n=1/0;for(const e of o){const t=ze(a.latitude,a.longitude,e.latitude,e.longitude);n=Math.min(n,t)}n>t&&(t=n,e=a)}if(!e)break;o.push(e)}return o})(e,t,a,3*n),s=[],l=function(e){const t=[];for(let a=0;a<e.length;a+=5)t.push(e.slice(a,a+5));return t}(o);for(const e of l){if(s.length>=n)break;const t=e.map(async e=>Be(e.latitude,e.longitude)?null:bn(e,i)),a=(await Promise.all(t)).filter(Boolean);s.push(...a)}const c=(r=s,[...r].sort((e,t)=>{const a="number"==typeof e.siqs?e.siqs:0,n="number"==typeof t.siqs?t.siqs:0,i=.7*a-.3*(e.distance||0);return.7*n-.3*(t.distance||0)-i})).slice(0,n);return((e,t,a,n,i)=>{const o=`spots-${e.toFixed(2)}-${t.toFixed(2)}-${a}-${n}`;kn.set(o,{spots:i,timestamp:Date.now()})})(e,t,a,n,c),c}catch(s){return[]}var r}const vn=Object.freeze(Object.defineProperty({__proto__:null,addLocationToStore:ia,clearLocationStore:function(){na.clear()},generateQualitySpots:wn,getAllLocationsFromStore:function(){return Array.from(na.values())},getLocationFromStore:function(e){return na.get(e)}},Symbol.toStringTag,{value:"Module"}));async function Nn(e,t,a,n=!1,i=50){e.toFixed(2),t.toFixed(2);const o=L(n?"certified":"calculated",e,t,a);if(o?.length>0)return n?o.filter(e=>e.isDarkSkyReserve||e.certification):o;const r=await Ue(e,t,a,n,i);if(!r?.length)return[];const s=r.filter(e=>!Be(e.latitude,e.longitude));return M(n?"certified":"calculated",e,t,a,s),s}async function Dn(e,t,a,n=!0,i=10){const o=L("calculated",e,t,a);if(o?.length>0)return o;const r=await wn(e,t,a,i,4);return r.length>0?(M("calculated",e,t,a,r),r):n&&a<1e4?Dn(e,t,Math.min(1.5*a,1e4),!1,i):[]}function Cn(e){return e&&Array.isArray(e)?[...e].sort((e,t)=>{const a=e.isDarkSkyReserve||e.certification?1:0,n=t.isDarkSkyReserve||t.certification?1:0;if(a!==n)return n-a;const i="number"==typeof e.siqs?e.siqs:0,o="number"==typeof t.siqs?t.siqs:0;return i!==o?o-i:void 0!==e.bortleScale&&void 0!==t.bortleScale?e.bortleScale-t.bortleScale:void 0!==e.distance&&void 0!==t.distance?e.distance-t.distance:0}):[]}const jn=Object.freeze(Object.defineProperty({__proto__:null,findCalculatedLocations:Dn,findCertifiedLocations:async function(e,t,a,n=100){return Nn(e,t,a,!0,n)},findLocationsWithinRadius:Nn,sortLocationsByQuality:Cn},Symbol.toStringTag,{value:"Module"})),Ln=e=>Boolean(e?.isDarkSkyReserve||e?.isUNESCO||e?.certification);function Mn(e,t){if(!e)return"";const a=e.text;if("zh"===t){if("Dark Sky Reserve"===a)return"暗夜保护区";if("Dark Sky Park"===a)return"暗夜公园";if("Dark Sky Community"===a)return"暗夜社区";if("Urban Night Sky"===a)return"城市夜空";if("Certified Location"===a)return"认证地点";
2if("Dark Sky Lodging"===a)return"暗夜住宿"}return a}const Rn=({point:e,onSelect:t,onViewDetails:r,userLocation:s,realTimeSiqs:l=null,siqsLoading:d=!1})=>{const{language:u,t:h}=c();o(),m();const g=n.useMemo(()=>function({certification:e,isDarkSkyReserve:t}){if(!e&&!t)return null;const a=(e||"").toLowerCase();return a.includes("lodging")?{icon:te,text:"Dark Sky Lodging",color:"text-primary border-primary/30 bg-primary/10"}:a.includes("sanctuary")||a.includes("reserve")||t?{icon:V,text:"Dark Sky Reserve",color:"text-primary border-primary/30 bg-primary/10"}:a.includes("park")?{icon:le,text:"Dark Sky Park",color:"text-primary border-primary/30 bg-primary/10"}:a.includes("community")?{icon:ce,text:"Dark Sky Community",color:"text-primary border-primary/30 bg-primary/10"}:a.includes("urban")?{icon:ce,text:"Urban Night Sky",color:"text-primary border-primary/30 bg-primary/10"}:{icon:de,text:"Certified Location",color:"text-primary border-primary/30 bg-primary/10"}}(e),[e]),f=Ft(e.latitude,e.longitude),[p,y]=i.useState(null);i.useEffect(()=>{null!==l&&l>0&&y(l)},[l]);const{displayName:x}=we({location:e,language:u,locationCounter:null}),S=e=>/[\u4e00-\u9fa5]/.test(e),k="zh"===u&&e.chineseName||e.name,b="zh"===u&&k&&!S(k)?x||h("未命名位置","Unnamed Location"):"en"===u&&k&&S(k)?x||h("Unnamed Location","未命名位置"):k||h("Unnamed Location","未命名位置"),w=x&&x!==b?x:"",v=Boolean(w),N=p??(null!==l?l:We(e.siqs)),C=et(N),j=d&&!p;return a.jsxs("div",{className:"tron-card p-3 rounded-lg cursor-pointer",onClick:()=>{t&&t(e)},children:[a.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1.5",children:[a.jsx(ve,{mainName:b,originalName:w,showOriginalName:v}),a.jsx("div",{className:"flex items-center shrink-0 bg-yellow-500/20 text-yellow-300 px-2 py-0.5 rounded-full border border-yellow-500/40",children:j?a.jsx("div",{className:"h-3.5 w-10 animate-pulse bg-yellow-500/30 rounded"}):a.jsxs(a.Fragment,{children:[a.jsx(z,{className:"h-3.5 w-3.5 text-yellow-400 mr-1",fill:"#facc15"}),a.jsx("span",{className:"text-xs font-medium",children:C})]})})]}),g&&a.jsx("div",{className:"flex items-center mt-1.5 mb-2",children:a.jsxs(D,{variant:"outline",className:`${g.color} px-2 py-0.5 rounded-full flex items-center`,children:[n.createElement(g.icon,{className:"h-4 w-4 mr-1.5"}),a.jsx("span",{className:"text-xs",children:Mn(g,u)})]})}),e.latitude&&e.longitude&&a.jsxs("div",{className:"mt-1.5 mb-2 flex items-center",children:[a.jsx(ue,{className:"h-3.5 w-3.5 text-muted-foreground mr-1 shrink-0"}),a.jsx("span",{className:"text-xs text-muted-foreground truncate",children:f||`${e.latitude.toFixed(4)}, ${e.longitude.toFixed(4)}`})]}),s&&e.latitude&&e.longitude&&a.jsxs("div",{className:"mt-1.5 mb-2 flex items-center",children:[a.jsx(q,{className:"h-3.5 w-3.5 text-muted-foreground mr-1"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:(L=e.distance,void 0===L?h("Unknown distance","未知距离"):L<1?h(`${Math.round(1e3*L)} m`,`${Math.round(1e3*L)} 米`):L<100?h(`${Math.round(L)} km`,`${Math.round(L)} 公里`):h(100*Math.round(L/100)+" km",100*Math.round(L/100)+" 公里"))})]}),a.jsx(Ne,{onViewDetails:r})]});var L},In=({currentSiqs:e,isVisible:t})=>{const{t:n}=c();return!t||!e||e<6?null:a.jsx(F.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.3},className:"bg-gradient-to-r from-green-500/20 to-blue-500/20 rounded-lg p-3 backdrop-blur-sm shadow-md mb-4 border border-green-500/30",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"text-yellow-400 shrink-0 mt-0.5",children:a.jsx(z,{className:"h-5 w-5"})}),a.jsx("div",{children:a.jsx("p",{className:"text-sm text-green-200/90",children:n("Your current location has favorable viewing conditions with a SIQS score of "+e.toFixed(1)+". For best results, find a site away from light pollution.","您当前位置的观测条件良好,SIQS评分为"+e.toFixed(1)+"。为获得最佳效果,请远离光污染区域。")})})]})})};async function An(e){if(!e.length)return[];const t=e.map(e=>{return{latitude:e.latitude,longitude:e.longitude,bortleScale:e.bortleScale||(t=e,t.bortleScale&&t.bortleScale>0&&t.bortleScale<=9?t.bortleScale:t.isDarkSkyReserve?3:t.certification?4:5)};var t}),a=await async function(e,t=3){if(!e||!e.length)return[];const a=[];for(let n=0;n<e.length;n+=t){const i=e.slice(n,n+t).map(e=>De(e.latitude,e.longitude,e.bortleScale||5).catch(e=>({siqs:0,isViable:!1}))),o=await Promise.all(i);a.push(...o),n+t<e.length&&await new Promise(e=>setTimeout(e,1e3))}return a}(t);return e.map((e,t)=>{if(t<a.length){const n=a[t];if(n&&n.siqs>0){const t=n.factors?.map(e=>({name:e.name,score:e.score,description:e.description||`${e.name} factor`}));return{...e,siqs:n.siqs,siqsResult:{score:n.siqs,isViable:n.isViable,factors:t||[]}}}}return e})}setInterval(()=>{Ce()},18e5);const $n=({onSelectPoint:e,userLocation:t,limit:n=3,hideEmptyMessage:o=!1})=>{const{t:r}=c(),[s,d]=i.useState(!1),u=Pn.getValue(),[m,g]=i.useState(!0),[f,p]=i.useState([]),[y,x]=i.useState([]);i.useEffect(()=>{try{const e=localStorage.getItem("cachedRecommendedLocations");
2if(e){const t=JSON.parse(e);Array.isArray(t)&&t.length>0&&(p(t),g(!1))}}catch(e){}},[]);const{displayedLocations:S,loading:k,searching:b}=(({userLocation:e,currentSiqs:t,searchRadius:a=100,maxInitialResults:n=50})=>{const{t:o}=c(),[r,s]=i.useState([]),[l,d]=i.useState(!1),[u,m]=i.useState("certified"),h="certified"===u?1e5:a,{locations:g,loading:f,searching:p,refreshSiqsData:y}=Bn(e,h);i.useEffect(()=>{try{const t=localStorage.getItem("cachedRecommendedLocations");if(!l&&t){const i=JSON.parse(t);if(Array.isArray(i)&&i.length>0){const t="certified"===u?i.filter(e=>e.isDarkSkyReserve||e.certification):e?i.filter(t=>!(!t.isDarkSkyReserve&&!t.certification)||(t.distance||ze(e.latitude,e.longitude,t.latitude,t.longitude))<=a):i,o="certified"===u?t:t.slice(0,n);s(o)}}}catch(t){}},[n,l,a,e,u]),i.useEffect(()=>{if(g.length>0){const i=g.filter(e=>Ln(e)),o=g.filter(e=>!Ln(e));let r="certified"===u?i:o;"calculated"===u&&(r=r.filter(e=>!Be(e.latitude,e.longitude)),e&&(r=r.filter(t=>(t.distance||ze(e.latitude,e.longitude,t.latitude,t.longitude))<=a)));const l=Ke(r),c="certified"===u?l:l.slice(0,n);s(c),d(!0);try{localStorage.setItem("cachedRecommendedLocations",JSON.stringify([...i,...o]))}catch(t){}}},[g,n,a,e,u]);const x=i.useCallback(()=>{e?(Re.info(o("Refreshing locations...","正在刷新位置...")),y()):Re.error(o("No location selected","未选择位置"))},[y,o,e]),S=i.useCallback(e=>{m(e)},[]);return{displayedLocations:r,loading:f&&!l,searching:p,refresh:x,switchView:S,activeView:u}})({userLocation:t,currentSiqs:u,maxInitialResults:n+5});i.useEffect(()=>{if(!k&&!s&&S.length>0){d(!0),g(!1);try{localStorage.setItem("cachedRecommendedLocations",JSON.stringify(S))}catch(e){}}},[k,s,S]),i.useEffect(()=>{const e=S.length>0?S:f;e.length>0&&(x(e),setTimeout(async()=>{try{const t=await async function(e){if(!e||0===e.length)return e;try{const t=function(e){const t=[];for(let a=0;a<e.length;a+=5)t.push(e.slice(a,a+5));return t}(e),a=[];for(const e of t){const t=await An(e);a.push(...t)}return a}catch(t){return e}}(e);x(t)}catch(t){}},100))},[S,f,t]);const w=i.useMemo(()=>{const e=y.length>0?y:S.length>0?S:f;return[...e.filter(e=>e.isDarkSkyReserve||e.certification),...e.filter(e=>!e.isDarkSkyReserve&&!e.certification)].slice(0,n)},[y,S,f,n]);return m&&0===f.length?a.jsx("div",{className:"mt-2 flex justify-center py-4",children:a.jsx(h,{className:"w-5 h-5 animate-spin text-primary/60"})}):0!==w.length||o?a.jsxs("div",{className:"mt-2",children:[null!==u&&a.jsx(In,{currentSiqs:u,isVisible:!0}),a.jsx(X,{children:a.jsx("div",{className:"space-y-3 mt-3",children:w.map((n,i)=>a.jsx(F.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.15,delay:.03*i},children:a.jsx(Rn,{point:n,onSelect:e,onViewDetails:()=>e?.(n),userLocation:t})},`${n.id||n.latitude}-${n.longitude}`))})}),w.length>0&&a.jsx("div",{className:"mt-4 flex justify-center",children:a.jsx(l,{to:"/photo-points",children:a.jsxs(N,{variant:"ghost",size:"sm",className:"bg-gradient-to-r from-blue-500/10 to-green-500/10 hover:from-blue-500/20 hover:to-green-500/20 text-primary/90 hover:text-primary",children:[r("View All Photo Points","查看所有摄影点"),a.jsx(me,{className:"ml-1 h-4 w-4"})]})})}),b&&a.jsx("div",{className:"flex justify-center mt-2",children:a.jsx(h,{className:"w-4 h-4 animate-spin text-primary/60"})})]}):a.jsxs("div",{className:"mt-2 text-center py-6",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:r("No recommended photo points found nearby.","在附近找不到推荐的摄影点。")}),a.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:r("Try expanding your search radius.","尝试扩大您的搜索半径。")}),t&&a.jsxs(N,{variant:"outline",size:"sm",className:"mt-4 bg-gradient-to-r from-blue-500/20 to-green-500/20 hover:from-blue-500/30 hover:to-green-500/30",onClick:()=>{document.dispatchEvent(new CustomEvent("expand-search-radius",{detail:{radius:1e3}}))},children:[a.jsx(q,{className:"h-3.5 w-3.5 mr-1.5"}),r("Expand Search","扩大搜索")]})]})},En=({onLocationSelect:e,onSelectLocation:t})=>{const[n,o]=i.useState(""),[r,s]=i.useState([]),[l,d]=i.useState(!1),[u,m]=i.useState([]),g=i.useRef(null),{t:f,language:p}=c();i.useEffect(()=>{try{const e=localStorage.getItem("recent_location_searches");if(e){const t=JSON.parse(e);Array.isArray(t)&&m(t.slice(0,5))}}catch(e){}},[]);const y=e=>{try{const t=[e,...u.filter(t=>t.latitude!==e.latitude||t.longitude!==e.longitude)].slice(0,5);m(t),localStorage.setItem("recent_location_searches",JSON.stringify(t))}catch(t){}},x=a=>{Pt(a),e?e(a):t&&t(a),s([]),o(""),g.current&&(g.current.value="")},S=i.useMemo(()=>{let e;return t=>{if(clearTimeout(e),""===t.trim())return s([]),void d(!1);const a=St(t);if(a){const e={name:`${a.latitude.toFixed(6)}, ${a.longitude.toFixed(6)}`,latitude:a.latitude,longitude:a.longitude,placeDetails:f("Entered coordinates","输入的坐标")};return s([e]),void d(!1)}d(!0),e=setTimeout(async()=>{try{const e=await _t(t,p);s(e)}catch(e){s([])}finally{d(!1)}},300)}},[p,f]),k=e=>{const t={name:e.name,latitude:e.latitude,longitude:e.longitude};y(e),x(t)};return a.jsxs("div",{className:"relative",children:[a.jsxs("form",{onSubmit:e=>{e.preventDefault();const t=St(n);if(t){const e={name:`${t.latitude.toFixed(6)}, ${t.longitude.toFixed(6)}`,latitude:t.latitude,longitude:t.longitude};y(e),x(e)}else r.length>0&&k(r[0])},className:"relative",children:[a.jsx("input",{type:"text",ref:g,placeholder:f("Search for a location or enter coordinates...","搜索地点或输入坐标..."),className:"w-full px-4 py-2 rounded-md bg-cosmic-800 border border-cosmic-700 text-white focus:outline-none focus:border-primary transition-colors duration-200",onChange:e=>{const t=e.target.value;o(t),S(t)}}),a.jsx("div",{className:"absolute inset-y-0 right-3 flex items-center",children:l?a.jsx(h,{className:"h-4 w-4 animate-spin text-primary"}):a.jsx(se,{className:"h-5 w-5 text-gray-400"})})]}),r.length>0&&a.jsx("ul",{className:"absolute z-10 mt-2 w-full rounded-md shadow-lg bg-cosmic-800 border border-cosmic-700 divide-y divide-cosmic-700 max-h-60 overflow-auto",children:r.map((e,t)=>a.jsxs("li",{className:"px-4 py-2 text-white hover:bg-cosmic-700 cursor-pointer transition-colors duration-200",onClick:()=>k(e),children:[e.name,e.placeDetails&&a.jsx("p",{className:"text-xs text-muted-foreground",children:e.placeDetails})]},t))}),!n&&u.length>0&&a.jsxs("div",{className:"absolute z-10 mt-2 w-full rounded-md shadow-lg bg-cosmic-800 border border-cosmic-700 divide-y divide-cosmic-700 max-h-60 overflow-auto",children:[a.jsx("div",{className:"px-4 py-2 text-sm text-muted-foreground",children:f("Recent Searches","最近搜索")}),u.map((e,t)=>a.jsx("li",{className:"px-4 py-2 text-white hover:bg-cosmic-700 cursor-pointer transition-colors duration-200 list-none",onClick:()=>k(e),children:e.name},`recent-${t}`))]})]})},Tn=n.memo(({locationName:e,loading:t,handleUseCurrentLocation:n,onSelectLocation:o,noAutoLocationRequest:r=!1})=>{const{t:s,language:l}=c(),d=i.useRef(!1),[u,m]=i.useState(!1);i.useEffect(()=>{if(!(e||t||d.current||r)){d.current=!0;const e=setTimeout(()=>{n()},500);return()=>clearTimeout(e)}},[e,t,n,r]);const g=e&&e.includes("°")?s("Your current location","您的当前位置"):e;return a.jsxs("div",{className:"flex flex-col space-y-3 relative z-10",children:[a.jsxs(N,{variant:e?"default":"outline",type:"button",onClick:n,disabled:t,className:"w-full transition-all duration-300 bg-gradient-to-r from-cyan-600/30 to-teal-600/30 hover:from-cyan-600/40 hover:to-teal-600/40 border border-cosmic-700/40 hover:border-cosmic-700/70 "+(e?"shadow-md hover:shadow-lg hover:translate-y-[-1px]":"hover:bg-primary/10"),"data-location-button":"true",children:[t?a.jsxs("div",{className:"flex items-center",children:[a.jsx(h,{className:"mr-2 h-4 w-4 animate-spin text-green-400"}),"zh"===l&&a.jsx("span",{children:"加载中"})]}):a.jsx(q,{className:"mr-2 h-4 w-4"}),e?a.jsx("span",{className:"truncate max-w-[90%] font-medium",children:g}):s("Use My Location","使用我的位置")]}),a.jsxs(N,{variant:"secondary",type:"button",onClick:()=>{m(!0)},className:"w-full transition-all duration-300 bg-gradient-to-r from-cyan-600/30 to-teal-600/30 hover:from-cyan-600/40 hover:to-teal-600/40 border border-cosmic-700/40 hover:border-cosmic-700/70",children:[a.jsx(se,{className:"h-4 w-4 mr-2"}),s("Search for a Location","搜索位置")]}),u&&a.jsx("div",{className:"fixed inset-0 z-50 bg-black/50 flex items-center justify-center p-4",children:a.jsxs("div",{className:"bg-cosmic-900 rounded-lg shadow-lg max-w-3xl w-full max-h-[90vh] overflow-hidden",children:[a.jsx("div",{className:"p-4 border-b border-cosmic-700",children:a.jsx("h3",{className:"text-lg font-medium",children:s("Search for a Location","搜索位置")})}),a.jsx("div",{className:"p-6",children:a.jsx(En,{onSelectLocation:e=>{o(e),m(!1),Re.success(s("Location selected: ","已选择位置:")+e.name,{duration:2e3})}})}),a.jsx("div",{className:"p-4 border-t border-cosmic-700 flex justify-end",children:a.jsx(N,{variant:"outline",onClick:()=>{m(!1)},className:"mr-2",children:s("Cancel","取消")})})]})})]})}),Fn=({siqsScore:e,locationName:t,latitude:o,longitude:r})=>{const{t:s,language:d}=c(),u=i.useMemo(()=>{const t=tt(e),a=Math.max(.1,Math.round(10*t)/10);let n;n=a>=8?s("Excellent","优秀"):a>=6?s("Good","良好"):a>=4?s("Average","一般"):a>=2?s("Poor","较差"):s("Bad","很差");const i=ma(a),o=(e=>{const t=e>10?e/10:e;return t>=8?"bg-green-500":t>=6?"bg-blue-500":t>=5?"bg-amber-500":t>=4?"bg-yellow-500":t>=2?"bg-orange-500":"bg-red-500"})(a);
2return{displayValue:a,interpretation:n,progressColor:i,colorClass:o,textColorClass:Ge(a)}},[e,s,d]),m=i.useMemo(()=>({backgroundColor:u.progressColor}),[u.progressColor]),h=i.useMemo(()=>`loc-${o.toFixed(6)}-${r.toFixed(6)}`,[o,r]);n.useEffect(()=>{if(o&&r){const e=5;(async()=>{try{await De(o,r,e)}catch(t){}})()}},[o,r]);const g=Math.max(1,10*u.displayValue);return a.jsxs(F.div,{className:"mb-4 pb-4 border-b border-cosmic-700/30",initial:{opacity:0,y:15},animate:{opacity:1,y:0},transition:{duration:.5},children:[a.jsxs("div",{className:"flex justify-between items-center mb-2",children:[a.jsx("h3",{className:"text-lg font-medium",children:s("Estimated SIQS","预估SIQS")}),a.jsx("span",{className:`text-xl font-bold px-2 py-1 rounded ${u.textColorClass}`,children:u.displayValue.toFixed(1)})]}),a.jsx(zt,{value:g,className:"h-3 my-2 bg-cosmic-800/40",style:m}),a.jsxs("div",{className:"flex justify-between items-center mt-2",children:[a.jsx("span",{className:"text-sm text-muted-foreground",children:s("Poor","较差")}),a.jsx("span",{className:`text-sm font-medium ${u.textColorClass}`,children:u.interpretation}),a.jsx("span",{className:"text-sm text-muted-foreground",children:s("Excellent","优秀")})]}),a.jsx("div",{className:"mt-6 flex justify-center",children:a.jsx(F.div,{whileHover:{scale:1.05},whileTap:{scale:.95},transition:{type:"spring",stiffness:400,damping:15},className:"relative w-full max-w-md",children:a.jsx(l,{to:`/location/${h}`,state:{id:h,name:t,latitude:o,longitude:r,siqsResult:{score:u.displayValue},timestamp:(new Date).toISOString(),fromCalculator:!0},children:a.jsxs(N,{size:"lg",className:"w-full bg-gradient-to-r from-blue-500/70 to-green-500/70 hover:from-blue-500/80 hover:to-green-500/80 shadow-lg hover:shadow-xl transition-all duration-300 group text-gray-50 py-2 text-sm font-medium",children:[s("See More Details","查看更多详情"),a.jsx(me,{className:"ml-2 h-5 w-5 group-hover:translate-x-1 transition-transform duration-300"})]})})})})]})},On=({className:e})=>{const{t:t}=c();return a.jsx("div",{className:"flex justify-between items-center mb-6",children:a.jsx("h2",{className:"text-xl font-bold",children:t("Calculate Stellar Imaging Quality Score","计算天文观测质量评分")})})},qn=({message:e,loading:t})=>{if(!e)return null;const n=e.toLowerCase().includes("found")||e.toLowerCase().includes("selected")||e.toLowerCase().includes("已找到")||e.toLowerCase().includes("已选择");return a.jsx("div",{className:"text-sm mt-2 mb-4",children:a.jsxs("div",{className:"flex items-center",children:[t?a.jsx(h,{className:"h-4 w-4 mr-2 text-green-500 animate-spin"}):n?a.jsx(he,{className:"h-4 w-4 mr-2 text-green-500"}):a.jsx(ge,{className:"h-4 w-4 mr-2 text-yellow-500"}),a.jsx("span",{children:e})]})})};n.memo(({className:e,hideRecommendedPoints:t=!1,noAutoLocationRequest:n=!1,onSiqsCalculated:r})=>{const{language:s}=c(),{loading:l,statusMessage:d,calculationInProgress:u,localBortleScale:m,locationSelectorProps:h,isMounted:g,siqsScore:f,calculateSIQSForLocation:p,setStatusMessage:y,setLoading:x,weatherData:S,forecastData:k}=function({noAutoLocationRequest:e=!1,onSiqsCalculated:t}){const{language:a,t:n}=c(),[r,s]=i.useState(!1),[l,d]=i.useState(null),[u,m]=i.useState(!1),[h,g]=i.useState(!1),[f,p]=i.useState(null),[y,x]=i.useState(!e),[S,k]=i.useState(""),[b,w]=i.useState(""),{setCachedData:v,getCachedData:N}=xt();i.useEffect(()=>{h||qt()&&x(!1)},[h]),i.useEffect(()=>(g(!0),()=>g(!1)),[]);const D=i.useMemo(()=>({language:a,noAutoLocationRequest:e||!y,bortleScale:f,setBortleScale:p,setStatusMessage:d,setShowAdvancedSettings:()=>{},getCachedData:N,setCachedData:v,latitude:S,longitude:b,setLatitude:k,setLongitude:w}),[a,e,y,f,d,N,v,S,b]),{setCachedData:C,getCachedData:j}=xt(),{isCalculating:L,siqsScore:M,calculateSIQSForLocation:I,weatherData:A,forecastData:$}=((e,t)=>{const a=o(),{user:n}=R(),[r,s]=i.useState(!1),[l,c]=i.useState(null),[d,u]=i.useState(null),[m,h]=i.useState(null),g=i.useMemo(()=>ft(),[]),f=i.useCallback(async(i,o,l,d=!1,m,g,f,p,y="en")=>{if(!r){s(!0),!d&&f&&f(!0);try{const r=`weather-${i.toFixed(4)}-${o.toFixed(4)}`,k=await(async(e,t,a,n,i,o,r="en",s,l=5e3)=>{const c=`${a}-${e.toFixed(4)}-${t.toFixed(4)}`,d=n(c,18e4);if(d)return d;let u=null;for(let g=0;g<=2;g++)try{const a=new AbortController,n=setTimeout(()=>a.abort(),l),o=await Ot({latitude:e,longitude:t,days:3},a.signal);if(clearTimeout(n),o)return i(c,o),o}catch(h){u=h instanceof Error?h:new Error(String(h)),g<2&&await new Promise(e=>setTimeout(e,500*(g+1)))}const m={temperature:20,humidity:50,cloudCover:30,windSpeed:10,precipitation:0,time:(new Date).toISOString(),condition:"Clear",weatherCondition:"Clear",aqi:50};return!o&&s&&s("en"===r?"Could not fetch real-time weather. Using offline data instead.":"无法获取实时天气数据,使用离线数据替代。"),i(c,m),m})(i,o,r,t,e,d,y,p);if(!k)return p&&p("en"===y?"Could not retrieve weather data. Please try again.":"无法获取天气数据,请重试。"),s(!1),void(!d&&f&&f(!1));c(k);const b=await pt(i,o);b&&h(b);const w=await(async(e,t,a,n,i,o,r,s="en",l)=>{if(!isFinite(e)||!isFinite(t))return null;if(i&&null!==n&&n>=1&&n<=9)return n;const c=`bortle-${e.toFixed(4)}-${t.toFixed(4)}`,d=o(c,432e5);if(d?.bortleScale&&"number"==typeof d.bortleScale&&d.bortleScale>=1&&d.bortleScale<=9)return d.bortleScale;try{const a=await vt(e,t,n);if(a.bortle>=1&&a.bortle<=9)return r(c,{bortleScale:a.bortle,confidence:a.confidence,source:a.source,timestamp:Date.now()}),a.bortle}catch(u){}return null!==n&&n>=1&&n<=9?(r(c,{bortleScale:n,source:"fallback",confidence:.5,timestamp:Date.now()}),n):(!i&&l&&l("en"===s?"Unable to determine light pollution level. Try uploading a night sky photo.":"无法确定光污染水平。请尝试上传夜空照片。"),r(c,{bortleScale:null,unknown:!0,source:"unknown",confidence:0,timestamp:Date.now()}),null)}
2)(i,o,0,m,d,t,e,y,p),v=w<1||w>9||isNaN(w)?5:w,N=ft(),D=await je(k,v,g,N,b),C=Le(D.score);try{await Me({latitude:i,longitude:o,locationName:l,siqsScore:C,astroNightCloudCover:b?.nighttimeCloudData?.average||null,additionalMetadata:{bortleScale:v,seeingConditions:g,moonPhase:N},userId:n?.id,source:"calculator"})}catch(x){}if(d)return u(C),void s(!1);const j=Tt(),L={id:j,name:l,latitude:i,longitude:o,bortleScale:v,seeingConditions:g,weatherData:k,siqsResult:{...D,score:C},moonPhase:N,timestamp:(new Date).toISOString()};a(`/location/${j}`,{state:L,replace:!1});try{localStorage.setItem(`location_${j}`,JSON.stringify(L)),localStorage.setItem("latest_siqs_location",JSON.stringify({name:l,latitude:i,longitude:o,bortleScale:v}))}catch(S){}setTimeout(()=>{s(!1),!d&&f&&f(!1)},300)}catch(k){p&&p("en"===y?"An error occurred while calculating SIQS. Please try again.":"计算SIQS时发生错误,请重试。"),s(!1),!d&&f&&f(!1)}}},[r,a,t,e]);return{isCalculating:r,weatherData:l,siqsScore:d,forecastData:m,currentMoonPhase:g,setSiqsScore:u,validateInputs:yt,calculateSIQSForLocation:f}})(C,j);return i.useEffect(()=>{m(L)},[L]),i.useEffect(()=>{t&&(t(M),Pn.setValue(M))},[M,t]),{loading:r,setLoading:s,statusMessage:l,setStatusMessage:d,calculationInProgress:u,localBortleScale:f,setLocalBortleScale:p,locationSelectorProps:D,isMounted:h,siqsScore:M,calculateSIQSForLocation:I,language:a,latitude:S,setLatitude:k,longitude:b,setLongitude:w,weatherData:A,forecastData:$}}({noAutoLocationRequest:n,onSiqsCalculated:r}),{userLocation:b,locationName:w,latitude:v,longitude:N,handleUseCurrentLocation:D,handleLocationSelect:C,handleRecommendedPointSelect:j}=function({locationSelectorProps:e,isMounted:t,setLocalBortleScale:a,calculateSIQSForLocation:n,setStatusMessage:o,language:r,seeingConditions:s}){const{userLocation:l,locationName:c,latitude:d,longitude:u,setLocationName:m,setLatitude:h,setLongitude:g,handleUseCurrentLocation:f,handleLocationSelect:p,handleRecommendedPointSelect:y}=(({language:e,noAutoLocationRequest:t,bortleScale:a,setBortleScale:n,setStatusMessage:o,setShowAdvancedSettings:r,getCachedData:s,setCachedData:l})=>{const[c,d]=i.useState(null),[u,m]=i.useState(""),[h,g]=i.useState(""),[f,p]=i.useState(""),[y,x]=i.useState(!1);i.useEffect(()=>{if(!(y||u||h||f))try{const e=localStorage.getItem("latest_siqs_location");if(e){const t=JSON.parse(e);t&&t.name&&"number"==typeof t.latitude&&"number"==typeof t.longitude&&(m(t.name),g(t.latitude.toString()),p(t.longitude.toString()),r(!0),null===a&&vt(t.latitude,t.longitude).then(e=>{e.bortle>=1&&e.bortle<=9&&n(e.bortle)}).catch(e=>{}))}}catch(e){}finally{x(!0)}},[y,u,h,f,a,n,r]);const S=i.useCallback(()=>{navigator.geolocation?(o("en"===e?"Getting current location...":"正在获取当前位置..."),navigator.geolocation.getCurrentPosition(t=>{const{latitude:a,longitude:i}=t.coords;g(a.toFixed(6)),p(i.toFixed(6)),d({latitude:a,longitude:i}),m("en"===e?"Current Location":"当前位置"),o("en"===e?"Current location found":"已找到当前位置"),r(!0),n(null);try{localStorage.setItem("latest_siqs_location",JSON.stringify({name:"en"===e?"Current Location":"当前位置",latitude:a,longitude:i}))}catch(s){}},t=>{o("en"===e?"Could not get your location. Please check browser permissions.":"无法获取您的位置。请检查浏览器权限。")})):o("en"===e?"Geolocation is not supported by your browser":"您的浏览器不支持地理位置")},[e,o,r,n]),k=i.useCallback(async t=>{m(t.name),g(t.latitude.toFixed(6)),p(t.longitude.toFixed(6)),n(null);try{localStorage.setItem("latest_siqs_location",JSON.stringify({name:t.name,latitude:t.latitude,longitude:t.longitude}))}catch(c){}const a=`loc-${t.latitude.toFixed(4)}-${t.longitude.toFixed(4)}`,i=s(a);if(i&&void 0!==i.bortleScale)return n(i.bortleScale),o("en"===e?`Selected location: ${t.name}`:`已选择位置:${t.name}`),void r(!0);try{const i=await vt(t.latitude,t.longitude);i.bortle>=1&&i.bortle<=9?(n(i.bortle),l(a,{name:t.name,bortleScale:i.bortle})):(n(null),o("en"===e?`Light pollution data unavailable for ${t.name}`:`无法获取${t.name}的光污染数据`),l(a,{name:t.name,bortleScale:null}))}catch(c){n(null)}o("en"===e?`Selected location: ${t.name}`:`已选择位置:${t.name}`),r(!0)},[e,n,o,r,s,l]),b=i.useCallback(t=>{m(t.name),g(t.latitude.toFixed(6)),p(t.longitude.toFixed(6));try{localStorage.setItem("latest_siqs_location",JSON.stringify({name:t.name,latitude:t.latitude,longitude:t.longitude}))}catch(a){}n(null),r(!0),o("en"===e?`Selected recommended location: ${t.name}`:`已选择推荐位置:${t.name}`)},[e,o,r,n]);return{userLocation:c,locationName:u,latitude:h,longitude:f,setLocationName:m,setLatitude:g,setLongitude:p,handleUseCurrentLocation:S,handleLocationSelect:k,handleRecommendedPointSelect:b}})(e);i.useEffect(()=>{t&&d&&u&&c&&"北京"!==c&&"Beijing"!==c&&(async()=>{const t=parseFloat(d),a=parseFloat(u);if(!isNaN(t)&&!isNaN(a))try{const n=await kt(t,a,r,{setCachedData:e.setCachedData,getCachedData:e.getCachedData});n&&n!==c&&m(n)}catch(n){}})()},[r,d,u,c,t,e,m]),i.useEffect(()=>{t&&c&&d&&u&&Pt({name:c,latitude:parseFloat(d),longitude:parseFloat(u),bortleScale:e.bortleScale||void 0})},[c,d,u,e.bortleScale,t]),i.useEffect(()=>{if(!t||e.noAutoLocationRequest)return;const n=qt();n&&!c&&(m(n.name),h(n.latitude.toString()),g(n.longitude.toString()),n.bortleScale&&a(n.bortleScale))},[t,e.noAutoLocationRequest,c,m,h,g,a]);const x=i.useCallback(()=>{const t=parseFloat(d),a=parseFloat(u);!c||isNaN(t)||isNaN(a)||t>=-90&&t<=90&&a>=-180&&a<=180&&n(t,a,c,!0,e.bortleScale,s,void 0,o,r)},[d,u,c,e.bortleScale,s,r,n,o]);return i.useEffect(()=>{if(!t||!c)return;const e=setTimeout(()=>{x()},500);return()=>clearTimeout(e)},[d,u,c,e.bortleScale,s,x,t]),{userLocation:l,locationName:c,latitude:d,longitude:u,handleUseCurrentLocation:f,handleLocationSelect:p,handleRecommendedPointSelect:y}}({locationSelectorProps:h,isMounted:g,setLocalBortleScale:h.setBortleScale,calculateSIQSForLocation:p,setStatusMessage:y,language:s,seeingConditions:2.5}),L=parseFloat(v||"0")||0,M=parseFloat(N||"0")||0;!function(e,t){const[a,n]=i.useState(2.5),[o,r]=i.useState(4),{getCachedData:s,setCachedData:l}=xt();i.useEffect(()=>{const a=`loc-${e.toFixed(4)}-${t.toFixed(4)}`,i=s(a);i&&("number"==typeof i.seeingConditions&&n(i.seeingConditions),"number"==typeof i.bortleScale&&r(i.bortleScale))},[e,t,s]),i.useCallback(a=>{n(a);const i=`loc-${e.toFixed(4)}-${t.toFixed(4)}`,o=s(i);l(i,{...o,seeingConditions:a})},[e,t,s,l]),i.useCallback(a=>{r(a);const n=`loc-${e.toFixed(4)}-${t.toFixed(4)}`,i=s(n);l(n,{...i,bortleScale:a})},[e,t,s,l])}(L,M),i.useEffect(()=>{w&&0!==L&&0!==M&&(Pn.metadata.setMetadata(w,L,M),m&&!u&&(x(!0),setTimeout(()=>{null!==f&&(Pn.setValue(f),r&&r(f)),x(!1)},300)))},[w,L,M,m,r,u,x,f]),i.useEffect(()=>{if(null!==f&&!l&&!u&&L&&M){let e=null;void 0!==S?.nighttimeCloudData?.average?e=S.nighttimeCloudData.average:void 0!==k?.astro_night_cloud_cover?e=k.astro_night_cloud_cover:void 0!==S?.cloudCover&&(e=S.cloudCover),Me({latitude:L,longitude:M,locationName:w||"Unknown",siqsScore:f,astroNightCloudCover:e,additionalMetadata:{language:s,source:"SIQSCalculator"},source:"calculator"})}},[f,l,u,L,M,w,S,k,s]);const I={hidden:{opacity:0,y:20},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:300,damping:24}}},A=!(t||l||u||d&&""!==d);return a.jsxs(F.div,{className:`glassmorphism-strong rounded-xl p-6 ${e} shadow-lg hover:shadow-xl transition-all duration-300 bg-cosmic-800/60 backdrop-blur-sm`,initial:"hidden",animate:"visible",variants:I,children:[a.jsx(On,{}),a.jsx(F.div,{variants:I,transition:{delay:.1},children:a.jsx(qn,{message:d,loading:u||l})}),null!==f&&a.jsx(F.div,{variants:I,transition:{delay:.2},children:a.jsx(Fn,{siqsScore:f,latitude:L,longitude:M,locationName:w})}),a.jsxs(F.div,{className:"space-y-4",variants:I,transition:{delay:.3},children:[a.jsx(Tn,{locationName:w,loading:l||u,handleUseCurrentLocation:D,onSelectLocation:C,noAutoLocationRequest:h.noAutoLocationRequest}),A&&a.jsx(F.div,{variants:I,transition:{delay:.4},initial:"hidden",animate:"visible",className:"min-h-[100px]",children:a.jsx($n,{onSelectPoint:j,userLocation:b,hideEmptyMessage:!0})})]})]})});const Pn={value:null,setValue:e=>{if(Pn.value=e,null!==e)try{localStorage.setItem("current_siqs_value",e.toString())}catch(t){}},getValue:()=>{if(null===Pn.value)try{const e=localStorage.getItem("current_siqs_value");if(e){const t=parseFloat(e);isNaN(t)||(Pn.value=t)}}catch(e){}return Pn.value},metadata:{locationName:null,latitude:null,longitude:null,timestamp:null,setMetadata:(e,t,a)=>{Pn.metadata.locationName=e,Pn.metadata.latitude=t,Pn.metadata.longitude=a,Pn.metadata.timestamp=(new Date).toISOString();try{localStorage.setItem("siqs_metadata",JSON.stringify({locationName:e,latitude:t,longitude:a,timestamp:Pn.metadata.timestamp}))}catch(n){}},getMetadata:()=>
2{if(!Pn.metadata.locationName)try{const e=localStorage.getItem("siqs_metadata");if(e){const t=JSON.parse(e);Pn.metadata.locationName=t.locationName||null,Pn.metadata.latitude=t.latitude||null,Pn.metadata.longitude=t.longitude||null,Pn.metadata.timestamp=t.timestamp||null}}catch(e){}return{locationName:Pn.metadata.locationName,latitude:Pn.metadata.latitude,longitude:Pn.metadata.longitude,timestamp:Pn.metadata.timestamp}}}},_n="v1.0.4-astronomical-night";try{const e=localStorage.getItem("siqs_algorithm_signature");e&&e!==_n?localStorage.setItem("siqs_algorithm_signature",_n):e||localStorage.setItem("siqs_algorithm_signature",_n)}catch(Hn){}const zn=class e{constructor(){t(this,"CACHE_TTL",9e5),t(this,"BATCH_DELAY",50)}static getInstance(){return e.instance||(e.instance=new e),e.instance}async getCalculatedLocations(e,t,a,n=20){const i=`calc-locations-${e.toFixed(3)}-${t.toFixed(3)}-${a}-${n}`;return I(i)||A.batch("calculated-locations",this.fetchCalculatedLocations.bind(this),e,t,a,n,i)}async getCertifiedLocations(e,t,a=1e4){const n="cert-locations-global",i=I(n);if(i)return this.filterByDistance(i,e,t,a);try{const{getRecommendedPhotoPoints:i}=await r(async()=>{const{getRecommendedPhotoPoints:e}=await import("./astroSpots-CZ76xRmE.js").then(e=>e.b);return{getRecommendedPhotoPoints:e}},__vite__mapDeps([18,19,2,1,3,4,5,6,7,8,12,16])),o=await i(e,t,a,!0,1e3);return o?.length?($(n,o,36e5),o):[]}catch(o){return[]}}async calculateSIQS(e,t,a){const n=`siqs-${e.toFixed(4)}-${t.toFixed(4)}-${a.toFixed(1)}`;return I(n)||A.batch("siqs-calculation",this.calculateSIQSInternal.bind(this),e,t,a,n)}async prefetchNearbyData(e,t,a=100){Promise.all([this.getCertifiedLocations(e,t,2*a),this.getCalculatedLocations(e,t,a,10)]).catch(e=>{})}async fetchCalculatedLocations(e,t,a,n,i){try{const{generateQualitySpots:o}=await r(async()=>{const{generateQualitySpots:e}=await Promise.resolve().then(()=>vn);return{generateQualitySpots:e}},void 0),s=(await o(e,t,a,n,4)).filter(e=>!Be(e.latitude,e.longitude));return $(i,s,this.CACHE_TTL),s}catch(o){return[]}}async calculateSIQSInternal(e,t,a,n){try{const i=await De(e,t,a,{useSingleHourSampling:!0,targetHour:1,cacheDurationMins:15});return $(n,i,this.CACHE_TTL),i}catch(i){return{siqs:0,isViable:!1}}}filterByDistance(e,t,a,n){return e.filter(e=>this.calculateDistance(t,a,e.latitude,e.longitude)<=n)}calculateDistance(e,t,a,n){const i=(a-e)*Math.PI/180,o=(n-t)*Math.PI/180,r=Math.sin(i/2)*Math.sin(i/2)+Math.cos(e*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.sin(o/2)*Math.sin(o/2);return 2*Math.atan2(Math.sqrt(r),Math.sqrt(1-r))*6371}};t(zn,"instance");const Vn=zn.getInstance(),Bn=(e,t=100)=>{const{t:a}=c(),[n,o]=i.useState(t),[r,s]=i.useState([]),[l,d]=i.useState([]),[u,m]=i.useState(t),[h,g]=i.useState(!1),[f,p]=i.useState(!1),[y,x]=i.useState(!1),[S,k]=i.useState(1),b=i.useRef(n),w=i.useRef(e),v=i.useRef([]),[N,D]=i.useState(!1),[C,j]=i.useState(0),L=Pn.getValue(),{findLocationsWithinRadius:M,sortLocationsByQuality:R}={findLocationsWithinRadius:i.useCallback(async(e,t,a)=>Nn(e,t,a),[]),sortLocationsByQuality:i.useCallback(e=>Cn(e),[])},{findCalculatedLocations:I}=(()=>{const{t:e}=c();return{findCalculatedLocations:i.useCallback(async(t,a,n,i=!0,o=10,r=!1,s=[])=>{try{const e=await Dn(t,a,n,i,o);if(r&&s.length>0){const t=new Set(s.map(e=>`${e.latitude.toFixed(4)},${e.longitude.toFixed(4)}`)),a=e.filter(e=>{const a=`${e.latitude.toFixed(4)},${e.longitude.toFixed(4)}`;return!t.has(a)}).filter(e=>void 0===e.siqs||null===e.siqs||Xe(e.siqs,5));return[...s,...a]}return e.filter(e=>void 0===e.siqs||null===e.siqs||Xe(e.siqs,5))}catch(l){return Re.error(e("Failed to find calculated locations","无法找到计算位置")),[]}},[e])}})(),A=i.useCallback((e,t,a)=>e.filter(e=>{const n=e.latitude-a.latitude,i=e.longitude-a.longitude;return 111*Math.sqrt(n*n+i*i)<=t}),[]),$=i.useCallback(async(t=!1)=>{if(e)try{const a=!w.current||Math.abs(e.latitude-w.current.latitude)>.001||Math.abs(e.longitude-w.current.longitude)>.001;if(!t&&!a&&n<=u&&l.length>0){const t=A(l,n,e),a=R(t);return s(a),void(v.current=a)}g(!0),b.current=n,w.current=e;const i=Math.max(1.5*n,n+50);Vn.prefetchNearbyData(e.latitude,e.longitude,i);const[o,r]=await Promise.all([Vn.getCertifiedLocations(e.latitude,e.longitude,1e4),Vn.getCalculatedLocations(e.latitude,e.longitude,i,20)]),c=[...o,...r];if(0===c.length)s([]),d([]),m(i),v.current=[],x(!1),D(!1);else{d(c),m(i);const t=A(c,n,e),a=R(t);s(a),v.current=a,x(a.length>=20),D(!0),j(0)}k(1)}catch(i){Vt.error(a("Failed to load recommended locations","加载推荐位置失败"),a("Please try again.","请重试。")),s([]),d([]),x(!1),D(!1)}finally{g(!1)}},[n,e,a,R,u,l,A]),T=i.useMemo(()=>E($,150),[$]),F=i.useCallback(async()=>
2{if(e&&y)try{g(!0);const t=S+1,a=(await M(e.latitude,e.longitude,n)).filter(e=>e.isDarkSkyReserve||e.certification||!Be(e.latitude,e.longitude)),i=new Set(r.map(e=>e.id)),o=a.filter(e=>!i.has(e.id));if(o.length>0){const e=[...r,...o],a=R(e);s(a),v.current=a,x(o.length>=10),k(t)}else x(!1)}catch(t){Vt.error(a("Failed to load more locations","加载更多位置失败"),a("Please try again.","请重试。"))}finally{g(!1)}},[y,r,S,n,e,a,M,R]),O=i.useCallback(async()=>{if(e&&!(C>=2))try{p(!0);const t=(await I(e.latitude,e.longitude,n)).filter(e=>!Be(e.latitude,e.longitude)),i=new Set(r.map(e=>`${e.latitude.toFixed(4)},${e.longitude.toFixed(4)}`)),o=t.filter(e=>{const t=`${e.latitude.toFixed(4)},${e.longitude.toFixed(4)}`;return!i.has(t)});if(o.length>0){const e=[...r,...o],t=R(e);s(t),v.current=t;const n=C+1;j(n),n>=2&&D(!1),Vt.success(a(`Added ${o.length} more locations`,`添加了${o.length}个更多位置`))}else Vt.info(a("No more unique locations found","未找到更多独特位置")),D(!1)}catch(t){Vt.error(a("Failed to load more locations","加载更多位置失败"))}finally{p(!1)}},[C,r,n,a,e,I,R]),q=i.useCallback(async()=>{if(e)try{g(!0),await T()}catch(t){Vt.error(a("Failed to refresh location data","刷新位置数据失败"))}finally{g(!1)}},[T,e,a]);return i.useEffect(()=>{if(!e)return;const t=n!==b.current;if(e&&!w.current||!e&&w.current||e&&w.current&&(Math.abs(e.latitude-w.current.latitude)>.001||Math.abs(e.longitude-w.current.longitude)>.001))T();else if(t)if(n<=u&&l.length>0){const t=A(l,n,e),a=R(t);s(a),v.current=a,b.current=n}else T()},[T,n,e,u,l,A,R]),{searchRadius:n,setSearchRadius:o,locations:r,loading:h,searching:f,hasMore:y,loadMore:F,refreshSiqsData:q,canLoadMoreCalculated:N,loadMoreCalculatedLocations:O,loadMoreClickCount:C,maxLoadMoreClicks:2,currentSiqs:L}},Un=()=>{const e=o(),{t:t}=c(),r=m(),[l,d]=i.useState(!1),[u,h]=i.useState("all"),{activeView:g,showMap:f,initialLoad:p,locationLoading:y,effectiveLocation:x,locationInitialized:S,calculatedSearchRadius:k,currentSearchRadius:b,handleRadiusChange:w,handleViewChange:v,handleLocationUpdate:D,handleResetLocation:C,toggleMapView:j}=(()=>{const{t:e}=c(),[t,a]=s(),[n,o]=i.useState(()=>xn(t.toString()));i.useEffect(()=>{const e=xn(t.toString());o(t=>t===e?t:e)},[t]);const[r,l]=i.useState(!0),[d,u]=i.useState(!0),[m,h]=i.useState(!1),[g,f]=i.useState(null),{coords:p,loading:y}=It(),[x,S]=i.useState(!1),[k,b]=i.useState(!1);i.useEffect(()=>{p&&(f({latitude:p.latitude,longitude:p.longitude}),S(!0))},[p]),i.useEffect(()=>{g||k||(b(!0),navigator.geolocation.getCurrentPosition(e=>{const{latitude:t,longitude:a}=e.coords;f({latitude:t,longitude:a}),S(!0)},e=>{f({latitude:35.8617,longitude:104.1954}),S(!0)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0}))},[g,k]);const[w,v]=i.useState(500),N="certified"===n?2e4:w,D=i.useCallback(e=>{v(e)},[]),C=i.useCallback((t,a)=>{isFinite(t)&&isFinite(a)?(f({latitude:t,longitude:a}),S(!0)):Re.error(e("Invalid location coordinates","无效的位置坐标"))},[e]),j=i.useCallback(()=>{try{localStorage.removeItem("geolocation_permission"),localStorage.removeItem("geolocation_denied_at")}catch(a){}const t=Re.loading(e("Getting your location...","正在获取您的位置..."));navigator.geolocation.getCurrentPosition(n=>{Re.dismiss(t);const{latitude:i,longitude:o}=n.coords;f({latitude:i,longitude:o}),Re.success(e("Location updated successfully","位置更新成功"));try{const e=window.leafletMap;e&&e.setView([i,o],12,{animate:!0,duration:1.5})}catch(a){}},a=>{Re.dismiss(t);let n=e("Unable to get your location","无法获取您的位置");1===a.code?n=e("Location permission denied","位置权限被拒绝"):2===a.code?n=e("Location unavailable","位置不可用"):3===a.code&&(n=e("Location request timed out","位置请求超时")),Re.error(n)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:0})},[e]),L=i.useCallback(e=>{e!==n&&(o(e),a(t=>{const a=new URLSearchParams(t);return"calculated"===e?a.delete("view"):a.set("view",e),a},{replace:!0}))},[n,a]),M=i.useCallback(()=>{l(e=>!e)},[]);return i.useEffect(()=>{const e=setTimeout(()=>{u(!1)},500);return()=>clearTimeout(e)},[]),{activeView:n,showMap:r,initialLoad:d,locationLoading:y,effectiveLocation:g,locationInitialized:x,calculatedSearchRadius:w,currentSearchRadius:N,handleRadiusChange:D,handleViewChange:L,handleLocationUpdate:C,handleResetLocation:j,toggleMapView:M}}
2)(),{setSearchRadius:L,locations:M,loading:R,hasMore:I,loadMore:A,refreshSiqsData:$,canLoadMoreCalculated:E,loadMoreCalculatedLocations:O,loadMoreClickCount:q,maxLoadMoreClicks:z}=Bn(x,b),{certifiedLocations:V,calculatedLocations:B}=function(e){const[t,a]=i.useState({certified:[],calculated:[]});i.useEffect(()=>{if(!e||0===e.length)return void a({certified:[],calculated:[]});const t=new Map,n=new Map,i=new Set;e.forEach(e=>{if(!e.latitude||!e.longitude)return;const a=`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`;i.has(a)||(!0===e.isDarkSkyReserve||e.certification&&""!==e.certification.trim()||"dark-site"===e.type?(t.set(a,e),i.add(a)):(n.set(a,e),i.add(a)))});const o=Array.from(t.values()),r=Array.from(n.values()),s=new Set(o.map(e=>`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`)),l=new Set(r.map(e=>`${e.latitude.toFixed(6)}-${e.longitude.toFixed(6)}`));[...s].filter(e=>l.has(e)).length;const c=[...o].sort((e,t)=>{const a=e=>{const t=(e.certification||"").toLowerCase();return e.isDarkSkyReserve||t.includes("reserve")?1:t.includes("park")?2:t.includes("community")?3:t.includes("urban")?4:t.includes("lodging")?5:6},n=a(e),i=a(t);return n!==i?n-i:(e.name||"").localeCompare(t.name||"")}),d=[...r].sort((e,t)=>(We(t.siqs)||0)-(We(e.siqs)||0));a({certified:c,calculated:d})},[e]);const n=i.useMemo(()=>t.certified,[t]),o=i.useMemo(()=>t.calculated,[t]),r=i.useMemo(()=>n.length>0,[n]),s=i.useMemo(()=>o.length>0,[o]),l=i.useMemo(()=>n.length,[n]),c=i.useMemo(()=>o.length,[o]);return{certifiedLocations:n,calculatedLocations:o,hasCertifiedLocations:r,hasCalculatedLocations:s,certifiedCount:l,calculatedCount:c}}(M),[H,G]=i.useState([]),[W,Z]=i.useState(!0),[Q,J]=i.useState([]),[Y,K]=i.useState(!0),[X,ee]=i.useState([]),[te,ae]=i.useState(!0),[ne,ie]=i.useState([]),[oe,re]=i.useState(!0),{isLoading:se,sortedAstroSpots:le,realTimeSiqs:de,stabilizedSiqs:ue,loadingSiqs:me,handleSiqsCalculated:he,handleCardClick:ge,handleMarkerClick:Se,refreshData:be}=jt("astrospots"===g);i.useEffect(()=>{(async()=>{try{Z(!0);const e=(await Bt()).map(e=>({...e,siqs:void 0,siqsResult:void 0}));G(e)}catch(e){}finally{Z(!1)}})()},[]),i.useEffect(()=>{(async()=>{try{K(!0);const e=(await Ut()).map(e=>({...e,siqs:void 0,siqsResult:void 0}));J(e)}catch(e){}finally{K(!1)}})()},[]),i.useEffect(()=>{(()=>{try{ae(!0);const e=Ht().map(e=>({...e,siqs:void 0,siqsResult:void 0}));ee(e)}catch(e){}finally{ae(!1)}})()},[]),i.useEffect(()=>{(async()=>{try{re(!0);const e=(await Gt()).map(e=>({...e,siqs:void 0,siqsResult:void 0}));ie(e)}catch(e){}finally{re(!1)}})()},[]),i.useEffect(()=>{S&&x&&(L(b),$())},[S,x,b,L,$]),n.useEffect(()=>{M.length>0&&M.filter(e=>Ye(e.siqs,0)||e.isDarkSkyReserve||e.certification)},[M]);const we=i.useCallback(t=>{if(t)try{const a=ke(t);a&&e(`/location/${a.locationId}`,{state:a.locationState})}catch(a){}},[e]),ve=i.useCallback(()=>{if("astrospots"===g)return void be();const e=g;v("certified"===e?"calculated":"certified"),setTimeout(()=>v(e),50)},[g,v,be]),Ne="astrospots"===g?t("Astrospots","观星点"):void 0,De="astrospots"===g?t("Explore shared Astrospots as map markers or a list, with booking-ready spots surfaced first.","以地图标记或列表形式探索共享观星点,并优先显示可预订地点。"):void 0,Ce=i.useMemo(()=>"all"===u?le:le.filter(e=>(e.spot_type||"nightscape")===u),[u,le]),je=i.useCallback(async()=>{await be()},[be]);return a.jsx(T,{children:a.jsxs(Kt,{children:[a.jsx(ea,{userLocation:x,locationLoading:y,getPosition:C,showMap:f,title:Ne,description:De}),"calculated"===g&&a.jsx("div",{className:"mb-6 w-full max-w-none px-[1px] sm:max-w-xl sm:mx-auto sm:px-0",children:a.jsx(aa,{currentValue:k,onValueChange:w,minValue:100,maxValue:1e3,stepValue:100,loading:R&&!y,loadingComplete:!R&&!y})}),"astrospots"===g&&a.jsx("div",{className:"mb-6 w-full max-w-none px-[1px] sm:max-w-xl sm:mx-auto sm:px-0",children:a.jsxs(Wt,{value:u,onValueChange:e=>h(e),children:[a.jsx(Zt,{className:"h-11 w-full rounded-full border-primary/30 bg-cosmic-900/70 text-sm text-foreground shadow-md backdrop-blur-md sm:w-64",children:a.jsx(Qt,{})}),a.jsxs(Jt,{className:"z-[9999] border-cosmic-700/50 bg-cosmic-900/95 backdrop-blur-md",children:[a.jsx(Yt,{value:"all",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx(fe,{className:"mr-2 h-4 w-4"}),t("All Astrospots","全部观星点")]})}),a.jsx(Yt,{value:"nightscape",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx(pe,{className:"mr-2 h-4 w-4"}),t("Nightscape","夜景")]})}),a.jsx(Yt,{value:"natural",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx(_,{className:"mr-2 h-4 w-4"}),t("Natural","自然")]})}),a.jsx(Yt,{value:"obscura",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx(P,{className:"mr-2 h-4 w-4"}),t("Obscura","奇观")]})}),a.jsx(Yt,{value:"observatory",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx(ce,{className:"mr-2 h-4 w-4"}),t("Global Observatory","全球天文台")]})})]})]})}),f&&"calculated"===g&&a.jsx("div",{className:"mb-4 text-center text-sm text-muted-foreground",children:t("Click anyw
2here on the map to update your search location!","点击地图上的任意位置以更新搜索位置!")}),a.jsxs(F.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4},className:"flex items-center justify-between mb-2 w-full max-w-none px-[1px] sm:max-w-xl sm:mx-auto sm:px-0",children:[a.jsx(ta,{activeView:g,onViewChange:v,loading:!1}),a.jsxs("div",{className:"flex items-center gap-2",children:["astrospots"===g&&a.jsx(N,{size:"icon",variant:"outline",onClick:()=>d(!0),className:"h-12 w-12 md:h-14 md:w-14 rounded-xl border-primary/40 bg-primary/10 text-primary hover:bg-primary/20",title:t("Add Astrospot","添加观星点"),"aria-label":t("Add Astrospot","添加观星点"),children:a.jsx(ye,{className:"h-5 w-5"})}),a.jsx(Xt,{onClick:j,onDoubleClick:ve,tooltip:t("Double-click to refresh map markers","双击以刷新地图标记"),ariaLabel:f?t("Show list","显示列表"):t("Show map","显示地图"),children:a.jsx(F.div,{initial:!1,animate:{rotate:f?0:180},transition:{duration:.3},className:"relative z-10",children:f?a.jsx(U,{className:"h-5 w-5 md:h-6 md:w-6 text-cyan-200"}):a.jsx(xe,{className:"h-5 w-5 md:h-6 md:w-6 text-cyan-200"})})})]})]}),a.jsx(pn,{showMap:f,activeView:g,initialLoad:p,effectiveLocation:x,certifiedLocations:V,calculatedLocations:B,obscuraLocations:H,mountainsLocations:Q,darkSkyLocations:X,naturalWondersLocations:ne,astroSpotLocations:Ce,searchRadius:b,calculatedSearchRadius:k,loading:"obscura"===g?W:"mountains"===g?Y:"darksky"===g?te:"natural-wonders"===g?oe:"astrospots"===g?se:R&&!y,hasMore:I,loadMore:A,refreshSiqs:$,onLocationClick:we,onLocationUpdate:D,canLoadMoreCalculated:E,loadMoreCalculated:O,loadMoreClickCount:q,maxLoadMoreClicks:z,adSlot:a.jsx(Rt,{placement:"feeds"}),isMobile:r,onAstroSpotCardClick:ge,onAstroSpotMarkerClick:Se,astroSpotRealTimeSiqs:de,astroSpotStabilizedSiqs:ue,astroSpotLoadingSiqs:me,onAstroSpotSiqsCalculated:he,onAstroSpotCreated:je}),"astrospots"===g&&l&&x&&a.jsx(Ct,{latitude:x.latitude,longitude:x.longitude,defaultName:t("My Astrospot","我的观星点"),stayOnPage:!0,onCreated:je,onClose:()=>d(!1)})]})})};export{Un 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.