(()=>{"use strict";const e=window.wp.i18n;document.addEventListener("DOMContentLoaded",(function(){const t=document.querySelector(".box-content"),n=document.querySelector(".top-buttons");function o(o,a){fetch(`/wp-json/gg-gym-data/gyms/nearby/?latitude=${o}&longitude=${a}&per_page=1`).then((e=>e.json())).then((o=>{if(o.length>0){const a=o[0],c=a.gym_name,s=a.address||"",l=a.address2||"",d=a.city||"",i=a.state.toLowerCase(),r=a.zip||"",m=a.gym_slug,p=`/locations/${i}/${m}`,u=a.online_enrollment_url,_=a.online_enrollment_enabled,g=a.internal_checkout_enabled,b=a.leads_enabled,h=g?`${p}/join/`:_&&u?u:null;t.querySelector(".box-content__content").remove();const C=document.createElement("div");C.className="box-content__box";const f=document.createElement("div");f.className="box-content__wrapper";const E=document.createElement("div");E.className="box-content__subtitle",E.textContent=(0,e.__)("Find Your Nearest Gold's Gym","gg-blocks");const y=document.createElement("h2");y.className="box-content__subheader";const N=document.createElement("span");N.className="gg-slug",N.textContent="Gold’s Gym ";const x=document.createTextNode(c);y.appendChild(N),y.appendChild(x);const v=document.createElement("div");v.className="box-content__links";const k=document.createElement("div");k.className="edit-location";const $=document.createElement("a");$.className="button",$.href=`/locations/?address=${encodeURIComponent(`${s} ${l} ${d} ${i}, ${r}`)}`,$.textContent=(0,e.__)("edit location","gg-blocks"),k.appendChild($);const w=document.createElement("div");w.className="gym-details";const G=document.createElement("a");if(G.className="button",G.href=p,G.textContent=(0,e.__)("gym details","gg-blocks"),w.appendChild(G),v.appendChild(k),v.appendChild(w),f.appendChild(E),f.appendChild(y),f.appendChild(v),C.appendChild(f),h||b){const t=document.createElement("div");if(t.className="box-content__buttons",h){const n=document.createElement("div");n.className="join-now-link";const o=document.createElement("a");o.className="button is-primary",o.href=h,g||(o.target="_blank",o.rel="noopener"),o.textContent=(0,e.__)("join 500k+ members","gg-blocks"),n.appendChild(o),t.appendChild(n)}if(b){const n=document.createElement("div");n.className="learn-more-link";const o=document.createElement("a");o.className="button is-secondary",o.href=`/locations/${i}/${m}/free-pass/`,o.textContent=(0,e.__)("Claim a free pass","gg-blocks"),n.appendChild(o),t.appendChild(n)}C.appendChild(t)}if(t.appendChild(C),n){if(n.innerHTML="",h){const t=document.createElement("div");t.className="top-buttons__button is-style-fill";const o=document.createElement("a");o.className="link",o.href=h,g||(o.target="_blank",o.rel="noopener"),o.textContent=(0,e.__)("Join Now","gg-blocks"),t.appendChild(o),n.appendChild(t)}if(b){const t=document.createElement("div");t.className="top-buttons__button is-style-outline";const o=document.createElement("a");o.className="link",o.href=`/locations/${i}/${m}/free-pass/`,o.textContent=(0,e.__)("Free pass","gg-blocks"),t.appendChild(o),n.appendChild(t)}}}})).catch((e=>{console.error("Error fetching nearby gym:",e)}))}function a(){"geolocation"in navigator?navigator.geolocation.getCurrentPosition((e=>{const{latitude:t,longitude:n}=e.coords;o(t,n)}),(e=>{console.error("Browser Location API Error:",e)})):console.warn("Geolocation is not available in this browser.")}"undefined"!=typeof geoip2?geoip2.city((e=>{const t=e.location.latitude,n=e.location.longitude;"US"===e.country.iso_code&&o(t,n)}),(e=>{console.error("GeoIP2 Error:",e),a()})):(console.warn("GeoIP2 is not available."),a())}))})();