1class StoreSelectorComponent extends HTMLElement{constructor(){super(),this.handleTriggerClick=this.open.bind(this),this.handleSelectorClick=this.onSelectorClick.bind(this),this.handleCloseClick=this.close.bind(this),this.handleModalClick=this.onModalClick.bind(this),this.handleOptionClick=this.onOptionClick.bind(this),this.handleClearClick=this.onClearClick.bind(this),this.handleKeydown=this.onKeydown.bind(this),this.handleDocumentClick=this.onDocumentClick.bind(this),this.handleGlobalCloseClick=StoreSelectorComponent.onGlobalCloseClick.bind(StoreSelectorComponent),this.locations=[],this.userCoordinates=null,this.optionButtons=[],this.defaultLocationId=-1,this.hiddenLocationMap=this.getHiddenLocations()}connectedCallback(){this.cacheElements(),StoreSelectorComponent.bindGlobalCloseListener(),this.placeholder=this.dataset.placeholder||"",this.filterParam=this.dataset.filterParam||"",this.locationsEndpoint=this.dataset.locationsEndpoint||"",this.loadingText=this.dataset.loadingText||"Loading stores...",this.errorText=this.dataset.errorText||"Unable to load stores right now.",this.cartErrorText=this.dataset.cartErrorText||"Some items in your cart cannot be fulfilled from that store.",this.emptyText=(this.statusEl?.textContent||"").trim()||"No stores are available right now.",this.defaultLocationId=this.parseId(this.dataset.defaultLocationId??"-1"),this.activeValue=this.dataset.activeValue||"",this.activeLabel=this.dataset.activeLabel||"",this.refreshOptionButtons(),this.attachEventListeners(),this.setActiveValue(this.activeValue,this.activeLabel),this.locationsEndpoint?this.loadLocations():this.syncWithInventorySelection()}disconnectedCallback(){this.detachEventListeners(),document.removeEventListener("keydown",this.handleKeydown),this.modalAttachedToBody&&this.modal?.parentNode&&this.modal.parentNode.removeChild(this.modal),document.removeEventListener("click",this.handleDocumentClick,!0)}cacheElements(){this.trigger=this.querySelector("[data-store-selector-open]"),this.modal=this.querySelector("[data-store-selector-modal]")||document.body.querySelector("[data-store-selector-modal][data-detached-from-host]"),this.modal&&!this.modal.dataset.detachedFromHost&&(this.modal.dataset.detachedFromHost="true",document.body.appendChild(this.modal),this.modalAttachedToBody=!0),this.modal&&(this.modal.__storeSelectorInstance=this,this.modal.hidden=!0,this.modal.setAttribute("aria-hidden","true")),this.dialog=this.modal?this.modal.querySelector(".store-selector__dialog"):null,this.overlay=this.modal?this.modal.querySelector("[data-store-selector-overlay]"):null,this.closeButtons=this.modal?Array.from(this.modal.querySelectorAll("[data-store-selector-close]")):[],this.optionsList=this.modal?this.modal.querySelector(".store-selector__options"):null,this.statusEl=this.modal?this.modal.querySelector("[data-store-selector-status]"):null,this.useLocationButton=this.modal?this.modal.querySelector("[data-store-selector-use-location]"):null,this.clearButton=this.modal?this.modal.querySelector("[data-store-selector-clear]"):null,this.valueTarget=this.querySelector("[data-store-selector-value]"),this.searchInput=this.modal?this.modal.querySelector("[data-store-selector-search]"):null}attachEventListeners(){this.addEventListener("click",this.handleSelectorClick),this.modal?.addEventListener("click",this.handleModalClick),this.overlay?.addEventListener("click",this.handleCloseClick),this.closeButtons.forEach(button=>button.addEventListener("click",this.handleCloseClick)),this.attachOptionListeners(this.optionButtons),this.clearButton?.addEventListener("click",this.handleClearClick),this.useLocationButton?.addEventListener("click",this.handleUseLocation),document.addEventListener("click",this.handleDocumentClick,!0)}detachEventListeners(){this.removeEventListener("click",this.handleSelectorClick),this.modal?.removeEventListener("click",this.handleModalClick),this.overlay?.removeEventListener("click",this.handleCloseClick),this.closeButtons.forEach(button=>button.removeEventListener("click",this.handleCloseClick)),this.detachOptionListeners(),this.clearButton?.removeEventListener("click",this.handleClearClick),this.useLocationButton?.removeEventListener("click",this.handleUseLocation),document.removeEventListener("click",this.handleDocumentClick,!0)}attachOptionListeners(buttons=[]){buttons.forEach(button=>button.addEventListener("click",this.handleOptionClick))}detachOptionListeners(){this.optionButtons.forEach(button=>button.removeEventListener("click",this.handleOptionClick))}refreshOptionButtons(){this.optionButtons=this.modal?Array.from(this.modal.querySelectorAll("[data-store-option]")):[]}handleUseLocation=()=>
1{if(!navigator.geolocation){console.warn("[StoreSelector] Geolocation not supported");return}navigator.geolocation.getCurrentPosition(position=>{const{latitude,longitude}=position.coords||{};this.setUserCoordinates(latitude,longitude),console.log("[StoreSelector] User coordinates",{latitude,longitude})},error=>{console.warn("[StoreSelector] Geolocation error",error)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:3e4})};onModalClick(event){event.target.closest("[data-store-selector-close],[data-store-selector-overlay]")&&(event.preventDefault(),this.close())}onDocumentClick(event){if(!this.modal||this.modal.hidden)return;const target=event.target;target&&this.modal.contains(target)&&target.closest("[data-store-selector-close],[data-store-selector-overlay]")&&(event.preventDefault(),this.close())}static bindGlobalCloseListener(){window.__storeSelectorGlobalCloseListenerBound||(window.__storeSelectorGlobalCloseListenerBound=!0,document.addEventListener("click",StoreSelectorComponent.onGlobalCloseClick,!0))}static onGlobalCloseClick(event){const closeTarget=event.target.closest("[data-store-selector-close],[data-store-selector-overlay]");if(!closeTarget)return;const modal=closeTarget.closest(".store-selector__modal"),instance=modal?.__storeSelectorInstance;if(console.debug("[StoreSelector] close click",{target:closeTarget,hasInstance:!!instance,modalHidden:modal?.hidden}),event.preventDefault(),instance&&typeof instance.close=="function"){instance.close();return}modal&&(modal.hidden=!0,modal.setAttribute("aria-hidden","true"),document.documentElement.classList.remove("store-selector-open"))}open(){if(!this.modal&&(this.modal=this.querySelector("[data-store-selector-modal]")||document.body.querySelector("[data-store-selector-modal]"),this.modal&&!this.modal.dataset.detachedFromHost&&(this.modal.dataset.detachedFromHost="true",document.body.appendChild(this.modal)),this.modal&&(this.dialog=this.modal.querySelector(".store-selector__dialog"),this.overlay=this.modal.querySelector("[data-store-selector-overlay]"),this.closeButtons=Array.from(this.modal.querySelectorAll("[data-store-selector-close]")),this.optionsList=this.modal.querySelector(".store-selector__options"),this.statusEl=this.modal.querySelector("[data-store-selector-status]"),this.clearButton=this.modal.querySelector("[data-store-selector-clear]"),this.searchInput=this.modal.querySelector("[data-store-selector-search]"),this.useLocationButton=this.modal.querySelector("[data-store-selector-use-location]"),this.refreshOptionButtons(),!this.optionButtons.length))){if(this.locationsEndpoint||(this.locationsEndpoint=this.dataset.locationsEndpoint||""),!this.locationsEndpoint){const donor=Array.from(document.querySelectorAll("store-selector")).find(el=>el!==this&&el.locationsEndpoint);donor&&(this.locationsEndpoint=donor.locationsEndpoint,donor.locations&&donor.locations.length&&(this.locations=[...donor.locations]))}this.locations.length?this.renderLocations(this.getSortedLocations()):this.locationsEndpoint&&this.loadLocations()}this.modal&&(this.refreshOptionButtons(),this.optionButtons.length&&(this.detachOptionListeners(),this.attachOptionListeners(this.optionButtons)),this.modal.__storeSelectorInstance=this,this.modal.hidden=!1,this.modal.removeAttribute("hidden"),this.modal.setAttribute("aria-hidden","false"),this.trigger?.setAttribute("aria-expanded","true"),this.dataset.open="true",document.documentElement.classList.add("store-selector-open"),document.addEventListener("keydown",this.handleKeydown),this.setStatus(""),this.searchInput||(this.searchInput=this.modal.querySelector("[data-store-selector-search]")),this.initSearchInput(),this.focusFirstElement())}onSelectorClick(event){event.target.closest("[data-store-selector-open]")&&this.open()}close(){this.modal&&(this.modal.__storeSelectorInstance=this,this.modal.hidden=!0,this.modal.setAttribute("hidden","hidden"),this.modal.setAttribute("aria-hidden","true"),this.trigger?.setAttribute("aria-expanded","false"),this.dataset.open="",document.removeEventListener("keydown",this.handleKeydown),document.querySelector('store-selector[data-open="true"]')||document.documentElement.classList.remove("store-selector-open"),this.trigger?.focus())}onOptionClick(event){const button=event.currentTarget;if(!button||button.disabled)return;const value=button.dataset.value||"",label=button.dataset.label||"",urlAdd=button.dataset.urlAdd||"",urlRemove=button.dataset.urlRemove||"";button.dataset.active==="true"?this.clearSelection(urlRemove||this.dataset.clearUrl||""):this.selectValue(value,label,urlAdd)}onClearClick(event){event.preventDefault(),this.clearSelection(this.dataset.clearUrl||"")}async selectValue(value,label,fallbackUrl){await this.applySelection(value,label,fallbackUrl)}async clearSelection(fallbackUrl){try{localStorage.removeItem("storeSelectorSelection")}catch{}if(typeof window.updatePickupCartAttributes=="function")try{await window.updatePickupCartAttributes({clearAll:!0})}catch(e){console.warn("[StoreSelector] Failed to clear cart attributes",e)}await this.applySelection("","",fallbackUrl)}async applySelection(value,label,fallbackUrl){const prevValue=this.activeValue,prevLabel=this.activeLabel;if(this.updateForms(value)){this.setActiveValue(value,label),this.close();return}const success=await this.applyLocationSelection(value,label);!success&&fallbackUrl&&window.location.assign(fallbackUrl),success?(this.setActiveValue(value,label),this.close()):this.setActiveValue(prevValue,prevLabel)}async applyLocationSelection(value,label){const targetValue=value===""||value===null?this.defaultLocationId:value,normalizedValue=this.parseId(targetValue),api=window.inventoryInfo?.api;if(this.setStatus(""),api?.selectLocation)try{await api.selectLocation(normalizedValue);try{localStorage.setItem("storeSelectorSelection",JSON.stringify({id:String(normalizedValue),label:label||""}))}catch{}return this.setStatus(""),await this.syncWithInventorySelection(),!0}catch(error){if(error?.status===422)return this.setStatus(this.cartErrorText),setTimeout(()=>{this.setStatus("")},5e3),!1;this.setStatus(this.errorText),setTimeout(()=>{this.setStatus("")},5e3),console.error("[StoreSelector] Failed to select location via API",error)}try{return localStorage.setItem("storeSelectorSelection",JSON.stringify({id:normalizedValue,label:label||normalizedValue})),this.setActiveValue(normalizedValue,label),!0}catch(error){console.error("[StoreSelector] Failed to persist selection",error)}return!1}updateForms(nextValue){if(!this.filterParam)return!1;const forms=this.getFacetForms();if(!forms.length)return!1;let changeTarget=null,stateChanged=!1;
1return forms.forEach(form=>{const inputs=Array.from(form.elements).filter(element=>element.name===this.filterParam);inputs.length&&(changeTarget||(changeTarget=inputs[0]),inputs.forEach(input=>{const shouldBeChecked=nextValue!==null&&input.value===nextValue;input.checked!==shouldBeChecked&&(input.checked=shouldBeChecked,stateChanged=!0)}))}),stateChanged&&changeTarget&&changeTarget.dispatchEvent(new Event("change",{bubbles:!0})),stateChanged}getFacetForms(){return Array.from(document.querySelectorAll('form[is="facet-form"]'))}setActiveValue(value,label){this.activeValue=value===null?"":String(value||""),this.dataset.activeValue=this.activeValue,this.dataset.activeLabel=label||"";let displayLabel=this.placeholder;if(this.activeValue&&label)displayLabel=label;else if(this.activeValue&&!label)if(this.locations&&this.locations.length>0){const foundLocation=this.locations.find(loc=>String(loc.id)===String(this.activeValue));foundLocation?.name?displayLabel=this.formatLocationLabel(foundLocation):displayLabel=this.placeholder}else displayLabel=this.placeholder;this.valueTarget&&(this.valueTarget.textContent=displayLabel||this.placeholder||"");const hasSelection=this.activeValue!==""&&String(this.activeValue)!==String(this.defaultLocationId);this.clearButton&&(this.clearButton.disabled=!hasSelection),this.optionButtons.forEach(button=>{const isActive=!!(this.activeValue&&button.dataset.value===this.activeValue);button.classList.toggle("is-active",isActive),button.dataset.active=isActive?"true":"false",button.setAttribute("aria-pressed",isActive?"true":"false")}),this.dispatchEvent(new CustomEvent("store-selector:change",{detail:{id:this.activeValue,label:label||this.activeValue},bubbles:!0,composed:!0}))}setStatus(text){this.statusEl&&(text?(this.statusEl.hidden=!1,this.statusEl.textContent=text):this.statusEl.hidden=!0)}setLoading(isLoading){if(this.dialog&&this.dialog.setAttribute("aria-busy",isLoading?"true":"false"),isLoading){this.setStatus(this.loadingText);return}if(this.optionButtons.length){this.setStatus("");return}this.statusEl&&!this.statusEl.hidden&&this.statusEl.textContent||this.setStatus(this.emptyText)}async loadLocations(){if(!(!this.locationsEndpoint||!this.optionsList)){this.setLoading(!0);try{const response=await fetch(this.locationsEndpoint,{cache:"no-store"});if(!response.ok)throw new Error(`HTTP ${response.status}`);const data=await response.json();if(this.locations=this.filterHidden(this.normalizeLocations(data)),this.mergeExternalCoords(),!this.locations.length){this.setStatus(this.emptyText),this.renderLocations([]);return}this.renderLocations(this.getSortedLocations()),this.setStatus(""),this.syncWithInventorySelection()}catch(error){console.error("[StoreSelector] Failed to load locations",error),this.renderLocations([]),this.setStatus(this.errorText)}finally{this.setLoading(!1)}}}normalizeLocations(data){return(Array.isArray(data?.locations)?data.locations:Array.isArray(data)?data:[]).map(location=>{const id=location?.id??location?.locationId??location?.location_id??location?.location?.id??null,rawName=location?.name||"",name=this.stripPrefix(rawName),latitude=this.parseCoord(location?.latitude??location?.lat??location?.location?.latitude??location?.location?.lat??null),longitude=this.parseCoord(location?.longitude??location?.lng??location?.lon??location?.long??location?.location?.longitude??location?.location?.lng??location?.location?.lon??location?.location?.long??null),city=location?.city||location?.location?.city||"",region=location?.province||location?.state||location?.region||location?.location?.province||location?.location?.state||"";return{id,name,latitude,longitude,city,region}}).filter(location=>location.id!==null&&location.name)}renderLocations(locations){if(!this.optionsList)return;if(this.detachOptionListeners(),this.optionsList.innerHTML="",!locations.length){this.optionButtons=[];return}const fragment=document.createDocumentFragment();locations.forEach(location=>{const item=document.createElement("li"),button=this.createLocationButton(location);item.appendChild(button),fragment.appendChild(item)}),this.optionsList.appendChild(fragment),this.optionButtons=this.modal?Array.from(this.modal.querySelectorAll("[data-store-option]")):[],this.attachOptionListeners(this.optionButtons),this.setActiveValue(this.activeValue,this.activeLabel)}createLocationButton(location){const button=document.createElement("button"),label=this.formatLocationLabel(location);let distanceHtml="";if(this.userCoordinates&&this.userCoordinates.latitude!=null&&this.userCoordinates.longitude!=null&&location.latitude!=null&&location.longitude!=null){const distanceKm=this.computeDistanceKm(this.userCoordinates.latitude,this.userCoordinates.longitude,location.latitude,location.longitude);Number.isFinite(distanceKm)&&(distanceHtml=`<span class="store-selector__option-distance">${this.formatDistance(distanceKm)}</span>`)}return button.type="button",button.className="store-selector__option btn btn--secondary",button.dataset.storeOption="",button.dataset.value=String(location.id),button.dataset.label=label,button.dataset.active="false",button.innerHTML=`
2 <span class="store-selector__option-label"> 3 <span class="store-selector__option-name">${label}</span> 4 ${distanceHtml} 5 </span> 6 <span class="store-selector__option-state"></span> 7 `,button}formatDistance(distanceKm){return distanceKm<1?`${Math.round(distanceKm*1e3)} m`:distanceKm<10?`${distanceKm.toFixed(1)} km`:`${Math.round(distanceKm)} km`}formatLocationLabel(location){return this.stripPrefix(location.name||"")}parseId(value){const numberValue=Number(value);return Number.isNaN(numberValue)?value:numberValue}parseCoord(value){if(value==null)return null;const num=typeof value=="string"?parseFloat(value):Number(value);return Number.isNaN(num)||!Number.isFinite(num)?null:num}stripPrefix(label=""){return label.replace(/^\d+\s*-\s*/,"").trim().replace(/\s*\([^)]*\)\s*/g,"").trim()}getHiddenLocations(){const hidden=window.inventoryInfo?.settings?.hiddenLocation;if(!hidden||typeof hidden!="object")return{};const map={};return Object.keys(hidden).forEach(key=>{hidden[key]&&(map[String(this.parseId(key))]=!0)}),map}filterHidden(list){return!Array.isArray(list)||!Object.keys(this.hiddenLocationMap||{}).length?list||[]:list.filter(loc=>!this.hiddenLocationMap[String(this.parseId(loc.id))])}mergeExternalCoords(){if(!Array.isArray(this.locations)||!this.locations.length)return;let external=window.storeLocationCoords;if(!external)return;if(typeof external=="string")try{external=JSON.parse(external)}catch(error){console.warn("[StoreSelector] Unable to parse storeLocationCoords string",error);return}let sourceList=[];Array.isArray(external)?sourceList=external:Array.isArray(external?.locations)?sourceList=external.locations:external&&typeof external=="object"&&Object.values(external).forEach(val=>{Array.isArray(val)?sourceList=sourceList.concat(val):sourceList.push(val)});const externalCount=sourceList.length,map={};sourceList.forEach(item=>{const id=item?.id??item?.location_id??item?.locationId??item?.location?.id??null;if(id==null)return;const key=String(this.parseId(id)),lat=this.parseCoord(item?.latitude??item?.lat??item?.location?.latitude??item?.location?.lat??null),lng=this.parseCoord(item?.longitude??item?.lng??item?.long??item?.lon??item?.location?.longitude??item?.location?.lng??item?.location?.long??item?.location?.lon??null);map[key]={latitude:lat,longitude:lng}});let matchedCount=0;this.locations=this.locations.map(loc=>{const key=String(this.parseId(loc.id)),coords=map[key];return coords?(matchedCount+=Number.isFinite(coords.latitude)||Number.isFinite(coords.longitude)?1:0,{...loc,latitude:coords.latitude??loc.latitude,longitude:coords.longitude??loc.longitude}):loc});const withCoords=this.locations.filter(loc=>Number.isFinite(loc.latitude)&&Number.isFinite(loc.longitude)).length}getSortedLocations(){if(!this.userCoordinates)return[...this.locations];const{latitude:userLat,longitude:userLng}=this.userCoordinates||{};if(userLat==null||userLng==null)return[...this.locations];const known=this.locations.map(loc=>({location:loc,distance:this.computeDistanceKm(userLat,userLng,loc.latitude,loc.longitude)})).filter(entry=>Number.isFinite(entry.distance));return known.sort((a,b)=>a.distance-b.distance),known.map(entry=>entry.location)}computeDistanceKm(lat1,lon1,lat2,lon2){if(lat1==null||lon1==null||lat2==null||lon2==null||Number.isNaN(lat1)||Number.isNaN(lon1)||Number.isNaN(lat2)||Number.isNaN(lon2))return Number.POSITIVE_INFINITY;const toRad=deg=>deg*Math.PI/180,R=6371,dLat=toRad(lat2-lat1),dLon=toRad(lon2-lon1),a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(toRad(lat1))*Math.cos(toRad(lat2))*Math.sin(dLon/2)*Math.sin(dLon/2),c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));return R*c}setUserCoordinates(lat,lng){this.userCoordinates={latitude:this.parseCoord(lat),longitude:this.parseCoord(lng)},this.mergeExternalCoords();const sorted=this.getSortedLocations();this.renderLocations(sorted)}async syncWithInventorySelection(){const api=window.inventoryInfo?.api;let currentId=api?.getSelectedLocationId?.()??null,label=this.activeLabel;if(currentId==null)try{const stored=JSON.parse(localStorage.getItem("storeSelectorSelection"));
7if(stored?.id&&(currentId=stored.id,label=stored.label||"",api?.selectLocation))try{await api.selectLocation(Number(currentId))}catch{}}catch{}if(currentId!=null)try{if(api?.getSelectedLocation)try{const location=await api.getSelectedLocation();location?.name&&(label=this.stripPrefix(location.name||""))}catch(error){console.warn("[StoreSelector] Failed to resolve current location details",error)}if(!label&&this.locations&&this.locations.length>0){const foundLocation=this.locations.find(loc=>String(loc.id)===String(currentId));foundLocation?.name&&(label=this.formatLocationLabel(foundLocation))}label?this.setActiveValue(String(currentId),label):this.setActiveValue("","")}catch(error){console.warn("[StoreSelector] Failed to read current location",error)}}initSearchInput(){if(!this.searchInput){console.warn("[StoreSelector] Search input not found");return}if(this.autocomplete)return;const apiKey=window.inventoryInfo?.settings?.geo?.apiKey;if(!apiKey){console.warn("[StoreSelector] Google Maps API key not found");return}this.initGoogleMapsAutocomplete(apiKey)}initGoogleMapsAutocomplete(apiKey){if(window.google&&window.google.maps&&window.google.maps.places){setTimeout(()=>{this.setupAutocomplete()},100);return}const scriptId="google-maps-places-api";if(document.getElementById(scriptId)){const checkGoogleMaps=setInterval(()=>{window.google&&window.google.maps&&window.google.maps.places&&(clearInterval(checkGoogleMaps),setTimeout(()=>{this.setupAutocomplete()},100))},100);setTimeout(()=>{clearInterval(checkGoogleMaps)},1e4);return}const script=document.createElement("script");script.id=scriptId,script.src=`https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places`,script.async=!0,script.defer=!0,script.onload=()=>{setTimeout(()=>{this.setupAutocomplete()},100)},script.onerror=()=>{console.warn("[StoreSelector] Failed to load Google Maps API")},document.head.appendChild(script)}setupAutocomplete(){if(!this.searchInput){console.warn("[StoreSelector] Search input not available for autocomplete setup");return}if(!window.google||!window.google.maps||!window.google.maps.places){console.warn("[StoreSelector] Google Maps Places API not loaded");return}try{const autocomplete=new window.google.maps.places.Autocomplete(this.searchInput,{types:["address"],fields:["geometry","formatted_address","name"]});this.autocomplete=autocomplete;const adjustZIndex=()=>{const pacContainer=document.querySelector(".pac-container");pacContainer&&(pacContainer.style.zIndex="2147483001")};let zIndexCheckInterval;this.searchInput.addEventListener("focus",()=>{adjustZIndex(),zIndexCheckInterval=setInterval(adjustZIndex,100)}),this.searchInput.addEventListener("blur",()=>{zIndexCheckInterval&&clearInterval(zIndexCheckInterval)}),this.searchInput.addEventListener("input",adjustZIndex);let placeSelected=!1;autocomplete.addListener("place_changed",()=>{const place=autocomplete.getPlace();if(!place.geometry||!place.geometry.location){console.warn("[StoreSelector] No geometry data for selected place"),placeSelected=!1;return}placeSelected=!0;const lat=place.geometry.location.lat(),lng=place.geometry.location.lng();this.setUserCoordinates(lat,lng)}),this.searchInput.addEventListener("focus",()=>{placeSelected=!1})}catch(error){console.error("[StoreSelector] Error setting up autocomplete:",error)}}onKeydown(event){if(event.key==="Escape"){event.preventDefault(),this.close();return}event.key==="Tab"&&this.maintainFocus(event)}maintainFocus(event){const focusable=this.getFocusableElements();if(!focusable.length){event.preventDefault();return}const first=focusable[0],last=focusable[focusable.length-1];event.shiftKey&&document.activeElement===first?(event.preventDefault(),last.focus()):!event.shiftKey&&document.activeElement===last&&(event.preventDefault(),first.focus())}getFocusableElements(){return this.dialog?Array.from(this.dialog.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')):[]}focusFirstElement(){const focusable=this.getFocusableElements();focusable.length?focusable[0].focus():this.dialog?.focus()}}customElements.get("store-selector")||customElements.define("store-selector",StoreSelectorComponent); 8//# sourceMappingURL=/cdn/shop/t/393/assets/store-selector.js.map?v=39611691407314077321785420333
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.