1const h=[".weather-tool[data-weather-account]","a.weather[data-weather-account]",".weather[data-weather-account]"].join(", "),c=new Map,i=new Map;function d(o){const t=o.getAttribute("data-weather-account");if(!t)return;if(c.has(t)){s(o,c.get(t));return}if(i.has(t)){i.get(t).then(()=>{c.has(t)&&s(o,c.get(t))});return}const e=new URLSearchParams({account:t,nb_days:"1"}),r=o.getAttribute("data-weather-nb-days");r&&e.set("nb_days",r);const a=fetch(`/wp-json/woody/weather/data?${e.toString()}`).then(n=>n.json()).then(n=>{if(n?.code||!n?.days?.length)return;const u=n.days[0]?.summary||{};c.set(t,u),l(t,u)}).catch(n=>{console.warn("Weather tool fetch error:",n)}).finally(()=>{i.delete(t)});i.set(t,a)}function l(o,t){document.querySelectorAll(h).forEach(e=>{e.getAttribute("data-weather-account")===o&&s(e,t)})}function s(o,t){t?.icon&&f(o,t.icon),y(o,t.average_temp),w(o,t.sky)}function w(o,t){if(!t)return;const e=o.querySelector(".weather-logo-label");e&&(e.textContent=t)}function f(o,t){const e=o.querySelector(".weather-icon")||o.querySelector(".wicon");if(!e||e.classList.contains("wicon")&&[...e.classList].some(a=>a.startsWith("wicon--")))return;if(e.classList.contains("weather-icon")){const a=[...e.classList].filter(n=>n!=="weather-icon"&&!n.startsWith("climacon-")&&n!==t);e.className=["weather-icon",t,...a].filter(Boolean).join(" ");return}if(e.classList.contains("wicon")){const a=[...e.classList].filter(n=>n!=="wicon"&&!n.startsWith("climacon-"));e.className=["wicon",t,...a].filter(Boolean).join(" ");return}const r=[...e.classList].filter(a=>a!=="weather-icon"&&!a.startsWith("climacon-")&&a!==t);e.className=["weather-icon",t,...r].filter(Boolean).join(" ")}function y(o,t){if(t==null)return;const e=o.querySelector(".weather-temp")?.textContent?.includes("\xB0C")?`${t}\xB0C`:`${t}\xB0`,r=o.querySelector(".temperature")||o.querySelector(".weather-temp")||o.querySelector("a > span:not(.wicon):not(.weather-icon)");r&&(r.textContent=e)}export{d as hydrateToolElement};
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.