1function getElement(selector,{context=document}={}){return context.querySelector(selector)}function getElements(selector,{context=document,asArray=!0}={}){const items=context.querySelectorAll(selector);return asArray?Array.from(items):items}function doesStringContainAny(str,items=[]){return items.some(i=>str.includes(i))}function createElement(tag,options={}){const el=document.createElement(tag);return Object.entries(options).forEach(([key,value])=>{el.setAttribute(key,value)}),el}function range(amount){return[...Array(amount).keys()]}function camelize(str){return str.replace(/(?:^\w|[A-Z]|\b\w)/g,(word,index)=>index===0?word.toLowerCase():word.toUpperCase()).replace(/\s+/g,"")}function resizeImage({src,size,crop=null,scale=null}={}){if(size==null)return src;if(size==="master")return src.replace(/http(s)?:/,"");const match=src.match(/\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?/i);if(match!=null){const prefix=src.split(match[0]),suffix=match[0],scaleString=scale?`@${scale}x`:"",cropString=crop?`_crop_${crop}`:"";return`${prefix[0]}_${size}${cropString}${scaleString}${suffix}`.replace(/http(s)?:/,"")}else return null}function getDefaultRequestConfig(type="json"){return{method:"POST",headers:{Accept:`application/${type}`,"Content-Type":"application/json"}}}function fetchJSON(url,config={}){return fetch(url,Object.assign({},getDefaultRequestConfig(),config)).then(response=>{if(!response.ok)throw response;return response.json()})}function fetchProductData(handle){try{return fetchJSON(`/products/${handle}.js`)}catch(e){console.error(e)}}function getOffsetTop(el,parent=document.body,offsetTop=0){return isNaN(el.offsetTop)||(offsetTop+=el.offsetTop),el.offsetParent===parent?offsetTop:getOffsetTop(el.offsetParent,parent,offsetTop)}function formatMoney(cents,format=window.theme.moneyFormat){typeof cents=="string"&&(cents=cents.replace(".",""));let value="";const placeholderRegex=/\{\{\s*(\w+)\s*\}\}/,formatString=format;function formatWithDelimiters(number,precision=2,thousands=",",decimal="."){if(isNaN(number)||number==null)return 0;number=(number/100).toFixed(precision);const parts=number.split("."),dollarsAmount=parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,`$1${thousands}`),centsAmount=parts[1]?decimal+parts[1]:"";return dollarsAmount+centsAmount}switch(formatString.match(placeholderRegex)[1]){case"amount":value=formatWithDelimiters(cents,2);break;case"amount_no_decimals":value=formatWithDelimiters(cents,0);break;case"amount_with_comma_separator":value=formatWithDelimiters(cents,2,".",",");break;case"amount_no_decimals_with_comma_separator":value=formatWithDelimiters(cents,0,".",",");break}return formatString.replace(placeholderRegex,value)}function getOrdinalForDay(day){if(day>3&&day<21)return"th";switch(day%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function translateString(translation,variables,options={delimiters:[["{{\\s*","\\s*}}"],["%{","}"]]}){return Object.entries(variables).reduce((baseTranslation,[key,value])=>{const replacePattern=options.delimiters.map(([start,end])=>`${start}${key}${end}`).join("|");return baseTranslation.replace(new RegExp(replacePattern,"g"),value)},translation)}function debounce(fn,wait){let t;return(...args)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(this,args),wait)}}function buildProperties(formData){const propertyKeyValues=[...formData.entries()].filter(([key,value])=>key.includes("properties[")&&value!=="");function propertyReducer(properties,[key,value]){const strippedKey=key.replace("properties[","").slice(0,-1);return{...properties,[strippedKey]:value}}return propertyKeyValues.reduce((properties,property)=>propertyReducer(properties,property),{})}function isInViewport(element){const rect=element.getBoundingClientRect();return rect.top>=0&&rect.left>=0&&rect.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&rect.right<=(window.innerWidth||document.documentElement.clientWidth)}function hasExitedTopOfViewport(element,useHeader){const rect=element.getBoundingClientRect(),viewportWidth=window.innerWidth||document.documentElement.clientWidth;let hasExitedTopOfViewport2=rect.top+rect.height<0;if(useHeader){const announcementBar=document.querySelector("header-announcement-bar"),announcementBarHeight=announcementBar!==null?announcementBar.offsetHeight:0,headerHeight=document.querySelector(".hd-Header").offsetHeight,combinedHeight=announcementBarHeight+headerHeight;hasExitedTopOfViewport2=rect.top+rect.height-combinedHeight<0}return hasExitedTopOfViewport2&&rect.left>=0&&rect.right<=viewportWidth}function scrollToY(scrollTargetY=0){window.scrollTo(0,scrollTargetY)}window.BAO.Utils={getElement,getElements,doesStringContainAny,createElement,range,camelize,resizeImage,getDefaultRequestConfig,fetchJSON,fetchProductData,getOffsetTop,formatMoney,getOrdinalForDay,translateString,debounce,buildProperties,isInViewport,hasExitedTopOfViewport,scrollToY}; 2//# sourceMappingURL=/cdn/shop/t/651/assets/bao-utils.js.map?v=148892058760894990311790082282
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.