@cos-design/weather-background 3.5.5 → 3.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +263 -257
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});require('./index.css');var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("react");c=s(c,1);let l=require("@cos-design/shared"),u=require("react/jsx-runtime");var d=e=>Math.min(1,Math.max(0,e)),f=e=>{let t=e.replace(`#`,``).trim(),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;if(n.length!==6)return[80,140,200];let r=Number.parseInt(n,16);return Number.isNaN(r)?[80,140,200]:[r>>16&255,r>>8&255,r&255]},p=([e,t,n])=>{let r=e=>Math.min(255,Math.max(0,Math.round(e))).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},m=(e,t,n)=>e+(t-e)*n,h=(e,t,n)=>[m(e[0],t[0],n),m(e[1],t[1],n),m(e[2],t[2],n)],g=(e,t,n)=>p(h(f(e),f(t),d(n))),_=e=>{let t=d(e);return t*t*(3-2*t)},v=(e=Date.now())=>{let t=new Date(e),n=new Date(t);n.setHours(6,0,0,0);let r=new Date(t);return r.setHours(18,0,0,0),{sunrise:n.getTime(),sunset:r.getTime()}},y=(e,t=new Date)=>{let n=e.trim().match(/^(\d{1,2}):(\d{2})$/);if(!n)return null;let r=Number(n[1]),i=Number(n[2]);if(r<0||r>23||i<0||i>59)return null;let a=new Date(t);return a.setHours(r,i,0,0),a.getTime()},b=(e,t=new Date)=>y(e??`14:00`,t)??y(`14:00`,t),x=(e,t)=>{let{sunrise:n,sunset:r}=t;if(!(r>n)){let t=v(e);n=t.sunrise,r=t.sunset}let i=Math.max(1,r-n),a=n+1440*60*1e3,o=r-1440*60*1e3,s=e>=n&&e<r,c;if(s)c=d((e-n)/i);else if(e>=r){let t=Math.max(1,a-r);c=d((e-r)/t)}else{let t=Math.max(1,n-o);c=d((e-o)/t)}let l=s?Math.sin(Math.PI*c):0,u=Math.abs(e-n),f=Math.abs(e-r),p=d(1-Math.min(u,f)/45e5);return{isDay:s,arcProgress:c,elevation:l,twilight:p}},ee=(e,t,n)=>{let r=d(n),i=Math.sin(Math.PI*r);return{x:e*(.1+.8*r),y:t*(.58-.4*i)}},S=`#e8895c`,C=`#f3c98a`,w=`#2a1f4a`,T=`#c4784a`,te=(e,t,n)=>{if(n.isDay){let t=_(n.elevation),r=(1-t)*.72;return[g(g(e[0],S,r),`#1a2438`,(1-t)*.12),g(g(e[1],C,r*.85),`#3a4558`,(1-t)*.08)]}let r=n.twilight;return[g(t[0],g(w,S,.35),r*.55),g(t[1],g(T,C,.4),r*.7)]},E=(e,t,n)=>{let r=e.createLinearGradient(0,0,0,t);return r.addColorStop(0,n[0]),r.addColorStop(1,n[1]),r},D=e=>{if(!e.isDay)return{scale:.92+e.twilight*.06,alpha:.75+e.twilight*.2};let t=e.elevation;return{scale:.82+t*.22,alpha:.65+t*.35}},O=2,k=[``,`薄雾`,`中雾`,`浓雾`],A=e=>Math.min(3,Math.max(1,Math.round(e))),j=e=>{let t=A(e);return`${t} · ${k[t]}`},M=e=>e===`fog`,N=(e,t)=>{let n=A(t);return n===1?{...e,fogBanks:3,haze:.06,cloudAlpha:Math.min(e.cloudAlpha,.28),sun:`soft`}:n===3?{...e,fogBanks:12,haze:.3,cloudAlpha:.42,sun:`dim`}:{...e,fogBanks:5,haze:.11,cloudAlpha:.32,sun:`dim`}},P=e=>{let t=A(e);return t===1?.45:t===3?.95:.65},F=e=>e===45?2:e===48?3:null,I=e=>e==null||!Number.isFinite(e)?null:e>=5e3?1:e>=1e3?2:3,L=2,R=[``,`细雹`,`密雹`,`巨雹`],z=e=>Math.min(3,Math.max(1,Math.round(e))),B=e=>{let t=z(e);return`${t} · ${R[t]}`},V=e=>e===`hail`,H=e=>{let t=z(e);return t===1?{count:75,sizeMin:.85,sizeMax:2.1,speedMul:.88}:t===3?{count:210,sizeMin:2.4,sizeMax:5.6,speedMul:1.22}:{count:145,sizeMin:1.4,sizeMax:3.8,speedMul:1}},U=e=>e===96?2:e===99?3:null,W=1,G=10,K=5,ne=5,q=e=>Math.min(10,Math.max(1,Math.round(e))),J=(e,t,n)=>e+(t-e)*n,Y=e=>{let t=q(e);return t<=2?1:t<=4?2:t<=6?3:t<=8?4:5},re=[`毛毛雨`,`小雨`,`中雨`,`暴雨`,`特大暴雨`],ie=[`毛毛雪`,`小雪`,`中雪`,`暴雪`,`特大暴雪`],ae=(e,t)=>{let n=Y(e);return(t===`rain`?re:ie)[n-1]},oe=(e,t)=>`${q(e)} · ${ae(e,t)}`,se=[``,...re],ce=[``,...ie],X=e=>e===`lightRain`||e===`moderateRain`||e===`heavyRain`?`rain`:e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`?`snow`:e,le=e=>e===`rain`||e===`lightRain`||e===`moderateRain`||e===`heavyRain`,ue=e=>e===`snow`||e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`,de=e=>le(e)||e===`thunderstorm`||e===`sleet`,fe=e=>ue(e)||e===`sleet`,pe=(e,t=5)=>e===`lightRain`?3:e===`moderateRain`?5:e===`heavyRain`?8:q(t),me=(e,t=5)=>e===`lightSnow`?3:e===`moderateSnow`?5:e===`heavySnow`?8:q(t),Z=(e,t)=>t===`rain`?e<=2?`lightRain`:e===3?`moderateRain`:`heavyRain`:e<=2?`lightSnow`:e===3?`moderateSnow`:`heavySnow`,he=(e,t=5,n=5)=>e===`rain`?Z(Y(t),`rain`):e===`lightRain`||e===`moderateRain`||e===`heavyRain`?Z(Y(pe(e)),`rain`):e===`snow`?Z(Y(n),`snow`):e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`?Z(Y(me(e)),`snow`):e,ge=(e,t)=>{let n=(q(t)-1)/9;return{count:Math.round(J(35,340,n)),speed:J(5.5,16,n),wind:J(-.4,-3.2,n),alpha:J(.28,.62,n),splash:q(t)>=5}},_e=e=>{let t=(q(e)-1)/9;return Math.round(J(30,360,t))},ve=e=>[51,56].includes(e)?2:[61,66,80].includes(e)?3:[53,55,57,63,81].includes(e)?5:[65,67].includes(e)?8:[82].includes(e)?10:[95].includes(e)?7:null,ye=e=>[77].includes(e)?2:[71,85].includes(e)?3:[73].includes(e)?5:[75].includes(e)?8:[86].includes(e)?10:null,be=2,xe=[``,`轻霾`,`中霾`,`重霾`],Q=e=>Math.min(3,Math.max(1,Math.round(e))),Se=e=>{let t=Q(e);return`${t} · ${xe[t]}`},Ce=e=>e===`smog`,we=(e,t)=>{let n=Q(t);return n===1?{...e,fogBanks:5,haze:.16,cloudAlpha:Math.min(e.cloudAlpha,.28),sun:`soft`}:n===3?{...e,fogBanks:16,haze:.48,cloudAlpha:.42,sun:`dim`}:{...e,fogBanks:12,haze:.34,cloudAlpha:.35,sun:`dim`}},Te=e=>{let t=Q(e);return t===1?.55:t===3?1.05:.85},Ee=e=>e==null||!Number.isFinite(e)?null:e>=5e3?1:e>=1e3?2:3,De={0:`sunny`,1:`sunny`,2:`partlyCloudy`,3:`overcast`,45:`fog`,48:`fog`,51:`rain`,53:`rain`,55:`rain`,56:`rain`,57:`rain`,61:`rain`,63:`rain`,65:`rain`,66:`rain`,67:`rain`,80:`rain`,81:`rain`,82:`rain`,71:`snow`,73:`snow`,75:`snow`,77:`snow`,85:`snow`,86:`snow`,95:`thunderstorm`,96:`hail`,99:`hail`},Oe=e=>X(De[e]??`overcast`),ke={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`idle`,error:null,current:null},Ae={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`locating`,error:null,current:null},je={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`fetching`,error:null,current:null},Me=e=>e!=null&&Number.isFinite(e.latitude)&&Number.isFinite(e.longitude),Ne=e=>{if(typeof e!=`string`||!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null},Pe=e=>{if(typeof e!=`string`||!e)return null;let t=e.match(/T(\d{2}):(\d{2})/);return t?`${t[1]}:${t[2]}`:null},Fe=(e,t)=>{if(e)try{let t=new Intl.DateTimeFormat(`en-GB`,{timeZone:e,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(new Date),n=t.find(e=>e.type===`hour`)?.value,r=t.find(e=>e.type===`minute`)?.value;if(n!=null&&r!=null)return`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`}catch{}return t??null},Ie=(e=!0,t)=>{let n=Me(t),r=n?t.latitude:null,i=n?t.longitude:null,a=e?n?je:Ae:ke,o=`${e}:${r},${i}`,[s,l]=(0,c.useState)(a),[u,d]=(0,c.useState)(o);return u!==o&&(d(o),l(t=>e&&t.weather?{...a,weather:t.weather,current:t.current}:a)),(0,c.useEffect)(()=>{if(!e)return;let t=!1,n=new AbortController,a=async(e,r)=>{try{let i=new URLSearchParams({latitude:String(e),longitude:String(r),current:`weather_code,wind_speed_10m,is_day,visibility`,daily:`sunrise,sunset`,timezone:`auto`,forecast_days:`1`}),a=await fetch(`https://api.open-meteo.com/v1/forecast?${i}`,{signal:n.signal});if(!a.ok)throw Error(`Open-Meteo 请求失败(HTTP ${a.status})`);let o=await a.json(),s=Number(o?.current?.weather_code);if(Number.isNaN(s))throw Error(`Open-Meteo 返回数据缺少 weather_code`);let c=Number(o?.current?.wind_speed_10m??0),u=Ne(o?.daily?.sunrise?.[0]),d=Ne(o?.daily?.sunset?.[0]),f=typeof o?.timezone==`string`?o.timezone:null,p=Pe(o?.current?.time)??Fe(f),m=Oe(s),h=ve(s),g=ye(s),_=o?.current?.visibility,v=_!=null&&Number.isFinite(Number(_))?Number(_):null,y=m===`fog`?I(v)??F(s)??2:null,b=m===`hail`?U(s)??2:null,x=m===`smog`?Ee(v)??2:null;if(t)return;l({weather:m,rainLevel:h,snowLevel:g,fogLevel:y,hailLevel:b,smogLevel:x,status:`success`,error:null,current:{weatherCode:s,windSpeed:c,isDay:o?.current?.is_day===1,latitude:e,longitude:r,timezone:f,localTime:p,visibility:v,rainLevel:h,snowLevel:g,fogLevel:y,hailLevel:b,smogLevel:x,sunrise:u,sunset:d}})}catch(e){if(t||e instanceof DOMException&&e.name===`AbortError`)return;l({weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`error`,error:e instanceof Error?e.message:`天气获取失败`,current:null})}};return r!=null&&i!=null?(a(r,i),()=>{t=!0,n.abort()}):typeof navigator>`u`||!navigator.geolocation?(Promise.resolve().then(()=>{t||l({weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`error`,error:`当前环境不支持定位`,current:null})}),()=>{t=!0}):(navigator.geolocation.getCurrentPosition(({coords:e})=>{t||(l(e=>({...e,status:`fetching`})),a(e.latitude,e.longitude))},e=>{t||l({weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`error`,error:e.message||`定位失败`,current:null})},{timeout:1e4,maximumAge:600*1e3}),()=>{t=!0,n.abort()})},[e,r,i]),s},Le=async(e,t,n)=>{let r=new URLSearchParams({latitude:String(e),longitude:String(t),daily:`sunrise,sunset`,timezone:`auto`,forecast_days:`1`}),i=await fetch(`https://api.open-meteo.com/v1/forecast?${r}`,{signal:n});if(!i.ok)return null;let a=await i.json(),o=Ne(a?.daily?.sunrise?.[0]),s=Ne(a?.daily?.sunset?.[0]);return o==null||s==null?null:{sunrise:o,sunset:s}},Re=e=>{let t=Me(e),n=t?e.latitude:null,r=t?e.longitude:null,i=`${n},${r}`,[a,o]=(0,c.useState)(null),[s,l]=(0,c.useState)(i);return s!==i&&(l(i),o(null)),(0,c.useEffect)(()=>{if(n==null||r==null)return;let e=!1,t=new AbortController;return Le(n,r,t.signal).then(t=>{e||o(t)}).catch(()=>{e||o(null)}),()=>{e=!0,t.abort()}},[n,r]),t?a:null},ze=3,Be=e=>Math.min(12,Math.max(0,Math.round(e))),Ve=e=>Math.max(0,Be(e)-2),He=.55,Ue=[0,3,8,16,24,33,44,55,68,81,95,110,125],We=[1,5,11,19,28,38,49,61,74,88,102,117,1/0],$=(e,t,n=0,r=0)=>{let i=t.gustiness,a=t.wander,o=n*.0017+r*.0024,s=e*He,c=Math.sin(s*.007+o),l=Math.sin(s*.021+1.37+o*1.4),u=Math.sin(s*.055+2.8+o*.6),d=1+(.5*c+.35*l+.15*u)*(.25+i*.75),f=Math.sin(s*.012+o*.8);f>.72&&(d+=(f-.72)*(.8+i*2.4)),Math.sin(s*.0095+.6+o)<-.55&&(d*=.45+i*.2),d=Math.max(.12,Math.min(2.25,d));let p=a*(.55*Math.sin(s*.0088+o)+.3*Math.sin(s*.026+1.9+o*1.1)+.15*Math.sin(s*.063+.4));return{intensity:d,angle:p,ux:Math.cos(p),uy:Math.sin(p)}},Ge=e=>{let t=Be(e);if(t<=0)return{count:0,alphaMul:0};let n=Math.min(1,(t/9)**1.15);return{count:Math.floor(3+n*n*50),alphaMul:.1+n*.9}},Ke=e=>Ue[Be(e)]??16,qe=e=>{let t=Math.max(0,e);for(let e=0;e<We.length;e++)if(t<=We[e])return e;return 12},Je=e=>{let t=qe(e),n=Ve(t),r=Ke(n),i=Math.max(.04,Math.min(r/16,4.2)),{alphaMul:a}=Ge(n),o=i**.82,s=Math.min(1,(n/8)**1.1),c=(.04+s*.32)*Math.PI;return{speedKmh:e,level:t,visualLevel:n,scale:i,cloud:.28+i*.72,rain:o,snowDrift:-(.04+o*.28),hail:.4+o*.85,fog:.32+o*.58,streak:.55+o*.95,streakVisibility:a,gustiness:s,wander:c}},Ye=e=>e.live&&e.liveWindKmh!=null&&Number.isFinite(e.liveWindKmh)?Math.max(0,e.liveWindKmh):Ke(e.windLevel);function Xe(e){let t=e.windMotion.cloud,{intensity:n,angle:r,uy:i}=e.windField,a=-Math.cos(r);for(let r of e.state.clouds){let o=Math.abs(r.speed)*t*n;r.x+=o*a,r.y+=o*i*.12,r.y<-80&&(r.y=-80),r.y>e.height*.55&&(r.y=e.height*.55),r.x-140*r.scale>e.width&&(r.x=-160*r.scale),r.x+180*r.scale<0&&(r.x=e.width+40*r.scale),e.ctx.drawImage(r.sprite,r.x+r.ox,r.y+r.oy)}}function Ze(e){let t=e.fogSprite;if(!t||e.state.fogBanks.length===0)return;let{canvas:n,baseR:r}=t,i=e.windMotion.fog,{intensity:a,angle:o,uy:s}=e.windField,c=-Math.cos(o);for(let t of e.state.fogBanks){let o=Math.abs(t.speed)*i*a;t.x+=o*c,t.y+=o*s*.1,t.y<e.height*.02&&(t.y=e.height*.02),t.y>e.height*.95&&(t.y=e.height*.95),c<0&&t.x+t.rw<0&&(t.x=e.width+t.rw),c>0&&t.x-t.rw>e.width&&(t.x=-t.rw),e.ctx.save(),e.ctx.translate(t.x,t.y),e.ctx.scale(t.rw/r,t.rh/r),e.ctx.globalAlpha=t.alpha,e.ctx.drawImage(n,-r,-r),e.ctx.restore()}}function Qe(e){if(e.cfg.haze<=0)return;let t=e.activeWeather===`smog`?`177, 164, 135`:`220, 226, 232`;e.activeNight&&(t=e.activeWeather===`smog`?`82, 74, 54`:`116, 128, 145`),e.ctx.fillStyle=`rgba(${t}, ${e.cfg.haze})`,e.ctx.fillRect(0,0,e.width,e.height)}function $e(e,t,n,r,i,a){if(a<=0)return[[e,t],[n,r]];let o=(e+n)/2+(Math.random()-.5)*i,s=(t+r)/2,c=$e(e,t,o,s,i*.55,a-1),l=$e(o,s,n,r,i*.55,a-1);return[...c.slice(0,-1),...l]}function et(e){if(e.state.windStreaks.length===0)return;let t=e.windMotion.streak,n=e.windMotion.streakVisibility;if(n<=.02)return;let r=e.state.t;for(let i of e.state.windStreaks){let a=$(r+i.phase*18,e.windMotion,i.x,i.y),o=a.intensity*(.55+.45*e.windField.intensity),s=a.angle*.65+e.windField.angle*.35,c=-1*Math.cos(s),l=Math.sin(s),u=i.speed*t*o;i.x+=u*c,i.y+=u*l*.45,i.wave+=.03+o*.025,(i.x<-i.length-40||i.x>e.width+i.length+40)&&(i.x=c<0?e.width+i.length+Math.random()*e.width*.25:-i.length-Math.random()*e.width*.25,i.y=Math.random()*e.height),i.y<-20&&(i.y=e.height+10),i.y>e.height+20&&(i.y=-10);let d=5+o*5,f=Math.sin(i.wave)*d,p=i.length*(.85+o*.2),m=i.x+c*p,h=i.y+l*p*.45,g=i.alpha*n*Math.min(1.35,.55+o*.55);if(e.ctx.beginPath(),e.ctx.moveTo(i.x,i.y),e.ctx.bezierCurveTo(i.x+c*p*.3,i.y+l*p*.3*.45+f,i.x+c*p*.7,i.y+l*p*.7*.45-f,m,h),e.ctx.strokeStyle=`rgba(235, 244, 250, ${g})`,e.ctx.lineWidth=i.width*(.85+o*.2),e.ctx.lineCap=`round`,e.ctx.stroke(),i.length>70&&n>.45&&o>.7){let t=i.x+c*p*.58,n=i.y+l*p*.58*.45-f*.4;e.ctx.save(),e.ctx.translate(t,n),e.ctx.rotate(s+i.wave*2),e.ctx.beginPath(),e.ctx.ellipse(0,0,4,1.6,0,0,Math.PI*2),e.ctx.fillStyle=`rgba(91, 76, 52, ${g*1.4})`,e.ctx.fill(),e.ctx.restore()}}}function tt(e){if(e.cfg.lightning){if(e.state.t>=e.state.nextStrike){e.state.nextStrike=e.state.t+150+Math.random()*300,e.state.flashAlpha=.5,e.state.boltLife=9;let t=e.width*(.15+Math.random()*.7);e.state.boltPoints=$e(t,e.height*.12,t+(Math.random()-.5)*e.width*.2,e.height*.92,60,6)}if(e.state.boltLife>0){--e.state.boltLife;let t=e.state.boltLife/9;e.ctx.beginPath(),e.state.boltPoints.forEach(([t,n],r)=>r===0?e.ctx.moveTo(t,n):e.ctx.lineTo(t,n)),e.ctx.strokeStyle=`rgba(240, 246, 255, ${t})`,e.ctx.lineWidth=2.4,e.ctx.shadowColor=`#bcd7ff`,e.ctx.shadowBlur=16,e.ctx.stroke(),e.ctx.shadowBlur=0}e.state.flashAlpha>.01&&(e.ctx.fillStyle=`rgba(226, 236, 255, ${e.state.flashAlpha})`,e.ctx.fillRect(0,0,e.width,e.height),e.state.flashAlpha*=.82)}}var nt=3.2,rt=e=>{let t=Math.ceil(e*2.8+4),n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=t/2,a=t/2,o=9+Math.floor(Math.random()*5),s=Array.from({length:o},(t,n)=>{let r=n/o*Math.PI*2+(Math.random()-.5)*.22,s=e*(.72+Math.random()*.44);return{x:i+Math.cos(r)*s,y:a+Math.sin(r)*s}}),c=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});r.beginPath();let l=c(s[s.length-1],s[0]);r.moveTo(l.x,l.y);for(let e=0;e<s.length;e++){let t=c(s[e],s[(e+1)%s.length]);r.quadraticCurveTo(s[e].x,s[e].y,t.x,t.y)}r.closePath();let u=i-e*.3,d=a-e*.34,f=r.createRadialGradient(u,d,e*.06,i,a,e*1.2);f.addColorStop(0,`rgba(255, 255, 255, 0.98)`),f.addColorStop(.42,`rgba(228, 241, 252, 0.96)`),f.addColorStop(.82,`rgba(176, 203, 224, 0.93)`),f.addColorStop(1,`rgba(130, 162, 188, 0.9)`),r.fillStyle=f,r.fill(),r.strokeStyle=`rgba(155, 190, 215, 0.62)`,r.lineWidth=Math.max(.45,e*.11),r.stroke();let p=1+Math.floor(Math.random()*2);for(let t=0;t<p;t++){let t=Math.random()*Math.PI*2,n=i+Math.cos(t)*e*(.28+Math.random()*.35),o=a+Math.sin(t)*e*(.28+Math.random()*.35);r.beginPath(),r.ellipse(n,o,e*(.14+Math.random()*.1),e*(.1+Math.random()*.08),t,0,Math.PI*2),r.fillStyle=`rgba(105, 135, 165, 0.28)`,r.fill()}if(Math.random()<.75){let t=Math.random()*Math.PI*2,n=i+Math.cos(t)*e*(.38+Math.random()*.28),o=a+Math.sin(t)*e*(.38+Math.random()*.28);r.beginPath(),r.arc(n,o,e*(.1+Math.random()*.08),0,Math.PI*2),r.fillStyle=`rgba(255, 255, 255, 0.55)`,r.fill()}return r.beginPath(),r.ellipse(i-e*.34,a-e*.36,e*.24,e*.17,-.35,0,Math.PI*2),r.fillStyle=`rgba(255, 255, 255, 0.78)`,r.fill(),n},it=(e=16)=>Array.from({length:e},()=>rt(nt)),at=e=>e[Math.floor(Math.random()*e.length)],ot=(e,t,n,r,i=!0,a,o=1)=>{let s=a?.min??1.4,c=a?.max??4.8;e.r=s+Math.random()**1.35*(c-s),e.x=Math.random()*(t+260)-130+(Math.random()-.5)*40,e.y=i?-e.r-Math.random()*n*.55:Math.random()*n,e.vx=(-1.2-Math.random()*4.8+(Math.random()-.5)*1.2)*o,e.vy=(5.5+Math.random()*11)*o,e.bounces=0,e.opacity=.45+Math.random()*.55,e.delay=Math.floor(Math.random()*(i?110:45)),e.gravity=(.11+Math.random()*.14)*(.9+o*.1),e.phase=Math.random()*Math.PI*2,e.gust=(Math.random()-.5)*1.4,e.maxBounces=+(Math.random()<.62),e.sprite=at(r),e.drawSize=e.r*2.8+4,e.rotation=Math.random()*Math.PI*2,e.rotationSpeed=(Math.random()-.5)*.06},st=(e,t,n,r,i=1)=>{let a={x:0,y:0,r:2,vx:0,vy:0,bounces:0,opacity:1,delay:0,gravity:.16,phase:0,gust:0,maxBounces:1,sprite:n[0],drawSize:9.6,rotation:0,rotationSpeed:0};return ot(a,e,t,n,Math.random()<.72,r,i),a};function ct(e){if(!e.cfg.rain)return;let{alpha:t,splash:n}=e.cfg.rain,r=e.cfg.rain.wind*e.windMotion.rain,{intensity:i,angle:a,uy:o}=e.windField,s=r*i*Math.cos(a),c=Math.abs(r)*i*o*.35;e.ctx.strokeStyle=`rgba(214, 228, 240, ${t})`,e.ctx.lineWidth=1.2,e.ctx.beginPath();for(let t of e.state.drops){let r=t.speed+c,i=Math.hypot(s,r)||1,a=s/i,o=r/i;e.ctx.moveTo(t.x,t.y),e.ctx.lineTo(t.x+a*t.len,t.y+o*t.len),t.x+=s,t.y+=r,t.y>e.height&&(n&&Math.random()<.3&&e.state.splashes.length<60&&e.state.splashes.push({x:t.x,r:1,alpha:.5}),t.y=-t.len,t.x=Math.random()*(e.width+160)-80)}e.ctx.stroke();for(let t=e.state.splashes.length-1;t>=0;t--){let n=e.state.splashes[t];if(n.r+=.8,n.alpha-=.035,n.alpha<=0){e.state.splashes.splice(t,1);continue}e.ctx.beginPath(),e.ctx.ellipse(n.x,e.height-3,n.r,n.r*.35,0,Math.PI,Math.PI*2),e.ctx.strokeStyle=`rgba(214, 228, 240, ${n.alpha})`,e.ctx.lineWidth=1,e.ctx.stroke()}}function lt(e){let t=e.windMotion.snowDrift,{intensity:n,angle:r,uy:i}=e.windField,a=t*n*Math.cos(r),o=Math.abs(t)*n*i*.4;for(let t of e.state.flakes){t.y+=t.speed+o,t.x+=Math.sin(e.state.t*.02+t.phase)*(.3+t.size*.08)+t.drift+a,t.rotation+=t.rotationSpeed,t.y-t.drawSize>e.height&&(t.y=-t.drawSize,t.x=Math.random()*e.width,t.phase=Math.random()*Math.PI*2,t.drift=(Math.random()-.5)*.4,t.opacity=.55+Math.random()*.45),t.x>e.width+20&&(t.x=-20),t.x<-20&&(t.x=e.width+20);let n=t.drawSize/2;e.ctx.save(),e.ctx.globalAlpha=t.opacity,e.ctx.translate(t.x,t.y),e.ctx.rotate(t.rotation),e.ctx.drawImage(t.sprite,-n,-n,t.drawSize,t.drawSize),e.ctx.restore()}}function ut(e){if(e.state.hailstones.length===0)return;let t=e.state.hailPool,n=e.windMotion.hail,r=e.state.t,i=e.windField;for(let a of e.state.hailstones){if(a.delay>0){--a.delay;continue}let o=$(r+a.phase*12,e.windMotion,a.x,a.y),s=o.intensity*(.4+.6*i.intensity),c=o.angle*.5+i.angle*.5,l=e.windMotion.snowDrift*.45*s*Math.cos(c),u=Math.abs(e.windMotion.snowDrift)*s*Math.sin(c)*.2,d=a.x,f=a.y;if(a.vy+=a.gravity+u*.02,a.vx+=a.gust*.004*n*s+l+(Math.random()-.5)*.08*n*s,a.x+=a.vx+Math.sin(r*.028+a.phase)*.35,a.y+=a.vy,e.ctx.beginPath(),e.ctx.moveTo(d,f),e.ctx.lineTo(a.x,a.y),e.ctx.strokeStyle=`rgba(225, 239, 250, ${a.opacity*.18})`,e.ctx.lineWidth=a.r*.35,e.ctx.stroke(),a.y+a.r>=e.height)if(a.bounces<a.maxBounces)a.y=e.height-a.r,a.vy*=-(.22+Math.random()*.28),a.vx=a.vx*(.55+Math.random()*.25)+(Math.random()-.5)*1.6,a.bounces+=1;else{ot(a,e.width,e.height,t,!0,e.hailSpec?{min:e.hailSpec.sizeMin,max:e.hailSpec.sizeMax}:void 0,e.hailSpec?.speedMul??1);continue}let p=a.drawSize/2;a.rotation+=a.rotationSpeed,e.ctx.save(),e.ctx.globalAlpha=a.opacity,e.ctx.translate(a.x,a.y),e.ctx.rotate(a.rotation),e.ctx.drawImage(a.sprite,-p,-p,a.drawSize,a.drawSize),e.ctx.restore()}}function dt(e){e.ctx.fillStyle=e.skyGradient,e.ctx.fillRect(0,0,e.width,e.height)}function ft(e){if(e.state.stars.length===0)return;let t=1;if(e.dayCycle){if(e.dayCycle.isDay)return;t=.35+(1-e.dayCycle.twilight)*.65}else if(!e.activeNight)return;for(let n of e.state.stars){let r=.35+(Math.sin(e.state.t*n.speed+n.phase)+1)*.325;e.ctx.beginPath(),e.ctx.arc(n.x,n.y,n.r,0,Math.PI*2),e.ctx.fillStyle=`rgba(226, 235, 255, ${r*t})`,e.ctx.fill()}}function pt(e){let t=e.celestial;if(!t)return;let{ctx:n,sunX:r,sunY:i,state:a}=e,o=1+Math.sin(a.t*t.breathSpeed)*t.breathAmp,s=e.dayCycle?D(e.dayCycle):{scale:1,alpha:1},c=t.half*o*s.scale,l=c*2;n.save(),n.globalAlpha=s.alpha,n.drawImage(t.canvas,r-c,i-c,l,l),n.restore()}function mt(e){if(e.activeNight){ft(e),pt(e);return}pt(e)}var ht={sunny:{sky:[`#4a9fe0`,`#c8e8fb`],sun:`full`,cloudCount:1,cloudColor:[255,255,255],cloudAlpha:.5,cloudSpread:.12,rain:null,fogBanks:0,haze:0,snowCount:0,lightning:!1},partlyCloudy:{sky:[`#5b9bd0`,`#cfe6f3`],sun:`soft`,cloudCount:5,cloudColor:[255,255,255],cloudAlpha:.85,cloudSpread:.22,rain:null,fogBanks:0,haze:0,snowCount:0,lightning:!1},overcast:{sky:[`#8a97a8`,`#c3cbd6`],sun:`none`,cloudCount:9,cloudColor:[100,116,139],cloudAlpha:.55,cloudSpread:.3,rain:null,fogBanks:0,haze:.06,snowCount:0,lightning:!1},rain:{sky:[`#55637a`,`#7e8ba0`],sun:`none`,cloudCount:8,cloudColor:[51,65,85],cloudAlpha:.65,cloudSpread:.26,rain:{count:150,speed:10,wind:-1.5,alpha:.5,splash:!0},fogBanks:0,haze:.06,snowCount:0,lightning:!1},lightRain:{sky:[`#6b7a8f`,`#9aa7b8`],sun:`none`,cloudCount:7,cloudColor:[71,85,105],cloudAlpha:.6,cloudSpread:.24,rain:{count:70,speed:7,wind:-.8,alpha:.4,splash:!1},fogBanks:0,haze:.04,snowCount:0,lightning:!1},moderateRain:{sky:[`#55637a`,`#7e8ba0`],sun:`none`,cloudCount:8,cloudColor:[51,65,85],cloudAlpha:.65,cloudSpread:.26,rain:{count:150,speed:10,wind:-1.5,alpha:.5,splash:!0},fogBanks:0,haze:.06,snowCount:0,lightning:!1},heavyRain:{sky:[`#3d4a5f`,`#5d6a80`],sun:`none`,cloudCount:9,cloudColor:[30,41,59],cloudAlpha:.7,cloudSpread:.3,rain:{count:280,speed:14,wind:-2.8,alpha:.55,splash:!0},fogBanks:0,haze:.1,snowCount:0,lightning:!1},thunderstorm:{sky:[`#252f42`,`#43506a`],sun:`none`,cloudCount:10,cloudColor:[15,23,42],cloudAlpha:.75,cloudSpread:.32,rain:{count:240,speed:13,wind:-2.2,alpha:.55,splash:!0},fogBanks:0,haze:.08,snowCount:0,lightning:!0},fog:{sky:[`#aab4bf`,`#d5dbe1`],sun:`dim`,cloudCount:3,cloudColor:[203,213,225],cloudAlpha:.4,cloudSpread:.2,rain:null,fogBanks:10,haze:.28,snowCount:0,lightning:!1},lightSnow:{sky:[`#aab8c8`,`#e2e8ef`],sun:`none`,cloudCount:5,cloudColor:[166,180,196],cloudAlpha:.45,cloudSpread:.22,rain:null,fogBanks:0,haze:.05,snowCount:70,lightning:!1},moderateSnow:{sky:[`#9fb0c4`,`#dde5ee`],sun:`none`,cloudCount:6,cloudColor:[148,163,184],cloudAlpha:.5,cloudSpread:.24,rain:null,fogBanks:0,haze:.08,snowCount:160,lightning:!1},heavySnow:{sky:[`#8495aa`,`#c7d1dc`],sun:`none`,cloudCount:9,cloudColor:[100,116,139],cloudAlpha:.62,cloudSpread:.3,rain:null,fogBanks:3,haze:.14,snowCount:300,lightning:!1},sleet:{sky:[`#78899e`,`#b8c5d2`],sun:`none`,cloudCount:8,cloudColor:[71,85,105],cloudAlpha:.6,cloudSpread:.28,rain:{count:100,speed:9,wind:-1.4,alpha:.42,splash:!0},fogBanks:0,haze:.09,snowCount:100,lightning:!1},hail:{sky:[`#46566c`,`#77889d`],sun:`none`,cloudCount:9,cloudColor:[30,41,59],cloudAlpha:.68,cloudSpread:.3,rain:{count:80,speed:11,wind:-2.5,alpha:.38,splash:!0},fogBanks:0,haze:.1,snowCount:0,lightning:!1},smog:{sky:[`#8f8b7e`,`#c5bca8`],sun:`dim`,cloudCount:3,cloudColor:[142,136,119],cloudAlpha:.35,cloudSpread:.2,rain:null,fogBanks:12,haze:.34,snowCount:0,lightning:!1},gale:{sky:[`#587087`,`#a6b5c2`],sun:`soft`,cloudCount:8,cloudColor:[203,213,225],cloudAlpha:.72,cloudSpread:.3,rain:null,fogBanks:0,haze:.04,snowCount:0,lightning:!1},snow:{sky:[`#9fb0c4`,`#dde5ee`],sun:`none`,cloudCount:6,cloudColor:[148,163,184],cloudAlpha:.5,cloudSpread:.24,rain:null,fogBanks:0,haze:.08,snowCount:160,lightning:!1}},gt={sunny:{sky:[`#0b1a33`,`#27476e`],stars:110},partlyCloudy:{sky:[`#0f1f38`,`#2c4666`],stars:60},overcast:{sky:[`#181f2a`,`#333e4e`],stars:0},rain:{sky:[`#11161f`,`#242c3a`],stars:0},lightRain:{sky:[`#151b26`,`#2b3442`],stars:0},moderateRain:{sky:[`#11161f`,`#242c3a`],stars:0},heavyRain:{sky:[`#0c1017`,`#1c232e`],stars:0},thunderstorm:{sky:[`#0a0e18`,`#192132`],stars:0},fog:{sky:[`#1c222b`,`#3a434e`],stars:0},snow:{sky:[`#131a26`,`#333f4f`],stars:8},lightSnow:{sky:[`#161e2b`,`#3a4656`],stars:20},moderateSnow:{sky:[`#131a26`,`#333f4f`],stars:8},heavySnow:{sky:[`#101623`,`#2a3545`],stars:0},sleet:{sky:[`#121924`,`#2c3745`],stars:0},hail:{sky:[`#0e141d`,`#26303e`],stars:0},smog:{sky:[`#1a1812`,`#38321f`],stars:0},gale:{sky:[`#101a26`,`#2e3d4d`],stars:30}},_t=([e,t,n])=>[Math.round(e*.3+18),Math.round(t*.3+24),Math.round(n*.3+42)];function vt(e,t,n,r){let[i,a,o]=n,s=1/0,c=1/0,l=-1/0,u=-1/0;for(let n of t){let t=n.dx*e,r=n.dy*e,i=n.r*e;s=Math.min(s,t-i),c=Math.min(c,r-i),l=Math.max(l,t+i),u=Math.max(u,r+i)}let d=Math.floor(s-2),f=Math.floor(c-2),p=Math.ceil(l+2)-d,m=Math.ceil(u+2)-f,h=document.createElement(`canvas`);h.width=p,h.height=m;let g=h.getContext(`2d`);for(let n of t){let t=n.dx*e-d,s=n.dy*e-f,c=n.r*e,l=g.createRadialGradient(t,s,0,t,s,c);l.addColorStop(0,`rgba(${i}, ${a}, ${o}, ${r})`),l.addColorStop(1,`rgba(${i}, ${a}, ${o}, 0)`),g.beginPath(),g.arc(t,s,c,0,Math.PI*2),g.fillStyle=l,g.fill()}return{sprite:h,ox:d,oy:f}}function yt(e,t,n,r,i){let a=.7+Math.random()*.9,o=4+Math.floor(Math.random()*3),s=Array.from({length:o},(e,t)=>({dx:(t-o/2)*26+(Math.random()-.5)*14,dy:(Math.random()-.5)*14,r:22+Math.random()*20})),{sprite:c,ox:l,oy:u}=vt(a,s,r,i);return{x:Math.random()*(e+240)-120,y:t*.06+Math.random()*t*n,scale:a,speed:.12+Math.random()*.22,puffs:s,sprite:c,ox:l,oy:u}}function bt(e,t=120){let n=t*2,r=document.createElement(`canvas`);r.width=n,r.height=n;let i=r.getContext(`2d`),a=i.createRadialGradient(t,t,0,t,t,t);return a.addColorStop(0,`rgba(${e}, 1)`),a.addColorStop(1,`rgba(${e}, 0)`),i.fillStyle=a,i.beginPath(),i.arc(t,t,t,0,Math.PI*2),i.fill(),{canvas:r,baseR:t}}function xt(e,t){let n=e.sun;if(n===`none`)return null;let r=n===`full`?1:n===`soft`?.62:.32,i=t*(n===`full`?.72:n===`soft`?.62:.5),a=t*(n===`full`?7.2:n===`soft`?5.2:3.6),o=a;n===`full`&&(o=Math.max(o,1.55*t*5.5)),o=Math.ceil(o+2);let s=o*2,c=document.createElement(`canvas`);c.width=s,c.height=s;let l=c.getContext(`2d`),u=o,d=o;l.save(),l.globalCompositeOperation=`lighter`;let f=l.createRadialGradient(u,d,0,u,d,a);f.addColorStop(0,`rgba(255, 230, 170, ${.14*r})`),f.addColorStop(.22,`rgba(255, 210, 140, ${.07*r})`),f.addColorStop(.5,`rgba(255, 195, 120, ${.03*r})`),f.addColorStop(1,`rgba(255, 200, 130, 0)`),l.fillStyle=f,l.fillRect(0,0,s,s);let p=t*(n===`full`?3.4:2.6),m=l.createRadialGradient(u,d,i*.15,u,d,p);if(m.addColorStop(0,`rgba(255, 240, 200, ${.32*r})`),m.addColorStop(.4,`rgba(255, 220, 150, ${.16*r})`),m.addColorStop(.75,`rgba(255, 200, 120, ${.05*r})`),m.addColorStop(1,`rgba(255, 190, 110, 0)`),l.fillStyle=m,l.beginPath(),l.arc(u,d,p,0,Math.PI*2),l.fill(),n===`full`){l.translate(u,d),l.scale(1.55,.55);let e=l.createRadialGradient(0,0,0,0,0,t*5.5);e.addColorStop(0,`rgba(255, 225, 170, 0.08)`),e.addColorStop(.5,`rgba(255, 205, 140, 0.03)`),e.addColorStop(1,`rgba(255, 195, 130, 0)`),l.fillStyle=e,l.beginPath(),l.arc(0,0,t*5.5,0,Math.PI*2),l.fill()}l.restore();let h=i*2.05,g=l.createRadialGradient(u,d,0,u,d,h);g.addColorStop(0,`rgba(255, 245, 210, ${.7*r})`),g.addColorStop(.4,`rgba(255, 230, 170, ${.35*r})`),g.addColorStop(.75,`rgba(255, 210, 140, ${.1*r})`),g.addColorStop(1,`rgba(255, 200, 130, 0)`),l.fillStyle=g,l.beginPath(),l.arc(u,d,h,0,Math.PI*2),l.fill();let _=l.createRadialGradient(u,d,0,u,d,i);return n===`dim`?(_.addColorStop(0,`rgba(255, 240, 210, ${.5*r})`),_.addColorStop(.55,`rgba(255, 220, 170, ${.3*r})`),_.addColorStop(1,`rgba(255, 200, 140, 0)`)):(_.addColorStop(0,`rgba(255, 250, 230, ${.98*r})`),_.addColorStop(.4,`rgba(255, 240, 195, ${.92*r})`),_.addColorStop(.75,`rgba(255, 220, 150, ${.55*r})`),_.addColorStop(1,`rgba(255, 205, 130, 0)`)),l.fillStyle=_,l.beginPath(),l.arc(u,d,i,0,Math.PI*2),l.fill(),{canvas:c,half:o,breathSpeed:.018,breathAmp:.018}}function St(e,t,n){if(e.sun===`none`)return null;let r=t*.82,i=e.sun===`dim`,a=i?.45:1,o=r*(i?4.2:6.2),s=Math.ceil(Math.max(o,r*2.6,r*1.35)+2),c=s*2,l=document.createElement(`canvas`);l.width=c,l.height=c;let u=l.getContext(`2d`),d=s,f=s;u.save(),u.globalCompositeOperation=`lighter`;let p=u.createRadialGradient(d,f,0,d,f,o);p.addColorStop(0,`rgba(200, 215, 240, ${.16*a})`),p.addColorStop(.25,`rgba(170, 190, 225, ${.07*a})`),p.addColorStop(.55,`rgba(140, 165, 210, ${.025*a})`),p.addColorStop(1,`rgba(130, 155, 200, 0)`),u.fillStyle=p,u.fillRect(0,0,c,c);let m=r*2.6,h=u.createRadialGradient(d,f,r*.2,d,f,m);h.addColorStop(0,`rgba(230, 236, 248, ${.28*a})`),h.addColorStop(.45,`rgba(190, 205, 230, ${.12*a})`),h.addColorStop(1,`rgba(160, 180, 220, 0)`),u.fillStyle=h,u.beginPath(),u.arc(d,f,m,0,Math.PI*2),u.fill(),u.restore();let g=u.createRadialGradient(d-r*.28,f-r*.3,0,d,f,r);g.addColorStop(0,`rgba(236, 240, 246, ${.96*a})`),g.addColorStop(.45,`rgba(214, 220, 230, ${.94*a})`),g.addColorStop(.82,`rgba(186, 196, 212, ${.9*a})`),g.addColorStop(1,`rgba(160, 172, 192, ${.75*a})`),u.beginPath(),u.arc(d,f,r,0,Math.PI*2),u.fillStyle=g,u.fill(),u.save(),u.beginPath(),u.arc(d,f,r*.98,0,Math.PI*2),u.clip();for(let e of[{dx:-.18,dy:.12,rx:.38,ry:.28,a:.14},{dx:.22,dy:-.08,rx:.26,ry:.2,a:.11},{dx:.05,dy:.32,rx:.2,ry:.14,a:.09}]){let t=d+e.dx*r,n=f+e.dy*r,i=u.createRadialGradient(t,n,0,t,n,e.rx*r);i.addColorStop(0,`rgba(140, 152, 170, ${e.a*a})`),i.addColorStop(.65,`rgba(150, 162, 178, ${e.a*.45*a})`),i.addColorStop(1,`rgba(160, 170, 185, 0)`),u.fillStyle=i,u.beginPath(),u.ellipse(t,n,e.rx*r,e.ry*r,.35,0,Math.PI*2),u.fill()}for(let e of n){let t=d+e.dx*r,n=f+e.dy*r,i=e.r*r,o=u.createRadialGradient(t-i*.25,n-i*.3,0,t,n,i);o.addColorStop(0,`rgba(155, 168, 186, ${.22*a})`),o.addColorStop(.55,`rgba(145, 158, 176, ${.28*a})`),o.addColorStop(.85,`rgba(200, 210, 224, ${.12*a})`),o.addColorStop(1,`rgba(210, 218, 230, 0)`),u.fillStyle=o,u.beginPath(),u.arc(t,n,i,0,Math.PI*2),u.fill()}let _=u.createRadialGradient(d-r*.35,f-r*.38,0,d-r*.1,f-r*.1,r*.7);_.addColorStop(0,`rgba(255, 255, 255, ${.28*a})`),_.addColorStop(.45,`rgba(245, 248, 252, ${.08*a})`),_.addColorStop(1,`rgba(240, 244, 250, 0)`),u.fillStyle=_,u.beginPath(),u.arc(d,f,r,0,Math.PI*2),u.fill(),u.restore();let v=u.createRadialGradient(d,f,r*.72,d,f,r*1.35);return v.addColorStop(0,`rgba(210, 220, 235, 0)`),v.addColorStop(.55,`rgba(200, 212, 232, ${.1*a})`),v.addColorStop(1,`rgba(180, 195, 220, 0)`),u.fillStyle=v,u.beginPath(),u.arc(d,f,r*1.35,0,Math.PI*2),u.fill(),{canvas:l,half:s,breathSpeed:.012,breathAmp:.012}}var Ct=e=>{let t=Math.ceil(e*2+4),n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=r.createRadialGradient(t/2,t/2,0,t/2,t/2,e+1);return i.addColorStop(0,`rgba(255, 255, 255, 1)`),i.addColorStop(.6,`rgba(255, 255, 255, 0.85)`),i.addColorStop(1,`rgba(255, 255, 255, 0)`),r.fillStyle=i,r.fillRect(0,0,t,t),n},wt=e=>{let t=Math.ceil(e*2+6),n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`);r.translate(t/2,t/2),r.strokeStyle=`rgba(255, 255, 255, 0.95)`,r.lineCap=`round`,r.lineWidth=Math.max(e*.11,.7),r.shadowColor=`rgba(255, 255, 255, 0.5)`,r.shadowBlur=e*.25;let i=1+Math.floor(Math.random()*3),a=Array.from({length:i},()=>({pos:.3+Math.random()*.5,len:e*(.22+Math.random()*.34),angle:Math.PI/3*(.8+Math.random()*.45)})),o=Math.random()<.55,s=e*(.14+Math.random()*.12),c=Math.random()<.45,l=e*(.14+Math.random()*.14);for(let t=0;t<6;t++){r.save(),r.rotate(t*Math.PI/3),r.beginPath(),r.moveTo(0,0),r.lineTo(0,-e);for(let t of a){let n=-e*t.pos;r.moveTo(0,n),r.lineTo(Math.sin(t.angle)*t.len,n-Math.cos(t.angle)*t.len),r.moveTo(0,n),r.lineTo(-Math.sin(t.angle)*t.len,n-Math.cos(t.angle)*t.len)}o&&(r.moveTo(0,-e),r.lineTo(s*.7,-e-s*.5),r.moveTo(0,-e),r.lineTo(-s*.7,-e-s*.5)),r.stroke(),r.restore()}if(c){r.beginPath();for(let e=0;e<6;e++){let t=e*Math.PI/3-Math.PI/2,n=Math.cos(t)*l,i=Math.sin(t)*l;e===0?r.moveTo(n,i):r.lineTo(n,i)}r.closePath(),r.stroke()}return n},Tt=()=>({dots:[1.2,1.6,2,2.3].map(e=>Ct(e)),crystals:[2.6,3.2,3.8,4.4,5].map(e=>wt(e*2.4))}),Et=e=>e[Math.floor(Math.random()*e.length)],Dt=(e,t,n,r)=>{let i=1+Math.random()**1.6*4.2,a=i>=2.4,o=Et(a?n.crystals:n.dots),s=a?i*4.8+6:i*2+4;return{x:Math.random()*e,y:r??Math.random()*t,size:i,speed:.4+i*.28+Math.random()*.4,phase:Math.random()*Math.PI*2,drift:(Math.random()-.5)*.4,rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.025,opacity:.55+Math.random()*.45,sprite:o,drawSize:s}},Ot=(e,t)=>t?e===`smog`?`96, 88, 66`:`138, 150, 168`:e===`smog`?`168, 155, 126`:`226, 232, 238`;function kt(e){let{ctx:t,width:n,height:r,activeWeather:i,dayCycleTimes:a=null,sceneTimeMs:o,liveClock:s=!1,windMotion:c,rainLevel:l=5,snowLevel:u=5,hailLevel:d=2,fogLevel:f=2,smogLevel:p=2}=e,m=ht[i],h=(()=>{let e=m;return de(i)&&e.rain&&(e={...e,rain:ge(e.rain,l)}),fe(i)&&(e={...e,snowCount:_e(u),fogBanks:u>=7?Math.max(e.fogBanks,3):e.fogBanks,haze:u>=7?Math.max(e.haze,.12):e.haze}),M(i)&&(e=N(e,f)),Ce(i)&&(e=we(e,p)),e})(),g=gt[i],_=a??null,v=_?x(s?Date.now():o,_):null,y=v?!v.isDay:!1,b=v?te(h.sky,g.sky,v):y?g.sky:h.sky,S=y?_t(h.cloudColor):h.cloudColor,C=Math.min(n,r)*.09,w=n*.72,T=r*.26;if(v){let e=ee(n,r,v.arcProgress);w=e.x,T=e.y}let D=E(t,r,b),O=[{dx:-.32,dy:.08,r:.17},{dx:.24,dy:-.22,r:.12},{dx:.04,dy:.34,r:.1},{dx:.36,dy:.24,r:.07}],k=xt(h,C),A=St(h,C,O),j=y?A:k,F=y||_!=null?Array.from({length:g.stars},()=>({x:Math.random()*n,y:Math.random()*r*.72,r:.4+Math.random()*1.1,phase:Math.random()*Math.PI*2,speed:.015+Math.random()*.035})):[],I=Array.from({length:h.cloudCount},()=>yt(n,r,h.cloudSpread,S,h.cloudAlpha)),L=h.rain?Array.from({length:h.rain.count},()=>({x:Math.random()*(n+160)-80,y:Math.random()*r,len:8+Math.random()*10,speed:h.rain.speed*(.75+Math.random()*.5)})):[],R=[],z=Array.from({length:h.fogBanks},(e,t)=>({x:Math.random()*n,y:t/Math.max(h.fogBanks-1,1)*r*.9+r*.05,rw:n*(.25+Math.random()*.3),rh:r*(.08+Math.random()*.08),speed:(.1+Math.random()*.25)*(t%2==0?1:-1),alpha:(.1+Math.random()*.1)*(M(i)?P(f):Ce(i)?Te(p):1)})),B=h.fogBanks>0?bt(Ot(i,y)):null,U=h.snowCount>0?Tt():null,W=U==null?[]:Array.from({length:h.snowCount},()=>Dt(n,r,U)),G=V(i)?H(d):null,K=G==null?null:it(),ne=K!=null&&G!=null?Array.from({length:G.count},()=>st(n,r,K,{min:G.sizeMin,max:G.sizeMax},G.speedMul)):[],q=(()=>{let{count:e}=Ge(c.visualLevel);return e<=0?[]:Array.from({length:e},()=>({x:Math.random()*n,y:Math.random()*r,length:35+Math.random()*120,speed:6+Math.random()*10,wave:Math.random()*Math.PI*2,alpha:.1+Math.random()*.28,width:.5+Math.random()*1.1,phase:Math.random()*Math.PI*2}))})(),J=[],Y=120+Math.random()*240;return{sky:b,cloudRgb:S,cfg:h,sunX:w,sunY:T,sunR:C,skyGradient:D,celestial:j,sunSprite:k,moonSprite:A,fogSprite:B,dayCycleTimes:_,dayCycle:v,sceneTimeMs:o,liveClock:s,hailSpec:G,state:{stars:F,moonCraters:O,clouds:I,drops:L,splashes:R,fogBanks:z,flakes:W,hailstones:ne,hailPool:K??[],windStreaks:q,t:0,flashAlpha:0,boltLife:0,boltPoints:J,nextStrike:Y}}}function At(e,t){if(!e.dayCycleTimes)return;let n=x(e.liveClock?t??Date.now():e.sceneTimeMs,e.dayCycleTimes),r=gt[e.activeWeather],i=te(e.cfg.sky,r.sky,n),a=ee(e.width,e.height,n.arcProgress);e.dayCycle=n,e.activeNight=!n.isDay,e.sky=i,e.skyGradient=E(e.ctx,e.height,i),e.sunX=a.x,e.sunY=a.y,e.celestial=n.isDay?e.sunSprite:e.moonSprite}function jt(e,t){t&&(e.state.t+=1),e.windField=$(e.state.t,e.windMotion),e.dayCycleTimes&&At(e,e.liveClock?Date.now():e.sceneTimeMs),dt(e),mt(e),Xe(e),Ze(e),Qe(e),ct(e),lt(e),ut(e),et(e),tt(e)}function Mt(e){let{ctx:t,width:n,height:r,activeWeather:i,activeNight:a,windMotion:o}=e,s=kt(e),c={ctx:t,width:n,height:r,activeWeather:i,activeNight:s.dayCycle?!s.dayCycle.isDay:a,windMotion:o,windField:$(0,o),...s};if(c.dayCycleTimes&&At(c,c.liveClock?Date.now():c.sceneTimeMs),typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return jt(c,!1),()=>void 0;let u=0,d=document.hidden,f=(0,l.bindVisibilityPause)(e=>{d=e}),p=()=>{u=requestAnimationFrame(p),!d&&jt(c,!0)};return p(),()=>{cancelAnimationFrame(u),f()}}var Nt={weatherBackground:`cos-weatherBackground-Mnm22`,canvas:`cos-canvas-nvqMt`,loadingOverlay:`cos-loadingOverlay-O58B7`,loadingSpinner:`cos-loadingSpinner-NQ9yG`,"weather-loading-spin":`cos-weather-loading-spin-IPFWZ`},Pt=({width:e,height:t,fill:n=!1,weather:r=`partlyCloudy`,time:i=`14:00`,live:a=!1,latitude:o,longitude:s,windLevel:d=3,rainLevel:f=5,snowLevel:p=5,hailLevel:m=2,fogLevel:h=2,smogLevel:g=2,onLiveWeather:_,loading:y=!1,ariaLabel:ee,loadingText:S=`天气加载中…`})=>{let{hostRef:C,width:w,height:T,hostStyle:te}=(0,l.useCanvasBox)({fill:n,width:e,height:t,defaultWidth:800,defaultHeight:450}),E=(0,c.useRef)(null),D=Ie(a,o!=null&&s!=null?{latitude:o,longitude:s}:void 0),O=X(a&&D.weather?D.weather:r),k=a&&D.rainLevel!=null?D.rainLevel:f,A=a&&D.snowLevel!=null?D.snowLevel:p,j=a&&D.fogLevel!=null?D.fogLevel:h,M=a&&D.hailLevel!=null?D.hailLevel:m,N=a&&D.smogLevel!=null?D.smogLevel:g,P=he(O,k,A),F=b(i),I=D.current?.sunrise??null,L=D.current?.sunset??null,R=D.current?.windSpeed??null,z=(0,c.useMemo)(()=>a&&I!=null&&L!=null?{sunrise:I,sunset:L}:v(F),[a,I,L,F]),B=Ye({live:a,windLevel:d,liveWindKmh:R}),V=(0,c.useMemo)(()=>Je(B),[B]),H=a&&D.current?!D.current.isDay:!x(F,z).isDay,U=y||a&&(D.status===`locating`||D.status===`fetching`),W=(0,c.useRef)(_);return(0,c.useEffect)(()=>{W.current=_}),(0,c.useEffect)(()=>{D.weather&&W.current?.(X(D.weather))},[D.weather]),(0,c.useEffect)(()=>{let e=E.current;if(!e)return;let t=window.devicePixelRatio||1;e.width=w*t,e.height=T*t;let n=e.getContext(`2d`);if(n)return n.setTransform(t,0,0,t,0,0),Mt({ctx:n,width:w,height:T,activeWeather:P,activeNight:H,dayCycleTimes:z,sceneTimeMs:F,liveClock:a,windMotion:V,rainLevel:k,snowLevel:A,fogLevel:j,hailLevel:M,smogLevel:N})},[H,P,z,k,A,j,M,N,T,a,F,w,V]),(0,u.jsxs)(`div`,{ref:C,className:Nt.weatherBackground,style:te,children:[(0,u.jsx)(`canvas`,{ref:E,className:Nt.canvas,style:{width:w,height:T},role:`img`,"aria-label":ee??`天气背景:${O}${H?`(夜间)`:``},${V.level}级风`}),U&&(0,u.jsxs)(`div`,{className:Nt.loadingOverlay,role:`status`,"aria-live":`polite`,children:[(0,u.jsx)(`div`,{className:Nt.loadingSpinner,"aria-hidden":!0}),(0,u.jsx)(`span`,{children:S})]})]})};exports.DEFAULT_FOG_LEVEL=O,exports.DEFAULT_HAIL_LEVEL=L,exports.DEFAULT_RAIN_LEVEL=K,exports.DEFAULT_SMOG_LEVEL=be,exports.DEFAULT_SNOW_LEVEL=ne,exports.DEFAULT_WIND_LEVEL=ze,exports.FOG_LEVEL_LABELS=k,exports.HAIL_LEVEL_LABELS=R,exports.MAX_PRECIP_LEVEL=G,exports.MIN_PRECIP_LEVEL=W,exports.RAIN_LEVEL_LABELS=se,exports.SMOG_LEVEL_LABELS=xe,exports.SNOW_LEVEL_LABELS=ce,exports.WeatherBackground=Pt,exports.default=Pt,exports.buildWindMotion=Je,exports.clampFogLevel=A,exports.clampHailLevel=z,exports.clampPrecipLevel=q,exports.clampSmogLevel=Q,exports.fogBankAlphaScale=P,exports.fogLevelFromVisibility=I,exports.fogLevelFromWmo=F,exports.formatFogLevel=j,exports.formatHailLevel=B,exports.formatLocalHm=Fe,exports.formatPrecipLevel=oe,exports.formatSmogLevel=Se,exports.hailLevelFromWmo=U,exports.hailSpec=H,exports.intensifyFogConfig=N,exports.intensifyRainConfig=ge,exports.intensifySmogConfig=we,exports.intensifySnowCount=_e,exports.isRainWeather=le,exports.isSnowWeather=ue,exports.kmhToWindLevel=qe,exports.mapWmoCodeToWeatherType=Oe,exports.normalizeWeatherType=X,exports.precipBand=Y,exports.precipLabel=ae,exports.rainLevelFromWeather=pe,exports.rainLevelFromWmo=ve,exports.resolveSceneWeather=he,exports.sampleWindField=$,exports.smogBankAlphaScale=Te,exports.smogLevelFromVisibility=Ee,exports.snowLevelFromWeather=me,exports.snowLevelFromWmo=ye,exports.supportsFogLevel=M,exports.supportsHailLevel=V,exports.supportsRainLevel=de,exports.supportsSmogLevel=Ce,exports.supportsSnowLevel=fe,exports.useLiveWeather=Ie,exports.useSunTimes=Re,exports.visualWindLevel=Ve,exports.windLevelToKmh=Ke,exports.windStreakSpec=Ge;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});require('./index.css');var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("react");c=s(c,1);let l=require("@cos-design/shared"),u=require("react/jsx-runtime");var d=e=>Math.min(1,Math.max(0,e)),f=e=>{let t=e.replace(`#`,``).trim(),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;if(n.length!==6)return[80,140,200];let r=Number.parseInt(n,16);return Number.isNaN(r)?[80,140,200]:[r>>16&255,r>>8&255,r&255]},p=([e,t,n])=>{let r=e=>Math.min(255,Math.max(0,Math.round(e))).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`},m=(e,t,n)=>e+(t-e)*n,h=(e,t,n)=>[m(e[0],t[0],n),m(e[1],t[1],n),m(e[2],t[2],n)],g=(e,t,n)=>p(h(f(e),f(t),d(n))),_=e=>{let t=d(e);return t*t*(3-2*t)},v=(e=Date.now())=>{let t=new Date(e),n=new Date(t);n.setHours(6,0,0,0);let r=new Date(t);return r.setHours(18,0,0,0),{sunrise:n.getTime(),sunset:r.getTime()}},y=(e,t=new Date)=>{let n=e.trim().match(/^(\d{1,2}):(\d{2})$/);if(!n)return null;let r=Number(n[1]),i=Number(n[2]);if(r<0||r>23||i<0||i>59)return null;let a=new Date(t);return a.setHours(r,i,0,0),a.getTime()},b=(e,t=new Date)=>y(e??`14:00`,t)??y(`14:00`,t),x=(e,t)=>{let{sunrise:n,sunset:r}=t;if(!(r>n)){let t=v(e);n=t.sunrise,r=t.sunset}let i=Math.max(1,r-n),a=n+1440*60*1e3,o=r-1440*60*1e3,s=e>=n&&e<r,c;if(s)c=d((e-n)/i);else if(e>=r){let t=Math.max(1,a-r);c=d((e-r)/t)}else{let t=Math.max(1,n-o);c=d((e-o)/t)}let l=s?Math.sin(Math.PI*c):0,u=Math.abs(e-n),f=Math.abs(e-r),p=d(1-Math.min(u,f)/45e5);return{isDay:s,arcProgress:c,elevation:l,twilight:p}},ee=(e,t,n)=>{let r=d(n),i=Math.sin(Math.PI*r);return{x:e*(.1+.8*r),y:t*(.58-.4*i)}},S=`#e8895c`,C=`#f3c98a`,w=`#2a1f4a`,T=`#c4784a`,te=(e,t,n)=>{if(n.isDay){let t=_(n.elevation),r=(1-t)*.72;return[g(g(e[0],S,r),`#1a2438`,(1-t)*.12),g(g(e[1],C,r*.85),`#3a4558`,(1-t)*.08)]}let r=n.twilight;return[g(t[0],g(w,S,.35),r*.55),g(t[1],g(T,C,.4),r*.7)]},E=(e,t,n)=>{let r=e.createLinearGradient(0,0,0,t);return r.addColorStop(0,n[0]),r.addColorStop(1,n[1]),r},D=e=>{if(!e.isDay)return{scale:.92+e.twilight*.06,alpha:.75+e.twilight*.2};let t=e.elevation;return{scale:.82+t*.22,alpha:.65+t*.35}},O=2,k=[``,`薄雾`,`中雾`,`浓雾`],A=e=>Math.min(3,Math.max(1,Math.round(e))),j=e=>{let t=A(e);return`${t} · ${k[t]}`},M=e=>e===`fog`,N=(e,t)=>{let n=A(t);return n===1?{...e,fogBanks:3,haze:.06,cloudAlpha:Math.min(e.cloudAlpha,.28),sun:`soft`}:n===3?{...e,fogBanks:12,haze:.3,cloudAlpha:.42,sun:`dim`}:{...e,fogBanks:5,haze:.11,cloudAlpha:.32,sun:`dim`}},P=e=>{let t=A(e);return t===1?.45:t===3?.95:.65},F=e=>e===45?2:e===48?3:null,I=e=>e==null||!Number.isFinite(e)?null:e>=5e3?1:e>=1e3?2:3,L=2,R=[``,`细雹`,`密雹`,`巨雹`],z=e=>Math.min(3,Math.max(1,Math.round(e))),B=e=>{let t=z(e);return`${t} · ${R[t]}`},V=e=>e===`hail`,H=e=>{let t=z(e);return t===1?{count:75,sizeMin:.85,sizeMax:2.1,speedMul:.88}:t===3?{count:210,sizeMin:2.4,sizeMax:5.6,speedMul:1.22}:{count:145,sizeMin:1.4,sizeMax:3.8,speedMul:1}},U=e=>e===96?2:e===99?3:null,W=1,G=10,K=5,ne=5,q=e=>Math.min(10,Math.max(1,Math.round(e))),J=(e,t,n)=>e+(t-e)*n,Y=e=>{let t=q(e);return t<=2?1:t<=4?2:t<=6?3:t<=8?4:5},re=[`毛毛雨`,`小雨`,`中雨`,`暴雨`,`特大暴雨`],ie=[`毛毛雪`,`小雪`,`中雪`,`暴雪`,`特大暴雪`],ae=(e,t)=>{let n=Y(e);return(t===`rain`?re:ie)[n-1]},oe=(e,t)=>`${q(e)} · ${ae(e,t)}`,se=[``,...re],ce=[``,...ie],X=e=>e===`lightRain`||e===`moderateRain`||e===`heavyRain`?`rain`:e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`?`snow`:e,le=e=>e===`rain`||e===`lightRain`||e===`moderateRain`||e===`heavyRain`,ue=e=>e===`snow`||e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`,de=e=>le(e)||e===`thunderstorm`||e===`sleet`,fe=e=>ue(e)||e===`sleet`,pe=(e,t=5)=>e===`lightRain`?3:e===`moderateRain`?5:e===`heavyRain`?8:q(t),me=(e,t=5)=>e===`lightSnow`?3:e===`moderateSnow`?5:e===`heavySnow`?8:q(t),Z=(e,t)=>t===`rain`?e<=2?`lightRain`:e===3?`moderateRain`:`heavyRain`:e<=2?`lightSnow`:e===3?`moderateSnow`:`heavySnow`,he=(e,t=5,n=5)=>e===`rain`?Z(Y(t),`rain`):e===`lightRain`||e===`moderateRain`||e===`heavyRain`?Z(Y(pe(e)),`rain`):e===`snow`?Z(Y(n),`snow`):e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`?Z(Y(me(e)),`snow`):e,ge=(e,t)=>{let n=(q(t)-1)/9;return{count:Math.round(J(35,340,n)),speed:J(5.5,16,n),wind:J(-.4,-3.2,n),alpha:J(.28,.62,n),splash:q(t)>=5}},_e=e=>{let t=(q(e)-1)/9;return Math.round(J(30,360,t))},ve=e=>[51,56].includes(e)?2:[61,66,80].includes(e)?3:[53,55,57,63,81].includes(e)?5:[65,67].includes(e)?8:[82].includes(e)?10:[95].includes(e)?7:null,ye=e=>[77].includes(e)?2:[71,85].includes(e)?3:[73].includes(e)?5:[75].includes(e)?8:[86].includes(e)?10:null,be=2,xe=[``,`轻霾`,`中霾`,`重霾`],Q=e=>Math.min(3,Math.max(1,Math.round(e))),Se=e=>{let t=Q(e);return`${t} · ${xe[t]}`},Ce=e=>e===`smog`,we=(e,t)=>{let n=Q(t);return n===1?{...e,fogBanks:5,haze:.16,cloudAlpha:Math.min(e.cloudAlpha,.28),sun:`soft`}:n===3?{...e,fogBanks:16,haze:.48,cloudAlpha:.42,sun:`dim`}:{...e,fogBanks:12,haze:.34,cloudAlpha:.35,sun:`dim`}},Te=e=>{let t=Q(e);return t===1?.55:t===3?1.05:.85},Ee=e=>e==null||!Number.isFinite(e)?null:e>=5e3?1:e>=1e3?2:3,De={0:`sunny`,1:`sunny`,2:`partlyCloudy`,3:`overcast`,45:`fog`,48:`fog`,51:`rain`,53:`rain`,55:`rain`,56:`rain`,57:`rain`,61:`rain`,63:`rain`,65:`rain`,66:`rain`,67:`rain`,80:`rain`,81:`rain`,82:`rain`,71:`snow`,73:`snow`,75:`snow`,77:`snow`,85:`snow`,86:`snow`,95:`thunderstorm`,96:`hail`,99:`hail`},Oe=e=>X(De[e]??`overcast`),ke={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`idle`,error:null,current:null},Ae={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`locating`,error:null,current:null},je={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`fetching`,error:null,current:null},Me=e=>e!=null&&Number.isFinite(e.latitude)&&Number.isFinite(e.longitude),Ne=e=>{if(typeof e!=`string`||!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null},Pe=e=>{if(typeof e!=`string`||!e)return null;let t=e.match(/T(\d{2}):(\d{2})/);return t?`${t[1]}:${t[2]}`:null},Fe=(e,t)=>{if(e)try{let t=new Intl.DateTimeFormat(`en-GB`,{timeZone:e,hour:`2-digit`,minute:`2-digit`,hour12:!1}).formatToParts(new Date),n=t.find(e=>e.type===`hour`)?.value,r=t.find(e=>e.type===`minute`)?.value;if(n!=null&&r!=null)return`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`}catch{}return t??null},Ie=(e=!0,t)=>{let n=Me(t),r=n?t.latitude:null,i=n?t.longitude:null,a=e?n?je:Ae:ke,o=`${e}:${r},${i}`,[s,l]=(0,c.useState)(a),[u,d]=(0,c.useState)(o);return u!==o&&(d(o),l(t=>e&&t.weather?{...a,weather:t.weather,current:t.current}:a)),(0,c.useEffect)(()=>{if(!e)return;let t=!1,n=new AbortController,a=async(e,r)=>{try{let i=new URLSearchParams({latitude:String(e),longitude:String(r),current:`weather_code,wind_speed_10m,is_day,visibility`,daily:`sunrise,sunset`,timezone:`auto`,forecast_days:`1`}),a=await fetch(`https://api.open-meteo.com/v1/forecast?${i}`,{signal:n.signal});if(!a.ok)throw Error(`Open-Meteo 请求失败(HTTP ${a.status})`);let o=await a.json(),s=Number(o?.current?.weather_code);if(Number.isNaN(s))throw Error(`Open-Meteo 返回数据缺少 weather_code`);let c=Number(o?.current?.wind_speed_10m??0),u=Ne(o?.daily?.sunrise?.[0]),d=Ne(o?.daily?.sunset?.[0]),f=typeof o?.timezone==`string`?o.timezone:null,p=Pe(o?.current?.time)??Fe(f),m=Oe(s),h=ve(s),g=ye(s),_=o?.current?.visibility,v=_!=null&&Number.isFinite(Number(_))?Number(_):null,y=m===`fog`?I(v)??F(s)??2:null,b=m===`hail`?U(s)??2:null,x=m===`smog`?Ee(v)??2:null;if(t)return;l({weather:m,rainLevel:h,snowLevel:g,fogLevel:y,hailLevel:b,smogLevel:x,status:`success`,error:null,current:{weatherCode:s,windSpeed:c,isDay:o?.current?.is_day===1,latitude:e,longitude:r,timezone:f,localTime:p,visibility:v,rainLevel:h,snowLevel:g,fogLevel:y,hailLevel:b,smogLevel:x,sunrise:u,sunset:d}})}catch(e){if(t||e instanceof DOMException&&e.name===`AbortError`)return;l({weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`error`,error:e instanceof Error?e.message:`天气获取失败`,current:null})}};return r!=null&&i!=null?(a(r,i),()=>{t=!0,n.abort()}):typeof navigator>`u`||!navigator.geolocation?(Promise.resolve().then(()=>{t||l({weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`error`,error:`当前环境不支持定位`,current:null})}),()=>{t=!0}):(navigator.geolocation.getCurrentPosition(({coords:e})=>{t||(l(e=>({...e,status:`fetching`})),a(e.latitude,e.longitude))},e=>{t||l({weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`error`,error:e.message||`定位失败`,current:null})},{timeout:1e4,maximumAge:600*1e3}),()=>{t=!0,n.abort()})},[e,r,i]),s},Le=async(e,t,n)=>{let r=new URLSearchParams({latitude:String(e),longitude:String(t),daily:`sunrise,sunset`,timezone:`auto`,forecast_days:`1`}),i=await fetch(`https://api.open-meteo.com/v1/forecast?${r}`,{signal:n});if(!i.ok)return null;let a=await i.json(),o=Ne(a?.daily?.sunrise?.[0]),s=Ne(a?.daily?.sunset?.[0]);return o==null||s==null?null:{sunrise:o,sunset:s}},Re=e=>{let t=Me(e),n=t?e.latitude:null,r=t?e.longitude:null,i=`${n},${r}`,[a,o]=(0,c.useState)(null),[s,l]=(0,c.useState)(i);return s!==i&&(l(i),o(null)),(0,c.useEffect)(()=>{if(n==null||r==null)return;let e=!1,t=new AbortController;return Le(n,r,t.signal).then(t=>{e||o(t)}).catch(()=>{e||o(null)}),()=>{e=!0,t.abort()}},[n,r]),t?a:null},ze=3,Be=e=>Math.min(12,Math.max(0,Math.round(e))),Ve=e=>Math.max(0,Be(e)-2),He=.55,Ue=[0,3,8,16,24,33,44,55,68,81,95,110,125],We=[1,5,11,19,28,38,49,61,74,88,102,117,1/0],$=(e,t,n=0,r=0)=>{let i=t.gustiness,a=t.wander,o=n*.0017+r*.0024,s=e*He,c=Math.sin(s*.007+o),l=Math.sin(s*.021+1.37+o*1.4),u=Math.sin(s*.055+2.8+o*.6),d=1+(.5*c+.35*l+.15*u)*(.25+i*.75),f=Math.sin(s*.012+o*.8);f>.72&&(d+=(f-.72)*(.8+i*2.4)),Math.sin(s*.0095+.6+o)<-.55&&(d*=.45+i*.2),d=Math.max(.12,Math.min(2.25,d));let p=a*(.55*Math.sin(s*.0088+o)+.3*Math.sin(s*.026+1.9+o*1.1)+.15*Math.sin(s*.063+.4));return{intensity:d,angle:p,ux:Math.cos(p),uy:Math.sin(p)}},Ge=e=>{let t=Be(e);if(t<=0)return{count:0,alphaMul:0};let n=Math.min(1,(t/9)**1.15);return{count:Math.floor(3+n*n*50),alphaMul:.1+n*.9}},Ke=e=>Ue[Be(e)]??16,qe=e=>{let t=Math.max(0,e);for(let e=0;e<We.length;e++)if(t<=We[e])return e;return 12},Je=e=>{let t=qe(e),n=Ve(t),r=Ke(n),i=Math.max(.04,Math.min(r/16,4.2)),{alphaMul:a}=Ge(n),o=i**.82,s=Math.min(1,(n/8)**1.1),c=(.04+s*.32)*Math.PI;return{speedKmh:e,level:t,visualLevel:n,scale:i,cloud:.28+i*.72,rain:o,snowDrift:-(.04+o*.28),hail:.4+o*.85,fog:.32+o*.58,streak:.55+o*.95,streakVisibility:a,gustiness:s,wander:c}},Ye=e=>e.live&&e.liveWindKmh!=null&&Number.isFinite(e.liveWindKmh)?Math.max(0,e.liveWindKmh):Ke(e.windLevel);function Xe(e){let t=e.windMotion.cloud,{intensity:n,angle:r,uy:i}=e.windField,a=-Math.cos(r);for(let r of e.state.clouds){let o=Math.abs(r.speed)*t*n;r.x+=o*a,r.y+=o*i*.12,r.y<-80&&(r.y=-80),r.y>e.height*.55&&(r.y=e.height*.55),r.x-140*r.scale>e.width&&(r.x=-160*r.scale),r.x+180*r.scale<0&&(r.x=e.width+40*r.scale),e.ctx.drawImage(r.sprite,r.x+r.ox,r.y+r.oy)}}function Ze(e){let t=e.fogSprite;if(!t||e.state.fogBanks.length===0)return;let{canvas:n,baseR:r}=t,i=e.windMotion.fog,{intensity:a,angle:o,uy:s}=e.windField,c=-Math.cos(o);for(let t of e.state.fogBanks){let o=Math.abs(t.speed)*i*a;t.x+=o*c,t.y+=o*s*.1,t.y<e.height*.02&&(t.y=e.height*.02),t.y>e.height*.95&&(t.y=e.height*.95),c<0&&t.x+t.rw<0&&(t.x=e.width+t.rw),c>0&&t.x-t.rw>e.width&&(t.x=-t.rw),e.ctx.save(),e.ctx.translate(t.x,t.y),e.ctx.scale(t.rw/r,t.rh/r),e.ctx.globalAlpha=t.alpha,e.ctx.drawImage(n,-r,-r),e.ctx.restore()}}function Qe(e){if(e.cfg.haze<=0)return;let t=e.activeWeather===`smog`?`177, 164, 135`:`220, 226, 232`;e.activeNight&&(t=e.activeWeather===`smog`?`82, 74, 54`:`116, 128, 145`),e.ctx.fillStyle=`rgba(${t}, ${e.cfg.haze})`,e.ctx.fillRect(0,0,e.width,e.height)}function $e(e,t,n,r,i,a){if(a<=0)return[[e,t],[n,r]];let o=(e+n)/2+(Math.random()-.5)*i,s=(t+r)/2,c=$e(e,t,o,s,i*.55,a-1),l=$e(o,s,n,r,i*.55,a-1);return[...c.slice(0,-1),...l]}function et(e){if(e.state.windStreaks.length===0)return;let t=e.windMotion.streak,n=e.windMotion.streakVisibility;if(n<=.02)return;let r=e.state.t;for(let i of e.state.windStreaks){let a=$(r+i.phase*18,e.windMotion,i.x,i.y),o=a.intensity*(.55+.45*e.windField.intensity),s=a.angle*.65+e.windField.angle*.35,c=-1*Math.cos(s),l=Math.sin(s),u=i.speed*t*o;i.x+=u*c,i.y+=u*l*.45,i.wave+=.03+o*.025,(i.x<-i.length-40||i.x>e.width+i.length+40)&&(i.x=c<0?e.width+i.length+Math.random()*e.width*.25:-i.length-Math.random()*e.width*.25,i.y=Math.random()*e.height),i.y<-20&&(i.y=e.height+10),i.y>e.height+20&&(i.y=-10);let d=5+o*5,f=Math.sin(i.wave)*d,p=i.length*(.85+o*.2),m=i.x+c*p,h=i.y+l*p*.45,g=i.alpha*n*Math.min(1.35,.55+o*.55);if(e.ctx.beginPath(),e.ctx.moveTo(i.x,i.y),e.ctx.bezierCurveTo(i.x+c*p*.3,i.y+l*p*.3*.45+f,i.x+c*p*.7,i.y+l*p*.7*.45-f,m,h),e.ctx.strokeStyle=`rgba(235, 244, 250, ${g})`,e.ctx.lineWidth=i.width*(.85+o*.2),e.ctx.lineCap=`round`,e.ctx.stroke(),i.length>70&&n>.45&&o>.7){let t=i.x+c*p*.58,n=i.y+l*p*.58*.45-f*.4;e.ctx.save(),e.ctx.translate(t,n),e.ctx.rotate(s+i.wave*2),e.ctx.beginPath(),e.ctx.ellipse(0,0,4,1.6,0,0,Math.PI*2),e.ctx.fillStyle=`rgba(91, 76, 52, ${g*1.4})`,e.ctx.fill(),e.ctx.restore()}}}function tt(e){if(e.cfg.lightning){if(e.state.t>=e.state.nextStrike){e.state.nextStrike=e.state.t+150+Math.random()*300,e.state.flashAlpha=.5,e.state.boltLife=9;let t=e.width*(.15+Math.random()*.7);e.state.boltPoints=$e(t,e.height*.12,t+(Math.random()-.5)*e.width*.2,e.height*.92,60,6)}if(e.state.boltLife>0){--e.state.boltLife;let t=e.state.boltLife/9;e.ctx.beginPath(),e.state.boltPoints.forEach(([t,n],r)=>r===0?e.ctx.moveTo(t,n):e.ctx.lineTo(t,n)),e.ctx.strokeStyle=`rgba(240, 246, 255, ${t})`,e.ctx.lineWidth=2.4,e.ctx.shadowColor=`#bcd7ff`,e.ctx.shadowBlur=16,e.ctx.stroke(),e.ctx.shadowBlur=0}e.state.flashAlpha>.01&&(e.ctx.fillStyle=`rgba(226, 236, 255, ${e.state.flashAlpha})`,e.ctx.fillRect(0,0,e.width,e.height),e.state.flashAlpha*=.82)}}var nt=3.2,rt=e=>{let t=Math.ceil(e*2.8+4),n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=t/2,a=t/2,o=9+Math.floor(Math.random()*5),s=Array.from({length:o},(t,n)=>{let r=n/o*Math.PI*2+(Math.random()-.5)*.22,s=e*(.72+Math.random()*.44);return{x:i+Math.cos(r)*s,y:a+Math.sin(r)*s}}),c=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});r.beginPath();let l=c(s[s.length-1],s[0]);r.moveTo(l.x,l.y);for(let e=0;e<s.length;e++){let t=c(s[e],s[(e+1)%s.length]);r.quadraticCurveTo(s[e].x,s[e].y,t.x,t.y)}r.closePath();let u=i-e*.3,d=a-e*.34,f=r.createRadialGradient(u,d,e*.06,i,a,e*1.2);f.addColorStop(0,`rgba(255, 255, 255, 0.98)`),f.addColorStop(.42,`rgba(228, 241, 252, 0.96)`),f.addColorStop(.82,`rgba(176, 203, 224, 0.93)`),f.addColorStop(1,`rgba(130, 162, 188, 0.9)`),r.fillStyle=f,r.fill(),r.strokeStyle=`rgba(155, 190, 215, 0.62)`,r.lineWidth=Math.max(.45,e*.11),r.stroke();let p=1+Math.floor(Math.random()*2);for(let t=0;t<p;t++){let t=Math.random()*Math.PI*2,n=i+Math.cos(t)*e*(.28+Math.random()*.35),o=a+Math.sin(t)*e*(.28+Math.random()*.35);r.beginPath(),r.ellipse(n,o,e*(.14+Math.random()*.1),e*(.1+Math.random()*.08),t,0,Math.PI*2),r.fillStyle=`rgba(105, 135, 165, 0.28)`,r.fill()}if(Math.random()<.75){let t=Math.random()*Math.PI*2,n=i+Math.cos(t)*e*(.38+Math.random()*.28),o=a+Math.sin(t)*e*(.38+Math.random()*.28);r.beginPath(),r.arc(n,o,e*(.1+Math.random()*.08),0,Math.PI*2),r.fillStyle=`rgba(255, 255, 255, 0.55)`,r.fill()}return r.beginPath(),r.ellipse(i-e*.34,a-e*.36,e*.24,e*.17,-.35,0,Math.PI*2),r.fillStyle=`rgba(255, 255, 255, 0.78)`,r.fill(),n},it=(e=16)=>Array.from({length:e},()=>rt(nt)),at=e=>e[Math.floor(Math.random()*e.length)],ot=(e,t,n,r,i=!0,a,o=1)=>{let s=a?.min??1.4,c=a?.max??4.8;e.r=s+Math.random()**1.35*(c-s),e.x=Math.random()*(t+260)-130+(Math.random()-.5)*40,e.y=i?-e.r-Math.random()*n*.55:Math.random()*n,e.vx=(-1.2-Math.random()*4.8+(Math.random()-.5)*1.2)*o,e.vy=(5.5+Math.random()*11)*o,e.bounces=0,e.opacity=.45+Math.random()*.55,e.delay=Math.floor(Math.random()*(i?110:45)),e.gravity=(.11+Math.random()*.14)*(.9+o*.1),e.phase=Math.random()*Math.PI*2,e.gust=(Math.random()-.5)*1.4,e.maxBounces=+(Math.random()<.62),e.sprite=at(r),e.drawSize=e.r*2.8+4,e.rotation=Math.random()*Math.PI*2,e.rotationSpeed=(Math.random()-.5)*.06},st=(e,t,n,r,i=1)=>{let a={x:0,y:0,r:2,vx:0,vy:0,bounces:0,opacity:1,delay:0,gravity:.16,phase:0,gust:0,maxBounces:1,sprite:n[0],drawSize:9.6,rotation:0,rotationSpeed:0};return ot(a,e,t,n,Math.random()<.72,r,i),a};function ct(e){if(!e.cfg.rain)return;let{alpha:t,splash:n}=e.cfg.rain,r=e.cfg.rain.wind*e.windMotion.rain,{intensity:i,angle:a,uy:o}=e.windField,s=r*i*Math.cos(a),c=Math.abs(r)*i*o*.35;e.ctx.strokeStyle=`rgba(214, 228, 240, ${t})`,e.ctx.lineWidth=1.2,e.ctx.beginPath();for(let t of e.state.drops){let r=t.speed+c,i=Math.hypot(s,r)||1,a=s/i,o=r/i;e.ctx.moveTo(t.x,t.y),e.ctx.lineTo(t.x+a*t.len,t.y+o*t.len),t.x+=s,t.y+=r,t.y>e.height&&(n&&Math.random()<.3&&e.state.splashes.length<60&&e.state.splashes.push({x:t.x,r:1,alpha:.5}),t.y=-t.len,t.x=Math.random()*(e.width+160)-80)}e.ctx.stroke();for(let t=e.state.splashes.length-1;t>=0;t--){let n=e.state.splashes[t];if(n.r+=.8,n.alpha-=.035,n.alpha<=0){e.state.splashes.splice(t,1);continue}e.ctx.beginPath(),e.ctx.ellipse(n.x,e.height-3,n.r,n.r*.35,0,Math.PI,Math.PI*2),e.ctx.strokeStyle=`rgba(214, 228, 240, ${n.alpha})`,e.ctx.lineWidth=1,e.ctx.stroke()}}function lt(e){let t=e.windMotion.snowDrift,{intensity:n,angle:r,uy:i}=e.windField,a=t*n*Math.cos(r),o=Math.abs(t)*n*i*.4;for(let t of e.state.flakes){t.y+=t.speed+o,t.x+=Math.sin(e.state.t*.02+t.phase)*(.3+t.size*.08)+t.drift+a,t.rotation+=t.rotationSpeed,t.y-t.drawSize>e.height&&(t.y=-t.drawSize,t.x=Math.random()*e.width,t.phase=Math.random()*Math.PI*2,t.drift=(Math.random()-.5)*.4,t.opacity=.55+Math.random()*.45),t.x>e.width+20&&(t.x=-20),t.x<-20&&(t.x=e.width+20);let n=t.drawSize/2;e.ctx.save(),e.ctx.globalAlpha=t.opacity,e.ctx.translate(t.x,t.y),e.ctx.rotate(t.rotation),e.ctx.drawImage(t.sprite,-n,-n,t.drawSize,t.drawSize),e.ctx.restore()}}function ut(e){if(e.state.hailstones.length===0)return;let t=e.state.hailPool,n=e.windMotion.hail,r=e.state.t,i=e.windField;for(let a of e.state.hailstones){if(a.delay>0){--a.delay;continue}let o=$(r+a.phase*12,e.windMotion,a.x,a.y),s=o.intensity*(.4+.6*i.intensity),c=o.angle*.5+i.angle*.5,l=e.windMotion.snowDrift*.45*s*Math.cos(c),u=Math.abs(e.windMotion.snowDrift)*s*Math.sin(c)*.2,d=a.x,f=a.y;if(a.vy+=a.gravity+u*.02,a.vx+=a.gust*.004*n*s+l+(Math.random()-.5)*.08*n*s,a.x+=a.vx+Math.sin(r*.028+a.phase)*.35,a.y+=a.vy,e.ctx.beginPath(),e.ctx.moveTo(d,f),e.ctx.lineTo(a.x,a.y),e.ctx.strokeStyle=`rgba(225, 239, 250, ${a.opacity*.18})`,e.ctx.lineWidth=a.r*.35,e.ctx.stroke(),a.y+a.r>=e.height)if(a.bounces<a.maxBounces)a.y=e.height-a.r,a.vy*=-(.22+Math.random()*.28),a.vx=a.vx*(.55+Math.random()*.25)+(Math.random()-.5)*1.6,a.bounces+=1;else{ot(a,e.width,e.height,t,!0,e.hailSpec?{min:e.hailSpec.sizeMin,max:e.hailSpec.sizeMax}:void 0,e.hailSpec?.speedMul??1);continue}let p=a.drawSize/2;a.rotation+=a.rotationSpeed,e.ctx.save(),e.ctx.globalAlpha=a.opacity,e.ctx.translate(a.x,a.y),e.ctx.rotate(a.rotation),e.ctx.drawImage(a.sprite,-p,-p,a.drawSize,a.drawSize),e.ctx.restore()}}function dt(e){e.ctx.fillStyle=e.skyGradient,e.ctx.fillRect(0,0,e.width,e.height)}function ft(e){if(e.state.stars.length===0)return;let t=1;if(e.dayCycle){if(e.dayCycle.isDay)return;t=.35+(1-e.dayCycle.twilight)*.65}else if(!e.activeNight)return;for(let n of e.state.stars){let r=.35+(Math.sin(e.state.t*n.speed+n.phase)+1)*.325;e.ctx.beginPath(),e.ctx.arc(n.x,n.y,n.r,0,Math.PI*2),e.ctx.fillStyle=`rgba(226, 235, 255, ${r*t})`,e.ctx.fill()}}function pt(e){let t=e.celestial;if(!t)return;let{ctx:n,sunX:r,sunY:i,state:a}=e,o=1+Math.sin(a.t*t.breathSpeed)*t.breathAmp,s=e.dayCycle?D(e.dayCycle):{scale:1,alpha:1},c=t.half*o*s.scale,l=c*2;n.save(),n.globalAlpha=s.alpha,n.drawImage(t.canvas,r-c,i-c,l,l),n.restore()}function mt(e){if(e.activeNight){ft(e),pt(e);return}pt(e)}var ht={sunny:{sky:[`#4a9fe0`,`#c8e8fb`],sun:`full`,cloudCount:1,cloudColor:[255,255,255],cloudAlpha:.5,cloudSpread:.12,rain:null,fogBanks:0,haze:0,snowCount:0,lightning:!1},partlyCloudy:{sky:[`#5b9bd0`,`#cfe6f3`],sun:`soft`,cloudCount:5,cloudColor:[255,255,255],cloudAlpha:.85,cloudSpread:.22,rain:null,fogBanks:0,haze:0,snowCount:0,lightning:!1},overcast:{sky:[`#8a97a8`,`#c3cbd6`],sun:`none`,cloudCount:9,cloudColor:[100,116,139],cloudAlpha:.55,cloudSpread:.3,rain:null,fogBanks:0,haze:.06,snowCount:0,lightning:!1},rain:{sky:[`#55637a`,`#7e8ba0`],sun:`none`,cloudCount:8,cloudColor:[51,65,85],cloudAlpha:.65,cloudSpread:.26,rain:{count:150,speed:10,wind:-1.5,alpha:.5,splash:!0},fogBanks:0,haze:.06,snowCount:0,lightning:!1},lightRain:{sky:[`#6b7a8f`,`#9aa7b8`],sun:`none`,cloudCount:7,cloudColor:[71,85,105],cloudAlpha:.6,cloudSpread:.24,rain:{count:70,speed:7,wind:-.8,alpha:.4,splash:!1},fogBanks:0,haze:.04,snowCount:0,lightning:!1},moderateRain:{sky:[`#55637a`,`#7e8ba0`],sun:`none`,cloudCount:8,cloudColor:[51,65,85],cloudAlpha:.65,cloudSpread:.26,rain:{count:150,speed:10,wind:-1.5,alpha:.5,splash:!0},fogBanks:0,haze:.06,snowCount:0,lightning:!1},heavyRain:{sky:[`#3d4a5f`,`#5d6a80`],sun:`none`,cloudCount:9,cloudColor:[30,41,59],cloudAlpha:.7,cloudSpread:.3,rain:{count:280,speed:14,wind:-2.8,alpha:.55,splash:!0},fogBanks:0,haze:.1,snowCount:0,lightning:!1},thunderstorm:{sky:[`#252f42`,`#43506a`],sun:`none`,cloudCount:10,cloudColor:[15,23,42],cloudAlpha:.75,cloudSpread:.32,rain:{count:240,speed:13,wind:-2.2,alpha:.55,splash:!0},fogBanks:0,haze:.08,snowCount:0,lightning:!0},fog:{sky:[`#aab4bf`,`#d5dbe1`],sun:`dim`,cloudCount:3,cloudColor:[203,213,225],cloudAlpha:.4,cloudSpread:.2,rain:null,fogBanks:10,haze:.28,snowCount:0,lightning:!1},lightSnow:{sky:[`#aab8c8`,`#e2e8ef`],sun:`none`,cloudCount:5,cloudColor:[166,180,196],cloudAlpha:.45,cloudSpread:.22,rain:null,fogBanks:0,haze:.05,snowCount:70,lightning:!1},moderateSnow:{sky:[`#9fb0c4`,`#dde5ee`],sun:`none`,cloudCount:6,cloudColor:[148,163,184],cloudAlpha:.5,cloudSpread:.24,rain:null,fogBanks:0,haze:.08,snowCount:160,lightning:!1},heavySnow:{sky:[`#8495aa`,`#c7d1dc`],sun:`none`,cloudCount:9,cloudColor:[100,116,139],cloudAlpha:.62,cloudSpread:.3,rain:null,fogBanks:3,haze:.14,snowCount:300,lightning:!1},sleet:{sky:[`#78899e`,`#b8c5d2`],sun:`none`,cloudCount:8,cloudColor:[71,85,105],cloudAlpha:.6,cloudSpread:.28,rain:{count:100,speed:9,wind:-1.4,alpha:.42,splash:!0},fogBanks:0,haze:.09,snowCount:100,lightning:!1},hail:{sky:[`#46566c`,`#77889d`],sun:`none`,cloudCount:9,cloudColor:[30,41,59],cloudAlpha:.68,cloudSpread:.3,rain:{count:80,speed:11,wind:-2.5,alpha:.38,splash:!0},fogBanks:0,haze:.1,snowCount:0,lightning:!1},smog:{sky:[`#8f8b7e`,`#c5bca8`],sun:`dim`,cloudCount:3,cloudColor:[142,136,119],cloudAlpha:.35,cloudSpread:.2,rain:null,fogBanks:12,haze:.34,snowCount:0,lightning:!1},gale:{sky:[`#587087`,`#a6b5c2`],sun:`soft`,cloudCount:8,cloudColor:[203,213,225],cloudAlpha:.72,cloudSpread:.3,rain:null,fogBanks:0,haze:.04,snowCount:0,lightning:!1},snow:{sky:[`#9fb0c4`,`#dde5ee`],sun:`none`,cloudCount:6,cloudColor:[148,163,184],cloudAlpha:.5,cloudSpread:.24,rain:null,fogBanks:0,haze:.08,snowCount:160,lightning:!1}},gt={sunny:{sky:[`#0b1a33`,`#27476e`],stars:110},partlyCloudy:{sky:[`#0f1f38`,`#2c4666`],stars:60},overcast:{sky:[`#181f2a`,`#333e4e`],stars:0},rain:{sky:[`#11161f`,`#242c3a`],stars:0},lightRain:{sky:[`#151b26`,`#2b3442`],stars:0},moderateRain:{sky:[`#11161f`,`#242c3a`],stars:0},heavyRain:{sky:[`#0c1017`,`#1c232e`],stars:0},thunderstorm:{sky:[`#0a0e18`,`#192132`],stars:0},fog:{sky:[`#1c222b`,`#3a434e`],stars:0},snow:{sky:[`#131a26`,`#333f4f`],stars:8},lightSnow:{sky:[`#161e2b`,`#3a4656`],stars:20},moderateSnow:{sky:[`#131a26`,`#333f4f`],stars:8},heavySnow:{sky:[`#101623`,`#2a3545`],stars:0},sleet:{sky:[`#121924`,`#2c3745`],stars:0},hail:{sky:[`#0e141d`,`#26303e`],stars:0},smog:{sky:[`#1a1812`,`#38321f`],stars:0},gale:{sky:[`#101a26`,`#2e3d4d`],stars:30}},_t=([e,t,n])=>[Math.round(e*.3+18),Math.round(t*.3+24),Math.round(n*.3+42)];function vt(e,t,n,r){let[i,a,o]=n,s=1/0,c=1/0,l=-1/0,u=-1/0;for(let n of t){let t=n.dx*e,r=n.dy*e,i=n.r*e;s=Math.min(s,t-i),c=Math.min(c,r-i),l=Math.max(l,t+i),u=Math.max(u,r+i)}let d=Math.floor(s-2),f=Math.floor(c-2),p=Math.ceil(l+2)-d,m=Math.ceil(u+2)-f,h=document.createElement(`canvas`);h.width=p,h.height=m;let g=h.getContext(`2d`);for(let n of t){let t=n.dx*e-d,s=n.dy*e-f,c=n.r*e,l=g.createRadialGradient(t,s,0,t,s,c);l.addColorStop(0,`rgba(${i}, ${a}, ${o}, ${r})`),l.addColorStop(1,`rgba(${i}, ${a}, ${o}, 0)`),g.beginPath(),g.arc(t,s,c,0,Math.PI*2),g.fillStyle=l,g.fill()}return{sprite:h,ox:d,oy:f}}function yt(e,t,n,r,i){let a=.7+Math.random()*.9,o=4+Math.floor(Math.random()*3),s=Array.from({length:o},(e,t)=>({dx:(t-o/2)*26+(Math.random()-.5)*14,dy:(Math.random()-.5)*14,r:22+Math.random()*20})),{sprite:c,ox:l,oy:u}=vt(a,s,r,i);return{x:Math.random()*(e+240)-120,y:t*.06+Math.random()*t*n,scale:a,speed:.12+Math.random()*.22,puffs:s,sprite:c,ox:l,oy:u}}function bt(e,t=120){let n=t*2,r=document.createElement(`canvas`);r.width=n,r.height=n;let i=r.getContext(`2d`),a=i.createRadialGradient(t,t,0,t,t,t);return a.addColorStop(0,`rgba(${e}, 1)`),a.addColorStop(1,`rgba(${e}, 0)`),i.fillStyle=a,i.beginPath(),i.arc(t,t,t,0,Math.PI*2),i.fill(),{canvas:r,baseR:t}}function xt(e,t){let n=e.sun;if(n===`none`)return null;let r=n===`full`?1:n===`soft`?.62:.32,i=t*(n===`full`?.72:n===`soft`?.62:.5),a=t*(n===`full`?7.2:n===`soft`?5.2:3.6),o=a;n===`full`&&(o=Math.max(o,1.55*t*5.5)),o=Math.ceil(o+2);let s=o*2,c=document.createElement(`canvas`);c.width=s,c.height=s;let l=c.getContext(`2d`),u=o,d=o;l.save(),l.globalCompositeOperation=`lighter`;let f=l.createRadialGradient(u,d,0,u,d,a);f.addColorStop(0,`rgba(255, 230, 170, ${.14*r})`),f.addColorStop(.22,`rgba(255, 210, 140, ${.07*r})`),f.addColorStop(.5,`rgba(255, 195, 120, ${.03*r})`),f.addColorStop(1,`rgba(255, 200, 130, 0)`),l.fillStyle=f,l.fillRect(0,0,s,s);let p=t*(n===`full`?3.4:2.6),m=l.createRadialGradient(u,d,i*.15,u,d,p);if(m.addColorStop(0,`rgba(255, 240, 200, ${.32*r})`),m.addColorStop(.4,`rgba(255, 220, 150, ${.16*r})`),m.addColorStop(.75,`rgba(255, 200, 120, ${.05*r})`),m.addColorStop(1,`rgba(255, 190, 110, 0)`),l.fillStyle=m,l.beginPath(),l.arc(u,d,p,0,Math.PI*2),l.fill(),n===`full`){l.translate(u,d),l.scale(1.55,.55);let e=l.createRadialGradient(0,0,0,0,0,t*5.5);e.addColorStop(0,`rgba(255, 225, 170, 0.08)`),e.addColorStop(.5,`rgba(255, 205, 140, 0.03)`),e.addColorStop(1,`rgba(255, 195, 130, 0)`),l.fillStyle=e,l.beginPath(),l.arc(0,0,t*5.5,0,Math.PI*2),l.fill()}l.restore();let h=i*2.05,g=l.createRadialGradient(u,d,0,u,d,h);g.addColorStop(0,`rgba(255, 245, 210, ${.7*r})`),g.addColorStop(.4,`rgba(255, 230, 170, ${.35*r})`),g.addColorStop(.75,`rgba(255, 210, 140, ${.1*r})`),g.addColorStop(1,`rgba(255, 200, 130, 0)`),l.fillStyle=g,l.beginPath(),l.arc(u,d,h,0,Math.PI*2),l.fill();let _=l.createRadialGradient(u,d,0,u,d,i);return n===`dim`?(_.addColorStop(0,`rgba(255, 240, 210, ${.5*r})`),_.addColorStop(.55,`rgba(255, 220, 170, ${.3*r})`),_.addColorStop(1,`rgba(255, 200, 140, 0)`)):(_.addColorStop(0,`rgba(255, 250, 230, ${.98*r})`),_.addColorStop(.4,`rgba(255, 240, 195, ${.92*r})`),_.addColorStop(.75,`rgba(255, 220, 150, ${.55*r})`),_.addColorStop(1,`rgba(255, 205, 130, 0)`)),l.fillStyle=_,l.beginPath(),l.arc(u,d,i,0,Math.PI*2),l.fill(),{canvas:c,half:o,breathSpeed:.018,breathAmp:.018}}function St(e,t,n){if(e.sun===`none`)return null;let r=t*.82,i=e.sun===`dim`,a=i?.45:1,o=r*(i?4.2:6.2),s=Math.ceil(Math.max(o,r*2.6,r*1.35)+2),c=s*2,l=document.createElement(`canvas`);l.width=c,l.height=c;let u=l.getContext(`2d`),d=s,f=s;u.save(),u.globalCompositeOperation=`lighter`;let p=u.createRadialGradient(d,f,0,d,f,o);p.addColorStop(0,`rgba(200, 215, 240, ${.16*a})`),p.addColorStop(.25,`rgba(170, 190, 225, ${.07*a})`),p.addColorStop(.55,`rgba(140, 165, 210, ${.025*a})`),p.addColorStop(1,`rgba(130, 155, 200, 0)`),u.fillStyle=p,u.fillRect(0,0,c,c);let m=r*2.6,h=u.createRadialGradient(d,f,r*.2,d,f,m);h.addColorStop(0,`rgba(230, 236, 248, ${.28*a})`),h.addColorStop(.45,`rgba(190, 205, 230, ${.12*a})`),h.addColorStop(1,`rgba(160, 180, 220, 0)`),u.fillStyle=h,u.beginPath(),u.arc(d,f,m,0,Math.PI*2),u.fill(),u.restore();let g=u.createRadialGradient(d-r*.28,f-r*.3,0,d,f,r);g.addColorStop(0,`rgba(236, 240, 246, ${.96*a})`),g.addColorStop(.45,`rgba(214, 220, 230, ${.94*a})`),g.addColorStop(.82,`rgba(186, 196, 212, ${.9*a})`),g.addColorStop(1,`rgba(160, 172, 192, ${.75*a})`),u.beginPath(),u.arc(d,f,r,0,Math.PI*2),u.fillStyle=g,u.fill(),u.save(),u.beginPath(),u.arc(d,f,r*.98,0,Math.PI*2),u.clip();for(let e of[{dx:-.18,dy:.12,rx:.38,ry:.28,a:.14},{dx:.22,dy:-.08,rx:.26,ry:.2,a:.11},{dx:.05,dy:.32,rx:.2,ry:.14,a:.09}]){let t=d+e.dx*r,n=f+e.dy*r,i=u.createRadialGradient(t,n,0,t,n,e.rx*r);i.addColorStop(0,`rgba(140, 152, 170, ${e.a*a})`),i.addColorStop(.65,`rgba(150, 162, 178, ${e.a*.45*a})`),i.addColorStop(1,`rgba(160, 170, 185, 0)`),u.fillStyle=i,u.beginPath(),u.ellipse(t,n,e.rx*r,e.ry*r,.35,0,Math.PI*2),u.fill()}for(let e of n){let t=d+e.dx*r,n=f+e.dy*r,i=e.r*r,o=u.createRadialGradient(t-i*.25,n-i*.3,0,t,n,i);o.addColorStop(0,`rgba(155, 168, 186, ${.22*a})`),o.addColorStop(.55,`rgba(145, 158, 176, ${.28*a})`),o.addColorStop(.85,`rgba(200, 210, 224, ${.12*a})`),o.addColorStop(1,`rgba(210, 218, 230, 0)`),u.fillStyle=o,u.beginPath(),u.arc(t,n,i,0,Math.PI*2),u.fill()}let _=u.createRadialGradient(d-r*.35,f-r*.38,0,d-r*.1,f-r*.1,r*.7);_.addColorStop(0,`rgba(255, 255, 255, ${.28*a})`),_.addColorStop(.45,`rgba(245, 248, 252, ${.08*a})`),_.addColorStop(1,`rgba(240, 244, 250, 0)`),u.fillStyle=_,u.beginPath(),u.arc(d,f,r,0,Math.PI*2),u.fill(),u.restore();let v=u.createRadialGradient(d,f,r*.72,d,f,r*1.35);return v.addColorStop(0,`rgba(210, 220, 235, 0)`),v.addColorStop(.55,`rgba(200, 212, 232, ${.1*a})`),v.addColorStop(1,`rgba(180, 195, 220, 0)`),u.fillStyle=v,u.beginPath(),u.arc(d,f,r*1.35,0,Math.PI*2),u.fill(),{canvas:l,half:s,breathSpeed:.012,breathAmp:.012}}var Ct=e=>{let t=Math.ceil(e*2+4),n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`),i=r.createRadialGradient(t/2,t/2,0,t/2,t/2,e+1);return i.addColorStop(0,`rgba(255, 255, 255, 1)`),i.addColorStop(.6,`rgba(255, 255, 255, 0.85)`),i.addColorStop(1,`rgba(255, 255, 255, 0)`),r.fillStyle=i,r.fillRect(0,0,t,t),n},wt=e=>{let t=Math.ceil(e*2+6),n=document.createElement(`canvas`);n.width=t,n.height=t;let r=n.getContext(`2d`);r.translate(t/2,t/2),r.strokeStyle=`rgba(255, 255, 255, 0.95)`,r.lineCap=`round`,r.lineWidth=Math.max(e*.11,.7),r.shadowColor=`rgba(255, 255, 255, 0.5)`,r.shadowBlur=e*.25;let i=1+Math.floor(Math.random()*3),a=Array.from({length:i},()=>({pos:.3+Math.random()*.5,len:e*(.22+Math.random()*.34),angle:Math.PI/3*(.8+Math.random()*.45)})),o=Math.random()<.55,s=e*(.14+Math.random()*.12),c=Math.random()<.45,l=e*(.14+Math.random()*.14);for(let t=0;t<6;t++){r.save(),r.rotate(t*Math.PI/3),r.beginPath(),r.moveTo(0,0),r.lineTo(0,-e);for(let t of a){let n=-e*t.pos;r.moveTo(0,n),r.lineTo(Math.sin(t.angle)*t.len,n-Math.cos(t.angle)*t.len),r.moveTo(0,n),r.lineTo(-Math.sin(t.angle)*t.len,n-Math.cos(t.angle)*t.len)}o&&(r.moveTo(0,-e),r.lineTo(s*.7,-e-s*.5),r.moveTo(0,-e),r.lineTo(-s*.7,-e-s*.5)),r.stroke(),r.restore()}if(c){r.beginPath();for(let e=0;e<6;e++){let t=e*Math.PI/3-Math.PI/2,n=Math.cos(t)*l,i=Math.sin(t)*l;e===0?r.moveTo(n,i):r.lineTo(n,i)}r.closePath(),r.stroke()}return n},Tt=()=>({dots:[1.2,1.6,2,2.3].map(e=>Ct(e)),crystals:[2.6,3.2,3.8,4.4,5].map(e=>wt(e*2.4))}),Et=e=>e[Math.floor(Math.random()*e.length)],Dt=(e,t,n,r)=>{let i=1+Math.random()**1.6*4.2,a=i>=2.4,o=Et(a?n.crystals:n.dots),s=a?i*4.8+6:i*2+4;return{x:Math.random()*e,y:r??Math.random()*t,size:i,speed:.4+i*.28+Math.random()*.4,phase:Math.random()*Math.PI*2,drift:(Math.random()-.5)*.4,rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.025,opacity:.55+Math.random()*.45,sprite:o,drawSize:s}},Ot=(e,t)=>t?e===`smog`?`96, 88, 66`:`138, 150, 168`:e===`smog`?`168, 155, 126`:`226, 232, 238`;function kt(e){let{ctx:t,width:n,height:r,activeWeather:i,dayCycleTimes:a=null,sceneTimeMs:o,liveClock:s=!1,windMotion:c,rainLevel:l=5,snowLevel:u=5,hailLevel:d=2,fogLevel:f=2,smogLevel:p=2}=e,m=ht[i],h=(()=>{let e=m;return de(i)&&e.rain&&(e={...e,rain:ge(e.rain,l)}),fe(i)&&(e={...e,snowCount:_e(u),fogBanks:u>=7?Math.max(e.fogBanks,3):e.fogBanks,haze:u>=7?Math.max(e.haze,.12):e.haze}),M(i)&&(e=N(e,f)),Ce(i)&&(e=we(e,p)),e})(),g=gt[i],_=a??null,v=_?x(s?Date.now():o,_):null,y=v?!v.isDay:!1,b=v?te(h.sky,g.sky,v):y?g.sky:h.sky,S=y?_t(h.cloudColor):h.cloudColor,C=Math.min(n,r)*.09,w=n*.72,T=r*.26;if(v){let e=ee(n,r,v.arcProgress);w=e.x,T=e.y}let D=E(t,r,b),O=[{dx:-.32,dy:.08,r:.17},{dx:.24,dy:-.22,r:.12},{dx:.04,dy:.34,r:.1},{dx:.36,dy:.24,r:.07}],k=xt(h,C),A=St(h,C,O),j=y?A:k,F=y||_!=null?Array.from({length:g.stars},()=>({x:Math.random()*n,y:Math.random()*r*.72,r:.4+Math.random()*1.1,phase:Math.random()*Math.PI*2,speed:.015+Math.random()*.035})):[],I=Array.from({length:h.cloudCount},()=>yt(n,r,h.cloudSpread,S,h.cloudAlpha)),L=h.rain?Array.from({length:h.rain.count},()=>({x:Math.random()*(n+160)-80,y:Math.random()*r,len:8+Math.random()*10,speed:h.rain.speed*(.75+Math.random()*.5)})):[],R=[],z=Array.from({length:h.fogBanks},(e,t)=>({x:Math.random()*n,y:t/Math.max(h.fogBanks-1,1)*r*.9+r*.05,rw:n*(.25+Math.random()*.3),rh:r*(.08+Math.random()*.08),speed:(.1+Math.random()*.25)*(t%2==0?1:-1),alpha:(.1+Math.random()*.1)*(M(i)?P(f):Ce(i)?Te(p):1)})),B=h.fogBanks>0?bt(Ot(i,y)):null,U=h.snowCount>0?Tt():null,W=U==null?[]:Array.from({length:h.snowCount},()=>Dt(n,r,U)),G=V(i)?H(d):null,K=G==null?null:it(),ne=K!=null&&G!=null?Array.from({length:G.count},()=>st(n,r,K,{min:G.sizeMin,max:G.sizeMax},G.speedMul)):[],q=(()=>{let{count:e}=Ge(c.visualLevel);return e<=0?[]:Array.from({length:e},()=>({x:Math.random()*n,y:Math.random()*r,length:35+Math.random()*120,speed:6+Math.random()*10,wave:Math.random()*Math.PI*2,alpha:.1+Math.random()*.28,width:.5+Math.random()*1.1,phase:Math.random()*Math.PI*2}))})(),J=[],Y=120+Math.random()*240;return{sky:b,cloudRgb:S,cfg:h,sunX:w,sunY:T,sunR:C,skyGradient:D,celestial:j,sunSprite:k,moonSprite:A,fogSprite:B,dayCycleTimes:_,dayCycle:v,sceneTimeMs:o,liveClock:s,hailSpec:G,state:{stars:F,moonCraters:O,clouds:I,drops:L,splashes:R,fogBanks:z,flakes:W,hailstones:ne,hailPool:K??[],windStreaks:q,t:0,flashAlpha:0,boltLife:0,boltPoints:J,nextStrike:Y}}}function At(e,t){if(!e.dayCycleTimes)return;let n=x(e.liveClock?t??Date.now():e.sceneTimeMs,e.dayCycleTimes),r=gt[e.activeWeather],i=te(e.cfg.sky,r.sky,n),a=ee(e.width,e.height,n.arcProgress);e.dayCycle=n,e.activeNight=!n.isDay,e.sky=i,e.skyGradient=E(e.ctx,e.height,i),e.sunX=a.x,e.sunY=a.y,e.celestial=n.isDay?e.sunSprite:e.moonSprite}function jt(e,t){t&&(e.state.t+=1),e.windField=$(e.state.t,e.windMotion),e.dayCycleTimes&&At(e,e.liveClock?Date.now():e.sceneTimeMs),dt(e),mt(e),Xe(e),Ze(e),Qe(e),ct(e),lt(e),ut(e),et(e),tt(e)}function Mt(e){let{ctx:t,width:n,height:r,activeWeather:i,activeNight:a,windMotion:o}=e,s=kt(e),c={ctx:t,width:n,height:r,activeWeather:i,activeNight:s.dayCycle?!s.dayCycle.isDay:a,windMotion:o,windField:$(0,o),...s};c.dayCycleTimes&&At(c,c.liveClock?Date.now():c.sceneTimeMs);let u=document.hidden,d=(0,l.prefersReducedMotion)(),f=(0,l.bindVisibilityPause)(e=>{u=e}),p=(0,l.bindPrefersReducedMotion)(e=>{d=e});if(d)return jt(c,!1),()=>{f(),p()};let m=0,h=()=>{m=requestAnimationFrame(h),!u&&(d||jt(c,!0))};return h(),()=>{cancelAnimationFrame(m),f(),p()}}var Nt={weatherBackground:`cos-weatherBackground-Mnm22`,canvas:`cos-canvas-nvqMt`,loadingOverlay:`cos-loadingOverlay-O58B7`,loadingSpinner:`cos-loadingSpinner-NQ9yG`,"weather-loading-spin":`cos-weather-loading-spin-IPFWZ`},Pt=({width:e,height:t,fill:n=!1,weather:r=`partlyCloudy`,time:i=`14:00`,live:a=!1,latitude:o,longitude:s,windLevel:d=3,rainLevel:f=5,snowLevel:p=5,hailLevel:m=2,fogLevel:h=2,smogLevel:g=2,onLiveWeather:_,loading:y=!1,ariaLabel:ee,loadingText:S=`天气加载中…`})=>{let{hostRef:C,width:w,height:T,hostStyle:te}=(0,l.useCanvasBox)({fill:n,width:e,height:t,defaultWidth:800,defaultHeight:450}),E=(0,c.useRef)(null),D=Ie(a,o!=null&&s!=null?{latitude:o,longitude:s}:void 0),O=X(a&&D.weather?D.weather:r),k=a&&D.rainLevel!=null?D.rainLevel:f,A=a&&D.snowLevel!=null?D.snowLevel:p,j=a&&D.fogLevel!=null?D.fogLevel:h,M=a&&D.hailLevel!=null?D.hailLevel:m,N=a&&D.smogLevel!=null?D.smogLevel:g,P=he(O,k,A),F=b(i),I=D.current?.sunrise??null,L=D.current?.sunset??null,R=D.current?.windSpeed??null,z=(0,c.useMemo)(()=>a&&I!=null&&L!=null?{sunrise:I,sunset:L}:v(F),[a,I,L,F]),B=Ye({live:a,windLevel:d,liveWindKmh:R}),V=(0,c.useMemo)(()=>Je(B),[B]),H=a&&D.current?!D.current.isDay:!x(F,z).isDay,U=y||a&&(D.status===`locating`||D.status===`fetching`),W=(0,c.useRef)(_);return(0,c.useEffect)(()=>{W.current=_}),(0,c.useEffect)(()=>{D.weather&&W.current?.(X(D.weather))},[D.weather]),(0,c.useEffect)(()=>{let e=E.current;if(!e)return;let t=window.devicePixelRatio||1;e.width=w*t,e.height=T*t;let n=e.getContext(`2d`);if(n)return n.setTransform(t,0,0,t,0,0),Mt({ctx:n,width:w,height:T,activeWeather:P,activeNight:H,dayCycleTimes:z,sceneTimeMs:F,liveClock:a,windMotion:V,rainLevel:k,snowLevel:A,fogLevel:j,hailLevel:M,smogLevel:N})},[H,P,z,k,A,j,M,N,T,a,F,w,V]),(0,u.jsxs)(`div`,{ref:C,className:Nt.weatherBackground,style:te,children:[(0,u.jsx)(`canvas`,{ref:E,className:Nt.canvas,style:{width:w,height:T},role:`img`,"aria-label":ee??`天气背景:${O}${H?`(夜间)`:``},${V.level}级风`}),U&&(0,u.jsxs)(`div`,{className:Nt.loadingOverlay,role:`status`,"aria-live":`polite`,children:[(0,u.jsx)(`div`,{className:Nt.loadingSpinner,"aria-hidden":!0}),(0,u.jsx)(`span`,{children:S})]})]})};exports.DEFAULT_FOG_LEVEL=O,exports.DEFAULT_HAIL_LEVEL=L,exports.DEFAULT_RAIN_LEVEL=K,exports.DEFAULT_SMOG_LEVEL=be,exports.DEFAULT_SNOW_LEVEL=ne,exports.DEFAULT_WIND_LEVEL=ze,exports.FOG_LEVEL_LABELS=k,exports.HAIL_LEVEL_LABELS=R,exports.MAX_PRECIP_LEVEL=G,exports.MIN_PRECIP_LEVEL=W,exports.RAIN_LEVEL_LABELS=se,exports.SMOG_LEVEL_LABELS=xe,exports.SNOW_LEVEL_LABELS=ce,exports.WeatherBackground=Pt,exports.default=Pt,exports.buildWindMotion=Je,exports.clampFogLevel=A,exports.clampHailLevel=z,exports.clampPrecipLevel=q,exports.clampSmogLevel=Q,exports.fogBankAlphaScale=P,exports.fogLevelFromVisibility=I,exports.fogLevelFromWmo=F,exports.formatFogLevel=j,exports.formatHailLevel=B,exports.formatLocalHm=Fe,exports.formatPrecipLevel=oe,exports.formatSmogLevel=Se,exports.hailLevelFromWmo=U,exports.hailSpec=H,exports.intensifyFogConfig=N,exports.intensifyRainConfig=ge,exports.intensifySmogConfig=we,exports.intensifySnowCount=_e,exports.isRainWeather=le,exports.isSnowWeather=ue,exports.kmhToWindLevel=qe,exports.mapWmoCodeToWeatherType=Oe,exports.normalizeWeatherType=X,exports.precipBand=Y,exports.precipLabel=ae,exports.rainLevelFromWeather=pe,exports.rainLevelFromWmo=ve,exports.resolveSceneWeather=he,exports.sampleWindField=$,exports.smogBankAlphaScale=Te,exports.smogLevelFromVisibility=Ee,exports.snowLevelFromWeather=me,exports.snowLevelFromWmo=ye,exports.supportsFogLevel=M,exports.supportsHailLevel=V,exports.supportsRainLevel=de,exports.supportsSmogLevel=Ce,exports.supportsSnowLevel=fe,exports.useLiveWeather=Ie,exports.useSunTimes=Re,exports.visualWindLevel=Ve,exports.windLevelToKmh=Ke,exports.windStreakSpec=Ge;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect as e, useMemo as t, useRef as n, useState as r } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as
|
|
2
|
+
import { bindPrefersReducedMotion as i, bindVisibilityPause as a, prefersReducedMotion as o, useCanvasBox as s } from "@cos-design/shared";
|
|
3
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
4
|
import './index.css';//#region src/components/weatherBackground/day-cycle.ts
|
|
5
|
-
var
|
|
5
|
+
var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
6
6
|
let t = e.replace("#", "").trim(), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
|
|
7
7
|
if (n.length !== 6) return [
|
|
8
8
|
80,
|
|
@@ -19,17 +19,17 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
19
19
|
r >> 8 & 255,
|
|
20
20
|
r & 255
|
|
21
21
|
];
|
|
22
|
-
},
|
|
22
|
+
}, f = ([e, t, n]) => {
|
|
23
23
|
let r = (e) => Math.min(255, Math.max(0, Math.round(e))).toString(16).padStart(2, "0");
|
|
24
24
|
return `#${r(e)}${r(t)}${r(n)}`;
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
],
|
|
30
|
-
let t =
|
|
25
|
+
}, p = (e, t, n) => e + (t - e) * n, m = (e, t, n) => [
|
|
26
|
+
p(e[0], t[0], n),
|
|
27
|
+
p(e[1], t[1], n),
|
|
28
|
+
p(e[2], t[2], n)
|
|
29
|
+
], h = (e, t, n) => f(m(d(e), d(t), u(n))), g = (e) => {
|
|
30
|
+
let t = u(e);
|
|
31
31
|
return t * t * (3 - 2 * t);
|
|
32
|
-
},
|
|
32
|
+
}, _ = (e = Date.now()) => {
|
|
33
33
|
let t = new Date(e), n = new Date(t);
|
|
34
34
|
n.setHours(6, 0, 0, 0);
|
|
35
35
|
let r = new Date(t);
|
|
@@ -37,52 +37,52 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
37
37
|
sunrise: n.getTime(),
|
|
38
38
|
sunset: r.getTime()
|
|
39
39
|
};
|
|
40
|
-
},
|
|
40
|
+
}, v = (e, t = /* @__PURE__ */ new Date()) => {
|
|
41
41
|
let n = e.trim().match(/^(\d{1,2}):(\d{2})$/);
|
|
42
42
|
if (!n) return null;
|
|
43
43
|
let r = Number(n[1]), i = Number(n[2]);
|
|
44
44
|
if (r < 0 || r > 23 || i < 0 || i > 59) return null;
|
|
45
45
|
let a = new Date(t);
|
|
46
46
|
return a.setHours(r, i, 0, 0), a.getTime();
|
|
47
|
-
},
|
|
47
|
+
}, y = (e, t = /* @__PURE__ */ new Date()) => v(e ?? "14:00", t) ?? v("14:00", t), b = (e, t) => {
|
|
48
48
|
let { sunrise: n, sunset: r } = t;
|
|
49
49
|
if (!(r > n)) {
|
|
50
|
-
let t =
|
|
50
|
+
let t = _(e);
|
|
51
51
|
n = t.sunrise, r = t.sunset;
|
|
52
52
|
}
|
|
53
|
-
let i = Math.max(1, r - n), a = n + 1440 * 60 * 1e3, o = r - 1440 * 60 * 1e3, s = e >= n && e < r,
|
|
54
|
-
if (s)
|
|
53
|
+
let i = Math.max(1, r - n), a = n + 1440 * 60 * 1e3, o = r - 1440 * 60 * 1e3, s = e >= n && e < r, c;
|
|
54
|
+
if (s) c = u((e - n) / i);
|
|
55
55
|
else if (e >= r) {
|
|
56
56
|
let t = Math.max(1, a - r);
|
|
57
|
-
|
|
57
|
+
c = u((e - r) / t);
|
|
58
58
|
} else {
|
|
59
59
|
let t = Math.max(1, n - o);
|
|
60
|
-
|
|
60
|
+
c = u((e - o) / t);
|
|
61
61
|
}
|
|
62
|
-
let
|
|
62
|
+
let l = s ? Math.sin(Math.PI * c) : 0, d = Math.abs(e - n), f = Math.abs(e - r), p = u(1 - Math.min(d, f) / 45e5);
|
|
63
63
|
return {
|
|
64
64
|
isDay: s,
|
|
65
|
-
arcProgress:
|
|
66
|
-
elevation:
|
|
65
|
+
arcProgress: c,
|
|
66
|
+
elevation: l,
|
|
67
67
|
twilight: p
|
|
68
68
|
};
|
|
69
|
-
},
|
|
70
|
-
let r =
|
|
69
|
+
}, x = (e, t, n) => {
|
|
70
|
+
let r = u(n), i = Math.sin(Math.PI * r);
|
|
71
71
|
return {
|
|
72
72
|
x: e * (.1 + .8 * r),
|
|
73
73
|
y: t * (.58 - .4 * i)
|
|
74
74
|
};
|
|
75
|
-
},
|
|
75
|
+
}, S = "#e8895c", C = "#f3c98a", w = "#2a1f4a", T = "#c4784a", ee = (e, t, n) => {
|
|
76
76
|
if (n.isDay) {
|
|
77
|
-
let t =
|
|
78
|
-
return [
|
|
77
|
+
let t = g(n.elevation), r = (1 - t) * .72;
|
|
78
|
+
return [h(h(e[0], S, r), "#1a2438", (1 - t) * .12), h(h(e[1], C, r * .85), "#3a4558", (1 - t) * .08)];
|
|
79
79
|
}
|
|
80
80
|
let r = n.twilight;
|
|
81
|
-
return [
|
|
82
|
-
},
|
|
81
|
+
return [h(t[0], h(w, S, .35), r * .55), h(t[1], h(T, C, .4), r * .7)];
|
|
82
|
+
}, te = (e, t, n) => {
|
|
83
83
|
let r = e.createLinearGradient(0, 0, 0, t);
|
|
84
84
|
return r.addColorStop(0, n[0]), r.addColorStop(1, n[1]), r;
|
|
85
|
-
},
|
|
85
|
+
}, E = (e) => {
|
|
86
86
|
if (!e.isDay) return {
|
|
87
87
|
scale: .92 + e.twilight * .06,
|
|
88
88
|
alpha: .75 + e.twilight * .2
|
|
@@ -92,16 +92,16 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
92
92
|
scale: .82 + t * .22,
|
|
93
93
|
alpha: .65 + t * .35
|
|
94
94
|
};
|
|
95
|
-
},
|
|
95
|
+
}, D = 2, O = [
|
|
96
96
|
"",
|
|
97
97
|
"薄雾",
|
|
98
98
|
"中雾",
|
|
99
99
|
"浓雾"
|
|
100
|
-
],
|
|
101
|
-
let t =
|
|
102
|
-
return `${t} · ${
|
|
103
|
-
},
|
|
104
|
-
let n =
|
|
100
|
+
], k = (e) => Math.min(3, Math.max(1, Math.round(e))), A = (e) => {
|
|
101
|
+
let t = k(e);
|
|
102
|
+
return `${t} · ${O[t]}`;
|
|
103
|
+
}, j = (e) => e === "fog", M = (e, t) => {
|
|
104
|
+
let n = k(t);
|
|
105
105
|
return n === 1 ? {
|
|
106
106
|
...e,
|
|
107
107
|
fogBanks: 3,
|
|
@@ -121,19 +121,19 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
121
121
|
cloudAlpha: .32,
|
|
122
122
|
sun: "dim"
|
|
123
123
|
};
|
|
124
|
-
},
|
|
125
|
-
let t =
|
|
124
|
+
}, N = (e) => {
|
|
125
|
+
let t = k(e);
|
|
126
126
|
return t === 1 ? .45 : t === 3 ? .95 : .65;
|
|
127
|
-
},
|
|
127
|
+
}, P = (e) => e === 45 ? 2 : e === 48 ? 3 : null, F = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, I = 2, L = [
|
|
128
128
|
"",
|
|
129
129
|
"细雹",
|
|
130
130
|
"密雹",
|
|
131
131
|
"巨雹"
|
|
132
|
-
],
|
|
133
|
-
let t =
|
|
134
|
-
return `${t} · ${
|
|
135
|
-
},
|
|
136
|
-
let t =
|
|
132
|
+
], R = (e) => Math.min(3, Math.max(1, Math.round(e))), z = (e) => {
|
|
133
|
+
let t = R(e);
|
|
134
|
+
return `${t} · ${L[t]}`;
|
|
135
|
+
}, B = (e) => e === "hail", ne = (e) => {
|
|
136
|
+
let t = R(e);
|
|
137
137
|
return t === 1 ? {
|
|
138
138
|
count: 75,
|
|
139
139
|
sizeMin: .85,
|
|
@@ -150,37 +150,37 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
150
150
|
sizeMax: 3.8,
|
|
151
151
|
speedMul: 1
|
|
152
152
|
};
|
|
153
|
-
}, V = (e) => e === 96 ? 2 : e === 99 ? 3 : null,
|
|
154
|
-
let t =
|
|
153
|
+
}, V = (e) => e === 96 ? 2 : e === 99 ? 3 : null, H = 1, U = 10, W = 5, G = 5, K = (e) => Math.min(10, Math.max(1, Math.round(e))), q = (e, t, n) => e + (t - e) * n, J = (e) => {
|
|
154
|
+
let t = K(e);
|
|
155
155
|
return t <= 2 ? 1 : t <= 4 ? 2 : t <= 6 ? 3 : t <= 8 ? 4 : 5;
|
|
156
|
-
},
|
|
156
|
+
}, re = [
|
|
157
157
|
"毛毛雨",
|
|
158
158
|
"小雨",
|
|
159
159
|
"中雨",
|
|
160
160
|
"暴雨",
|
|
161
161
|
"特大暴雨"
|
|
162
|
-
],
|
|
162
|
+
], ie = [
|
|
163
163
|
"毛毛雪",
|
|
164
164
|
"小雪",
|
|
165
165
|
"中雪",
|
|
166
166
|
"暴雪",
|
|
167
167
|
"特大暴雪"
|
|
168
|
-
],
|
|
169
|
-
let n =
|
|
170
|
-
return (t === "rain" ?
|
|
171
|
-
},
|
|
172
|
-
let n = (
|
|
168
|
+
], ae = (e, t) => {
|
|
169
|
+
let n = J(e);
|
|
170
|
+
return (t === "rain" ? re : ie)[n - 1];
|
|
171
|
+
}, oe = (e, t) => `${K(e)} · ${ae(e, t)}`, se = ["", ...re], ce = ["", ...ie], Y = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? "rain" : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? "snow" : e, le = (e) => e === "rain" || e === "lightRain" || e === "moderateRain" || e === "heavyRain", ue = (e) => e === "snow" || e === "lightSnow" || e === "moderateSnow" || e === "heavySnow", de = (e) => le(e) || e === "thunderstorm" || e === "sleet", fe = (e) => ue(e) || e === "sleet", pe = (e, t = 5) => e === "lightRain" ? 3 : e === "moderateRain" ? 5 : e === "heavyRain" ? 8 : K(t), me = (e, t = 5) => e === "lightSnow" ? 3 : e === "moderateSnow" ? 5 : e === "heavySnow" ? 8 : K(t), X = (e, t) => t === "rain" ? e <= 2 ? "lightRain" : e === 3 ? "moderateRain" : "heavyRain" : e <= 2 ? "lightSnow" : e === 3 ? "moderateSnow" : "heavySnow", he = (e, t = 5, n = 5) => e === "rain" ? X(J(t), "rain") : e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? X(J(pe(e)), "rain") : e === "snow" ? X(J(n), "snow") : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? X(J(me(e)), "snow") : e, ge = (e, t) => {
|
|
172
|
+
let n = (K(t) - 1) / 9;
|
|
173
173
|
return {
|
|
174
|
-
count: Math.round(
|
|
175
|
-
speed:
|
|
176
|
-
wind:
|
|
177
|
-
alpha:
|
|
178
|
-
splash:
|
|
174
|
+
count: Math.round(q(35, 340, n)),
|
|
175
|
+
speed: q(5.5, 16, n),
|
|
176
|
+
wind: q(-.4, -3.2, n),
|
|
177
|
+
alpha: q(.28, .62, n),
|
|
178
|
+
splash: K(t) >= 5
|
|
179
179
|
};
|
|
180
|
-
},
|
|
181
|
-
let t = (
|
|
182
|
-
return Math.round(
|
|
183
|
-
},
|
|
180
|
+
}, _e = (e) => {
|
|
181
|
+
let t = (K(e) - 1) / 9;
|
|
182
|
+
return Math.round(q(30, 360, t));
|
|
183
|
+
}, ve = (e) => [51, 56].includes(e) ? 2 : [
|
|
184
184
|
61,
|
|
185
185
|
66,
|
|
186
186
|
80
|
|
@@ -190,16 +190,16 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
190
190
|
57,
|
|
191
191
|
63,
|
|
192
192
|
81
|
|
193
|
-
].includes(e) ? 5 : [65, 67].includes(e) ? 8 : [82].includes(e) ? 10 : [95].includes(e) ? 7 : null,
|
|
193
|
+
].includes(e) ? 5 : [65, 67].includes(e) ? 8 : [82].includes(e) ? 10 : [95].includes(e) ? 7 : null, ye = (e) => [77].includes(e) ? 2 : [71, 85].includes(e) ? 3 : [73].includes(e) ? 5 : [75].includes(e) ? 8 : [86].includes(e) ? 10 : null, be = 2, xe = [
|
|
194
194
|
"",
|
|
195
195
|
"轻霾",
|
|
196
196
|
"中霾",
|
|
197
197
|
"重霾"
|
|
198
|
-
],
|
|
199
|
-
let t =
|
|
200
|
-
return `${t} · ${
|
|
201
|
-
},
|
|
202
|
-
let n =
|
|
198
|
+
], Z = (e) => Math.min(3, Math.max(1, Math.round(e))), Se = (e) => {
|
|
199
|
+
let t = Z(e);
|
|
200
|
+
return `${t} · ${xe[t]}`;
|
|
201
|
+
}, Ce = (e) => e === "smog", we = (e, t) => {
|
|
202
|
+
let n = Z(t);
|
|
203
203
|
return n === 1 ? {
|
|
204
204
|
...e,
|
|
205
205
|
fogBanks: 5,
|
|
@@ -219,10 +219,10 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
219
219
|
cloudAlpha: .35,
|
|
220
220
|
sun: "dim"
|
|
221
221
|
};
|
|
222
|
-
},
|
|
223
|
-
let t =
|
|
222
|
+
}, Te = (e) => {
|
|
223
|
+
let t = Z(e);
|
|
224
224
|
return t === 1 ? .55 : t === 3 ? 1.05 : .85;
|
|
225
|
-
},
|
|
225
|
+
}, Ee = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, De = {
|
|
226
226
|
0: "sunny",
|
|
227
227
|
1: "sunny",
|
|
228
228
|
2: "partlyCloudy",
|
|
@@ -251,7 +251,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
251
251
|
95: "thunderstorm",
|
|
252
252
|
96: "hail",
|
|
253
253
|
99: "hail"
|
|
254
|
-
},
|
|
254
|
+
}, Oe = (e) => Y(De[e] ?? "overcast"), ke = {
|
|
255
255
|
weather: null,
|
|
256
256
|
rainLevel: null,
|
|
257
257
|
snowLevel: null,
|
|
@@ -261,7 +261,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
261
261
|
status: "idle",
|
|
262
262
|
error: null,
|
|
263
263
|
current: null
|
|
264
|
-
},
|
|
264
|
+
}, Ae = {
|
|
265
265
|
weather: null,
|
|
266
266
|
rainLevel: null,
|
|
267
267
|
snowLevel: null,
|
|
@@ -271,7 +271,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
271
271
|
status: "locating",
|
|
272
272
|
error: null,
|
|
273
273
|
current: null
|
|
274
|
-
},
|
|
274
|
+
}, je = {
|
|
275
275
|
weather: null,
|
|
276
276
|
rainLevel: null,
|
|
277
277
|
snowLevel: null,
|
|
@@ -281,15 +281,15 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
281
281
|
status: "fetching",
|
|
282
282
|
error: null,
|
|
283
283
|
current: null
|
|
284
|
-
},
|
|
284
|
+
}, Me = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude), Q = (e) => {
|
|
285
285
|
if (typeof e != "string" || !e) return null;
|
|
286
286
|
let t = Date.parse(e);
|
|
287
287
|
return Number.isFinite(t) ? t : null;
|
|
288
|
-
},
|
|
288
|
+
}, Ne = (e) => {
|
|
289
289
|
if (typeof e != "string" || !e) return null;
|
|
290
290
|
let t = e.match(/T(\d{2}):(\d{2})/);
|
|
291
291
|
return t ? `${t[1]}:${t[2]}` : null;
|
|
292
|
-
},
|
|
292
|
+
}, Pe = (e, t) => {
|
|
293
293
|
if (e) try {
|
|
294
294
|
let t = new Intl.DateTimeFormat("en-GB", {
|
|
295
295
|
timeZone: e,
|
|
@@ -300,8 +300,8 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
300
300
|
if (n != null && r != null) return `${n.padStart(2, "0")}:${r.padStart(2, "0")}`;
|
|
301
301
|
} catch {}
|
|
302
302
|
return t ?? null;
|
|
303
|
-
},
|
|
304
|
-
let i =
|
|
303
|
+
}, Fe = (t = !0, n) => {
|
|
304
|
+
let i = Me(n), a = i ? n.latitude : null, o = i ? n.longitude : null, s = t ? i ? je : Ae : ke, c = `${t}:${a},${o}`, [l, u] = r(s), [d, f] = r(c);
|
|
305
305
|
return d !== c && (f(c), u((e) => t && e.weather ? {
|
|
306
306
|
...s,
|
|
307
307
|
weather: e.weather,
|
|
@@ -321,7 +321,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
321
321
|
if (!a.ok) throw Error(`Open-Meteo 请求失败(HTTP ${a.status})`);
|
|
322
322
|
let o = await a.json(), s = Number(o?.current?.weather_code);
|
|
323
323
|
if (Number.isNaN(s)) throw Error("Open-Meteo 返回数据缺少 weather_code");
|
|
324
|
-
let c = Number(o?.current?.wind_speed_10m ?? 0), l =
|
|
324
|
+
let c = Number(o?.current?.wind_speed_10m ?? 0), l = Q(o?.daily?.sunrise?.[0]), d = Q(o?.daily?.sunset?.[0]), f = typeof o?.timezone == "string" ? o.timezone : null, p = Ne(o?.current?.time) ?? Pe(f), m = Oe(s), h = ve(s), g = ye(s), _ = o?.current?.visibility, v = _ != null && Number.isFinite(Number(_)) ? Number(_) : null, y = m === "fog" ? F(v) ?? P(s) ?? 2 : null, b = m === "hail" ? V(s) ?? 2 : null, x = m === "smog" ? Ee(v) ?? 2 : null;
|
|
325
325
|
if (e) return;
|
|
326
326
|
u({
|
|
327
327
|
weather: m,
|
|
@@ -409,7 +409,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
409
409
|
a,
|
|
410
410
|
o
|
|
411
411
|
]), l;
|
|
412
|
-
},
|
|
412
|
+
}, Ie = async (e, t, n) => {
|
|
413
413
|
let r = new URLSearchParams({
|
|
414
414
|
latitude: String(e),
|
|
415
415
|
longitude: String(t),
|
|
@@ -418,17 +418,17 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
418
418
|
forecast_days: "1"
|
|
419
419
|
}), i = await fetch(`https://api.open-meteo.com/v1/forecast?${r}`, { signal: n });
|
|
420
420
|
if (!i.ok) return null;
|
|
421
|
-
let a = await i.json(), o =
|
|
421
|
+
let a = await i.json(), o = Q(a?.daily?.sunrise?.[0]), s = Q(a?.daily?.sunset?.[0]);
|
|
422
422
|
return o == null || s == null ? null : {
|
|
423
423
|
sunrise: o,
|
|
424
424
|
sunset: s
|
|
425
425
|
};
|
|
426
|
-
},
|
|
427
|
-
let n =
|
|
426
|
+
}, Le = (t) => {
|
|
427
|
+
let n = Me(t), i = n ? t.latitude : null, a = n ? t.longitude : null, o = `${i},${a}`, [s, c] = r(null), [l, u] = r(o);
|
|
428
428
|
return l !== o && (u(o), c(null)), e(() => {
|
|
429
429
|
if (i == null || a == null) return;
|
|
430
430
|
let e = !1, t = new AbortController();
|
|
431
|
-
return
|
|
431
|
+
return Ie(i, a, t.signal).then((t) => {
|
|
432
432
|
e || c(t);
|
|
433
433
|
}).catch(() => {
|
|
434
434
|
e || c(null);
|
|
@@ -436,7 +436,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
436
436
|
e = !0, t.abort();
|
|
437
437
|
};
|
|
438
438
|
}, [i, a]), n ? s : null;
|
|
439
|
-
},
|
|
439
|
+
}, Re = 3, ze = (e) => Math.min(12, Math.max(0, Math.round(e))), Be = (e) => Math.max(0, ze(e) - 2), Ve = .55, He = [
|
|
440
440
|
0,
|
|
441
441
|
3,
|
|
442
442
|
8,
|
|
@@ -450,7 +450,7 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
450
450
|
95,
|
|
451
451
|
110,
|
|
452
452
|
125
|
|
453
|
-
],
|
|
453
|
+
], Ue = [
|
|
454
454
|
1,
|
|
455
455
|
5,
|
|
456
456
|
11,
|
|
@@ -464,8 +464,8 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
464
464
|
102,
|
|
465
465
|
117,
|
|
466
466
|
Infinity
|
|
467
|
-
],
|
|
468
|
-
let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e *
|
|
467
|
+
], $ = (e, t, n = 0, r = 0) => {
|
|
468
|
+
let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e * Ve, c = Math.sin(s * .007 + o), l = Math.sin(s * .021 + 1.37 + o * 1.4), u = Math.sin(s * .055 + 2.8 + o * .6), d = 1 + (.5 * c + .35 * l + .15 * u) * (.25 + i * .75), f = Math.sin(s * .012 + o * .8);
|
|
469
469
|
f > .72 && (d += (f - .72) * (.8 + i * 2.4)), Math.sin(s * .0095 + .6 + o) < -.55 && (d *= .45 + i * .2), d = Math.max(.12, Math.min(2.25, d));
|
|
470
470
|
let p = a * (.55 * Math.sin(s * .0088 + o) + .3 * Math.sin(s * .026 + 1.9 + o * 1.1) + .15 * Math.sin(s * .063 + .4));
|
|
471
471
|
return {
|
|
@@ -474,8 +474,8 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
474
474
|
ux: Math.cos(p),
|
|
475
475
|
uy: Math.sin(p)
|
|
476
476
|
};
|
|
477
|
-
},
|
|
478
|
-
let t =
|
|
477
|
+
}, We = (e) => {
|
|
478
|
+
let t = ze(e);
|
|
479
479
|
if (t <= 0) return {
|
|
480
480
|
count: 0,
|
|
481
481
|
alphaMul: 0
|
|
@@ -485,12 +485,12 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
485
485
|
count: Math.floor(3 + n * n * 50),
|
|
486
486
|
alphaMul: .1 + n * .9
|
|
487
487
|
};
|
|
488
|
-
},
|
|
488
|
+
}, Ge = (e) => He[ze(e)] ?? 16, Ke = (e) => {
|
|
489
489
|
let t = Math.max(0, e);
|
|
490
|
-
for (let e = 0; e <
|
|
490
|
+
for (let e = 0; e < Ue.length; e++) if (t <= Ue[e]) return e;
|
|
491
491
|
return 12;
|
|
492
|
-
},
|
|
493
|
-
let t =
|
|
492
|
+
}, qe = (e) => {
|
|
493
|
+
let t = Ke(e), n = Be(t), r = Ge(n), i = Math.max(.04, Math.min(r / 16, 4.2)), { alphaMul: a } = We(n), o = i ** .82, s = Math.min(1, (n / 8) ** 1.1), c = (.04 + s * .32) * Math.PI;
|
|
494
494
|
return {
|
|
495
495
|
speedKmh: e,
|
|
496
496
|
level: t,
|
|
@@ -506,17 +506,17 @@ var c = (e) => Math.min(1, Math.max(0, e)), l = (e) => {
|
|
|
506
506
|
gustiness: s,
|
|
507
507
|
wander: c
|
|
508
508
|
};
|
|
509
|
-
},
|
|
509
|
+
}, Je = (e) => e.live && e.liveWindKmh != null && Number.isFinite(e.liveWindKmh) ? Math.max(0, e.liveWindKmh) : Ge(e.windLevel);
|
|
510
510
|
//#endregion
|
|
511
511
|
//#region src/components/weatherBackground/scene/draw-atmosphere.ts
|
|
512
|
-
function
|
|
512
|
+
function Ye(e) {
|
|
513
513
|
let t = e.windMotion.cloud, { intensity: n, angle: r, uy: i } = e.windField, a = -Math.cos(r);
|
|
514
514
|
for (let r of e.state.clouds) {
|
|
515
515
|
let o = Math.abs(r.speed) * t * n;
|
|
516
516
|
r.x += o * a, r.y += o * i * .12, r.y < -80 && (r.y = -80), r.y > e.height * .55 && (r.y = e.height * .55), r.x - 140 * r.scale > e.width && (r.x = -160 * r.scale), r.x + 180 * r.scale < 0 && (r.x = e.width + 40 * r.scale), e.ctx.drawImage(r.sprite, r.x + r.ox, r.y + r.oy);
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
|
-
function
|
|
519
|
+
function Xe(e) {
|
|
520
520
|
let t = e.fogSprite;
|
|
521
521
|
if (!t || e.state.fogBanks.length === 0) return;
|
|
522
522
|
let { canvas: n, baseR: r } = t, i = e.windMotion.fog, { intensity: a, angle: o, uy: s } = e.windField, c = -Math.cos(o);
|
|
@@ -525,27 +525,27 @@ function Ye(e) {
|
|
|
525
525
|
t.x += o * c, t.y += o * s * .1, t.y < e.height * .02 && (t.y = e.height * .02), t.y > e.height * .95 && (t.y = e.height * .95), c < 0 && t.x + t.rw < 0 && (t.x = e.width + t.rw), c > 0 && t.x - t.rw > e.width && (t.x = -t.rw), e.ctx.save(), e.ctx.translate(t.x, t.y), e.ctx.scale(t.rw / r, t.rh / r), e.ctx.globalAlpha = t.alpha, e.ctx.drawImage(n, -r, -r), e.ctx.restore();
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
function
|
|
528
|
+
function Ze(e) {
|
|
529
529
|
if (e.cfg.haze <= 0) return;
|
|
530
530
|
let t = e.activeWeather === "smog" ? "177, 164, 135" : "220, 226, 232";
|
|
531
531
|
e.activeNight && (t = e.activeWeather === "smog" ? "82, 74, 54" : "116, 128, 145"), e.ctx.fillStyle = `rgba(${t}, ${e.cfg.haze})`, e.ctx.fillRect(0, 0, e.width, e.height);
|
|
532
532
|
}
|
|
533
533
|
//#endregion
|
|
534
534
|
//#region src/components/weatherBackground/lightning.ts
|
|
535
|
-
function
|
|
535
|
+
function Qe(e, t, n, r, i, a) {
|
|
536
536
|
if (a <= 0) return [[e, t], [n, r]];
|
|
537
|
-
let o = (e + n) / 2 + (Math.random() - .5) * i, s = (t + r) / 2, c =
|
|
537
|
+
let o = (e + n) / 2 + (Math.random() - .5) * i, s = (t + r) / 2, c = Qe(e, t, o, s, i * .55, a - 1), l = Qe(o, s, n, r, i * .55, a - 1);
|
|
538
538
|
return [...c.slice(0, -1), ...l];
|
|
539
539
|
}
|
|
540
540
|
//#endregion
|
|
541
541
|
//#region src/components/weatherBackground/scene/draw-effects.ts
|
|
542
|
-
function
|
|
542
|
+
function $e(e) {
|
|
543
543
|
if (e.state.windStreaks.length === 0) return;
|
|
544
544
|
let t = e.windMotion.streak, n = e.windMotion.streakVisibility;
|
|
545
545
|
if (n <= .02) return;
|
|
546
546
|
let r = e.state.t;
|
|
547
547
|
for (let i of e.state.windStreaks) {
|
|
548
|
-
let a =
|
|
548
|
+
let a = $(r + i.phase * 18, e.windMotion, i.x, i.y), o = a.intensity * (.55 + .45 * e.windField.intensity), s = a.angle * .65 + e.windField.angle * .35, c = -1 * Math.cos(s), l = Math.sin(s), u = i.speed * t * o;
|
|
549
549
|
i.x += u * c, i.y += u * l * .45, i.wave += .03 + o * .025, (i.x < -i.length - 40 || i.x > e.width + i.length + 40) && (i.x = c < 0 ? e.width + i.length + Math.random() * e.width * .25 : -i.length - Math.random() * e.width * .25, i.y = Math.random() * e.height), i.y < -20 && (i.y = e.height + 10), i.y > e.height + 20 && (i.y = -10);
|
|
550
550
|
let d = 5 + o * 5, f = Math.sin(i.wave) * d, p = i.length * (.85 + o * .2), m = i.x + c * p, h = i.y + l * p * .45, g = i.alpha * n * Math.min(1.35, .55 + o * .55);
|
|
551
551
|
if (e.ctx.beginPath(), e.ctx.moveTo(i.x, i.y), e.ctx.bezierCurveTo(i.x + c * p * .3, i.y + l * p * .3 * .45 + f, i.x + c * p * .7, i.y + l * p * .7 * .45 - f, m, h), e.ctx.strokeStyle = `rgba(235, 244, 250, ${g})`, e.ctx.lineWidth = i.width * (.85 + o * .2), e.ctx.lineCap = "round", e.ctx.stroke(), i.length > 70 && n > .45 && o > .7) {
|
|
@@ -554,12 +554,12 @@ function Qe(e) {
|
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function et(e) {
|
|
558
558
|
if (e.cfg.lightning) {
|
|
559
559
|
if (e.state.t >= e.state.nextStrike) {
|
|
560
560
|
e.state.nextStrike = e.state.t + 150 + Math.random() * 300, e.state.flashAlpha = .5, e.state.boltLife = 9;
|
|
561
561
|
let t = e.width * (.15 + Math.random() * .7);
|
|
562
|
-
e.state.boltPoints =
|
|
562
|
+
e.state.boltPoints = Qe(t, e.height * .12, t + (Math.random() - .5) * e.width * .2, e.height * .92, 60, 6);
|
|
563
563
|
}
|
|
564
564
|
if (e.state.boltLife > 0) {
|
|
565
565
|
--e.state.boltLife;
|
|
@@ -571,7 +571,7 @@ function $e(e) {
|
|
|
571
571
|
}
|
|
572
572
|
//#endregion
|
|
573
573
|
//#region src/components/weatherBackground/sprites/hail.ts
|
|
574
|
-
var
|
|
574
|
+
var tt = 3.2, nt = (e) => {
|
|
575
575
|
let t = Math.ceil(e * 2.8 + 4), n = document.createElement("canvas");
|
|
576
576
|
n.width = t, n.height = t;
|
|
577
577
|
let r = n.getContext("2d"), i = t / 2, a = t / 2, o = 9 + Math.floor(Math.random() * 5), s = Array.from({ length: o }, (t, n) => {
|
|
@@ -604,10 +604,10 @@ var et = 3.2, tt = (e) => {
|
|
|
604
604
|
r.beginPath(), r.arc(n, o, e * (.1 + Math.random() * .08), 0, Math.PI * 2), r.fillStyle = "rgba(255, 255, 255, 0.55)", r.fill();
|
|
605
605
|
}
|
|
606
606
|
return r.beginPath(), r.ellipse(i - e * .34, a - e * .36, e * .24, e * .17, -.35, 0, Math.PI * 2), r.fillStyle = "rgba(255, 255, 255, 0.78)", r.fill(), n;
|
|
607
|
-
},
|
|
607
|
+
}, rt = (e = 16) => Array.from({ length: e }, () => nt(tt)), it = (e) => e[Math.floor(Math.random() * e.length)], at = (e, t, n, r, i = !0, a, o = 1) => {
|
|
608
608
|
let s = a?.min ?? 1.4, c = a?.max ?? 4.8;
|
|
609
|
-
e.r = s + Math.random() ** 1.35 * (c - s), e.x = Math.random() * (t + 260) - 130 + (Math.random() - .5) * 40, e.y = i ? -e.r - Math.random() * n * .55 : Math.random() * n, e.vx = (-1.2 - Math.random() * 4.8 + (Math.random() - .5) * 1.2) * o, e.vy = (5.5 + Math.random() * 11) * o, e.bounces = 0, e.opacity = .45 + Math.random() * .55, e.delay = Math.floor(Math.random() * (i ? 110 : 45)), e.gravity = (.11 + Math.random() * .14) * (.9 + o * .1), e.phase = Math.random() * Math.PI * 2, e.gust = (Math.random() - .5) * 1.4, e.maxBounces = +(Math.random() < .62), e.sprite =
|
|
610
|
-
},
|
|
609
|
+
e.r = s + Math.random() ** 1.35 * (c - s), e.x = Math.random() * (t + 260) - 130 + (Math.random() - .5) * 40, e.y = i ? -e.r - Math.random() * n * .55 : Math.random() * n, e.vx = (-1.2 - Math.random() * 4.8 + (Math.random() - .5) * 1.2) * o, e.vy = (5.5 + Math.random() * 11) * o, e.bounces = 0, e.opacity = .45 + Math.random() * .55, e.delay = Math.floor(Math.random() * (i ? 110 : 45)), e.gravity = (.11 + Math.random() * .14) * (.9 + o * .1), e.phase = Math.random() * Math.PI * 2, e.gust = (Math.random() - .5) * 1.4, e.maxBounces = +(Math.random() < .62), e.sprite = it(r), e.drawSize = e.r * 2.8 + 4, e.rotation = Math.random() * Math.PI * 2, e.rotationSpeed = (Math.random() - .5) * .06;
|
|
610
|
+
}, ot = (e, t, n, r, i = 1) => {
|
|
611
611
|
let a = {
|
|
612
612
|
x: 0,
|
|
613
613
|
y: 0,
|
|
@@ -626,11 +626,11 @@ var et = 3.2, tt = (e) => {
|
|
|
626
626
|
rotation: 0,
|
|
627
627
|
rotationSpeed: 0
|
|
628
628
|
};
|
|
629
|
-
return
|
|
629
|
+
return at(a, e, t, n, Math.random() < .72, r, i), a;
|
|
630
630
|
};
|
|
631
631
|
//#endregion
|
|
632
632
|
//#region src/components/weatherBackground/scene/draw-precipitation.ts
|
|
633
|
-
function
|
|
633
|
+
function st(e) {
|
|
634
634
|
if (!e.cfg.rain) return;
|
|
635
635
|
let { alpha: t, splash: n } = e.cfg.rain, r = e.cfg.rain.wind * e.windMotion.rain, { intensity: i, angle: a, uy: o } = e.windField, s = r * i * Math.cos(a), c = Math.abs(r) * i * o * .35;
|
|
636
636
|
e.ctx.strokeStyle = `rgba(214, 228, 240, ${t})`, e.ctx.lineWidth = 1.2, e.ctx.beginPath();
|
|
@@ -652,7 +652,7 @@ function ot(e) {
|
|
|
652
652
|
e.ctx.beginPath(), e.ctx.ellipse(n.x, e.height - 3, n.r, n.r * .35, 0, Math.PI, Math.PI * 2), e.ctx.strokeStyle = `rgba(214, 228, 240, ${n.alpha})`, e.ctx.lineWidth = 1, e.ctx.stroke();
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function ct(e) {
|
|
656
656
|
let t = e.windMotion.snowDrift, { intensity: n, angle: r, uy: i } = e.windField, a = t * n * Math.cos(r), o = Math.abs(t) * n * i * .4;
|
|
657
657
|
for (let t of e.state.flakes) {
|
|
658
658
|
t.y += t.speed + o, t.x += Math.sin(e.state.t * .02 + t.phase) * (.3 + t.size * .08) + t.drift + a, t.rotation += t.rotationSpeed, t.y - t.drawSize > e.height && (t.y = -t.drawSize, t.x = Math.random() * e.width, t.phase = Math.random() * Math.PI * 2, t.drift = (Math.random() - .5) * .4, t.opacity = .55 + Math.random() * .45), t.x > e.width + 20 && (t.x = -20), t.x < -20 && (t.x = e.width + 20);
|
|
@@ -660,7 +660,7 @@ function st(e) {
|
|
|
660
660
|
e.ctx.save(), e.ctx.globalAlpha = t.opacity, e.ctx.translate(t.x, t.y), e.ctx.rotate(t.rotation), e.ctx.drawImage(t.sprite, -n, -n, t.drawSize, t.drawSize), e.ctx.restore();
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
function
|
|
663
|
+
function lt(e) {
|
|
664
664
|
if (e.state.hailstones.length === 0) return;
|
|
665
665
|
let t = e.state.hailPool, n = e.windMotion.hail, r = e.state.t, i = e.windField;
|
|
666
666
|
for (let a of e.state.hailstones) {
|
|
@@ -668,10 +668,10 @@ function ct(e) {
|
|
|
668
668
|
--a.delay;
|
|
669
669
|
continue;
|
|
670
670
|
}
|
|
671
|
-
let o =
|
|
671
|
+
let o = $(r + a.phase * 12, e.windMotion, a.x, a.y), s = o.intensity * (.4 + .6 * i.intensity), c = o.angle * .5 + i.angle * .5, l = e.windMotion.snowDrift * .45 * s * Math.cos(c), u = Math.abs(e.windMotion.snowDrift) * s * Math.sin(c) * .2, d = a.x, f = a.y;
|
|
672
672
|
if (a.vy += a.gravity + u * .02, a.vx += a.gust * .004 * n * s + l + (Math.random() - .5) * .08 * n * s, a.x += a.vx + Math.sin(r * .028 + a.phase) * .35, a.y += a.vy, e.ctx.beginPath(), e.ctx.moveTo(d, f), e.ctx.lineTo(a.x, a.y), e.ctx.strokeStyle = `rgba(225, 239, 250, ${a.opacity * .18})`, e.ctx.lineWidth = a.r * .35, e.ctx.stroke(), a.y + a.r >= e.height) if (a.bounces < a.maxBounces) a.y = e.height - a.r, a.vy *= -(.22 + Math.random() * .28), a.vx = a.vx * (.55 + Math.random() * .25) + (Math.random() - .5) * 1.6, a.bounces += 1;
|
|
673
673
|
else {
|
|
674
|
-
|
|
674
|
+
at(a, e.width, e.height, t, !0, e.hailSpec ? {
|
|
675
675
|
min: e.hailSpec.sizeMin,
|
|
676
676
|
max: e.hailSpec.sizeMax
|
|
677
677
|
} : void 0, e.hailSpec?.speedMul ?? 1);
|
|
@@ -683,10 +683,10 @@ function ct(e) {
|
|
|
683
683
|
}
|
|
684
684
|
//#endregion
|
|
685
685
|
//#region src/components/weatherBackground/scene/draw-sky.ts
|
|
686
|
-
function
|
|
686
|
+
function ut(e) {
|
|
687
687
|
e.ctx.fillStyle = e.skyGradient, e.ctx.fillRect(0, 0, e.width, e.height);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function dt(e) {
|
|
690
690
|
if (e.state.stars.length === 0) return;
|
|
691
691
|
let t = 1;
|
|
692
692
|
if (e.dayCycle) {
|
|
@@ -698,25 +698,25 @@ function ut(e) {
|
|
|
698
698
|
e.ctx.beginPath(), e.ctx.arc(n.x, n.y, n.r, 0, Math.PI * 2), e.ctx.fillStyle = `rgba(226, 235, 255, ${r * t})`, e.ctx.fill();
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
function
|
|
701
|
+
function ft(e) {
|
|
702
702
|
let t = e.celestial;
|
|
703
703
|
if (!t) return;
|
|
704
|
-
let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ?
|
|
704
|
+
let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ? E(e.dayCycle) : {
|
|
705
705
|
scale: 1,
|
|
706
706
|
alpha: 1
|
|
707
707
|
}, c = t.half * o * s.scale, l = c * 2;
|
|
708
708
|
n.save(), n.globalAlpha = s.alpha, n.drawImage(t.canvas, r - c, i - c, l, l), n.restore();
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function pt(e) {
|
|
711
711
|
if (e.activeNight) {
|
|
712
|
-
|
|
712
|
+
dt(e), ft(e);
|
|
713
713
|
return;
|
|
714
714
|
}
|
|
715
|
-
|
|
715
|
+
ft(e);
|
|
716
716
|
}
|
|
717
717
|
//#endregion
|
|
718
718
|
//#region src/components/weatherBackground/configs.ts
|
|
719
|
-
var
|
|
719
|
+
var mt = {
|
|
720
720
|
sunny: {
|
|
721
721
|
sky: ["#4a9fe0", "#c8e8fb"],
|
|
722
722
|
sun: "full",
|
|
@@ -1048,7 +1048,7 @@ var pt = {
|
|
|
1048
1048
|
snowCount: 160,
|
|
1049
1049
|
lightning: !1
|
|
1050
1050
|
}
|
|
1051
|
-
},
|
|
1051
|
+
}, ht = {
|
|
1052
1052
|
sunny: {
|
|
1053
1053
|
sky: ["#0b1a33", "#27476e"],
|
|
1054
1054
|
stars: 110
|
|
@@ -1117,14 +1117,14 @@ var pt = {
|
|
|
1117
1117
|
sky: ["#101a26", "#2e3d4d"],
|
|
1118
1118
|
stars: 30
|
|
1119
1119
|
}
|
|
1120
|
-
},
|
|
1120
|
+
}, gt = ([e, t, n]) => [
|
|
1121
1121
|
Math.round(e * .3 + 18),
|
|
1122
1122
|
Math.round(t * .3 + 24),
|
|
1123
1123
|
Math.round(n * .3 + 42)
|
|
1124
1124
|
];
|
|
1125
1125
|
//#endregion
|
|
1126
1126
|
//#region src/components/weatherBackground/sprites/cloud.ts
|
|
1127
|
-
function
|
|
1127
|
+
function _t(e, t, n, r) {
|
|
1128
1128
|
let [i, a, o] = n, s = Infinity, c = Infinity, l = -Infinity, u = -Infinity;
|
|
1129
1129
|
for (let n of t) {
|
|
1130
1130
|
let t = n.dx * e, r = n.dy * e, i = n.r * e;
|
|
@@ -1143,12 +1143,12 @@ function gt(e, t, n, r) {
|
|
|
1143
1143
|
oy: f
|
|
1144
1144
|
};
|
|
1145
1145
|
}
|
|
1146
|
-
function
|
|
1146
|
+
function vt(e, t, n, r, i) {
|
|
1147
1147
|
let a = .7 + Math.random() * .9, o = 4 + Math.floor(Math.random() * 3), s = Array.from({ length: o }, (e, t) => ({
|
|
1148
1148
|
dx: (t - o / 2) * 26 + (Math.random() - .5) * 14,
|
|
1149
1149
|
dy: (Math.random() - .5) * 14,
|
|
1150
1150
|
r: 22 + Math.random() * 20
|
|
1151
|
-
})), { sprite: c, ox: l, oy: u } =
|
|
1151
|
+
})), { sprite: c, ox: l, oy: u } = _t(a, s, r, i);
|
|
1152
1152
|
return {
|
|
1153
1153
|
x: Math.random() * (e + 240) - 120,
|
|
1154
1154
|
y: t * .06 + Math.random() * t * n,
|
|
@@ -1160,7 +1160,7 @@ function _t(e, t, n, r, i) {
|
|
|
1160
1160
|
oy: u
|
|
1161
1161
|
};
|
|
1162
1162
|
}
|
|
1163
|
-
function
|
|
1163
|
+
function yt(e, t = 120) {
|
|
1164
1164
|
let n = t * 2, r = document.createElement("canvas");
|
|
1165
1165
|
r.width = n, r.height = n;
|
|
1166
1166
|
let i = r.getContext("2d"), a = i.createRadialGradient(t, t, 0, t, t, t);
|
|
@@ -1171,7 +1171,7 @@ function vt(e, t = 120) {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
//#endregion
|
|
1173
1173
|
//#region src/components/weatherBackground/sprites/celestial.ts
|
|
1174
|
-
function
|
|
1174
|
+
function bt(e, t) {
|
|
1175
1175
|
let n = e.sun;
|
|
1176
1176
|
if (n === "none") return null;
|
|
1177
1177
|
let r = n === "full" ? 1 : n === "soft" ? .62 : .32, i = t * (n === "full" ? .72 : n === "soft" ? .62 : .5), a = t * (n === "full" ? 7.2 : n === "soft" ? 5.2 : 3.6), o = a;
|
|
@@ -1199,7 +1199,7 @@ function yt(e, t) {
|
|
|
1199
1199
|
breathAmp: .018
|
|
1200
1200
|
};
|
|
1201
1201
|
}
|
|
1202
|
-
function
|
|
1202
|
+
function xt(e, t, n) {
|
|
1203
1203
|
if (e.sun === "none") return null;
|
|
1204
1204
|
let r = t * .82, i = e.sun === "dim", a = i ? .45 : 1, o = r * (i ? 4.2 : 6.2), s = Math.ceil(Math.max(o, r * 2.6, r * 1.35) + 2), c = s * 2, l = document.createElement("canvas");
|
|
1205
1205
|
l.width = c, l.height = c;
|
|
@@ -1253,12 +1253,12 @@ function bt(e, t, n) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
//#endregion
|
|
1255
1255
|
//#region src/components/weatherBackground/sprites/snow.ts
|
|
1256
|
-
var
|
|
1256
|
+
var St = (e) => {
|
|
1257
1257
|
let t = Math.ceil(e * 2 + 4), n = document.createElement("canvas");
|
|
1258
1258
|
n.width = t, n.height = t;
|
|
1259
1259
|
let r = n.getContext("2d"), i = r.createRadialGradient(t / 2, t / 2, 0, t / 2, t / 2, e + 1);
|
|
1260
1260
|
return i.addColorStop(0, "rgba(255, 255, 255, 1)"), i.addColorStop(.6, "rgba(255, 255, 255, 0.85)"), i.addColorStop(1, "rgba(255, 255, 255, 0)"), r.fillStyle = i, r.fillRect(0, 0, t, t), n;
|
|
1261
|
-
},
|
|
1261
|
+
}, Ct = (e) => {
|
|
1262
1262
|
let t = Math.ceil(e * 2 + 6), n = document.createElement("canvas");
|
|
1263
1263
|
n.width = t, n.height = t;
|
|
1264
1264
|
let r = n.getContext("2d");
|
|
@@ -1285,22 +1285,22 @@ var xt = (e) => {
|
|
|
1285
1285
|
r.closePath(), r.stroke();
|
|
1286
1286
|
}
|
|
1287
1287
|
return n;
|
|
1288
|
-
},
|
|
1288
|
+
}, wt = () => ({
|
|
1289
1289
|
dots: [
|
|
1290
1290
|
1.2,
|
|
1291
1291
|
1.6,
|
|
1292
1292
|
2,
|
|
1293
1293
|
2.3
|
|
1294
|
-
].map((e) =>
|
|
1294
|
+
].map((e) => St(e)),
|
|
1295
1295
|
crystals: [
|
|
1296
1296
|
2.6,
|
|
1297
1297
|
3.2,
|
|
1298
1298
|
3.8,
|
|
1299
1299
|
4.4,
|
|
1300
1300
|
5
|
|
1301
|
-
].map((e) =>
|
|
1302
|
-
}),
|
|
1303
|
-
let i = 1 + Math.random() ** 1.6 * 4.2, a = i >= 2.4, o =
|
|
1301
|
+
].map((e) => Ct(e * 2.4))
|
|
1302
|
+
}), Tt = (e) => e[Math.floor(Math.random() * e.length)], Et = (e, t, n, r) => {
|
|
1303
|
+
let i = 1 + Math.random() ** 1.6 * 4.2, a = i >= 2.4, o = Tt(a ? n.crystals : n.dots), s = a ? i * 4.8 + 6 : i * 2 + 4;
|
|
1304
1304
|
return {
|
|
1305
1305
|
x: Math.random() * e,
|
|
1306
1306
|
y: r ?? Math.random() * t,
|
|
@@ -1314,25 +1314,25 @@ var xt = (e) => {
|
|
|
1314
1314
|
sprite: o,
|
|
1315
1315
|
drawSize: s
|
|
1316
1316
|
};
|
|
1317
|
-
},
|
|
1318
|
-
function
|
|
1319
|
-
let { ctx: t, width: n, height: r, activeWeather: i, dayCycleTimes: a = null, sceneTimeMs: o, liveClock: s = !1, windMotion: c, rainLevel: l = 5, snowLevel: u = 5, hailLevel: d = 2, fogLevel: f = 2, smogLevel: p = 2 } = e, m =
|
|
1317
|
+
}, Dt = (e, t) => t ? e === "smog" ? "96, 88, 66" : "138, 150, 168" : e === "smog" ? "168, 155, 126" : "226, 232, 238";
|
|
1318
|
+
function Ot(e) {
|
|
1319
|
+
let { ctx: t, width: n, height: r, activeWeather: i, dayCycleTimes: a = null, sceneTimeMs: o, liveClock: s = !1, windMotion: c, rainLevel: l = 5, snowLevel: u = 5, hailLevel: d = 2, fogLevel: f = 2, smogLevel: p = 2 } = e, m = mt[i], h = (() => {
|
|
1320
1320
|
let e = m;
|
|
1321
|
-
return
|
|
1321
|
+
return de(i) && e.rain && (e = {
|
|
1322
1322
|
...e,
|
|
1323
|
-
rain:
|
|
1324
|
-
}),
|
|
1323
|
+
rain: ge(e.rain, l)
|
|
1324
|
+
}), fe(i) && (e = {
|
|
1325
1325
|
...e,
|
|
1326
|
-
snowCount:
|
|
1326
|
+
snowCount: _e(u),
|
|
1327
1327
|
fogBanks: u >= 7 ? Math.max(e.fogBanks, 3) : e.fogBanks,
|
|
1328
1328
|
haze: u >= 7 ? Math.max(e.haze, .12) : e.haze
|
|
1329
|
-
}),
|
|
1330
|
-
})(), g =
|
|
1331
|
-
if (
|
|
1332
|
-
let e =
|
|
1333
|
-
|
|
1329
|
+
}), j(i) && (e = M(e, f)), Ce(i) && (e = we(e, p)), e;
|
|
1330
|
+
})(), g = ht[i], _ = a ?? null, v = _ ? b(s ? Date.now() : o, _) : null, y = v ? !v.isDay : !1, S = v ? ee(h.sky, g.sky, v) : y ? g.sky : h.sky, C = y ? gt(h.cloudColor) : h.cloudColor, w = Math.min(n, r) * .09, T = n * .72, E = r * .26;
|
|
1331
|
+
if (v) {
|
|
1332
|
+
let e = x(n, r, v.arcProgress);
|
|
1333
|
+
T = e.x, E = e.y;
|
|
1334
1334
|
}
|
|
1335
|
-
let
|
|
1335
|
+
let D = te(t, r, S), O = [
|
|
1336
1336
|
{
|
|
1337
1337
|
dx: -.32,
|
|
1338
1338
|
dy: .08,
|
|
@@ -1353,29 +1353,29 @@ function Dt(e) {
|
|
|
1353
1353
|
dy: .24,
|
|
1354
1354
|
r: .07
|
|
1355
1355
|
}
|
|
1356
|
-
],
|
|
1356
|
+
], k = bt(h, w), A = xt(h, w, O), P = y ? A : k, F = y || _ != null ? Array.from({ length: g.stars }, () => ({
|
|
1357
1357
|
x: Math.random() * n,
|
|
1358
1358
|
y: Math.random() * r * .72,
|
|
1359
1359
|
r: .4 + Math.random() * 1.1,
|
|
1360
1360
|
phase: Math.random() * Math.PI * 2,
|
|
1361
1361
|
speed: .015 + Math.random() * .035
|
|
1362
|
-
})) : [],
|
|
1362
|
+
})) : [], I = Array.from({ length: h.cloudCount }, () => vt(n, r, h.cloudSpread, C, h.cloudAlpha)), L = h.rain ? Array.from({ length: h.rain.count }, () => ({
|
|
1363
1363
|
x: Math.random() * (n + 160) - 80,
|
|
1364
1364
|
y: Math.random() * r,
|
|
1365
1365
|
len: 8 + Math.random() * 10,
|
|
1366
1366
|
speed: h.rain.speed * (.75 + Math.random() * .5)
|
|
1367
|
-
})) : [],
|
|
1367
|
+
})) : [], R = [], z = Array.from({ length: h.fogBanks }, (e, t) => ({
|
|
1368
1368
|
x: Math.random() * n,
|
|
1369
1369
|
y: t / Math.max(h.fogBanks - 1, 1) * r * .9 + r * .05,
|
|
1370
1370
|
rw: n * (.25 + Math.random() * .3),
|
|
1371
1371
|
rh: r * (.08 + Math.random() * .08),
|
|
1372
1372
|
speed: (.1 + Math.random() * .25) * (t % 2 == 0 ? 1 : -1),
|
|
1373
|
-
alpha: (.1 + Math.random() * .1) * (
|
|
1374
|
-
})),
|
|
1375
|
-
min:
|
|
1376
|
-
max:
|
|
1377
|
-
},
|
|
1378
|
-
let { count: e } =
|
|
1373
|
+
alpha: (.1 + Math.random() * .1) * (j(i) ? N(f) : Ce(i) ? Te(p) : 1)
|
|
1374
|
+
})), V = h.fogBanks > 0 ? yt(Dt(i, y)) : null, H = h.snowCount > 0 ? wt() : null, U = H == null ? [] : Array.from({ length: h.snowCount }, () => Et(n, r, H)), W = B(i) ? ne(d) : null, G = W == null ? null : rt(), K = G != null && W != null ? Array.from({ length: W.count }, () => ot(n, r, G, {
|
|
1375
|
+
min: W.sizeMin,
|
|
1376
|
+
max: W.sizeMax
|
|
1377
|
+
}, W.speedMul)) : [], q = (() => {
|
|
1378
|
+
let { count: e } = We(c.visualLevel);
|
|
1379
1379
|
return e <= 0 ? [] : Array.from({ length: e }, () => ({
|
|
1380
1380
|
x: Math.random() * n,
|
|
1381
1381
|
y: Math.random() * r,
|
|
@@ -1386,166 +1386,172 @@ function Dt(e) {
|
|
|
1386
1386
|
width: .5 + Math.random() * 1.1,
|
|
1387
1387
|
phase: Math.random() * Math.PI * 2
|
|
1388
1388
|
}));
|
|
1389
|
-
})(),
|
|
1389
|
+
})(), J = [], re = 120 + Math.random() * 240;
|
|
1390
1390
|
return {
|
|
1391
1391
|
sky: S,
|
|
1392
1392
|
cloudRgb: C,
|
|
1393
1393
|
cfg: h,
|
|
1394
|
-
sunX:
|
|
1395
|
-
sunY:
|
|
1396
|
-
sunR:
|
|
1397
|
-
skyGradient:
|
|
1398
|
-
celestial:
|
|
1399
|
-
sunSprite:
|
|
1400
|
-
moonSprite:
|
|
1401
|
-
fogSprite:
|
|
1394
|
+
sunX: T,
|
|
1395
|
+
sunY: E,
|
|
1396
|
+
sunR: w,
|
|
1397
|
+
skyGradient: D,
|
|
1398
|
+
celestial: P,
|
|
1399
|
+
sunSprite: k,
|
|
1400
|
+
moonSprite: A,
|
|
1401
|
+
fogSprite: V,
|
|
1402
1402
|
dayCycleTimes: _,
|
|
1403
|
-
dayCycle:
|
|
1403
|
+
dayCycle: v,
|
|
1404
1404
|
sceneTimeMs: o,
|
|
1405
1405
|
liveClock: s,
|
|
1406
|
-
hailSpec:
|
|
1406
|
+
hailSpec: W,
|
|
1407
1407
|
state: {
|
|
1408
|
-
stars:
|
|
1409
|
-
moonCraters:
|
|
1410
|
-
clouds:
|
|
1411
|
-
drops:
|
|
1412
|
-
splashes:
|
|
1413
|
-
fogBanks:
|
|
1414
|
-
flakes:
|
|
1415
|
-
hailstones:
|
|
1416
|
-
hailPool:
|
|
1417
|
-
windStreaks:
|
|
1408
|
+
stars: F,
|
|
1409
|
+
moonCraters: O,
|
|
1410
|
+
clouds: I,
|
|
1411
|
+
drops: L,
|
|
1412
|
+
splashes: R,
|
|
1413
|
+
fogBanks: z,
|
|
1414
|
+
flakes: U,
|
|
1415
|
+
hailstones: K,
|
|
1416
|
+
hailPool: G ?? [],
|
|
1417
|
+
windStreaks: q,
|
|
1418
1418
|
t: 0,
|
|
1419
1419
|
flashAlpha: 0,
|
|
1420
1420
|
boltLife: 0,
|
|
1421
|
-
boltPoints:
|
|
1422
|
-
nextStrike:
|
|
1421
|
+
boltPoints: J,
|
|
1422
|
+
nextStrike: re
|
|
1423
1423
|
}
|
|
1424
1424
|
};
|
|
1425
1425
|
}
|
|
1426
|
-
function
|
|
1426
|
+
function kt(e, t) {
|
|
1427
1427
|
if (!e.dayCycleTimes) return;
|
|
1428
|
-
let n =
|
|
1429
|
-
e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient =
|
|
1428
|
+
let n = b(e.liveClock ? t ?? Date.now() : e.sceneTimeMs, e.dayCycleTimes), r = ht[e.activeWeather], i = ee(e.cfg.sky, r.sky, n), a = x(e.width, e.height, n.arcProgress);
|
|
1429
|
+
e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient = te(e.ctx, e.height, i), e.sunX = a.x, e.sunY = a.y, e.celestial = n.isDay ? e.sunSprite : e.moonSprite;
|
|
1430
1430
|
}
|
|
1431
1431
|
//#endregion
|
|
1432
1432
|
//#region src/components/weatherBackground/scene/create-weather-scene.ts
|
|
1433
|
-
function
|
|
1434
|
-
t && (e.state.t += 1), e.windField =
|
|
1433
|
+
function At(e, t) {
|
|
1434
|
+
t && (e.state.t += 1), e.windField = $(e.state.t, e.windMotion), e.dayCycleTimes && kt(e, e.liveClock ? Date.now() : e.sceneTimeMs), ut(e), pt(e), Ye(e), Xe(e), Ze(e), st(e), ct(e), lt(e), $e(e), et(e);
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1437
|
-
let { ctx: t, width: n, height: r, activeWeather:
|
|
1436
|
+
function jt(e) {
|
|
1437
|
+
let { ctx: t, width: n, height: r, activeWeather: s, activeNight: c, windMotion: l } = e, u = Ot(e), d = {
|
|
1438
1438
|
ctx: t,
|
|
1439
1439
|
width: n,
|
|
1440
1440
|
height: r,
|
|
1441
|
-
activeWeather:
|
|
1442
|
-
activeNight:
|
|
1443
|
-
windMotion:
|
|
1444
|
-
windField:
|
|
1445
|
-
...
|
|
1441
|
+
activeWeather: s,
|
|
1442
|
+
activeNight: u.dayCycle ? !u.dayCycle.isDay : c,
|
|
1443
|
+
windMotion: l,
|
|
1444
|
+
windField: $(0, l),
|
|
1445
|
+
...u
|
|
1446
1446
|
};
|
|
1447
|
-
|
|
1448
|
-
let
|
|
1449
|
-
|
|
1450
|
-
}),
|
|
1451
|
-
|
|
1447
|
+
d.dayCycleTimes && kt(d, d.liveClock ? Date.now() : d.sceneTimeMs);
|
|
1448
|
+
let f = document.hidden, p = o(), m = a((e) => {
|
|
1449
|
+
f = e;
|
|
1450
|
+
}), h = i((e) => {
|
|
1451
|
+
p = e;
|
|
1452
|
+
});
|
|
1453
|
+
if (p) return At(d, !1), () => {
|
|
1454
|
+
m(), h();
|
|
1455
|
+
};
|
|
1456
|
+
let g = 0, _ = () => {
|
|
1457
|
+
g = requestAnimationFrame(_), !f && (p || At(d, !0));
|
|
1452
1458
|
};
|
|
1453
|
-
return
|
|
1454
|
-
cancelAnimationFrame(
|
|
1459
|
+
return _(), () => {
|
|
1460
|
+
cancelAnimationFrame(g), m(), h();
|
|
1455
1461
|
};
|
|
1456
1462
|
}
|
|
1457
|
-
var
|
|
1463
|
+
var Mt = {
|
|
1458
1464
|
weatherBackground: "cos-weatherBackground-Mnm22",
|
|
1459
1465
|
canvas: "cos-canvas-nvqMt",
|
|
1460
1466
|
loadingOverlay: "cos-loadingOverlay-O58B7",
|
|
1461
1467
|
loadingSpinner: "cos-loadingSpinner-NQ9yG",
|
|
1462
1468
|
"weather-loading-spin": "cos-weather-loading-spin-IPFWZ"
|
|
1463
|
-
},
|
|
1464
|
-
let { hostRef:
|
|
1465
|
-
fill:
|
|
1469
|
+
}, Nt = ({ width: r, height: i, fill: a = !1, weather: o = "partlyCloudy", time: u = "14:00", live: d = !1, latitude: f, longitude: p, windLevel: m = 3, rainLevel: h = 5, snowLevel: g = 5, hailLevel: v = 2, fogLevel: x = 2, smogLevel: S = 2, onLiveWeather: C, loading: w = !1, ariaLabel: T, loadingText: ee = "天气加载中…" }) => {
|
|
1470
|
+
let { hostRef: te, width: E, height: D, hostStyle: O } = s({
|
|
1471
|
+
fill: a,
|
|
1466
1472
|
width: r,
|
|
1467
1473
|
height: i,
|
|
1468
1474
|
defaultWidth: 800,
|
|
1469
1475
|
defaultHeight: 450
|
|
1470
|
-
}),
|
|
1476
|
+
}), k = n(null), A = Fe(d, f != null && p != null ? {
|
|
1471
1477
|
latitude: f,
|
|
1472
1478
|
longitude: p
|
|
1473
|
-
} : void 0),
|
|
1474
|
-
sunrise:
|
|
1475
|
-
sunset:
|
|
1476
|
-
} :
|
|
1479
|
+
} : void 0), j = Y(d && A.weather ? A.weather : o), M = d && A.rainLevel != null ? A.rainLevel : h, N = d && A.snowLevel != null ? A.snowLevel : g, P = d && A.fogLevel != null ? A.fogLevel : x, F = d && A.hailLevel != null ? A.hailLevel : v, I = d && A.smogLevel != null ? A.smogLevel : S, L = he(j, M, N), R = y(u), z = A.current?.sunrise ?? null, B = A.current?.sunset ?? null, ne = A.current?.windSpeed ?? null, V = t(() => d && z != null && B != null ? {
|
|
1480
|
+
sunrise: z,
|
|
1481
|
+
sunset: B
|
|
1482
|
+
} : _(R), [
|
|
1477
1483
|
d,
|
|
1484
|
+
z,
|
|
1478
1485
|
B,
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
]), U = qe({
|
|
1486
|
+
R
|
|
1487
|
+
]), H = Je({
|
|
1482
1488
|
live: d,
|
|
1483
1489
|
windLevel: m,
|
|
1484
|
-
liveWindKmh:
|
|
1485
|
-
}),
|
|
1490
|
+
liveWindKmh: ne
|
|
1491
|
+
}), U = t(() => qe(H), [H]), W = d && A.current ? !A.current.isDay : !b(R, V).isDay, G = w || d && (A.status === "locating" || A.status === "fetching"), K = n(C);
|
|
1486
1492
|
return e(() => {
|
|
1487
|
-
|
|
1493
|
+
K.current = C;
|
|
1488
1494
|
}), e(() => {
|
|
1489
|
-
|
|
1490
|
-
}, [
|
|
1491
|
-
let e =
|
|
1495
|
+
A.weather && K.current?.(Y(A.weather));
|
|
1496
|
+
}, [A.weather]), e(() => {
|
|
1497
|
+
let e = k.current;
|
|
1492
1498
|
if (!e) return;
|
|
1493
1499
|
let t = window.devicePixelRatio || 1;
|
|
1494
|
-
e.width =
|
|
1500
|
+
e.width = E * t, e.height = D * t;
|
|
1495
1501
|
let n = e.getContext("2d");
|
|
1496
|
-
if (n) return n.setTransform(t, 0, 0, t, 0, 0),
|
|
1502
|
+
if (n) return n.setTransform(t, 0, 0, t, 0, 0), jt({
|
|
1497
1503
|
ctx: n,
|
|
1498
|
-
width:
|
|
1499
|
-
height:
|
|
1500
|
-
activeWeather:
|
|
1501
|
-
activeNight:
|
|
1502
|
-
dayCycleTimes:
|
|
1503
|
-
sceneTimeMs:
|
|
1504
|
+
width: E,
|
|
1505
|
+
height: D,
|
|
1506
|
+
activeWeather: L,
|
|
1507
|
+
activeNight: W,
|
|
1508
|
+
dayCycleTimes: V,
|
|
1509
|
+
sceneTimeMs: R,
|
|
1504
1510
|
liveClock: d,
|
|
1505
|
-
windMotion:
|
|
1506
|
-
rainLevel:
|
|
1507
|
-
snowLevel:
|
|
1508
|
-
fogLevel:
|
|
1509
|
-
hailLevel:
|
|
1510
|
-
smogLevel:
|
|
1511
|
+
windMotion: U,
|
|
1512
|
+
rainLevel: M,
|
|
1513
|
+
snowLevel: N,
|
|
1514
|
+
fogLevel: P,
|
|
1515
|
+
hailLevel: F,
|
|
1516
|
+
smogLevel: I
|
|
1511
1517
|
});
|
|
1512
1518
|
}, [
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1519
|
+
W,
|
|
1520
|
+
L,
|
|
1521
|
+
V,
|
|
1522
|
+
M,
|
|
1516
1523
|
N,
|
|
1517
1524
|
P,
|
|
1518
1525
|
F,
|
|
1519
1526
|
I,
|
|
1520
|
-
L,
|
|
1521
|
-
O,
|
|
1522
|
-
d,
|
|
1523
|
-
z,
|
|
1524
1527
|
D,
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1528
|
+
d,
|
|
1529
|
+
R,
|
|
1530
|
+
E,
|
|
1531
|
+
U
|
|
1532
|
+
]), /* @__PURE__ */ l("div", {
|
|
1533
|
+
ref: te,
|
|
1534
|
+
className: Mt.weatherBackground,
|
|
1535
|
+
style: O,
|
|
1536
|
+
children: [/* @__PURE__ */ c("canvas", {
|
|
1537
|
+
ref: k,
|
|
1538
|
+
className: Mt.canvas,
|
|
1533
1539
|
style: {
|
|
1534
|
-
width:
|
|
1535
|
-
height:
|
|
1540
|
+
width: E,
|
|
1541
|
+
height: D
|
|
1536
1542
|
},
|
|
1537
1543
|
role: "img",
|
|
1538
|
-
"aria-label":
|
|
1539
|
-
}),
|
|
1540
|
-
className:
|
|
1544
|
+
"aria-label": T ?? `天气背景:${j}${W ? "(夜间)" : ""},${U.level}级风`
|
|
1545
|
+
}), G && /* @__PURE__ */ l("div", {
|
|
1546
|
+
className: Mt.loadingOverlay,
|
|
1541
1547
|
role: "status",
|
|
1542
1548
|
"aria-live": "polite",
|
|
1543
|
-
children: [/* @__PURE__ */
|
|
1544
|
-
className:
|
|
1549
|
+
children: [/* @__PURE__ */ c("div", {
|
|
1550
|
+
className: Mt.loadingSpinner,
|
|
1545
1551
|
"aria-hidden": !0
|
|
1546
|
-
}), /* @__PURE__ */
|
|
1552
|
+
}), /* @__PURE__ */ c("span", { children: ee })]
|
|
1547
1553
|
})]
|
|
1548
1554
|
});
|
|
1549
1555
|
};
|
|
1550
1556
|
//#endregion
|
|
1551
|
-
export {
|
|
1557
|
+
export { D as DEFAULT_FOG_LEVEL, I as DEFAULT_HAIL_LEVEL, W as DEFAULT_RAIN_LEVEL, be as DEFAULT_SMOG_LEVEL, G as DEFAULT_SNOW_LEVEL, Re as DEFAULT_WIND_LEVEL, O as FOG_LEVEL_LABELS, L as HAIL_LEVEL_LABELS, U as MAX_PRECIP_LEVEL, H as MIN_PRECIP_LEVEL, se as RAIN_LEVEL_LABELS, xe as SMOG_LEVEL_LABELS, ce as SNOW_LEVEL_LABELS, Nt as WeatherBackground, Nt as default, qe as buildWindMotion, k as clampFogLevel, R as clampHailLevel, K as clampPrecipLevel, Z as clampSmogLevel, N as fogBankAlphaScale, F as fogLevelFromVisibility, P as fogLevelFromWmo, A as formatFogLevel, z as formatHailLevel, Pe as formatLocalHm, oe as formatPrecipLevel, Se as formatSmogLevel, V as hailLevelFromWmo, ne as hailSpec, M as intensifyFogConfig, ge as intensifyRainConfig, we as intensifySmogConfig, _e as intensifySnowCount, le as isRainWeather, ue as isSnowWeather, Ke as kmhToWindLevel, Oe as mapWmoCodeToWeatherType, Y as normalizeWeatherType, J as precipBand, ae as precipLabel, pe as rainLevelFromWeather, ve as rainLevelFromWmo, he as resolveSceneWeather, $ as sampleWindField, Te as smogBankAlphaScale, Ee as smogLevelFromVisibility, me as snowLevelFromWeather, ye as snowLevelFromWmo, j as supportsFogLevel, B as supportsHailLevel, de as supportsRainLevel, Ce as supportsSmogLevel, fe as supportsSnowLevel, Fe as useLiveWeather, Le as useSunTimes, Be as visualWindLevel, Ge as windLevelToKmh, We as windStreakSpec };
|