@cos-design/weather-background 3.5.4 → 3.5.5
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 +209 -205
- package/dist/packages/shared/src/index.d.ts +10 -3
- package/dist/packages/shared/src/math.d.ts +1 -0
- package/dist/packages/shared/src/photo.d.ts +15 -0
- package/dist/packages/shared/src/pointer.d.ts +14 -0
- package/dist/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/packages/shared/src/size.d.ts +8 -0
- package/dist/packages/shared/src/use-element-size.d.ts +45 -0
- package/dist/packages/shared/src/visibility.d.ts +2 -0
- package/dist/src/components/weatherBackground/types.d.ts +6 -0
- package/package.json +2 -2
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}},S=(e,t,n)=>{let r=d(n),i=Math.sin(Math.PI*r);return{x:e*(.1+.8*r),y:t*(.58-.4*i)}},C=`#e8895c`,w=`#f3c98a`,T=`#2a1f4a`,E=`#c4784a`,D=(e,t,n)=>{if(n.isDay){let t=_(n.elevation),r=(1-t)*.72;return[g(g(e[0],C,r),`#1a2438`,(1-t)*.12),g(g(e[1],w,r*.85),`#3a4558`,(1-t)*.08)]}let r=n.twilight;return[g(t[0],g(T,C,.35),r*.55),g(t[1],g(E,w,.4),r*.7)]},O=(e,t,n)=>{let r=e.createLinearGradient(0,0,0,t);return r.addColorStop(0,n[0]),r.addColorStop(1,n[1]),r},k=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}},A=2,j=[``,`薄雾`,`中雾`,`浓雾`],M=e=>Math.min(3,Math.max(1,Math.round(e))),N=e=>{let t=M(e);return`${t} · ${j[t]}`},P=e=>e===`fog`,F=(e,t)=>{let n=M(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`}},I=e=>{let t=M(e);return t===1?.45:t===3?.95:.65},L=e=>e===45?2:e===48?3:null,R=e=>e==null||!Number.isFinite(e)?null:e>=5e3?1:e>=1e3?2:3,ee=2,z=[``,`细雹`,`密雹`,`巨雹`],B=e=>Math.min(3,Math.max(1,Math.round(e))),te=e=>{let t=B(e);return`${t} · ${z[t]}`},ne=e=>e===`hail`,re=e=>{let t=B(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}},V=e=>e===96?2:e===99?3:null,ie=1,H=10,U=5,ae=5,W=e=>Math.min(10,Math.max(1,Math.round(e))),G=(e,t,n)=>e+(t-e)*n,K=e=>{let t=W(e);return t<=2?1:t<=4?2:t<=6?3:t<=8?4:5},oe=[`毛毛雨`,`小雨`,`中雨`,`暴雨`,`特大暴雨`],se=[`毛毛雪`,`小雪`,`中雪`,`暴雪`,`特大暴雪`],ce=(e,t)=>{let n=K(e);return(t===`rain`?oe:se)[n-1]},le=(e,t)=>`${W(e)} · ${ce(e,t)}`,ue=[``,...oe],de=[``,...se],q=e=>e===`lightRain`||e===`moderateRain`||e===`heavyRain`?`rain`:e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`?`snow`:e,fe=e=>e===`rain`||e===`lightRain`||e===`moderateRain`||e===`heavyRain`,pe=e=>e===`snow`||e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`,me=e=>fe(e)||e===`thunderstorm`||e===`sleet`,he=e=>pe(e)||e===`sleet`,ge=(e,t=5)=>e===`lightRain`?3:e===`moderateRain`?5:e===`heavyRain`?8:W(t),_e=(e,t=5)=>e===`lightSnow`?3:e===`moderateSnow`?5:e===`heavySnow`?8:W(t),J=(e,t)=>t===`rain`?e<=2?`lightRain`:e===3?`moderateRain`:`heavyRain`:e<=2?`lightSnow`:e===3?`moderateSnow`:`heavySnow`,ve=(e,t=5,n=5)=>e===`rain`?J(K(t),`rain`):e===`lightRain`||e===`moderateRain`||e===`heavyRain`?J(K(ge(e)),`rain`):e===`snow`?J(K(n),`snow`):e===`lightSnow`||e===`moderateSnow`||e===`heavySnow`?J(K(_e(e)),`snow`):e,ye=(e,t)=>{let n=(W(t)-1)/9;return{count:Math.round(G(35,340,n)),speed:G(5.5,16,n),wind:G(-.4,-3.2,n),alpha:G(.28,.62,n),splash:W(t)>=5}},be=e=>{let t=(W(e)-1)/9;return Math.round(G(30,360,t))},xe=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,Se=e=>[77].includes(e)?2:[71,85].includes(e)?3:[73].includes(e)?5:[75].includes(e)?8:[86].includes(e)?10:null,Ce=2,we=[``,`轻霾`,`中霾`,`重霾`],Y=e=>Math.min(3,Math.max(1,Math.round(e))),Te=e=>{let t=Y(e);return`${t} · ${we[t]}`},X=e=>e===`smog`,Ee=(e,t)=>{let n=Y(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`}},De=e=>{let t=Y(e);return t===1?.55:t===3?1.05:.85},Oe=e=>e==null||!Number.isFinite(e)?null:e>=5e3?1:e>=1e3?2:3,ke={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`},Ae=e=>q(ke[e]??`overcast`),je={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`idle`,error:null,current:null},Me={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`locating`,error:null,current:null},Ne={weather:null,rainLevel:null,snowLevel:null,fogLevel:null,hailLevel:null,smogLevel:null,status:`fetching`,error:null,current:null},Pe=e=>e!=null&&Number.isFinite(e.latitude)&&Number.isFinite(e.longitude),Z=e=>{if(typeof e!=`string`||!e)return null;let t=Date.parse(e);return Number.isFinite(t)?t:null},Fe=e=>{if(typeof e!=`string`||!e)return null;let t=e.match(/T(\d{2}):(\d{2})/);return t?`${t[1]}:${t[2]}`:null},Ie=(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},Le=(e=!0,t)=>{let n=Pe(t),r=n?t.latitude:null,i=n?t.longitude:null,a=e?n?Ne:Me:je,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=Z(o?.daily?.sunrise?.[0]),d=Z(o?.daily?.sunset?.[0]),f=typeof o?.timezone==`string`?o.timezone:null,p=Fe(o?.current?.time)??Ie(f),m=Ae(s),h=xe(s),g=Se(s),_=o?.current?.visibility,v=_!=null&&Number.isFinite(Number(_))?Number(_):null,y=m===`fog`?R(v)??L(s)??2:null,b=m===`hail`?V(s)??2:null,x=m===`smog`?Oe(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},Re=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=Z(a?.daily?.sunrise?.[0]),s=Z(a?.daily?.sunset?.[0]);return o==null||s==null?null:{sunrise:o,sunset:s}},ze=e=>{let t=Pe(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 Re(n,r,t.signal).then(t=>{e||o(t)}).catch(()=>{e||o(null)}),()=>{e=!0,t.abort()}},[n,r]),t?a:null},Be=3,Ve=e=>Math.min(12,Math.max(0,Math.round(e))),He=e=>Math.max(0,Ve(e)-2),Ue=.55,We=[0,3,8,16,24,33,44,55,68,81,95,110,125],Ge=[1,5,11,19,28,38,49,61,74,88,102,117,1/0],Q=(e,t,n=0,r=0)=>{let i=t.gustiness,a=t.wander,o=n*.0017+r*.0024,s=e*Ue,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)}},Ke=e=>{let t=Ve(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}},qe=e=>We[Ve(e)]??16,Je=e=>{let t=Math.max(0,e);for(let e=0;e<Ge.length;e++)if(t<=Ge[e])return e;return 12},Ye=e=>{let t=Je(e),n=He(t),r=qe(n),i=Math.max(.04,Math.min(r/16,4.2)),{alphaMul:a}=Ke(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}},Xe=e=>e.live&&e.liveWindKmh!=null&&Number.isFinite(e.liveWindKmh)?Math.max(0,e.liveWindKmh):qe(e.windLevel);function Ze(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 Qe(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 $e(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 et(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=et(e,t,o,s,i*.55,a-1),l=et(o,s,n,r,i*.55,a-1);return[...c.slice(0,-1),...l]}function tt(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=Q(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 nt(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=et(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 rt=3.2,it=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},at=(e=16)=>Array.from({length:e},()=>it(rt)),ot=e=>e[Math.floor(Math.random()*e.length)],st=(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=ot(r),e.drawSize=e.r*2.8+4,e.rotation=Math.random()*Math.PI*2,e.rotationSpeed=(Math.random()-.5)*.06},ct=(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 st(a,e,t,n,Math.random()<.72,r,i),a};function lt(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 ut(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 dt(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=Q(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{st(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 ft(e){e.ctx.fillStyle=e.skyGradient,e.ctx.fillRect(0,0,e.width,e.height)}function pt(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 mt(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?k(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 ht(e){if(e.activeNight){pt(e),mt(e);return}mt(e)}var gt={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}},_t={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}},vt=([e,t,n])=>[Math.round(e*.3+18),Math.round(t*.3+24),Math.round(n*.3+42)];function yt(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 bt(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}=yt(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 xt(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 St(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 Ct(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 wt=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},Tt=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},Et=()=>({dots:[1.2,1.6,2,2.3].map(e=>wt(e)),crystals:[2.6,3.2,3.8,4.4,5].map(e=>Tt(e*2.4))}),Dt=e=>e[Math.floor(Math.random()*e.length)],Ot=(e,t,n,r)=>{let i=1+Math.random()**1.6*4.2,a=i>=2.4,o=Dt(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}},kt=(e,t)=>t?e===`smog`?`96, 88, 66`:`138, 150, 168`:e===`smog`?`168, 155, 126`:`226, 232, 238`;function At(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=gt[i],h=(()=>{let e=m;return me(i)&&e.rain&&(e={...e,rain:ye(e.rain,l)}),he(i)&&(e={...e,snowCount:be(u),fogBanks:u>=7?Math.max(e.fogBanks,3):e.fogBanks,haze:u>=7?Math.max(e.haze,.12):e.haze}),P(i)&&(e=F(e,f)),X(i)&&(e=Ee(e,p)),e})(),g=_t[i],_=a??null,v=_?x(s?Date.now():o,_):null,y=v?!v.isDay:!1,b=v?D(h.sky,g.sky,v):y?g.sky:h.sky,C=y?vt(h.cloudColor):h.cloudColor,w=Math.min(n,r)*.09,T=n*.72,E=r*.26;if(v){let e=S(n,r,v.arcProgress);T=e.x,E=e.y}let k=O(t,r,b),A=[{dx:-.32,dy:.08,r:.17},{dx:.24,dy:-.22,r:.12},{dx:.04,dy:.34,r:.1},{dx:.36,dy:.24,r:.07}],j=St(h,w),M=Ct(h,w,A),N=y?M:j,L=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})):[],R=Array.from({length:h.cloudCount},()=>bt(n,r,h.cloudSpread,C,h.cloudAlpha)),ee=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)})):[],z=[],B=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)*(P(i)?I(f):X(i)?De(p):1)})),te=h.fogBanks>0?xt(kt(i,y)):null,V=h.snowCount>0?Et():null,ie=V==null?[]:Array.from({length:h.snowCount},()=>Ot(n,r,V)),H=ne(i)?re(d):null,U=H==null?null:at(),ae=U!=null&&H!=null?Array.from({length:H.count},()=>ct(n,r,U,{min:H.sizeMin,max:H.sizeMax},H.speedMul)):[],W=(()=>{let{count:e}=Ke(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}))})(),G=[],K=120+Math.random()*240;return{sky:b,cloudRgb:C,cfg:h,sunX:T,sunY:E,sunR:w,skyGradient:k,celestial:N,sunSprite:j,moonSprite:M,fogSprite:te,dayCycleTimes:_,dayCycle:v,sceneTimeMs:o,liveClock:s,hailSpec:H,state:{stars:L,moonCraters:A,clouds:R,drops:ee,splashes:z,fogBanks:B,flakes:ie,hailstones:ae,hailPool:U??[],windStreaks:W,t:0,flashAlpha:0,boltLife:0,boltPoints:G,nextStrike:K}}}function jt(e,t){if(!e.dayCycleTimes)return;let n=x(e.liveClock?t??Date.now():e.sceneTimeMs,e.dayCycleTimes),r=_t[e.activeWeather],i=D(e.cfg.sky,r.sky,n),a=S(e.width,e.height,n.arcProgress);e.dayCycle=n,e.activeNight=!n.isDay,e.sky=i,e.skyGradient=O(e.ctx,e.height,i),e.sunX=a.x,e.sunY=a.y,e.celestial=n.isDay?e.sunSprite:e.moonSprite}function Mt(e,t){t&&(e.state.t+=1),e.windField=Q(e.state.t,e.windMotion),e.dayCycleTimes&&jt(e,e.liveClock?Date.now():e.sceneTimeMs),ft(e),ht(e),Ze(e),Qe(e),$e(e),lt(e),ut(e),dt(e),tt(e),nt(e)}function Nt(e){let{ctx:t,width:n,height:r,activeWeather:i,activeNight:a,windMotion:o}=e,s=At(e),c={ctx:t,width:n,height:r,activeWeather:i,activeNight:s.dayCycle?!s.dayCycle.isDay:a,windMotion:o,windField:Q(0,o),...s};if(c.dayCycleTimes&&jt(c,c.liveClock?Date.now():c.sceneTimeMs),typeof window<`u`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return Mt(c,!1),()=>void 0;let u=0,d=document.hidden,f=(0,l.bindVisibilityPause)(e=>{d=e}),p=()=>{u=requestAnimationFrame(p),!d&&Mt(c,!0)};return p(),()=>{cancelAnimationFrame(u),f()}}var $={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=800,height:t=450,weather:n=`partlyCloudy`,time:r=`14:00`,live:i=!1,latitude:a,longitude:o,windLevel:s=3,rainLevel:l=5,snowLevel:d=5,hailLevel:f=2,fogLevel:p=2,smogLevel:m=2,onLiveWeather:h,loading:g=!1})=>{let _=(0,c.useRef)(null),y=Le(i,a!=null&&o!=null?{latitude:a,longitude:o}:void 0),S=q(i&&y.weather?y.weather:n),C=i&&y.rainLevel!=null?y.rainLevel:l,w=i&&y.snowLevel!=null?y.snowLevel:d,T=i&&y.fogLevel!=null?y.fogLevel:p,E=i&&y.hailLevel!=null?y.hailLevel:f,D=i&&y.smogLevel!=null?y.smogLevel:m,O=ve(S,C,w),k=b(r),A=y.current?.sunrise??null,j=y.current?.sunset??null,M=y.current?.windSpeed??null,N=(0,c.useMemo)(()=>i&&A!=null&&j!=null?{sunrise:A,sunset:j}:v(k),[i,A,j,k]),P=Xe({live:i,windLevel:s,liveWindKmh:M}),F=(0,c.useMemo)(()=>Ye(P),[P]),I=i&&y.current?!y.current.isDay:!x(k,N).isDay,L=g||i&&(y.status===`locating`||y.status===`fetching`),R=(0,c.useRef)(h);return(0,c.useEffect)(()=>{R.current=h}),(0,c.useEffect)(()=>{y.weather&&R.current?.(q(y.weather))},[y.weather]),(0,c.useEffect)(()=>{let n=_.current;if(!n)return;let r=window.devicePixelRatio||1;n.width=e*r,n.height=t*r;let a=n.getContext(`2d`);if(a)return a.setTransform(r,0,0,r,0,0),Nt({ctx:a,width:e,height:t,activeWeather:O,activeNight:I,dayCycleTimes:N,sceneTimeMs:k,liveClock:i,windMotion:F,rainLevel:C,snowLevel:w,fogLevel:T,hailLevel:E,smogLevel:D})},[I,O,N,C,w,T,E,D,t,i,k,e,F]),(0,u.jsxs)(`div`,{className:$.weatherBackground,style:{width:e,height:t},children:[(0,u.jsx)(`canvas`,{ref:_,className:$.canvas,style:{width:e,height:t},role:`img`,"aria-label":`天气背景:${S}${I?`(夜间)`:``},${F.level}级风`}),L&&(0,u.jsxs)(`div`,{className:$.loadingOverlay,role:`status`,"aria-live":`polite`,children:[(0,u.jsx)(`div`,{className:$.loadingSpinner,"aria-hidden":!0}),(0,u.jsx)(`span`,{children:`天气加载中…`})]})]})};exports.DEFAULT_FOG_LEVEL=A,exports.DEFAULT_HAIL_LEVEL=ee,exports.DEFAULT_RAIN_LEVEL=U,exports.DEFAULT_SMOG_LEVEL=Ce,exports.DEFAULT_SNOW_LEVEL=ae,exports.DEFAULT_WIND_LEVEL=Be,exports.FOG_LEVEL_LABELS=j,exports.HAIL_LEVEL_LABELS=z,exports.MAX_PRECIP_LEVEL=H,exports.MIN_PRECIP_LEVEL=ie,exports.RAIN_LEVEL_LABELS=ue,exports.SMOG_LEVEL_LABELS=we,exports.SNOW_LEVEL_LABELS=de,exports.WeatherBackground=Pt,exports.default=Pt,exports.buildWindMotion=Ye,exports.clampFogLevel=M,exports.clampHailLevel=B,exports.clampPrecipLevel=W,exports.clampSmogLevel=Y,exports.fogBankAlphaScale=I,exports.fogLevelFromVisibility=R,exports.fogLevelFromWmo=L,exports.formatFogLevel=N,exports.formatHailLevel=te,exports.formatLocalHm=Ie,exports.formatPrecipLevel=le,exports.formatSmogLevel=Te,exports.hailLevelFromWmo=V,exports.hailSpec=re,exports.intensifyFogConfig=F,exports.intensifyRainConfig=ye,exports.intensifySmogConfig=Ee,exports.intensifySnowCount=be,exports.isRainWeather=fe,exports.isSnowWeather=pe,exports.kmhToWindLevel=Je,exports.mapWmoCodeToWeatherType=Ae,exports.normalizeWeatherType=q,exports.precipBand=K,exports.precipLabel=ce,exports.rainLevelFromWeather=ge,exports.rainLevelFromWmo=xe,exports.resolveSceneWeather=ve,exports.sampleWindField=Q,exports.smogBankAlphaScale=De,exports.smogLevelFromVisibility=Oe,exports.snowLevelFromWeather=_e,exports.snowLevelFromWmo=Se,exports.supportsFogLevel=P,exports.supportsHailLevel=ne,exports.supportsRainLevel=me,exports.supportsSmogLevel=X,exports.supportsSnowLevel=he,exports.useLiveWeather=Le,exports.useSunTimes=ze,exports.visualWindLevel=He,exports.windLevelToKmh=qe,exports.windStreakSpec=Ke;
|
|
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;
|
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 { bindVisibilityPause as i } from "@cos-design/shared";
|
|
3
|
-
import { jsx as
|
|
2
|
+
import { bindVisibilityPause as i, useCanvasBox as a } from "@cos-design/shared";
|
|
3
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
4
|
import './index.css';//#region src/components/weatherBackground/day-cycle.ts
|
|
5
|
-
var
|
|
5
|
+
var c = (e) => Math.min(1, Math.max(0, e)), l = (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 s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
19
19
|
r >> 8 & 255,
|
|
20
20
|
r & 255
|
|
21
21
|
];
|
|
22
|
-
},
|
|
22
|
+
}, u = ([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
|
+
}, d = (e, t, n) => e + (t - e) * n, f = (e, t, n) => [
|
|
26
|
+
d(e[0], t[0], n),
|
|
27
|
+
d(e[1], t[1], n),
|
|
28
|
+
d(e[2], t[2], n)
|
|
29
|
+
], p = (e, t, n) => u(f(l(e), l(t), c(n))), m = (e) => {
|
|
30
|
+
let t = c(e);
|
|
31
31
|
return t * t * (3 - 2 * t);
|
|
32
|
-
},
|
|
32
|
+
}, h = (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,49 +37,49 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
37
37
|
sunrise: n.getTime(),
|
|
38
38
|
sunset: r.getTime()
|
|
39
39
|
};
|
|
40
|
-
},
|
|
40
|
+
}, g = (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
|
+
}, _ = (e, t = /* @__PURE__ */ new Date()) => g(e ?? "14:00", t) ?? g("14:00", t), v = (e, t) => {
|
|
48
48
|
let { sunrise: n, sunset: r } = t;
|
|
49
49
|
if (!(r > n)) {
|
|
50
|
-
let t =
|
|
50
|
+
let t = h(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,
|
|
54
|
-
if (
|
|
53
|
+
let i = Math.max(1, r - n), a = n + 1440 * 60 * 1e3, o = r - 1440 * 60 * 1e3, s = e >= n && e < r, l;
|
|
54
|
+
if (s) l = c((e - n) / i);
|
|
55
55
|
else if (e >= r) {
|
|
56
56
|
let t = Math.max(1, a - r);
|
|
57
|
-
l =
|
|
57
|
+
l = c((e - r) / t);
|
|
58
58
|
} else {
|
|
59
59
|
let t = Math.max(1, n - o);
|
|
60
|
-
l =
|
|
60
|
+
l = c((e - o) / t);
|
|
61
61
|
}
|
|
62
|
-
let u =
|
|
62
|
+
let u = s ? Math.sin(Math.PI * l) : 0, d = Math.abs(e - n), f = Math.abs(e - r), p = c(1 - Math.min(d, f) / 45e5);
|
|
63
63
|
return {
|
|
64
|
-
isDay:
|
|
64
|
+
isDay: s,
|
|
65
65
|
arcProgress: l,
|
|
66
66
|
elevation: u,
|
|
67
67
|
twilight: p
|
|
68
68
|
};
|
|
69
|
-
},
|
|
70
|
-
let r =
|
|
69
|
+
}, y = (e, t, n) => {
|
|
70
|
+
let r = c(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
|
+
}, b = "#e8895c", x = "#f3c98a", S = "#2a1f4a", C = "#c4784a", w = (e, t, n) => {
|
|
76
76
|
if (n.isDay) {
|
|
77
|
-
let t =
|
|
78
|
-
return [
|
|
77
|
+
let t = m(n.elevation), r = (1 - t) * .72;
|
|
78
|
+
return [p(p(e[0], b, r), "#1a2438", (1 - t) * .12), p(p(e[1], x, r * .85), "#3a4558", (1 - t) * .08)];
|
|
79
79
|
}
|
|
80
80
|
let r = n.twilight;
|
|
81
|
-
return [
|
|
82
|
-
},
|
|
81
|
+
return [p(t[0], p(S, b, .35), r * .55), p(t[1], p(C, x, .4), r * .7)];
|
|
82
|
+
}, ee = (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
|
}, T = (e) => {
|
|
@@ -150,36 +150,36 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (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, te = 1, H = 10, U = 5, W = 5, G = (e) => Math.min(10, Math.max(1, Math.round(e))), K = (e, t, n) => e + (t - e) * n, q = (e) => {
|
|
154
|
+
let t = G(e);
|
|
155
155
|
return t <= 2 ? 1 : t <= 4 ? 2 : t <= 6 ? 3 : t <= 8 ? 4 : 5;
|
|
156
|
-
},
|
|
156
|
+
}, ne = [
|
|
157
157
|
"毛毛雨",
|
|
158
158
|
"小雨",
|
|
159
159
|
"中雨",
|
|
160
160
|
"暴雨",
|
|
161
161
|
"特大暴雨"
|
|
162
|
-
],
|
|
162
|
+
], re = [
|
|
163
163
|
"毛毛雪",
|
|
164
164
|
"小雪",
|
|
165
165
|
"中雪",
|
|
166
166
|
"暴雪",
|
|
167
167
|
"特大暴雪"
|
|
168
|
-
],
|
|
169
|
-
let n =
|
|
170
|
-
return (t === "rain" ?
|
|
171
|
-
}, ae = (e, t) => `${
|
|
172
|
-
let n = (
|
|
168
|
+
], ie = (e, t) => {
|
|
169
|
+
let n = q(e);
|
|
170
|
+
return (t === "rain" ? ne : re)[n - 1];
|
|
171
|
+
}, ae = (e, t) => `${G(e)} · ${ie(e, t)}`, oe = ["", ...ne], se = ["", ...re], J = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? "rain" : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? "snow" : e, ce = (e) => e === "rain" || e === "lightRain" || e === "moderateRain" || e === "heavyRain", le = (e) => e === "snow" || e === "lightSnow" || e === "moderateSnow" || e === "heavySnow", ue = (e) => ce(e) || e === "thunderstorm" || e === "sleet", de = (e) => le(e) || e === "sleet", fe = (e, t = 5) => e === "lightRain" ? 3 : e === "moderateRain" ? 5 : e === "heavyRain" ? 8 : G(t), pe = (e, t = 5) => e === "lightSnow" ? 3 : e === "moderateSnow" ? 5 : e === "heavySnow" ? 8 : G(t), Y = (e, t) => t === "rain" ? e <= 2 ? "lightRain" : e === 3 ? "moderateRain" : "heavyRain" : e <= 2 ? "lightSnow" : e === 3 ? "moderateSnow" : "heavySnow", me = (e, t = 5, n = 5) => e === "rain" ? Y(q(t), "rain") : e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? Y(q(fe(e)), "rain") : e === "snow" ? Y(q(n), "snow") : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? Y(q(pe(e)), "snow") : e, he = (e, t) => {
|
|
172
|
+
let n = (G(t) - 1) / 9;
|
|
173
173
|
return {
|
|
174
|
-
count: Math.round(
|
|
175
|
-
speed:
|
|
176
|
-
wind:
|
|
177
|
-
alpha:
|
|
178
|
-
splash:
|
|
174
|
+
count: Math.round(K(35, 340, n)),
|
|
175
|
+
speed: K(5.5, 16, n),
|
|
176
|
+
wind: K(-.4, -3.2, n),
|
|
177
|
+
alpha: K(.28, .62, n),
|
|
178
|
+
splash: G(t) >= 5
|
|
179
179
|
};
|
|
180
180
|
}, ge = (e) => {
|
|
181
|
-
let t = (
|
|
182
|
-
return Math.round(
|
|
181
|
+
let t = (G(e) - 1) / 9;
|
|
182
|
+
return Math.round(K(30, 360, t));
|
|
183
183
|
}, _e = (e) => [51, 56].includes(e) ? 2 : [
|
|
184
184
|
61,
|
|
185
185
|
66,
|
|
@@ -195,11 +195,11 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
195
195
|
"轻霾",
|
|
196
196
|
"中霾",
|
|
197
197
|
"重霾"
|
|
198
|
-
],
|
|
199
|
-
let t =
|
|
198
|
+
], X = (e) => Math.min(3, Math.max(1, Math.round(e))), xe = (e) => {
|
|
199
|
+
let t = X(e);
|
|
200
200
|
return `${t} · ${be[t]}`;
|
|
201
201
|
}, Se = (e) => e === "smog", Ce = (e, t) => {
|
|
202
|
-
let n =
|
|
202
|
+
let n = X(t);
|
|
203
203
|
return n === 1 ? {
|
|
204
204
|
...e,
|
|
205
205
|
fogBanks: 5,
|
|
@@ -220,7 +220,7 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
220
220
|
sun: "dim"
|
|
221
221
|
};
|
|
222
222
|
}, we = (e) => {
|
|
223
|
-
let t =
|
|
223
|
+
let t = X(e);
|
|
224
224
|
return t === 1 ? .55 : t === 3 ? 1.05 : .85;
|
|
225
225
|
}, Te = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, Ee = {
|
|
226
226
|
0: "sunny",
|
|
@@ -251,7 +251,7 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
251
251
|
95: "thunderstorm",
|
|
252
252
|
96: "hail",
|
|
253
253
|
99: "hail"
|
|
254
|
-
}, De = (e) =>
|
|
254
|
+
}, De = (e) => J(Ee[e] ?? "overcast"), Oe = {
|
|
255
255
|
weather: null,
|
|
256
256
|
rainLevel: null,
|
|
257
257
|
snowLevel: null,
|
|
@@ -281,7 +281,7 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
281
281
|
status: "fetching",
|
|
282
282
|
error: null,
|
|
283
283
|
current: null
|
|
284
|
-
}, je = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude),
|
|
284
|
+
}, je = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude), Z = (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;
|
|
@@ -321,7 +321,7 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (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 = Z(o?.daily?.sunrise?.[0]), d = Z(o?.daily?.sunset?.[0]), f = typeof o?.timezone == "string" ? o.timezone : null, p = Me(o?.current?.time) ?? Ne(f), m = De(s), h = _e(s), g = ve(s), _ = o?.current?.visibility, v = _ != null && Number.isFinite(Number(_)) ? Number(_) : null, y = m === "fog" ? P(v) ?? N(s) ?? 2 : null, b = m === "hail" ? V(s) ?? 2 : null, x = m === "smog" ? Te(v) ?? 2 : null;
|
|
325
325
|
if (e) return;
|
|
326
326
|
u({
|
|
327
327
|
weather: m,
|
|
@@ -418,7 +418,7 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (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 = Z(a?.daily?.sunrise?.[0]), s = Z(a?.daily?.sunset?.[0]);
|
|
422
422
|
return o == null || s == null ? null : {
|
|
423
423
|
sunrise: o,
|
|
424
424
|
sunset: s
|
|
@@ -464,7 +464,7 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
464
464
|
102,
|
|
465
465
|
117,
|
|
466
466
|
Infinity
|
|
467
|
-
],
|
|
467
|
+
], Q = (e, t, n = 0, r = 0) => {
|
|
468
468
|
let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e * Be, 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));
|
|
@@ -485,12 +485,12 @@ var s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
485
485
|
count: Math.floor(3 + n * n * 50),
|
|
486
486
|
alphaMul: .1 + n * .9
|
|
487
487
|
};
|
|
488
|
-
},
|
|
488
|
+
}, We = (e) => Ve[Re(e)] ?? 16, Ge = (e) => {
|
|
489
489
|
let t = Math.max(0, e);
|
|
490
490
|
for (let e = 0; e < He.length; e++) if (t <= He[e]) return e;
|
|
491
491
|
return 12;
|
|
492
|
-
},
|
|
493
|
-
let t =
|
|
492
|
+
}, Ke = (e) => {
|
|
493
|
+
let t = Ge(e), n = ze(t), r = We(n), i = Math.max(.04, Math.min(r / 16, 4.2)), { alphaMul: a } = Ue(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 s = (e) => Math.min(1, Math.max(0, e)), c = (e) => {
|
|
|
506
506
|
gustiness: s,
|
|
507
507
|
wander: c
|
|
508
508
|
};
|
|
509
|
-
},
|
|
509
|
+
}, qe = (e) => e.live && e.liveWindKmh != null && Number.isFinite(e.liveWindKmh) ? Math.max(0, e.liveWindKmh) : We(e.windLevel);
|
|
510
510
|
//#endregion
|
|
511
511
|
//#region src/components/weatherBackground/scene/draw-atmosphere.ts
|
|
512
|
-
function
|
|
512
|
+
function Je(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 Ye(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 Je(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 Xe(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 Ze(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 = Ze(e, t, o, s, i * .55, a - 1), l = Ze(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 Qe(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 = Q(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 Ze(e) {
|
|
|
554
554
|
}
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function $e(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 = Ze(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 Qe(e) {
|
|
|
571
571
|
}
|
|
572
572
|
//#endregion
|
|
573
573
|
//#region src/components/weatherBackground/sprites/hail.ts
|
|
574
|
-
var
|
|
574
|
+
var et = 3.2, tt = (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 $e = 3.2, et = (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
|
+
}, nt = (e = 16) => Array.from({ length: e }, () => tt(et)), rt = (e) => e[Math.floor(Math.random() * e.length)], it = (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 = rt(r), e.drawSize = e.r * 2.8 + 4, e.rotation = Math.random() * Math.PI * 2, e.rotationSpeed = (Math.random() - .5) * .06;
|
|
610
|
+
}, at = (e, t, n, r, i = 1) => {
|
|
611
611
|
let a = {
|
|
612
612
|
x: 0,
|
|
613
613
|
y: 0,
|
|
@@ -626,11 +626,11 @@ var $e = 3.2, et = (e) => {
|
|
|
626
626
|
rotation: 0,
|
|
627
627
|
rotationSpeed: 0
|
|
628
628
|
};
|
|
629
|
-
return
|
|
629
|
+
return it(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 ot(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 at(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 st(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 ot(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 ct(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 st(e) {
|
|
|
668
668
|
--a.delay;
|
|
669
669
|
continue;
|
|
670
670
|
}
|
|
671
|
-
let o =
|
|
671
|
+
let o = Q(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
|
+
it(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 st(e) {
|
|
|
683
683
|
}
|
|
684
684
|
//#endregion
|
|
685
685
|
//#region src/components/weatherBackground/scene/draw-sky.ts
|
|
686
|
-
function
|
|
686
|
+
function lt(e) {
|
|
687
687
|
e.ctx.fillStyle = e.skyGradient, e.ctx.fillRect(0, 0, e.width, e.height);
|
|
688
688
|
}
|
|
689
|
-
function
|
|
689
|
+
function ut(e) {
|
|
690
690
|
if (e.state.stars.length === 0) return;
|
|
691
691
|
let t = 1;
|
|
692
692
|
if (e.dayCycle) {
|
|
@@ -698,7 +698,7 @@ function lt(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 dt(e) {
|
|
702
702
|
let t = e.celestial;
|
|
703
703
|
if (!t) return;
|
|
704
704
|
let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ? T(e.dayCycle) : {
|
|
@@ -707,16 +707,16 @@ function ut(e) {
|
|
|
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 ft(e) {
|
|
711
711
|
if (e.activeNight) {
|
|
712
|
-
|
|
712
|
+
ut(e), dt(e);
|
|
713
713
|
return;
|
|
714
714
|
}
|
|
715
|
-
|
|
715
|
+
dt(e);
|
|
716
716
|
}
|
|
717
717
|
//#endregion
|
|
718
718
|
//#region src/components/weatherBackground/configs.ts
|
|
719
|
-
var
|
|
719
|
+
var pt = {
|
|
720
720
|
sunny: {
|
|
721
721
|
sky: ["#4a9fe0", "#c8e8fb"],
|
|
722
722
|
sun: "full",
|
|
@@ -1048,7 +1048,7 @@ var ft = {
|
|
|
1048
1048
|
snowCount: 160,
|
|
1049
1049
|
lightning: !1
|
|
1050
1050
|
}
|
|
1051
|
-
},
|
|
1051
|
+
}, mt = {
|
|
1052
1052
|
sunny: {
|
|
1053
1053
|
sky: ["#0b1a33", "#27476e"],
|
|
1054
1054
|
stars: 110
|
|
@@ -1117,14 +1117,14 @@ var ft = {
|
|
|
1117
1117
|
sky: ["#101a26", "#2e3d4d"],
|
|
1118
1118
|
stars: 30
|
|
1119
1119
|
}
|
|
1120
|
-
},
|
|
1120
|
+
}, ht = ([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 gt(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 ht(e, t, n, r) {
|
|
|
1143
1143
|
oy: f
|
|
1144
1144
|
};
|
|
1145
1145
|
}
|
|
1146
|
-
function
|
|
1146
|
+
function _t(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 } = gt(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 gt(e, t, n, r, i) {
|
|
|
1160
1160
|
oy: u
|
|
1161
1161
|
};
|
|
1162
1162
|
}
|
|
1163
|
-
function
|
|
1163
|
+
function vt(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 _t(e, t = 120) {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
//#endregion
|
|
1173
1173
|
//#region src/components/weatherBackground/sprites/celestial.ts
|
|
1174
|
-
function
|
|
1174
|
+
function yt(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 vt(e, t) {
|
|
|
1199
1199
|
breathAmp: .018
|
|
1200
1200
|
};
|
|
1201
1201
|
}
|
|
1202
|
-
function
|
|
1202
|
+
function bt(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 yt(e, t, n) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
//#endregion
|
|
1255
1255
|
//#region src/components/weatherBackground/sprites/snow.ts
|
|
1256
|
-
var
|
|
1256
|
+
var xt = (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
|
+
}, St = (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 bt = (e) => {
|
|
|
1285
1285
|
r.closePath(), r.stroke();
|
|
1286
1286
|
}
|
|
1287
1287
|
return n;
|
|
1288
|
-
},
|
|
1288
|
+
}, Ct = () => ({
|
|
1289
1289
|
dots: [
|
|
1290
1290
|
1.2,
|
|
1291
1291
|
1.6,
|
|
1292
1292
|
2,
|
|
1293
1293
|
2.3
|
|
1294
|
-
].map((e) =>
|
|
1294
|
+
].map((e) => xt(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) => St(e * 2.4))
|
|
1302
|
+
}), wt = (e) => e[Math.floor(Math.random() * e.length)], Tt = (e, t, n, r) => {
|
|
1303
|
+
let i = 1 + Math.random() ** 1.6 * 4.2, a = i >= 2.4, o = wt(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,9 +1314,9 @@ var bt = (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
|
+
}, Et = (e, t) => t ? e === "smog" ? "96, 88, 66" : "138, 150, 168" : e === "smog" ? "168, 155, 126" : "226, 232, 238";
|
|
1318
|
+
function Dt(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 = pt[i], h = (() => {
|
|
1320
1320
|
let e = m;
|
|
1321
1321
|
return ue(i) && e.rain && (e = {
|
|
1322
1322
|
...e,
|
|
@@ -1327,12 +1327,12 @@ function Et(e) {
|
|
|
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
1329
|
}), A(i) && (e = j(e, f)), Se(i) && (e = Ce(e, p)), e;
|
|
1330
|
-
})(), g =
|
|
1330
|
+
})(), g = mt[i], _ = a ?? null, b = _ ? v(s ? Date.now() : o, _) : null, x = b ? !b.isDay : !1, S = b ? w(h.sky, g.sky, b) : x ? g.sky : h.sky, C = x ? ht(h.cloudColor) : h.cloudColor, T = Math.min(n, r) * .09, E = n * .72, D = r * .26;
|
|
1331
1331
|
if (b) {
|
|
1332
|
-
let e =
|
|
1333
|
-
|
|
1332
|
+
let e = y(n, r, b.arcProgress);
|
|
1333
|
+
E = e.x, D = e.y;
|
|
1334
1334
|
}
|
|
1335
|
-
let
|
|
1335
|
+
let O = ee(t, r, S), k = [
|
|
1336
1336
|
{
|
|
1337
1337
|
dx: -.32,
|
|
1338
1338
|
dy: .08,
|
|
@@ -1353,28 +1353,28 @@ function Et(e) {
|
|
|
1353
1353
|
dy: .24,
|
|
1354
1354
|
r: .07
|
|
1355
1355
|
}
|
|
1356
|
-
],
|
|
1356
|
+
], N = yt(h, T), P = bt(h, T, k), F = x ? P : N, I = x || _ != 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
|
+
})) : [], L = Array.from({ length: h.cloudCount }, () => _t(n, r, h.cloudSpread, C, h.cloudAlpha)), R = 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
|
+
})) : [], V = [], te = 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
1373
|
alpha: (.1 + Math.random() * .1) * (A(i) ? M(f) : Se(i) ? we(p) : 1)
|
|
1374
|
-
})),
|
|
1375
|
-
min:
|
|
1376
|
-
max:
|
|
1377
|
-
},
|
|
1374
|
+
})), H = h.fogBanks > 0 ? vt(Et(i, x)) : null, U = h.snowCount > 0 ? Ct() : null, W = U == null ? [] : Array.from({ length: h.snowCount }, () => Tt(n, r, U)), G = z(i) ? B(d) : null, K = G == null ? null : nt(), q = K != null && G != null ? Array.from({ length: G.count }, () => at(n, r, K, {
|
|
1375
|
+
min: G.sizeMin,
|
|
1376
|
+
max: G.sizeMax
|
|
1377
|
+
}, G.speedMul)) : [], ne = (() => {
|
|
1378
1378
|
let { count: e } = Ue(c.visualLevel);
|
|
1379
1379
|
return e <= 0 ? [] : Array.from({ length: e }, () => ({
|
|
1380
1380
|
x: Math.random() * n,
|
|
@@ -1386,69 +1386,69 @@ function Et(e) {
|
|
|
1386
1386
|
width: .5 + Math.random() * 1.1,
|
|
1387
1387
|
phase: Math.random() * Math.PI * 2
|
|
1388
1388
|
}));
|
|
1389
|
-
})(),
|
|
1389
|
+
})(), re = [], ie = 120 + Math.random() * 240;
|
|
1390
1390
|
return {
|
|
1391
1391
|
sky: S,
|
|
1392
|
-
cloudRgb:
|
|
1392
|
+
cloudRgb: C,
|
|
1393
1393
|
cfg: h,
|
|
1394
|
-
sunX:
|
|
1395
|
-
sunY:
|
|
1396
|
-
sunR:
|
|
1397
|
-
skyGradient:
|
|
1398
|
-
celestial:
|
|
1399
|
-
sunSprite:
|
|
1400
|
-
moonSprite:
|
|
1401
|
-
fogSprite:
|
|
1402
|
-
dayCycleTimes:
|
|
1394
|
+
sunX: E,
|
|
1395
|
+
sunY: D,
|
|
1396
|
+
sunR: T,
|
|
1397
|
+
skyGradient: O,
|
|
1398
|
+
celestial: F,
|
|
1399
|
+
sunSprite: N,
|
|
1400
|
+
moonSprite: P,
|
|
1401
|
+
fogSprite: H,
|
|
1402
|
+
dayCycleTimes: _,
|
|
1403
1403
|
dayCycle: b,
|
|
1404
1404
|
sceneTimeMs: o,
|
|
1405
1405
|
liveClock: s,
|
|
1406
|
-
hailSpec:
|
|
1406
|
+
hailSpec: G,
|
|
1407
1407
|
state: {
|
|
1408
|
-
stars:
|
|
1409
|
-
moonCraters:
|
|
1410
|
-
clouds:
|
|
1411
|
-
drops:
|
|
1412
|
-
splashes:
|
|
1408
|
+
stars: I,
|
|
1409
|
+
moonCraters: k,
|
|
1410
|
+
clouds: L,
|
|
1411
|
+
drops: R,
|
|
1412
|
+
splashes: V,
|
|
1413
1413
|
fogBanks: te,
|
|
1414
|
-
flakes:
|
|
1415
|
-
hailstones:
|
|
1416
|
-
hailPool:
|
|
1417
|
-
windStreaks:
|
|
1414
|
+
flakes: W,
|
|
1415
|
+
hailstones: q,
|
|
1416
|
+
hailPool: K ?? [],
|
|
1417
|
+
windStreaks: ne,
|
|
1418
1418
|
t: 0,
|
|
1419
1419
|
flashAlpha: 0,
|
|
1420
1420
|
boltLife: 0,
|
|
1421
|
-
boltPoints:
|
|
1422
|
-
nextStrike:
|
|
1421
|
+
boltPoints: re,
|
|
1422
|
+
nextStrike: ie
|
|
1423
1423
|
}
|
|
1424
1424
|
};
|
|
1425
1425
|
}
|
|
1426
|
-
function
|
|
1426
|
+
function Ot(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 = v(e.liveClock ? t ?? Date.now() : e.sceneTimeMs, e.dayCycleTimes), r = mt[e.activeWeather], i = w(e.cfg.sky, r.sky, n), a = y(e.width, e.height, n.arcProgress);
|
|
1429
|
+
e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient = ee(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 kt(e, t) {
|
|
1434
|
+
t && (e.state.t += 1), e.windField = Q(e.state.t, e.windMotion), e.dayCycleTimes && Ot(e, e.liveClock ? Date.now() : e.sceneTimeMs), lt(e), ft(e), Je(e), Ye(e), Xe(e), ot(e), st(e), ct(e), Qe(e), $e(e);
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1437
|
-
let { ctx: t, width: n, height: r, activeWeather: a, activeNight: o, windMotion: s } = e, c =
|
|
1436
|
+
function At(e) {
|
|
1437
|
+
let { ctx: t, width: n, height: r, activeWeather: a, activeNight: o, windMotion: s } = e, c = Dt(e), l = {
|
|
1438
1438
|
ctx: t,
|
|
1439
1439
|
width: n,
|
|
1440
1440
|
height: r,
|
|
1441
1441
|
activeWeather: a,
|
|
1442
1442
|
activeNight: c.dayCycle ? !c.dayCycle.isDay : o,
|
|
1443
1443
|
windMotion: s,
|
|
1444
|
-
windField:
|
|
1444
|
+
windField: Q(0, s),
|
|
1445
1445
|
...c
|
|
1446
1446
|
};
|
|
1447
|
-
if (l.dayCycleTimes &&
|
|
1447
|
+
if (l.dayCycleTimes && Ot(l, l.liveClock ? Date.now() : l.sceneTimeMs), typeof window < "u" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return kt(l, !1), () => void 0;
|
|
1448
1448
|
let u = 0, d = document.hidden, f = i((e) => {
|
|
1449
1449
|
d = e;
|
|
1450
1450
|
}), p = () => {
|
|
1451
|
-
u = requestAnimationFrame(p), !d &&
|
|
1451
|
+
u = requestAnimationFrame(p), !d && kt(l, !0);
|
|
1452
1452
|
};
|
|
1453
1453
|
return p(), () => {
|
|
1454
1454
|
cancelAnimationFrame(u), f();
|
|
@@ -1460,88 +1460,92 @@ var $ = {
|
|
|
1460
1460
|
loadingOverlay: "cos-loadingOverlay-O58B7",
|
|
1461
1461
|
loadingSpinner: "cos-loadingSpinner-NQ9yG",
|
|
1462
1462
|
"weather-loading-spin": "cos-weather-loading-spin-IPFWZ"
|
|
1463
|
-
},
|
|
1464
|
-
let
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1463
|
+
}, jt = ({ width: r, height: i, fill: c = !1, weather: l = "partlyCloudy", time: u = "14:00", live: d = !1, latitude: f, longitude: p, windLevel: m = 3, rainLevel: g = 5, snowLevel: y = 5, hailLevel: b = 2, fogLevel: x = 2, smogLevel: S = 2, onLiveWeather: C, loading: w = !1, ariaLabel: ee, loadingText: T = "天气加载中…" }) => {
|
|
1464
|
+
let { hostRef: E, width: D, height: O, hostStyle: k } = a({
|
|
1465
|
+
fill: c,
|
|
1466
|
+
width: r,
|
|
1467
|
+
height: i,
|
|
1468
|
+
defaultWidth: 800,
|
|
1469
|
+
defaultHeight: 450
|
|
1470
|
+
}), A = n(null), j = Pe(d, f != null && p != null ? {
|
|
1471
|
+
latitude: f,
|
|
1472
|
+
longitude: p
|
|
1473
|
+
} : void 0), M = J(d && j.weather ? j.weather : l), N = d && j.rainLevel != null ? j.rainLevel : g, P = d && j.snowLevel != null ? j.snowLevel : y, F = d && j.fogLevel != null ? j.fogLevel : x, I = d && j.hailLevel != null ? j.hailLevel : b, L = d && j.smogLevel != null ? j.smogLevel : S, R = me(M, N, P), z = _(u), B = j.current?.sunrise ?? null, V = j.current?.sunset ?? null, te = j.current?.windSpeed ?? null, H = t(() => d && B != null && V != null ? {
|
|
1474
|
+
sunrise: B,
|
|
1475
|
+
sunset: V
|
|
1476
|
+
} : h(z), [
|
|
1477
|
+
d,
|
|
1478
|
+
B,
|
|
1479
|
+
V,
|
|
1480
|
+
z
|
|
1481
|
+
]), U = qe({
|
|
1482
|
+
live: d,
|
|
1483
|
+
windLevel: m,
|
|
1484
|
+
liveWindKmh: te
|
|
1485
|
+
}), W = t(() => Ke(U), [U]), G = d && j.current ? !j.current.isDay : !v(z, H).isDay, K = w || d && (j.status === "locating" || j.status === "fetching"), q = n(C);
|
|
1480
1486
|
return e(() => {
|
|
1481
|
-
|
|
1487
|
+
q.current = C;
|
|
1482
1488
|
}), e(() => {
|
|
1483
|
-
|
|
1484
|
-
}, [
|
|
1485
|
-
let e =
|
|
1489
|
+
j.weather && q.current?.(J(j.weather));
|
|
1490
|
+
}, [j.weather]), e(() => {
|
|
1491
|
+
let e = A.current;
|
|
1486
1492
|
if (!e) return;
|
|
1487
1493
|
let t = window.devicePixelRatio || 1;
|
|
1488
|
-
e.width =
|
|
1494
|
+
e.width = D * t, e.height = O * t;
|
|
1489
1495
|
let n = e.getContext("2d");
|
|
1490
|
-
if (n) return n.setTransform(t, 0, 0, t, 0, 0),
|
|
1496
|
+
if (n) return n.setTransform(t, 0, 0, t, 0, 0), At({
|
|
1491
1497
|
ctx: n,
|
|
1492
|
-
width:
|
|
1493
|
-
height:
|
|
1494
|
-
activeWeather:
|
|
1495
|
-
activeNight:
|
|
1496
|
-
dayCycleTimes:
|
|
1497
|
-
sceneTimeMs:
|
|
1498
|
-
liveClock:
|
|
1499
|
-
windMotion:
|
|
1500
|
-
rainLevel:
|
|
1501
|
-
snowLevel:
|
|
1502
|
-
fogLevel:
|
|
1503
|
-
hailLevel:
|
|
1504
|
-
smogLevel:
|
|
1498
|
+
width: D,
|
|
1499
|
+
height: O,
|
|
1500
|
+
activeWeather: R,
|
|
1501
|
+
activeNight: G,
|
|
1502
|
+
dayCycleTimes: H,
|
|
1503
|
+
sceneTimeMs: z,
|
|
1504
|
+
liveClock: d,
|
|
1505
|
+
windMotion: W,
|
|
1506
|
+
rainLevel: N,
|
|
1507
|
+
snowLevel: P,
|
|
1508
|
+
fogLevel: F,
|
|
1509
|
+
hailLevel: I,
|
|
1510
|
+
smogLevel: L
|
|
1505
1511
|
});
|
|
1506
1512
|
}, [
|
|
1507
|
-
|
|
1508
|
-
|
|
1513
|
+
G,
|
|
1514
|
+
R,
|
|
1515
|
+
H,
|
|
1516
|
+
N,
|
|
1517
|
+
P,
|
|
1518
|
+
F,
|
|
1509
1519
|
I,
|
|
1510
|
-
|
|
1511
|
-
D,
|
|
1520
|
+
L,
|
|
1512
1521
|
O,
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
R
|
|
1520
|
-
]), /* @__PURE__ */ o("div", {
|
|
1522
|
+
d,
|
|
1523
|
+
z,
|
|
1524
|
+
D,
|
|
1525
|
+
W
|
|
1526
|
+
]), /* @__PURE__ */ s("div", {
|
|
1527
|
+
ref: E,
|
|
1521
1528
|
className: $.weatherBackground,
|
|
1522
|
-
style:
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
},
|
|
1526
|
-
children: [/* @__PURE__ */ a("canvas", {
|
|
1527
|
-
ref: C,
|
|
1529
|
+
style: k,
|
|
1530
|
+
children: [/* @__PURE__ */ o("canvas", {
|
|
1531
|
+
ref: A,
|
|
1528
1532
|
className: $.canvas,
|
|
1529
1533
|
style: {
|
|
1530
|
-
width:
|
|
1531
|
-
height:
|
|
1534
|
+
width: D,
|
|
1535
|
+
height: O
|
|
1532
1536
|
},
|
|
1533
1537
|
role: "img",
|
|
1534
|
-
"aria-label": `天气背景:${
|
|
1535
|
-
}),
|
|
1538
|
+
"aria-label": ee ?? `天气背景:${M}${G ? "(夜间)" : ""},${W.level}级风`
|
|
1539
|
+
}), K && /* @__PURE__ */ s("div", {
|
|
1536
1540
|
className: $.loadingOverlay,
|
|
1537
1541
|
role: "status",
|
|
1538
1542
|
"aria-live": "polite",
|
|
1539
|
-
children: [/* @__PURE__ */
|
|
1543
|
+
children: [/* @__PURE__ */ o("div", {
|
|
1540
1544
|
className: $.loadingSpinner,
|
|
1541
1545
|
"aria-hidden": !0
|
|
1542
|
-
}), /* @__PURE__ */
|
|
1546
|
+
}), /* @__PURE__ */ o("span", { children: T })]
|
|
1543
1547
|
})]
|
|
1544
1548
|
});
|
|
1545
1549
|
};
|
|
1546
1550
|
//#endregion
|
|
1547
|
-
export { E as DEFAULT_FOG_LEVEL, F as DEFAULT_HAIL_LEVEL,
|
|
1551
|
+
export { E as DEFAULT_FOG_LEVEL, F as DEFAULT_HAIL_LEVEL, U as DEFAULT_RAIN_LEVEL, ye as DEFAULT_SMOG_LEVEL, W as DEFAULT_SNOW_LEVEL, Le as DEFAULT_WIND_LEVEL, D as FOG_LEVEL_LABELS, I as HAIL_LEVEL_LABELS, H as MAX_PRECIP_LEVEL, te as MIN_PRECIP_LEVEL, oe as RAIN_LEVEL_LABELS, be as SMOG_LEVEL_LABELS, se as SNOW_LEVEL_LABELS, jt as WeatherBackground, jt as default, Ke as buildWindMotion, O as clampFogLevel, L as clampHailLevel, G as clampPrecipLevel, X as clampSmogLevel, M as fogBankAlphaScale, P as fogLevelFromVisibility, N as fogLevelFromWmo, k as formatFogLevel, R as formatHailLevel, Ne as formatLocalHm, ae as formatPrecipLevel, xe as formatSmogLevel, V as hailLevelFromWmo, B as hailSpec, j as intensifyFogConfig, he as intensifyRainConfig, Ce as intensifySmogConfig, ge as intensifySnowCount, ce as isRainWeather, le as isSnowWeather, Ge as kmhToWindLevel, De as mapWmoCodeToWeatherType, J as normalizeWeatherType, q as precipBand, ie as precipLabel, fe as rainLevelFromWeather, _e as rainLevelFromWmo, me as resolveSceneWeather, Q as sampleWindField, we as smogBankAlphaScale, Te as smogLevelFromVisibility, pe as snowLevelFromWeather, ve as snowLevelFromWmo, A as supportsFogLevel, z as supportsHailLevel, ue as supportsRainLevel, Se as supportsSmogLevel, de as supportsSnowLevel, Pe as useLiveWeather, Ie as useSunTimes, ze as visualWindLevel, We as windLevelToKmh, Ue as windStreakSpec };
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { clamp } from './math';
|
|
2
|
+
export { bindVisibilityPause } from './visibility';
|
|
3
|
+
export { prefersReducedMotion, bindPrefersReducedMotion } from './reduced-motion';
|
|
4
|
+
export { observeElementSize } from './size';
|
|
5
|
+
export type { ElementSize } from './size';
|
|
6
|
+
export { getRelativePointerPosition } from './pointer';
|
|
7
|
+
export type { PointerPosition } from './pointer';
|
|
8
|
+
export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from './photo';
|
|
9
|
+
export { useElementSize, resolveCanvasBoxSize, useCanvasBox } from './use-element-size';
|
|
10
|
+
export type { UseElementSizeOptions, CanvasBoxSizeInput, CanvasBoxSize, UseCanvasBoxOptions, UseCanvasBoxResult } from './use-element-size';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 图片预览组件通用照片项 */
|
|
2
|
+
export interface PhotoItem {
|
|
3
|
+
/** 图片地址 */
|
|
4
|
+
src: string;
|
|
5
|
+
/** 图片替代文本 */
|
|
6
|
+
alt?: string;
|
|
7
|
+
/** 照片标题 */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** 照片说明 */
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
/** 线性浏览:当前索引变化(相册 / 胶卷 / 晾绳等) */
|
|
13
|
+
export type PhotoIndexChangeHandler<T = PhotoItem> = (index: number, photo: T) => void;
|
|
14
|
+
/** 环形浏览:正对镜头的面变化(走马灯 / 旋转木马等) */
|
|
15
|
+
export type PhotoFaceChangeHandler<T = PhotoItem> = (index: number, photo?: T) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PointerPosition {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
type PointLike = {
|
|
6
|
+
clientX: number;
|
|
7
|
+
clientY: number;
|
|
8
|
+
};
|
|
9
|
+
/** 相对元素左上角的指针坐标(兼容 mouse / touch / pointer) */
|
|
10
|
+
export declare const getRelativePointerPosition: (element: Element, event: PointLike | {
|
|
11
|
+
touches?: ArrayLike<PointLike>;
|
|
12
|
+
changedTouches?: ArrayLike<PointLike>;
|
|
13
|
+
}) => PointerPosition | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { ElementSize } from './size';
|
|
3
|
+
export interface UseElementSizeOptions {
|
|
4
|
+
/** 为 false 时不观察 */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** 观察元素尺寸(clientWidth / clientHeight) */
|
|
8
|
+
export declare const useElementSize: <T extends Element>(ref: RefObject<T | null>, options?: UseElementSizeOptions) => ElementSize;
|
|
9
|
+
export interface CanvasBoxSizeInput {
|
|
10
|
+
/** 为 true 时跟随父容器尺寸(需父级有明确高度) */
|
|
11
|
+
fill?: boolean;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
defaultWidth: number;
|
|
15
|
+
defaultHeight: number;
|
|
16
|
+
measured: ElementSize;
|
|
17
|
+
}
|
|
18
|
+
export interface CanvasBoxSize {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
22
|
+
pending: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** 根据 fill / 显式宽高 / 测量结果解析画布逻辑尺寸 */
|
|
25
|
+
export declare const resolveCanvasBoxSize: ({ fill, width, height, defaultWidth, defaultHeight, measured }: CanvasBoxSizeInput) => CanvasBoxSize;
|
|
26
|
+
export interface UseCanvasBoxOptions {
|
|
27
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
28
|
+
fill?: boolean;
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
defaultWidth: number;
|
|
32
|
+
defaultHeight: number;
|
|
33
|
+
}
|
|
34
|
+
export interface UseCanvasBoxResult {
|
|
35
|
+
hostRef: RefObject<HTMLDivElement | null>;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
/** 挂到宿主容器的样式(fill 时为 100%×100%) */
|
|
39
|
+
hostStyle: CSSProperties;
|
|
40
|
+
fill: boolean;
|
|
41
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
42
|
+
pending: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** 画布/效果宿主尺寸:fill 时跟随父容器,否则用显式宽高或默认值 */
|
|
45
|
+
export declare const useCanvasBox: ({ fill, width: widthProp, height: heightProp, defaultWidth, defaultHeight }: UseCanvasBoxOptions) => UseCanvasBoxResult;
|
|
@@ -22,6 +22,8 @@ export type WeatherType = 'sunny' | 'partlyCloudy' | 'overcast'
|
|
|
22
22
|
export interface WeatherBackgroundProps {
|
|
23
23
|
width?: number;
|
|
24
24
|
height?: number;
|
|
25
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
26
|
+
fill?: boolean;
|
|
25
27
|
/** 天气类型:sunny / partlyCloudy / overcast / rain 雨天 / thunderstorm / fog / snow 雪天 / sleet / hail / smog;雨量用 rainLevel,雪量用 snowLevel,风效用 windLevel */
|
|
26
28
|
weather?: WeatherType;
|
|
27
29
|
/**
|
|
@@ -51,6 +53,10 @@ export interface WeatherBackgroundProps {
|
|
|
51
53
|
onLiveWeather?: (weather: WeatherType) => void;
|
|
52
54
|
/** 外部受控 loading:在当前画面上叠加加载遮罩(live 模式定位/请求期间会自动显示,无需传入) */
|
|
53
55
|
loading?: boolean;
|
|
56
|
+
/** 画布无障碍标签;不传时使用默认中文描述 */
|
|
57
|
+
ariaLabel?: string;
|
|
58
|
+
/** 加载状态文案 */
|
|
59
|
+
loadingText?: string;
|
|
54
60
|
}
|
|
55
61
|
export interface WeatherConfig {
|
|
56
62
|
sky: [string, string];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cos-design/weather-background",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.5",
|
|
4
4
|
"description": "WeatherBackground component from cos-design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,6 +52,6 @@
|
|
|
52
52
|
"registry": "https://registry.npmjs.org"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@cos-design/shared": "3.5.
|
|
55
|
+
"@cos-design/shared": "3.5.6"
|
|
56
56
|
}
|
|
57
57
|
}
|