1const defaultSectionsUrl=()=>["/apps/","/a/","/tools/","/community/"].some(url=>window.location.pathname.includes(url))?"/":window.location.pathname,DEFAULT_SECTIONS_URL=defaultSectionsUrl();class BaoCart{async addItemFromForm(form,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL,attributes={}}={}){const formData=new FormData(form);formData.append("sections",sections),formData.append("sections_url",sectionsUrl),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD_FROM_FORM,{form,formData,attributes});const config=window.BAO.Utils.getDefaultRequestConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"],config.body=formData;try{const state=await window.BAO.Utils.fetchJSON(`${window.routes.cartAddUrl}`,config);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_ADD_FROM_FORM,{form,formData,state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){this.handleAddToCartError(err)}}async addItem(items,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL,attributes={},form}={}){Array.isArray(items)||(items=[items]),"last_added_id"in attributes||(attributes.last_added_id=items[0].productId),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD,{items,attributes,form});const body={items,attributes};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartAdd(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_ADD,{items,state,form}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){this.handleAddToCartError(err)}}async updateQuantity(key,quantity,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_ITEM_QUANTITY,{key,quantity});const body={id:key,quantity};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartChange(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_ITEM_QUANTITY,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){console.error(err)}}async removeItem(key,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_REMOVE_ITEM,{key});const body={id:key,quantity:0};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartChange(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_REMOVE_ITEM,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){console.error(err)}}async removeItems(keys,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){for(window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_REMOVE_ITEM,{keys});keys.length>0;){const key=keys.shift(),isLastKey=keys.length===0,body={id:key,quantity:0};isLastKey&§ions.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartChange(body);if(isLastKey)return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_REMOVE_ITEM,{state}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(err){console.error(err)}}}async updateItemProperties(key,properties,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){const body={id:key,properties};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{return this.cartChange(body)}catch(e){console.error(e)}}async updateCartAttributes(attributes,{sections=window.BAO.sectionRenderer.pushCartSections.map(s=>s.section),sectionsUrl=DEFAULT_SECTIONS_URL}={}){window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.BEFORE_UPDATE_CART_ATTRIBUTES,{attributes});const body={attributes};sections.length&&(body.sections=sections,body.sections_url=sectionsUrl);try{const state=await this.cartUpdate(body);return window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.AFTER_UPDATE_CART_ATTRIBUTES,{attributes}),window.BAO.dispatchEvent(window.BAO.EVENTS.PUSH_CART.CHANGED,{state}),state}catch(e){console.error(e)}}async updateNote(note){window.BAO.dispatchEvent(window.BAO.EVENTS.CART_NOTE.BEFORE_CHANGE,{note});try{const state=await this.cartUpdate({note});return window.BAO.dispatchEvent(window.BAO.EVENTS.CART_NOTE.AFTER_CHANGE,{state,note}),state}catch(e){console.error(e)}}handleAddToCartError(res){const pushCart=window.BAO.Utils.getElement("push-cart");pushCart&&pushCart.handleError(res)}cartGet(){return window.BAO.Utils.fetchJSON("/cart.js",{...window.BAO.Utils.getDefaultRequestConfig(),method:"GET"})}cartAdd(body){return window.BAO.Utils.fetchJSON(`${window.routes.cartAddUrl}`,{...window.BAO.Utils.getDefaultRequestConfig(),body:JSON.stringify(body)})}cartChange(body){return window.BAO.Utils.fetchJSON(`${window.routes.cartChangeUrl}`,{...window.BAO.Utils.getDefaultRequestConfig(),body:JSON.stringify(body)})}
1cartUpdate(body){return window.BAO.Utils.fetchJSON(`${window.routes.cartUpdateUrl}`,{...window.BAO.Utils.getDefaultRequestConfig(),body:JSON.stringify(body)})}}window.BAO.Cart=new BaoCart; 2//# sourceMappingURL=/cdn/shop/t/291/assets/bao-cart.js.map?v=38884637578015409251761906981
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.