1import{_ as w}from"./app-C6vu4kPS.js";import{C as m}from"./filter-combobox-CCYZqGZa.js";const g={noLocations:"Sorry, no locations were found. Please refine your search and try again.",generic:"Sorry, we were unable to find your current location. Please enter a city or ZIP Code and try again."},y="No cities or ZIP Codes were found. Please refine your search and try again.";class v{constructor(e,t){this.root=e,this.config=t,this.careers=t.careers??[],this.offices=t.offices??[],this.nearbyCareers=this.careers,this.nearbyOffices=this.offices,this.observer=new IntersectionObserver(i=>{i[0]?.isIntersecting&&(this.observer?.disconnect(),this.observer=null,this.reveal())}),this.observer.observe(e)}root;config;careers;offices;displayMode="positions";isListView=!1;keyword="";keywordJobIds=null;selectedPosition=null;searchPerformed=!1;isSearching=!1;current={nearbyCount:null,address:null,location:null,distance:null};nearbyCareers;nearbyOffices;google=null;map=null;markers=new Map;services={autocomplete:null,geocoder:null};geocodedPlaces={};geolocationLocation=null;geocodedLocation=null;locationBox=null;positionBox=null;observer=null;stamped=!1;cleanups=[];destroy(){this.observer?.disconnect(),this.locationBox?.destroy(),this.positionBox?.destroy();for(const e of this.cleanups)e();this.cleanups=[];for(const e of this.markers.values())e.setMap(null);this.markers.clear()}on(e,t,i){e.addEventListener(t,i),this.cleanups.push(()=>e.removeEventListener(t,i))}q(e){return this.root.querySelector(e)}reveal(){if(this.stamped)return;const e=this.root.querySelector("template[data-careers-locator-template]");if(!e)return;this.stamped=!0,this.root.appendChild(e.content.cloneNode(!0)),e.remove();const t=this.q("[data-distance]");t&&(this.current.distance=parseInt(t.value,10),this.updateDistanceLabel()),this.wire(),this.updatePositionFromUrl();const s=new URLSearchParams(window.location.search).get("keyword");if(s){this.keyword=s;const r=this.q("[data-keyword]");r&&(r.value=s)}this.loadMap()}wire(){const e=this.q("[data-view-toggle]");e&&this.on(e,"change",()=>this.setListView(e.checked));for(const o of Array.from(this.root.querySelectorAll("[data-view-map]")))this.on(o,"click",()=>this.setListView(!1));for(const o of Array.from(this.root.querySelectorAll("[data-view-list]")))this.on(o,"click",()=>this.setListView(!0));for(const o of Array.from(this.root.querySelectorAll("[data-display-mode]")))this.on(o,"change",()=>{const n=o.getAttribute("data-display-mode");this.displayMode=n,this.updateCareers(!0),this.render()});const t=this.q("[data-search-form]");t&&this.on(t,"submit",o=>{o.preventDefault(),this.performSearch()});const i=this.q("[data-keyword]");i&&this.on(i,"input",()=>{this.keyword=i.value});const s=this.q("[data-clear-filters]");s&&this.on(s,"click",()=>this.clearFilters());const r=this.q("[data-geolocate]");r&&this.on(r,"click",()=>this.updateCurrentLocation());const d=this.q("[data-distance]");d&&this.on(d,"input",()=>{this.current.distance=d.value,d.value===d.max&&(this.current.distance=100),this.updateDistanceLabel()});const c=this.q('[data-combobox="location"]');if(c){const o=new m(c);o.shouldOpen=()=>o.input.value.length!==0&&o.open,o.onSearch=n=>{if(this.updateGeoActionVisibility(),n.length===0){o.setOptions([]);return}this.loadLocationPredictions(o,n)},o.onSelect=n=>{this.updateGeoActionVisibility(),this.onLocationSelected(n.value)},o.onCleared=()=>{this.current.location=null,this.current.address=null,this.updateGeoActionVisibility(),this.updateCareers(!1)},this.locationBox=o}const a=this.q('[data-combobox="position"]');if(a){const o=new m(a),n=(this.config.positions??[]).map(l=>({label:l,value:l}));o.shouldOpen=()=>o.open,o.setOptions(n),o.onSearch=l=>{const p=n.filter(b=>b.label.toLowerCase().includes(l.toLowerCase()));o.setOptions(p)},o.onSelect=l=>{this.selectedPosition=String(l.value),o.setOptions(n)},o.onCleared=()=>{this.selectedPosition=null},this.positionBox=o}const f=o=>{const n=o.target.closest("a");if(n&&n.hash==="#careers-search"&&n.href){const l=new URL(n.href,window.location.origin);this.updatePositionFromParam(l.searchParams.get("position"))}};document.addEventListener("click",f),this.cleanups.push(()=>document.removeEventListener("click",f));for(const o of Array.from(this.root.querySelectorAll("[data-list] li.career-item"))){this.on(o,"mouseenter",()=>{window.outerWidth>768&&this.onCareerItemMouseEnter(o)}),this.on(o,"mouseleave",()=>{window.outerWidth>768&&this.onCareerItemMouseLeave(o)});const n=o.querySelector("[data-show-on-map]");n&&this.on(n,"click",l=>{l.preventDefault(),this.onCareerItemMouseEnter(o)})}}updateGeoActionVisibility(){const e=this.q("[data-geolocate]");if(!e||!this.locationBox)return;const t=this.locationBox.input.value.length!==0&&this.locationBox.isOpen();e.style.visibility=t?"hidden":"visible"}async loadMap(){const e=this.q("[data-map-canvas]");if(!(!e||!this.config.apiKey))try{const{Loader:t}=await w(async()=>{const{Loader:s}=await import("./index-D1WUwHAH.js");
1return{Loader:s}},[]),i=await new t({apiKey:this.config.apiKey,version:"weekly",libraries:["places","geometry"]}).load();this.google=i,this.map=new i.maps.Map(e,this.config.mapConfig??{}),this.services.autocomplete=new i.maps.places.AutocompleteService,this.services.geocoder=new i.maps.Geocoder,this.syncMarkers(),this.resetPosition()}catch{}}syncMarkers(){if(!this.google||!this.map)return;const e=new Map;for(const t of this.nearbyOffices)e.set(String(t.id),t);for(const[t,i]of this.markers)e.has(t)||(i.setVisible(!1),i.setMap(null),this.markers.delete(t));for(const[t,i]of e){if(this.markers.has(t))continue;const s=i.position??{lat:Number(i.latitude),lng:Number(i.longitude)},r=new this.google.maps.Marker({id:t,position:s,map:this.map,optimized:!1});r.setIcon(this.config.iconConfig?.inactive),r.addListener("click",()=>this.markerHoverOver(t)),r.addListener("mouseover",()=>this.markerHoverOver(t)),r.addListener("mouseout",()=>{r.setIcon(this.config.iconConfig?.inactive),r.setZIndex(1)}),this.markers.set(t,r)}}resetPosition(){if(!this.google||!this.map||this.nearbyOffices.length===0)return;const e=new this.google.maps.LatLngBounds;for(const t of this.nearbyOffices)e.extend(t.position??{lat:Number(t.latitude),lng:Number(t.longitude)});this.map.setCenter(e.getCenter()),this.map.fitBounds(e)}setMarkerActive(e,t){const i=this.markers.get(e);i&&(i.setIcon(this.config.iconConfig?.[t?"active":"inactive"]),i.setZIndex(t?2:1))}markerHoverOver(e){for(const s of this.markers.keys())s!==e&&this.setMarkerActive(s,!1);this.setMarkerActive(e,!0);const t=this.activeMapViewList();if(!t)return;const i=this.displayMode==="positions"?t.querySelector(`li[data-location-id="${e}"]`):t.querySelector(`li[data-item-id="${e}"]`);if(i){for(const s of Array.from(t.querySelectorAll("li.hover")))s.classList.remove("hover");i.classList.add("hover"),this.scrollToCareerItem(i,t)}}onCareerItemMouseEnter(e){this.scrollToMap();const t=e.getAttribute("data-location-id")||e.getAttribute("data-item-id");if(!t)return;for(const s of this.markers.keys())this.setMarkerActive(s,s===t);const i=this.markers.get(t);i&&this.map&&this.map.panTo(i.getPosition())}onCareerItemMouseLeave(e){this.scrollToMap();const t=e.getAttribute("data-location-id")||e.getAttribute("data-item-id");t&&this.setMarkerActive(t,!1)}isMobile(){return window.outerWidth<=768}scrollToMap(){const e=this.q("[data-map]");if(this.isMobile()&&e){const t=document.querySelector("header"),i=e.getBoundingClientRect().y+window.scrollY-(t?.offsetHeight??0);window.scroll({top:i,left:0,behavior:"smooth"})}}scrollToCareerItem(e,t){if(this.isMobile()){const r=document.querySelector("header"),d=e.getBoundingClientRect().y+window.scrollY-(r?.offsetHeight??0);window.scroll({top:d,left:0,behavior:"smooth"});return}const i=this.q("[data-locator-region]"),s=Math.min(t.scrollHeight,Math.max(0,e.getBoundingClientRect().y+t.scrollTop-t.getBoundingClientRect().y-(i?.clientHeight??0)/2+e.offsetHeight/2));t.scroll({top:s,left:0,behavior:"smooth"})}performSearch(){this.searchPerformed=!0,this.isSearching=!0,this.renderSubmitLabel(),this.keyword?fetch(`/api/careers/search?keyword=${encodeURIComponent(this.keyword)}`,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(e=>e.ok?e.json():Promise.reject(new Error(String(e.status)))).then(e=>{this.keywordJobIds=e}).catch(()=>{this.keywordJobIds=[]}).finally(()=>{this.isSearching=!1,this.renderSubmitLabel(),this.updateCareers(!1),this.render()}):(this.keywordJobIds=null,this.updateCareers(!1),this.isSearching=!1,this.renderSubmitLabel(),this.render())}clearFilters(){this.searchPerformed=!1,this.locationBox?.clearSelection(),this.keyword="";const e=this.q("[data-keyword]");e&&(e.value=""),this.selectedPosition=null,this.positionBox?.clearSelection(),this.keywordJobIds=null,this.current.location=null,this.current.address=null,this.updateCareers(!0),this.render()}updateCareers(e){let t=this.careers;if(this.keywordJobIds!==null){const n=new Set(this.keywordJobIds.map(String));t=t.filter(l=>n.has(String(l.id)))}this.selectedPosition&&this.config.careerCategories?.[this.selectedPosition]&&(t=t.filter(l=>l.mapped_category===this.selectedPosition));const i=new Set(t.map(n=>n.location_id));let s=this.offices.filter(n=>i.has(n.id));if(this.current.distance===null||this.current.location===null){this.nearbyCareers=t,this.nearbyOffices=s,this.current.nearbyCount=this.displayMode==="positions"?this.nearbyCareers.length:this.nearbyOffices.length,e&&this.scrollToMap(),this.setSearchError(null);return}const r=this.q("[data-distance]"),d=5,c=parseInt(r?.max??"50",10);let a=this.current.distance,o=(this.displayMode==="positions"?t:s).map(n=>{const l=n.position?n.position.lat:n.lat,p=n.position?n.position.lng:n.lng;return{...n,distance:this.google.maps.geometry.spherical.computeDistanceBetween(new this.google.maps.LatLng(l,p),new this.google.maps.LatLng(this.current.location))*621371e-9}}).sort((n,l)=>(n.distance??0)-(l.distance??0));if(e&&o.length&&(a=Math.min(Math.max(Math.ceil((o[0].distance??0)/5)*5,d),c).toString()),o=o.filter(n=>Math.ceil(n.distance??0)<=Number(a)),o.length>0){if(e&&r&&(this.current.distance=a,r.min=String(a),r.value=String(a),this.updateDistanceLabel()),this.displayMode==="positions"){this.nearbyCareers=o;const n=new Set(this.nearbyCareers.map(l=>l.location_id));this.nearbyOffices=s.filter(l=>n.has(l.id))}else{this.nearbyOffices=o;const n=new Set(this.nearbyOffices.map(l=>l.id));this.nearbyCareers=t.filter(l=>n.has(l.location_id))}this.current.nearbyCount=o.length,e&&this.scrollToMap(),this.setSearchError(null)}else this.current.nearbyCount=0,this.nearbyCareers=[],this.nearbyOffices=[],this.setSearchError(g.noLocations)}updateDistanceLabel(){const e=this.q("[data-distance]"),t=this.q("[data-distance-label-row]"),i=this.q("[data-distance-label]");if(!e||!i||!t)return;const s=e.value;i.innerHTML=s+(s===e.max?"+":"")+" miles",t.removeAttribute("hidden"),this.updateRangeControlVisibility()}updateRangeControlVisibility(){const e=this.q("[data-range-control]"),t=this.q("[data-distance]");if(!e||!t)return;const i=!!this.current.location&&t.min!==t.max&&!!this.current.nearbyCount;e.style.display=i?"":"none"}setSearchError(e){const t=this.q("[data-search-error]");t&&(e===null?(t.style.display="none",t.innerHTML=""):(t.innerHTML=e,t.style.display=""))}renderSubmitLabel(){const e=this.q("[data-search-submit]");e&&(e.textContent=this.isSearching?"Searching...":"Search")}setListView(e){this.isListView=e;const t=this.q("[data-view-toggle]");t&&(t.checked=e),this.render()}activeMapViewList(){return this.q(`[data-list="${this.displayMode==="positions"?"careers":"offices"}"]`)}render(){const e=this.q("[data-locator-region]");if(!e)return;e.classList.toggle("list-view",this.isListView);const t=this.displayMode==="positions"?this.nearbyCareers:this.nearbyOffices,i=this.q('[data-list="careers"]'),s=this.q('[data-list="offices"]'),r=this.q('[data-list-view="careers"]'),d=this.q('[data-list-view="office
1s"]'),c=this.q("[data-map]");if(i?.toggleAttribute("hidden",!(!this.isListView&&this.displayMode==="positions"&&this.nearbyCareers.length>0)),s?.toggleAttribute("hidden",!(!this.isListView&&this.displayMode==="offices"&&this.nearbyOffices.length>0)),r?.toggleAttribute("hidden",!(this.isListView&&this.displayMode==="positions"&&t.length>0)),d?.toggleAttribute("hidden",!(this.isListView&&this.displayMode==="offices"&&t.length>0)),c?.toggleAttribute("hidden",this.isListView),this.q("[data-no-results]")?.remove(),this.searchPerformed&&t.length===0){const a=document.createElement("div");a.className="no-results",a.setAttribute("data-no-results",""),a.textContent="No matching positions were found.",e.prepend(a)}this.renderListItems(i,this.nearbyCareers.map(a=>String(a.id))),this.renderListItems(s,this.nearbyOffices.map(a=>String(a.id))),this.renderListItems(r,this.nearbyCareers.map(a=>String(a.id))),this.renderListItems(d,this.nearbyOffices.map(a=>String(a.id))),this.renderCountLine(i,this.nearbyCareers.length,"position"),this.renderCountLine(s,this.nearbyOffices.length,"office");for(const a of Array.from(this.root.querySelectorAll("[data-display-mode]")))a.checked=a.getAttribute("data-display-mode")===this.displayMode;this.updateRangeControlVisibility(),this.syncMarkers(),this.resetPosition()}renderListItems(e,t){if(!e)return;const i=e.querySelector("ul[data-items]")??e.querySelector("ul");if(!i)return;const s=i.__pool??new Map;for(const c of Array.from(i.querySelectorAll("li.career-item"))){const a=c.getAttribute("data-item-id");a&&!s.has(a)&&s.set(a,c)}i.__pool=s;const r=new Set,d=[];for(const c of t){if(r.has(c))continue;r.add(c);const a=s.get(c);a&&d.push(a)}i.replaceChildren(...d)}renderCountLine(e,t,i){if(!e)return;const s=e.querySelector("[data-count-line]");if(!s)return;const r=`${t} ${i}${t===1?"":"s"}`;if(!!this.current.nearbyCount&&!!this.current.address&&!!this.current.location&&!!this.current.distance){const c=document.createElement("strong");c.innerHTML=r;const a=document.createElement("span");a.innerHTML=this.current.address??"",s.replaceChildren(c,document.createTextNode(" near "),a)}else if(this.current.nearbyCount){const c=document.createElement("strong");c.innerHTML=r;const a=document.createElement("span");a.textContent=" found",s.replaceChildren(c,a)}else{const c=document.createElement("span");c.innerHTML=this.config.strings?.allStores??"All available positions",s.replaceChildren(c)}}async loadLocationPredictions(e,t){if(!(!this.services.autocomplete||!this.google))try{const s=(await new Promise((r,d)=>{this.services.autocomplete.getPlacePredictions({input:t,componentRestrictions:{country:"us"},types:["(regions)"],language:"en",fields:["address_components","geometry","name"]},(c,a)=>{a!==this.google.maps.places.PlacesServiceStatus.OK||!c?d(new Error(a)):r(c)})})).map(r=>{let d=r.description.split(", ").slice(0,-1).join(", ");if(Array.isArray(r.types)&&r.types.length){const c=r.types[0];if(c==="postal_code")d=`${r.structured_formatting.main_text} (ZIP Code)`;else if(c==="administrative_area_level_1")return null}return{label:d,value:r}}).filter(r=>r!==null);e.setOptions(s,s.length===0?y:null)}catch{e.setOptions([],y)}}async onLocationSelected(e){const t=e.place_id;if(!Object.prototype.hasOwnProperty.call(this.geocodedPlaces,t)){const{results:i}=await this.services.geocoder.geocode({placeId:t});this.geocodedPlaces[t]=i[0]}this.setCurrentLocationFromGeocodeResult(this.geocodedPlaces[t]),this.performSearch()}setCurrentLocation(e,t){this.current.location=e,this.current.address=t,this.locationBox?.setSelectedLabel(t)}setCurrentLocationFromGeocodeResult(e){this.setCurrentLocation({lat:e.geometry.location.lat(),lng:e.geometry.location.lng()},this.getLocationStringFromAddressComponents(e.address_components))}getLocationStringFromAddressComponents(e){const t=[];for(const i of e??[])Array.isArray(i.types)&&(i.types.indexOf("administrative_area_level_1")>-1||i.types.indexOf("locality")>-1)&&t.push(i.short_name);return t.length===2?t.join(", "):null}updateCurrentLocation(){if(this.geolocationLocation!==null){this.setCurrentLocationFromGeocodeResult(this.geolocationLocation),this.performSearch();return}navigator.geolocation&&navigator.geolocation.getCurrentPosition(e=>
1{const t={lat:e.coords.latitude,lng:e.coords.longitude};this.services.geocoder.geocode({location:t}).then(i=>{i.results[0]?(this.setSearchError(null),this.setCurrentLocation(t,this.getLocationStringFromAddressComponents(i.results[0].address_components)),this.geolocationLocation=i.results[0],this.performSearch()):this.updateGeocodedLocation()}).catch(()=>{this.updateGeocodedLocation()})},()=>{this.updateGeocodedLocation()})}async updateGeocodedLocation(){if(this.geocodedLocation!==null){this.setCurrentLocationFromGeocodeResult(this.geocodedLocation);return}try{const t=await(await fetch(`https://www.googleapis.com/geolocation/v1/geolocate?key=${this.config.apiKey}`,{method:"POST"})).json();if(t.location){const{results:i}=await this.services.geocoder.geocode({location:t.location});this.geocodedLocation=this.geocodedPlaces[i[0].place_id]=i[0],this.setCurrentLocationFromGeocodeResult(i[0])}}catch{this.current.nearbyCount=null,this.current.location=null,this.setSearchError(g.generic)}}updatePositionFromParam(e){const t=this.config.positions??[];if(e&&t.length>0){const i=decodeURIComponent(e).replace(/_/g," ").toLowerCase(),s=t.find(r=>r.toLowerCase()===i);this.selectedPosition=s??null,s&&this.positionBox?.setSelectedLabel(s)}}updatePositionFromUrl(){const e=new URLSearchParams(window.location.search);this.updatePositionFromParam(e.get("position"))}}const u=new Map;function S(h,e={}){u.has(h)||u.set(h,new v(h,e))}function k(){for(const h of u.values())h.destroy();u.clear()}export{k as destroy,S as initialize};
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.