text: (()=>{const e="03e64a8cec1bb05f4d68afc1e84e2fb095a44bc7",t=document.querySelector(".input-text"),o=document.querySelector(".search-form"),n=document.getElementById("aqi-index"),r=document.getElementById("aqi-level"),a=document.getElementById("health-implications"),i=document.getElementById("cautionary-statement");let s="";const l=L.map("mapid",{zoomControl:!1});new L.Control.Zoom({position:"bottomleft"}).addTo(l);let c="";const d=async function(e){return fetch(`https://api.opencagedata.com/geocode/v1/json?q=${e}&key=33391df72f7d48e39576fde1f6b56d60`)};renderResJson=function(e,t){e>300?(n.innerText=`${t}: ⚫ ${e} ⚫`,r.innerText="☣️ Pericoloso! ☣️",a.innerText="Health alert: everyone may experience more serious health effects",i.innerText="Everyone should avoid all outdoor exertion"):e>200?(n.innerText=`${t}: 🟤 ${e} 🟤`,r.innerText="⚠️ Molto malsano ⚠️",a.innerText="Health warnings of emergency conditions. The entire population is more likely to be affected.",i.innerText="Active children and adults, and people with respiratory disease, such as asthma, should avoid all outdoor exertion; everyone else, especially children, should limit outdoor exertion."):e>150?(n.innerText=`${t}: 🔴 ${e} 🔴`,r.innerText="🏭 Malsano 🏭",a.innerText="Everyone may begin to experience health effects; members of sensitive groups may experience more serious health effects",i.innerText="Active children and adults, and people with respiratory disease, such as asthma, should avoid prolonged outdoor exertion; everyone else, especially children, should limit prolonged outdoor exertion"):e>100?(n.innerText=`${t}: 🟠 ${e} 🟠`,r.innerText="🌆 Malsano per gruppi sensibili 🌆",a.innerText="Members of sensitive groups may experience health effects. The general public is not likely to be affected.",i.innerText="Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion."):e>50?(n.innerText=`${t}: 🟡 ${e} 🟡`,r.innerText="🍃 Moderato 🍃",a.innerText="Air quality is acceptable; however, for some pollutants there may be a moderate health concern for a very small number of people who are unusually sensitive to air pollution.",i.innerText="Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion."):e>0?(n.innerText=`${t}: 🟢 ${e} 🟢`,r.innerText="🍀 Buono 🍀",a.innerText="Air quality is considered satisfactory, and air pollution poses little or no risk",i.innerText="None"):errorLayout()},resetLayout=function(){n.innerText="⌛",r.innerText="⌛",a.innerText="⌛",i.innerText="⌛"},errorLayout=function(){n.innerText="⚠️",r.innerText="Error: It seems there isn't an AQI Station in here. Check map to discover near Stations",a.innerText="💤",i.innerText="💤"},o.addEventListener("submit",(function(o){o.preventDefault(),s=t.value,resetLayout(),async function(t){try{const o=await fetch(`https://api.waqi.info/feed/${t}/?token=${e}`),n=await o.json();if("error"==n.status)throw divmap.innerHTML="Can't find the place, sorry!",new Error(`"${n.data}."Maybe look for closest station from you!`);renderResJson(n.data.aqi,t),async function(e){let t=(await d(e)).json();coordsRes=(await t).results[0].geometry,coordsArr=Object.values(coordsRes),c.removeFrom(l),c=L.marker(coordsArr),c.addTo(l),l.setView(coordsArr)}(t)}catch(e){console.error(e.message),errorLayout()}}(s)})),t.addEventListener("focus",(function(){t.select()})),l.on("click",(async function(e){let t=[e.latlng.lat,e.latlng.lng];c.removeFrom(l),c=L.marker(t),c.addTo(l),l.setView(t);const o=(await async function(e){return fetch(`https://api.opencagedata.com/geocode/v1/json?q=${e[0]}+${e[1]}&key=33391df72f7d48e39576fde1f6b56d60`)}(t)).json(),n=(await o).results[0].components.county||(await o).results[0].components.state||(await o).results[0].components.municipality,r=(await o).results[0].annotations.flag,a=(await o).results[0].formatted;c.bindPopup(`<b>${r} - ${n}</b><br><b>${a}</b>`).openPopup()})),async function(){try{const t=await fetch(`https://api.waqi.info/feed/here/?token=${e}`),o=await t.json(),n=o.data.city.name,r=o.data.aqi;renderResJson(r,n),async function(t){let o=(await d(t)).json();coordsRes=(await o).results[0].geometry,coordsArr=Object.values(coordsRes),l.setView(coordsArr,6),L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(l),L.tileLayer(`https://tiles.aqicn.org/tiles/usepa-aqi/{z}/{x}/{y}.png?token=${e}`).addTo(l),c=L.marker(coordsArr),c.addTo(l)}(n)}catch(e){console.error(e.message)}}(),async function(){const e=await fetch("/.netlify/functions/lambda.js");await e.json(),console.log(e)}()})();