1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2935],{4809:(e,t,a)=>{a.d(t,{FO:()=>i,Jv:()=>r,QT:()=>o});let n=e=>Math.log(Math.tan(Math.PI/4+e*Math.PI/360));function i(e,t,a,i){let s=Math.max(e[0][0],t[0][0]),r=Math.max(e[0][1],t[0][1]),o=Math.min(e[1][0],t[1][0]),l=Math.min(e[1][1],t[1][1]);if(s>=o||r>=l||a.x<=0||a.y<=0)return null;let c=n(o),d=n(s),u=Math.max(1,Math.min(2,i||1)),m=a.x*(l-r)/(t[1][1]-t[0][1])*u,p=a.y*(c-d)/(n(t[1][0])-n(t[0][0]))*u,h=Math.min(1,1600/Math.max(m,p),Math.sqrt(1e6/(m*p)));return{bounds:[[s,r],[o,l]],width:Math.max(1,Math.floor(m*h)),height:Math.max(1,Math.floor(p*h)),northY:c,southY:d}}function s(e,t,a){return[e.bounds[0][1]+t/e.width*(e.bounds[1][1]-e.bounds[0][1]),(2*Math.atan(Math.exp(e.northY-a/e.height*(e.northY-e.southY)))-Math.PI/2)*180/Math.PI]}function r(e,[t,a]){return[(t-e.bounds[0][1])/(e.bounds[1][1]-e.bounds[0][1])*e.width,(e.northY-n(a))/(e.northY-e.southY)*e.height]}function*o(e,t,a,n){let{width:i,height:r}=e,o=i+2,l=new Float64Array(o*(r+2));for(let t=-1;t<=r;t+=1){for(let n=-1;n<=i;n+=1)l[(t+1)*o+n+1]=a(...s(e,n+.5,t+.5))??NaN;yield}for(let c=0;c<r;c+=1){for(let r=0;r<i;r+=1){let d=(c+1)*o+r+1,u=l[d],m=Number.isFinite(u),p=!1;for(let e=-1;e<=1&&!p;e+=1)for(let t=-1;t<=1;t+=1)if(Number.isFinite(l[d+e*o+t])!==m){p=!0;break}let h=232*!!m;if(p){let t=0,n=0;for(let i=0;i<4;i+=1)for(let o=0;o<4;o+=1){let l=a(...s(e,r+(o+.5)/4,c+(i+.5)/4));null!==l&&(t+=l,n+=1)}h=232*n/16,u=n?t/n:NaN}if(!h)continue;let[x,f,b]=n(u),g=(c*i+r)*4;t[g]=x,t[g+1]=f,t[g+2]=b,t[g+3]=h}yield}}},62935:(e,t,a)=>{a.r(t),a.d(t,{default:()=>O});var n=a(95155),i=a(12115),s=a(59481),r=a(15378),o=a(24999);a(90737);var l=a(65508),c=a(11286),d=a(4809);function u({boundary:e,metric:t,stations:a}){let r=(0,s.ko)(),l=(0,i.useMemo)(()=>e?(0,c.xo)({boundary:e,metric:t,stations:a}):null,[e,t,a]),[m,p]=(0,i.useState)(null);return((0,i.useEffect)(()=>{if(!l)return;let e=(0,c.DD)(l),t=!1,a=null,n=null,i=()=>{null!==a&&window.clearTimeout(a),a=null,n?.port1.close(),n?.port2.close(),n=null},s=()=>{i();let e=r.getBounds().pad(.15),a=r.getSize(),s=(0,d.FO)(l.bounds,[[e.getSouth(),e.getWest()],[e.getNorth(),e.getEast()]],{x:1.3*a.x,y:1.3*a.y},window.devicePixelRatio);if(!s){p(null),t=!1;return}n=new MessageChannel;let c=Math.min(1,256/Math.max(s.width,s.height));!t&&c<1?o({...s,width:Math.max(1,Math.round(s.width*c)),height:Math.max(1,Math.round(s.height*c))},()=>o(s)):o(s)},o=(s,r)=>{let o=n;if(!o)return;let u=document.createElement("canvas");u.width=s.width,u.height=s.height;let m=u.getContext("2d");if(!m)return void i();let h=m.createImageData(s.width,s.height),x=(0,d.QT)(s,h.data,e,e=>(0,c.pL)(e,l.scale));o.port1.onmessage=()=>{n===o&&(()=>{let e,n=performance.now()+8;do e=x.next();while(!e.done&&performance.now()<n);e.done?(m.putImageData(h,0,0),function(e,t,a){let n=t.features.flatMap(({geometry:e})=>"Polygon"===e.type?[e.coordinates]:e.coordinates),i=e=>(0,d.Jv)(a,e);for(let t of(e.globalCompositeOperation="destination-in",e.beginPath(),n))for(let a of t){let t=a[0];if(!t)continue;let[n,s]=i(t);e.moveTo(n,s);for(let t=1;t<a.length;t+=1){let[r,o]=i(a[t]);(t===a.length-1||Math.abs(r-n)+Math.abs(o-s)>=.25)&&(e.lineTo(r,o),n=r,s=o)}e.closePath()}e.fillStyle="#000000",e.fill("evenodd"),e.globalCompositeOperation="source-over"}(m,l.boundary,s),p({model:l,frame:s,url:u.toDataURL("image/png")}),t=!0,r?a=window.setTimeout(r,0):i()):o.port2.postMessage(null)})()},o.port2.postMessage(null)},u=()=>{i(),a=window.setTimeout(s,60)};return r.on("movestart zoomstart",i),r.on("moveend zoomend resize",u),window.addEventListener("resize",u),s(),()=>{i(),r.off("movestart zoomstart",i),r.off("moveend zoomend resize",u),window.removeEventListener("resize",u)}},[r,l]),l&&m&&m.model===l)?(0,n.jsx)(o.a,{bounds:m.frame.bounds,interactive:!1,opacity:.9,url:m.url,zIndex:250}):null}var m=a(21536),p=a(56634);let h={"pais-vasco":"/provincial-boundaries/pais-vasco.json",asturias:"/provincial-boundaries/asturias.json",galicia:"/provincial-boundaries/galicia.json",cantabria:"/provincial-boundaries/cantabria.json",cordillera:"/provincial-boundaries/cordillera.json"},x={cantabrico:["galicia","asturias","cantabria","pais-vasco"]};function f(){throw Error("invalid_provincial_boundaries")}function b(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function g(e){return Array.isArray(e)&&e.length>=2&&"number"==typeof e[0]&&Number.isFinite(e[0])&&e[0]>=-180&&e[0]<=180&&"number"==typeof e[1]&&Number.isFinite(e[1])&&e[1]>=-90&&e[1]<=90}function v(e){return Array.isArray(e)&&e.length>=4&&e.every(g)}function y(e){return Array.isArray(e)&&e.length>=1&&e.every(v)}function w(e){var t;return!!b(e)&&"Feature"===e.type&&!!b(e.properties)&&"string"==typeof e.properties.name&&e.properties.name.trim().length>0&&"string"==typeof e.properties.nationalCode&&/^\d{11}$/.test(e.properties.nationalCode)&&!!b(t=e.geometry)&&("Polygon"===t.type?y(t.coordinates):"MultiPolygon"===t.type&&Array.isArray(t.coordinates)&&t.coordinates.length>=1&&t.coordinates.every(y))}function j({regionId:e}
1){let[t,a]=(0,i.useState)(null);return((0,i.useEffect)(()=>{let t=x[e]??[e],n=t.map(e=>h[e]??null);if(n.some(e=>null===e))return;let i=new AbortController;return Promise.all(n.map(async(e,a)=>{var n,s;let r,o=await fetch(e,{headers:{Accept:"application/geo+json, application/json"},signal:i.signal});if(!o.ok)throw Error(`provincial_boundaries_${o.status}`);return n=await o.json(),s=t[a],b(n)&&"FeatureCollection"===n.type||f(),n.regionId===s&&"https://api-features.ign.es"===n.source&&"string"==typeof n.attribution&&n.attribution.includes("ign.es")&&Array.isArray(n.features)&&0!==n.features.length&&n.features.every(w)||f(),new Set(r=n.features.map(e=>e.properties.nationalCode)).size!==r.length&&f(),n})).then(t=>a({type:"FeatureCollection",regionId:e,source:"https://api-features.ign.es",attribution:t[0]?.attribution??"https://api-features.ign.es",features:t.flatMap(({features:e})=>e)})).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||console.error("Failed to load provincial boundaries:",e)}),()=>{i.abort(),a(null)}},[e]),t&&t.regionId===e)?(0,n.jsx)(m.Z,{name:"observation-provincial-boundaries",style:{zIndex:350,pointerEvents:"none"},children:(0,n.jsx)(p.k,{data:t,interactive:!1,pathOptions:{color:"#111827",fill:!1,opacity:.62,weight:1.1}},e)}):null}function N({rainToday:e=!1,boundary:t,metric:a,stations:i}){if("windDirection"===a)return(0,n.jsxs)("aside",{className:"pointer-events-none border-t bg-white px-3 py-2 text-xs text-slate-800 sm:absolute sm:right-3 sm:top-3 sm:z-[500] sm:max-w-[calc(100%-1.5rem)] sm:rounded-xl sm:border sm:bg-white/95 sm:shadow-lg",children:[(0,n.jsx)("p",{className:"font-semibold",children:"Direcci\xf3n del viento"}),(0,n.jsx)("p",{className:"mt-0.5 text-slate-600",children:"Flechas en estaciones"})]});let s=(0,c.XW)(a);if(!(t?(0,c.xo)({boundary:t,metric:a,stations:i}):null))return(0,n.jsxs)("aside",{className:"pointer-events-none border-t border-amber-300/90 bg-amber-50/95 px-3 py-2 text-xs text-amber-950 sm:absolute sm:right-3 sm:top-3 sm:z-[500] sm:max-w-[calc(100%-1.5rem)] sm:rounded-xl sm:border sm:shadow-lg",children:[(0,n.jsx)("p",{className:"font-semibold",children:e?"Precipitaci\xf3n \xb7 Hoy":s.label}),(0,n.jsx)("p",{className:"mt-0.5",children:"Cobertura insuficiente para interpolar"})]});let r=(0,c.Kx)(s);return(0,n.jsxs)("aside",{className:"pointer-events-none border-t border-slate-200/90 bg-white px-3 py-2 text-xs text-slate-800 sm:absolute sm:right-3 sm:top-3 sm:z-[500] sm:w-[min(230px,calc(100%-1.5rem))] sm:rounded-xl sm:border sm:bg-white/95 sm:shadow-lg",children:[(0,n.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,n.jsx)("p",{className:"font-semibold",children:e?"Precipitaci\xf3n \xb7 Hoy":s.label}),(0,n.jsx)("span",{className:"text-[10px] font-medium text-slate-500",children:s.unit})]}),(0,n.jsx)("div",{className:"mt-2 h-2.5 rounded-full ring-1 ring-black/10",style:{background:r},"aria-hidden":"true"}),(0,n.jsx)("div",{className:"relative mt-1 h-3 tabular-nums text-[9px] text-slate-600",children:s.stops.filter(e=>s.legendValues.includes(e.value)).map(e=>{let t=(0,c.N2)(e.value,s);return(0,n.jsx)("span",{className:"absolute whitespace-nowrap",style:{left:`${t}%`,transform:`translateX(${0===t?0:100===t?-100:-50}%)`},children:e.label},e.value)})}),(0,n.jsx)("p",{className:"mt-1.5 text-[10px] font-medium text-slate-600",children:"Estimaci\xf3n interpolada \xb7 IDW"}),(0,n.jsx)("p",{className:"mt-0.5 text-[10px] text-slate-600",children:"Incluye zonas sin estaciones cercanas"})]})}var M=a(69722),z=a.n(M),k=a(98500),$=a.n(k),A=a(48144),E=a(22812),C=a(21362),S=a(86765),D=a(68055),P=a(97617),I=a(3747);function T({metric:e,rainToday:t=!1,returnPath:a,stations:r}){let o=(0,s.ko)(),[l,d]=(0,i.useState)({}),[u,m]=(0,i.useState)(()=>o.getSize());(0,i.useEffect)(()=>{let e=!1,t=()=>{let t=o.getSize();if(m(e=>e.x===t.x&&e.y===t.y?e:t),e)return;if(t.x>=640)return void d({});let a=r.map(({station:e})=>
1{let t=o.latLngToContainerPoint([e.coordinates.lat,e.coordinates.lng]);return{id:e.idema,x:t.x,y:t.y}}).filter(({x:e,y:a})=>e>=0&&e<=t.x&&a>=0&&a<=t.y);d((0,P.U9)(a,t.x,t.y))},a=()=>{e=!0},n=()=>{e=!1,t()};return t(),o.on("moveend resize",t),o.on("autopanstart popupopen",a),o.on("popupclose",n),()=>{o.off("moveend resize",t),o.off("autopanstart popupopen",a),o.off("popupclose",n)}},[o,e,r]);let p=(0,P.F)(u.x,u.y);return r.map(i=>{var s;let r,o=(0,P.Nv)(e,i),d=new URLSearchParams({origen:"mapas",volver:a}),m=`/estaciones/aemet/${encodeURIComponent(i.station.idema)}?${d.toString()}`,h=(0,I.dk)(i.fetchedAt),x=t?"Precipitaci\xf3n desde las 00:00":(0,P.f6)(e),f=`Estaci\xf3n ${i.station.name}: ${x}, ${o}`,b=i.metrics,g=[{label:"M\xe1x",value:(0,I.p8)(b.maximumTemperatureC,"\xb0C",0)},{label:"M\xedn",value:(0,I.p8)(b.minimumTemperatureC,"\xb0C",0)},{label:"Hum",value:(0,I.p8)(b.relativeHumidityPct,"%",0)},{label:"Viento",value:null===(s=b.windSpeedMs)?"Sin dato":`${Math.round(3.6*s).toLocaleString("es-ES")} km/h`}];return(0,n.jsx)(S.p,{position:[i.station.coordinates.lat,i.station.coordinates.lng],icon:function(e,t,a=[0,0],n=!1){let i=(0,P.Nw)(e,t),s="â"===i||"Sin dato"===i,r=t.metrics.windDirectionDeg,o="windDirection"===e&&null!==r?`<span aria-hidden="true" style="display:block;font-size:20px;line-height:1;transform:rotate(${r}deg)">â</span>`:`<span>${(0,P.hU)(s?"â":i)}</span>`,l=(0,c.Sr)("windDirection"===e?r:(0,c.WG)(t,e),e),[d,u]=a,m=d||u?`<svg aria-hidden="true" width="44" height="44" style="position:absolute;inset:0;overflow:visible;pointer-events:none"><line x1="${22-d}" y1="${22-u}" x2="22" y2="22" stroke="#475569" stroke-width="1" opacity=".6"/><circle cx="${22-d}" cy="${22-u}" r="2" fill="#334155"/></svg>`:"",p=`<div style="position:relative;display:flex;width:44px;height:44px;align-items:center;justify-content:center">${m}<span style="position:relative;pointer-events:auto;display:inline-flex;min-width:30px;height:24px;box-sizing:border-box;align-items:center;justify-content:center;padding:0 4px;border:1px solid rgba(255,255,255,.94);border-radius:8px;background:${l.backgroundColor};color:${l.color};box-shadow:0 2px 6px rgba(15,23,42,.24);font:750 11px/1 system-ui;white-space:nowrap">${o}</span></div>`;return z().divIcon({className:n?"asturmet-observation-marker !pointer-events-none":"asturmet-observation-marker",html:p,iconSize:[44,44],iconAnchor:[22-d,22-u],popupAnchor:[0,-20]})}(e,i,l[i.station.idema],u.x<640),keyboard:!0,eventHandlers:{add:e=>{e.target.getElement()?.setAttribute("aria-label",f)}},title:`${i.station.name}: ${x}, ${o}`,alt:`Estaci\xf3n ${i.station.name}: ${o}`,children:(0,n.jsx)(D.z,{...p,autoPanPadding:[12,12],children:(0,n.jsxs)("div",{className:"overflow-hidden rounded-xl text-sm text-slate-900",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-4 px-1 pb-3",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("p",{className:"truncate text-base font-semibold",children:i.station.name}),(0,n.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["AEMET \xb7 ",i.station.idema]})]}),(0,n.jsxs)("div",{className:"shrink-0 text-right",children:[(0,n.jsxs)("p",{className:"text-xl font-bold tabular-nums text-sky-700",children:["windDirection"===e&&null!==b.windDirectionDeg&&(0,n.jsx)(A.A,{className:"mr-1 inline-block h-4 w-4",style:{transform:`rotate(${b.windDirectionDeg}deg)`},"aria-hidden":"true"}),(r=(0,P.Nv)(e,i),"windDirection"===e?r.replace(/^Dirección /,""):r)]}),(0,n.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-slate-500",children:x})]})]}),(0,n.jsx)("div",{className:"grid grid-cols-4 divide-x divide-slate-200 border-y border-slate-200 bg-slate-50",children:g.map(e=>(0,n.jsxs)("div",{className:"min-w-0 px-1.5 py-2 text-center",children:[(0,n.jsx)("p",{className:"truncate text-xs font-semibold tabular-nums",children:e.value}),(0,n.jsx)("p",{className:"mt-1 text-[9px] uppercase tracking-wide text-slate-500",children:e.label})]},e.label))}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-1 py-2.5 text-xs text-slate-600",children:[(0,n.jsx)("span",{children:(0,I._C)(h)}),(0,n.jsx)("span",{children:(0,I.bf)(i.observedAt)})]}),"fresh"!==h&&(0,n.jsxs)("p",{className:"flex gap-2 border-y border-amber-200 bg-amber-50 px-2 py-2 text-xs text-amber-900",children:[(0,n.jsx)(E.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),"AEMET a\xfan no ha publicado una lectura m\xe1s reciente."]}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-3 px-1 pt-2.5",children:[(0,n.jsx)("span",{className:"text-xs font-medium text-slate-500",children:"Fuente: AEMET OpenData"}),(0,n.jsxs)($(),{href:m,className:"inline-flex min-h-11 items-center gap-1 rounded-lg px-2 font-semibold text-sky-700 underline-offset-4 hover:bg-sky-50 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-600",children:["Ver estaci\xf3n ",(0,n.jsx)(C.A,{className:"h-4 w-4","aria-hidden":"true"})]})]})]})},`${u.x}-${u.y}`)},`${i.station.idema}-${e}`)})}var F=a(8764);function _({boundaryBounds:e,localRadar:t,stations:a}){let n=(0,s.ko)(),r=(0,i.useCallback)(()=>
1{let i=(0,P.m5)(n.getSize().x);t?n.setView([t.lat,t.lng],t.zoom,{animate:!1}):e?n.fitBounds(e,{animate:!1,padding:i}):a.length>0&&n.fitBounds(a.map(({station:e})=>[e.coordinates.lat,e.coordinates.lng]),{animate:!1,maxZoom:9,padding:i})},[e,t,n,a]);return(0,i.useEffect)(()=>(r(),n.on("resize",r),()=>{n.off("resize",r)}),[r,n]),null}function O({controls:e,boundary:t,boundaryBounds:a,localRadar:s,metric:c,rainToday:d=!1,onRadarFrameError:m,radar:p,regionId:h,returnPath:x,stations:f,stationsEnabled:b}){let g=(0,i.useMemo)(()=>p?[[p.bounds.south,p.bounds.west],[p.bounds.north,p.bounds.east]]:null,[p]),v=s?[s.lat,s.lng]:f[0]?[f[0].station.coordinates.lat,f[0].station.coordinates.lng]:[43.3,-5.9];return(0,n.jsxs)("div",{className:"relative",role:"region","aria-label":"Mapa de observaciones meteorol\xf3gicas",children:[(0,n.jsxs)("div",{className:`relative ${P.Pz}`,children:[(0,n.jsxs)(r.W,{center:v,zoom:s?.zoom??8,minZoom:4,zoomSnap:.1,zoomAnimation:!1,maxZoom:12,scrollWheelZoom:!0,attributionControl:!1,className:"z-0 h-full w-full [&:has(.leaflet-popup)_.leaflet-control-zoom]:invisible",children:[(0,n.jsx)(l.A,{className:"grayscale-[20%] contrast-90"}),(0,n.jsx)(u,{boundary:t,metric:c,stations:f}),p&&g&&(0,n.jsx)(o.a,{bounds:g,url:(0,F.vm)(p.image.url),opacity:.66,zIndex:300,eventHandlers:{error:m}}),(0,n.jsx)(j,{regionId:h}),b&&(0,n.jsx)(T,{metric:c,rainToday:d,returnPath:x,stations:f}),(0,n.jsx)(_,{boundaryBounds:a,localRadar:s,stations:f})]}),e]}),(0,n.jsx)(N,{rainToday:d,boundary:t,metric:c,stations:f})]})}},65508:(e,t,a)=>{a.d(t,{A:()=>o});var n=a(95155),i=a(47684);let s="https://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png",r=function(e="cb1_2e9g_1_bd235f20c1c2fe1296ba13a3"){let t=e?.trim();return t?`${s}?key=${encodeURIComponent(t)}`:s}();function o({className:e}){return(0,n.jsx)(i.e,{url:r,className:e,attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, © <a href="https://carto.com/attribution/">CARTO</a>'})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.