1window.BAO.Utils={},window.BAO.Utils.getElement=function(selector,{context=document}={}){return context.querySelector(selector)},window.BAO.Utils.getElements=function(selector,{context=document,asArray=!0}={}){const items=context.querySelectorAll(selector);return asArray?Array.from(items):items},window.BAO.Utils.doesStringContainAny=function(str,items=[]){return items.some(i=>str.includes(i))},window.BAO.Utils.createElement=function(tag,options={}){const el=document.createElement(tag);return Object.entries(options).forEach(([key,value])=>{el.setAttribute(key,value)}),el},window.BAO.Utils.range=function(amount){return[...Array(amount).keys()]},window.BAO.Utils.camelize=function(str){return str.replace(/(?:^\w|[A-Z]|\b\w)/g,(word,index)=>index===0?word.toLowerCase():word.toUpperCase()).replace(/\s+/g,"")},window.BAO.Utils.resizeImage=function({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},window.BAO.Utils.getDefaultRequestConfig=function(type="json"){return{method:"POST",headers:{Accept:`application/${type}`,"Content-Type":"application/json"}}},window.BAO.Utils.fetchJSON=function(url,config={}){return fetch(url,Object.assign({},window.BAO.Utils.getDefaultRequestConfig(),config)).then(response=>{if(!response.ok)throw response;return response.json()})},window.BAO.Utils.fetchProductData=function(handle){try{return window.BAO.Utils.fetchJSON(`/products/${handle}.js`)}catch(e){console.error(e)}},window.BAO.Utils.getOffsetTop=function getOffsetTop(el,parent=document.body,offsetTop=0){return isNaN(el.offsetTop)||(offsetTop+=el.offsetTop),el.offsetParent===parent?offsetTop:getOffsetTop(el.offsetParent,parent,offsetTop)},window.BAO.Utils.getOffsetLeft=function getOffsetLeft(el,parent=document.body,offsetLeft=0){return isNaN(el.offsetLeft)||(offsetLeft+=el.offsetLeft),el.offsetParent===parent?offsetLeft:getOffsetLeft(el.offsetParent,parent,offsetLeft)},window.BAO.Utils.formatMoney=function(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)},window.BAO.Utils.getOrdinalForDay=function(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"}},window.BAO.Utils.translateString=function(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)},window.BAO.Utils.debounce=function(fn,wait){let t;return(...args)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(this,args),wait)}},window.BAO.Utils.buildProperties=function(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),{})},window.BAO.Utils.isInViewport=function(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)},window.BAO.Utils.isChild=function(child,parent,levelsDeep=3){let node=child.parentNode,count=0;for(;node;){if(node===parent)return!0;
1if(levelsDeep===count||child===parent)return!1;count++,node=node.parentNode}return!1},window.BAO.Utils.elementReady=function(selector){return new Promise((resolve,reject)=>{const el=document.querySelector(selector);if(el){resolve(el);return}new MutationObserver((mutationRecords,observer)=>{Array.from(document.querySelectorAll(selector)).forEach(element=>{resolve(element),observer.disconnect()})}).observe(document.documentElement,{childList:!0,subtree:!0})})},window.BAO.Utils.copyToClipboard=function(string){let textarea,result;try{textarea=document.createElement("textarea"),textarea.setAttribute("readonly",!0),textarea.setAttribute("contenteditable",!0),textarea.style.position="fixed",textarea.value=string,document.body.appendChild(textarea),textarea.focus(),textarea.select();const range2=document.createRange();range2.selectNodeContents(textarea);const sel=window.getSelection();sel.removeAllRanges(),sel.addRange(range2),textarea.setSelectionRange(0,textarea.value.length),result=document.execCommand("copy")}catch(err){console.error(err),result=null}finally{document.body.removeChild(textarea)}if(!result){const copyHotkey=navigator.platform.toUpperCase().indexOf("MAC")>=0?"\u2318C":"CTRL+C";if(result=prompt(`Press ${copyHotkey}`,string),!result)return!1}return!0}; 2//# sourceMappingURL=/cdn/shop/t/291/assets/bao-utils.js.map?v=2861621957182201751761906980
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.