Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commercelayer

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commercelayer - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

2

dist/commercelayer.min.js

@@ -1,2 +0,2 @@

!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}([function(e,t,n){"use strict";var o=n(7),i=n(17),a=Object.prototype.toString;function r(e){return"[object Array]"===a.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===a.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===a.call(e)},isBuffer:i,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===a.call(e)},isFile:function(e){return"[object File]"===a.call(e)},isBlob:function(e){return"[object Blob]"===a.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]=n}for(var o=0,i=arguments.length;o<i;o++)u(arguments[o],n);return t},extend:function(e,t,n){return u(t,function(t,i){e[i]=n&&"function"==typeof t?o(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){const o=n(5),i=n(35);e.exports={getOrderCookieName:function(){return`order_token_${o.clientId()}_${o.marketId()}_${o.countryCode()}`},getAccessTokenCookieName:function(){return`access_token_${o.clientId()}_${o.marketId()}`},getAccessTokenRetryLockCookieName:function(){return`${this.getAccessTokenCookieName()}_retry_lock`},getOrderToken:function(){return i.get(this.getOrderCookieName())},setOrderToken:function(e){return i.set(this.getOrderCookieName(),e,{expires:30})},deleteOrderToken:function(){return i.remove(this.getOrderCookieName())},getAccessTokenCookie:function(){return i.get(this.getAccessTokenCookieName())},setAccessTokenCookie:function(e,t){i.set(this.getAccessTokenCookieName(),e,t)},getAccessTokenRetryLockCookie:function(){return i.get(this.getAccessTokenRetryLockCookieName())},setAccessTokenRetryLockCookie:function(){i.set(this.getAccessTokenRetryLockCookieName(),"1",{expires:1/1440})},getElementFromTemplate:function(e){return"TEMPLATE"==e.tagName?document.importNode(e.content.firstElementChild,!0):document.importNode(e.firstElementChild,!0)},getInventoryFirstAvailableLevel:function(e){if(first_level=e.levels[0],0==first_level.quantity)for(k=1;k<e.levels.length;k++)if(level=e.levels[k],level.quantity>0){first_level=level;break}return first_level}}},function(e,t){e.exports={config:document.querySelector("#clayer-config"),main:document.querySelector("#clayer-main"),prices:Array.prototype.slice.call(document.querySelectorAll(".clayer-price"),0),variants:Array.prototype.slice.call(document.querySelectorAll(".clayer-variant"),0),variantSelect:document.querySelector(".clayer-variant-select"),availabilityMessageContainer:document.querySelector("#clayer-availability-message-container"),availabilityMessageAvailableTemplate:document.querySelector("#clayer-availability-message-available-template"),availabilityMessageUnavailableTemplate:document.querySelector("#clayer-availability-message-unavailable-template"),addToBag:document.querySelector(".clayer-add-to-bag"),shoppingBagContainer:document.querySelector("#clayer-shopping-bag-container"),shoppingBagItemsContainer:document.querySelector("#clayer-shopping-bag-items-container"),shoppingBagItemTemplate:document.querySelector("#clayer-shopping-bag-item-template"),shoppingBagItemsCount:document.querySelector("#clayer-shopping-bag-items-count"),shoppingBagSubtotal:document.querySelector("#clayer-shopping-bag-subtotal"),shoppingBagShipping:document.querySelector("#clayer-shopping-bag-shipping"),shoppingBagPayment:document.querySelector("#clayer-shopping-bag-payment"),shoppingBagDiscount:document.querySelector("#clayer-shopping-bag-discount"),shoppingBagTaxes:document.querySelector("#clayer-shopping-bag-taxes"),shoppingBagTotal:document.querySelector("#clayer-shopping-bag-total"),shoppingBagCheckout:document.querySelector("#clayer-shopping-bag-checkout"),shoppingBagClose:document.querySelector("#clayer-shopping-bag-close"),shoppingBagToggle:document.querySelector("#clayer-shopping-bag-toggle"),shoppingBagUnavailableMessage:document.querySelector(".clayer-shopping-bag-unavailable-message")}},function(e,t,n){e.exports=n(16)},function(e,t,n){"use strict";(function(t){var o=n(0),i=n(20),a={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:("undefined"!=typeof XMLHttpRequest?s=n(8):void 0!==t&&(s=n(8)),s),transformRequest:[function(e,t){return i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],function(e){c.headers[e]={}}),o.forEach(["post","put","patch"],function(e){c.headers[e]=o.merge(a)}),e.exports=c}).call(this,n(19))},function(e,t,n){const o=n(2);e.exports={baseUrl:function(){return o.config.dataset.baseUrl},clientId:function(){return o.config.dataset.clientId},marketId:function(){return o.config.dataset.marketId},countryCode:function(){return o.config.dataset.countryCode},languageCode:function(){return o.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return o.config.dataset.cartUrl},returnUrl:function(){return o.config.dataset.returnUrl},privacyUrl:function(){return o.config.dataset.privacyUrl},termsUrl:function(){return o.config.dataset.termsUrl}}},function(e,t,n){const o=n(2),a=n(3),r=(n(12),n(13)),s=n(5),c=n(1),u=n(14);e.exports={getPrices:function(){$prices=o.prices,$prices.length>0&&(skuCodes=[],$prices.forEach(function(e){skuCodes.push(e.dataset.skuCode)}),skus=[],skusEndpoint="/api/skus?filter[codes]="+skuCodes.join(",")+"&include=prices&page[size]=25",skuAttributes=["id","code","prices.formatted_amount","prices.formatted_compare_at_amount","prices.amount_cents","prices.compare_at_amount_cents"],a.get(skusEndpoint).then(function(e){if(u.updatePrices(r(e.data).get(skuAttributes)),pageCount=e.data.meta.page_count,pageCount>1)for(p=2;p<=pageCount;p++)skusEndpointWithPage=skusEndpoint+"&page[number]="+p,a.get(skusEndpointWithPage).then(function(e){u.updatePrices(r(e.data).get(skuAttributes))})}))},getVariants:function(){u.disableElement(o.addToBag),$variants=o.variants,$variants.length>0&&(skuCodes=[],$variants.forEach(function(e){u.disableElement(e),skuCodes.push(e.dataset.skuCode)}),a.get("/api/skus?filter[codes]="+skuCodes.join(",")).then(function(t){for(skus=r(t.data).get(["id","code"]),i=0;i<skus.length;i++)variant=document.querySelector('.clayer-variant[data-sku-code="'+skus[i].code+'"]'),variant&&(variant.value=skus[i].id,u.enableElement(variant),0==i&&e.exports.selectVariant(variant))}))},getInventory:function(e,t){a.get("/api/skus/"+e+"?fields[skus]=inventory").then(function(n){sku=n.data.data,u.updateAvailabilityMessage(sku.attributes.inventory),sku.attributes.inventory.available?(u.updateAddToBagSKU(e,t),u.enableAddToBag()):u.disableAddToBag()})},selectVariant:function(t){switch(t.tagName){case"INPUT":switch(t.type){case"radio":t.click();break;case"hidden":e.exports.getInventory(t.value,t.dataset.skuName)}break;case"OPTION":$select=t.parentNode,$select.value=t.value,$select.dispatchEvent(new Event("change"))}},createOrder:function(){return a.post("/api/orders",{data:{type:"orders",attributes:{shipping_country_code_lock:s.countryCode(),language_code:s.languageCode(),cart_url:s.cartUrl(),return_url:s.returnUrl(),privacy_url:s.privacyUrl(),terms_url:s.termsUrl()}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return c.setOrderToken(e.data.data.attributes.token),e.data.data})},refreshOrder:function(){c.getOrderToken()&&this.getOrder().then(function(e){e&&"placed"==e.attributes.status&&(c.deleteOrderToken(),u.clearShoppingBag())})},createLineItem:function(e,t,n,o){return a.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:o,_update_quantity:1},relationships:{order:{data:{type:"orders",id:e}},item:{data:{type:"skus",id:t}}}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},deleteLineItem:function(e){return a.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return a.patch("/api/line_items/"+e,{data:{type:"line_items",id:e,attributes:t}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},updateLineItemQty:function(e,t){api=this,api.updateLineItem(e,{quantity:t}).then(function(e){api.getOrder()}).catch(function(e){if(e.response)switch(e.response.status){case 422:u.displayShoppingBagUnavailableMessage()}})},updateShoppingBagItems:function(e){if(api=this,$shoppingBagItemsContainer=o.shoppingBagItemsContainer,$shoppingBagItemsContainer&&(normalized_order=r(e).get(["id","formatted_subtotal_amount","formatted_discount_amount","formatted_shipping_amount","formatted_payment_method_amount","formatted_total_tax_amount","formatted_total_amount_with_taxes","line_items.id","line_items.item_type","line_items.image_url","line_items.name","line_items.quantity","line_items.formatted_unit_amount","line_items.formatted_total_amount"])[0],normalized_order.line_items))for($shoppingBagItemsContainer.innerHTML="",i=0;i<normalized_order.line_items.length;i++)if(line_item=normalized_order.line_items[i],"skus"==line_item.item_type&&($shoppingBagItemTemplate=o.shoppingBagItemTemplate,$shoppingBagItemTemplate)){for($shoppingBagItem=c.getElementFromTemplate($shoppingBagItemTemplate),$shoppingBagItemImage=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-image"),$shoppingBagItemImage.src=line_item.image_url,$shoppingBagItemName=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-name"),$shoppingBagItemName.innerHTML=line_item.name,$shoppingBagItemQtyContainer=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-qty-container"),$qtySelect=document.createElement("select"),$qtySelect.dataset.lineItemId=line_item.id,qty=1;qty<=10;qty++)$option=document.createElement("option"),$option.value=qty,$option.text=qty,qty==line_item.quantity&&($option.selected=!0),$qtySelect.appendChild($option);$qtySelect.addEventListener("change",function(e){api.updateLineItemQty(this.dataset.lineItemId,this.value)}),$shoppingBagItemQtyContainer.appendChild($qtySelect),$shoppingBagItemUnitAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-unit-amount"),$shoppingBagItemUnitAmount.innerHTML=line_item.formatted_unit_amount,$shoppingBagItemTotalAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-total-amount"),$shoppingBagItemTotalAmount.innerHTML=line_item.formatted_total_amount,$shoppingBagItemRemove=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-remove"),$shoppingBagItemRemove.dataset.lineItemId=line_item.id,$shoppingBagItemRemove.addEventListener("click",function(e){e.preventDefault(),api.deleteLineItem(this.dataset.lineItemId).then(function(e){api.getOrder()})}),$shoppingBagItemsContainer.appendChild($shoppingBagItem)}},getOrder:function(){return api=this,a.get("/api/orders?include=line_items&filter[token]="+c.getOrderToken()).then(function(e){if(e.data.data.length>0)return api.updateShoppingBagItems(e.data),u.hideShoppingBagUnavailableMessage(),u.updateShoppingBagSummary(e.data.data[0]),u.updateShoppingBagCheckout(e.data),0==e.data.data[0].attributes.skus_count&&u.clearShoppingBag(),e.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}}},function(e,t,n){"use strict";var o=n(0),i=n(21),a=n(23),r=n(24),s=n(25),c=n(9),u="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(26);e.exports=function(e){return new Promise(function(t,p){var l=e.data,d=e.headers;o.isFormData(l)&&delete d["Content-Type"];var f=new XMLHttpRequest,g="onreadystatechange",h=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in f||s(e.url)||(f=new window.XDomainRequest,g="onload",h=!0,f.onprogress=function(){},f.ontimeout=function(){}),e.auth){var m=e.auth.username||"",y=e.auth.password||"";d.Authorization="Basic "+u(m+":"+y)}if(f.open(e.method.toUpperCase(),a(e.url,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,f[g]=function(){if(f&&(4===f.readyState||h)&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in f?r(f.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?f.response:f.responseText,status:1223===f.status?204:f.status,statusText:1223===f.status?"No Content":f.statusText,headers:n,config:e,request:f};i(t,p,o),f=null}},f.onerror=function(){p(c("Network Error",e,null,f)),f=null},f.ontimeout=function(){p(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",f)),f=null},o.isStandardBrowserEnv()){var v=n(27),b=(e.withCredentials||s(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;b&&(d[e.xsrfHeaderName]=b)}if("setRequestHeader"in f&&o.forEach(d,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete d[t]:f.setRequestHeader(t,e)}),e.withCredentials&&(f.withCredentials=!0),e.responseType)try{f.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){f&&(f.abort(),p(e),f=null)}),void 0===l&&(l=null),f.send(l)})}},function(e,t,n){"use strict";var o=n(22);e.exports=function(e,t,n,i,a){var r=new Error(e);return o(r,t,n,i,a)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,n){const o=n(3),i=n(5),a=n(1);o.defaults.baseURL=i.baseUrl(),o.defaults.headers.common.Accept="application/vnd.api+json",o.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+a.getAccessTokenCookie(),e},function(e){return Promise.reject(e)}),o.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&function(){if(navigator.cookieEnabled)return!0;document.cookie="cookietest=1";var e=-1!=document.cookie.indexOf("cookietest=");return document.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}()&&null==a.getAccessTokenRetryLockCookie()?(a.setAccessTokenRetryLockCookie(),o.post("/oauth/token",{grant_type:"client_credentials",client_id:i.clientId(),scope:"market:"+i.marketId()}).then(function(e){return a.setAccessTokenCookie(e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return e.config.headers.Authorization="Bearer "+t,o.request(e.config)})):Promise.reject(e)})},function(e,t,n){var o,i,a;i=[],void 0===(a="function"==typeof(o=function(){function e(o,i){if(!(this instanceof e)){var a=new e(o);return i?a.get(i):a}if("string"==typeof o&&(o=JSON.parse(o)),!o||!o.data)throw new Error("Invalid json api normalizer input");var r,s,c,u;this.dataset=o,this.isCollection=t(o.data),this.haystack=(r=o.included,s=this.isCollection?o.data:[o.data],c=[],n(u=r||[],function(e){c.push(e.type+"@"+e.id)}),n(s,function(e){c.indexOf(e.type+"@"+e.id)<0&&u.push(e)}),u)}function t(e){return e instanceof Array}function n(e,n,o){if(t(e))for(var i=e.length,a=0;a<i;a++)n.call(o,e[a],a);else for(var r in e)e.hasOwnProperty(r)&&n.call(o,r,e[r])}function o(e,t,o){var i=[];return n(e,function(e,n){i.push(t.call(o,e,n))}),i}function i(i,s,c){var u={};return n(i,function(n,i){if(i)u[n]=function(e,n,i,s){var c=i.relationships&&i.relationships[e]&&i.relationships[e].data,u=c&&r(c,s);return t(u)?o(u,function(e){return a(n,e,s)}):u?a(n,u,s):void 0}(n,i,s,c);else{var p=s.relationships&&s.relationships[n]&&s.relationships[n].data;if(p){var l=r(p,c);u[n]=l?new e({data:l,included:c}):void 0}else u[n]=function(e,t){return["id","type"].indexOf(e)>=0?t[e]:t.attributes[e]}(n,s)}}),u}function a(t,n,o){return s.call(new e({data:n,included:o}),t)}function r(e,i){var a=[],r=t(e)?o(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(i,function(e){r.indexOf(e.type+"@"+e.id)>=0&&a.push(e)}),0===a.length?void 0:1!==a.length||t(e)?a:a[0]}function s(e){return this.isCollection?o(this.dataset.data,function(t){return i(e,t,this.haystack)},this):i(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var i,a,r=s.call(this,(i=t(e)?e:[e],a={},n(i,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var o in n)n.hasOwnProperty(o)&&("object"==typeof n[o]&&null!==n[o]?(void 0===t[o]&&(t[o]={}),e(t[o],n[o])):t[o]=n[o]);return t}(a,function(e){for(var t={},n=t,o=e.length,i=0;i<o;i++)n=n[e[i]]=n[e[i]]||(i+1===o?void 0:{});return t}(t)):a[e]=void 0}),a));return this.isCollection?t(e)?r:o(r,function(t){return t[e]}):t(e)?r:r[e]},e})?o.apply(t,i):o)||(e.exports=a)},function(e,t,n){const o=n(2),i=n(1),a=n(13);e.exports={enableElement:function(e){e&&e.classList.remove("disabled")},disableElement:function(e){e&&e.classList.add("disabled")},setElementHTML(e,t,n){el=e.querySelector(t),el&&(el.innerHTML=n)},displayElement:function(e){e&&(e.style.display="block")},hideElement:function(e){e&&(e.style.display="none")},updatePrices:function(e){for(k=0;k<e.length;k++)priceAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .amount'),priceAmount&&(priceAmount.innerHTML=e[k].prices[0].formatted_amount),priceCompareAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .compare-at-amount'),priceCompareAmount&&e[k].prices[0].compare_at_amount_cents>e[k].prices[0].amount_cents&&(priceCompareAmount.innerHTML=e[k].prices[0].formatted_compare_at_amount)},updateAddToBagSKU:function(e,t){$addToBag=o.addToBag,$addToBag&&($addToBag.dataset.skuId=e,$addToBag.dataset.skuName=t)},enableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.enableElement($addToBag)},disableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.disableElement($addToBag)},updateAvailabilityMessage:function(e){$container=o.availabilityMessageContainer,$container&&(first_level=i.getInventoryFirstAvailableLevel(e),first_level.quantity>0?(dlt=first_level.delivery_lead_times[0],qty=first_level.quantity,minDays=dlt.min.days,maxDays=dlt.max.days,shippingMethodName=dlt.shipping_method.name,shippingMethodPrice=dlt.shipping_method.formatted_price_amount,this.displayAvailableMessage(qty,minDays,maxDays,shippingMethodName,shippingMethodPrice)):this.displayUnavailableMessage())},updateShoppingBagSummary:function(e){$shoppingBagItemsCount=o.shoppingBagItemsCount,$shoppingBagItemsCount&&($shoppingBagItemsCount.innerHTML=e.attributes.skus_count),$shoppingBagTotal=o.shoppingBagTotal,$shoppingBagTotal&&($shoppingBagTotal.innerHTML=e.attributes.formatted_total_amount_with_taxes),$shoppingBagSubtotal=o.shoppingBagSubtotal,$shoppingBagSubtotal&&($shoppingBagSubtotal.innerHTML=e.attributes.formatted_subtotal_amount),$shoppingBagShipping=o.shoppingBagShipping,$shoppingBagShipping&&($shoppingBagShipping.innerHTML=e.attributes.formatted_shipping_amount),$shoppingBagPayment=o.shoppingBagPayment,$shoppingBagPayment&&($shoppingBagPayment.innerHTML=e.attributes.formatted_payment_method_amount),$shoppingBagTaxes=o.shoppingBagTaxes,$shoppingBagTaxes&&($shoppingBagTaxes.innerHTML=e.attributes.formatted_total_tax_amount),$shoppingBagDiscount=o.shoppingBagDiscount,$shoppingBagDiscount&&($shoppingBagDiscount.innerHTML=e.attributes.formatted_discount_amount)},updateShoppingBagCheckout:function(e){$shoppingBagCheckout=o.shoppingBagCheckout,$shoppingBagCheckout&&(normalized_order=a(e).get(["line_items.id","checkout_url"])[0],normalized_order.line_items?(this.enableElement($shoppingBagCheckout),$shoppingBagCheckout.href=normalized_order.checkout_url):($shoppingBagCheckout.href="",this.disableElement($shoppingBagCheckout)))},displayAvailableMessage:function(e,t,n,a,r){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageAvailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),this.setElementHTML($el,".clayer-availability-message-available-qty",e),this.setElementHTML($el,".clayer-availability-message-available-min-days",t),this.setElementHTML($el,".clayer-availability-message-available-max-days",n),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-name",a),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-price",r),$container.innerHTML="",$container.appendChild($el)))},displayUnavailableMessage:function(){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageUnavailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),$container.innerHTML="",$container.appendChild($el)))},toggleShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=o.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=o.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){o.shoppingBagItemsContainer&&(o.shoppingBagItemsContainer.innerHTML="")},displayShoppingBagUnavailableMessage:function(){this.displayElement(o.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(o.shoppingBagUnavailableMessage)}}},function(e,t,n){function o(){const o=n(6),i=n(36);n(1);t.init=function(){o.getPrices(),o.getVariants(),i.setVariantSelect(),i.setAddToShoppingBag(),i.setShoppingBagToggle(),o.refreshOrder()},window.commercelayer=e.exports,e.exports.init()}"loading"==document.readyState?document.addEventListener("readystatechange",function(e){"interactive"==document.readyState&&o()}):(console.log(document.readyState),document.addEventListener("DOMContentLoaded",function(e){o()}))},function(e,t,n){"use strict";var o=n(0),i=n(7),a=n(18),r=n(4);function s(e){var t=new a(e),n=i(a.prototype.request,t);return o.extend(n,a.prototype,t),o.extend(n,t),n}var c=s(r);c.Axios=a,c.create=function(e){return s(o.merge(r,e))},c.Cancel=n(11),c.CancelToken=n(33),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(34),e.exports=c,e.exports.default=c},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
!function(e){var t={};function n(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(o,i,function(t){return e[t]}.bind(null,i));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}([function(e,t,n){"use strict";var o=n(7),i=n(17),a=Object.prototype.toString;function r(e){return"[object Array]"===a.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===a.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===a.call(e)},isBuffer:i,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===a.call(e)},isFile:function(e){return"[object File]"===a.call(e)},isBlob:function(e){return"[object Blob]"===a.call(e)},isFunction:c,isStream:function(e){return s(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,o){"object"==typeof t[o]&&"object"==typeof n?t[o]=e(t[o],n):t[o]=n}for(var o=0,i=arguments.length;o<i;o++)u(arguments[o],n);return t},extend:function(e,t,n){return u(t,function(t,i){e[i]=n&&"function"==typeof t?o(t,n):t}),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t,n){const o=n(5),i=n(35);e.exports={getOrderCookieName:function(){return`order_token_${o.clientId()}_${o.marketId()}_${o.countryCode()}`},getAccessTokenCookieName:function(){return`access_token_${o.clientId()}_${o.marketId()}`},getAccessTokenRetryLockCookieName:function(){return`${this.getAccessTokenCookieName()}_retry_lock`},getOrderToken:function(){return i.get(this.getOrderCookieName())},setOrderToken:function(e){return i.set(this.getOrderCookieName(),e,{expires:30})},deleteOrderToken:function(){return i.remove(this.getOrderCookieName())},getAccessTokenCookie:function(){return i.get(this.getAccessTokenCookieName())},setAccessTokenCookie:function(e,t){i.set(this.getAccessTokenCookieName(),e,t)},getAccessTokenRetryLockCookie:function(){return i.get(this.getAccessTokenRetryLockCookieName())},setAccessTokenRetryLockCookie:function(){i.set(this.getAccessTokenRetryLockCookieName(),"1",{expires:1/1440})},getElementFromTemplate:function(e){return"TEMPLATE"==e.tagName?document.importNode(e.content.firstElementChild,!0):document.importNode(e.firstElementChild,!0)},getInventoryFirstAvailableLevel:function(e){if(first_level=e.levels[0],0==first_level.quantity)for(k=1;k<e.levels.length;k++)if(level=e.levels[k],level.quantity>0){first_level=level;break}return first_level}}},function(e,t){e.exports={config:document.querySelector("#clayer-config"),main:document.querySelector("#clayer-main"),prices:Array.prototype.slice.call(document.querySelectorAll(".clayer-price"),0),variants:Array.prototype.slice.call(document.querySelectorAll(".clayer-variant"),0),variantSelect:document.querySelector(".clayer-variant-select"),availabilityMessageContainer:document.querySelector("#clayer-availability-message-container"),availabilityMessageAvailableTemplate:document.querySelector("#clayer-availability-message-available-template"),availabilityMessageUnavailableTemplate:document.querySelector("#clayer-availability-message-unavailable-template"),addToBag:document.querySelector(".clayer-add-to-bag"),shoppingBagContainer:document.querySelector("#clayer-shopping-bag-container"),shoppingBagItemsContainer:document.querySelector("#clayer-shopping-bag-items-container"),shoppingBagItemTemplate:document.querySelector("#clayer-shopping-bag-item-template"),shoppingBagItemsCount:document.querySelector("#clayer-shopping-bag-items-count"),shoppingBagSubtotal:document.querySelector("#clayer-shopping-bag-subtotal"),shoppingBagShipping:document.querySelector("#clayer-shopping-bag-shipping"),shoppingBagPayment:document.querySelector("#clayer-shopping-bag-payment"),shoppingBagDiscount:document.querySelector("#clayer-shopping-bag-discount"),shoppingBagTaxes:document.querySelector("#clayer-shopping-bag-taxes"),shoppingBagTotal:document.querySelector("#clayer-shopping-bag-total"),shoppingBagCheckout:document.querySelector("#clayer-shopping-bag-checkout"),shoppingBagClose:document.querySelector("#clayer-shopping-bag-close"),shoppingBagToggle:document.querySelector("#clayer-shopping-bag-toggle"),shoppingBagUnavailableMessage:document.querySelector(".clayer-shopping-bag-unavailable-message")}},function(e,t,n){e.exports=n(16)},function(e,t,n){"use strict";(function(t){var o=n(0),i=n(20),a={"Content-Type":"application/x-www-form-urlencoded"};function r(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:("undefined"!=typeof XMLHttpRequest?s=n(8):void 0!==t&&(s=n(8)),s),transformRequest:[function(e,t){return i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],function(e){c.headers[e]={}}),o.forEach(["post","put","patch"],function(e){c.headers[e]=o.merge(a)}),e.exports=c}).call(this,n(19))},function(e,t,n){const o=n(2);e.exports={baseUrl:function(){return o.config.dataset.baseUrl},clientId:function(){return o.config.dataset.clientId},marketId:function(){return o.config.dataset.marketId},countryCode:function(){return o.config.dataset.countryCode},languageCode:function(){return o.config.dataset.languageCode.split("-")[0]},cartUrl:function(){return o.config.dataset.cartUrl},returnUrl:function(){return o.config.dataset.returnUrl},privacyUrl:function(){return o.config.dataset.privacyUrl},termsUrl:function(){return o.config.dataset.termsUrl}}},function(e,t,n){const o=n(2),a=n(3),r=(n(12),n(13)),s=n(5),c=n(1),u=n(14);e.exports={getPrices:function(){$prices=o.prices,$prices.length>0&&(skuCodes=[],$prices.forEach(function(e){skuCodes.push(e.dataset.skuCode)}),skus=[],skusEndpoint="/api/skus?filter[codes]="+skuCodes.join(",")+"&include=prices&page[size]=25",skuAttributes=["id","code","prices.formatted_amount","prices.formatted_compare_at_amount","prices.amount_cents","prices.compare_at_amount_cents"],a.get(skusEndpoint).then(function(e){if(u.updatePrices(r(e.data).get(skuAttributes)),pageCount=e.data.meta.page_count,pageCount>1)for(p=2;p<=pageCount;p++)skusEndpointWithPage=skusEndpoint+"&page[number]="+p,a.get(skusEndpointWithPage).then(function(e){u.updatePrices(r(e.data).get(skuAttributes))})}))},getVariants:function(){u.disableElement(o.addToBag),$variants=o.variants,$variants.length>0&&(skuCodes=[],$variants.forEach(function(e){u.disableElement(e),skuCodes.push(e.dataset.skuCode)}),a.get("/api/skus?filter[codes]="+skuCodes.join(",")).then(function(t){for(skus=r(t.data).get(["id","code"]),i=0;i<skus.length;i++)variant=document.querySelector('.clayer-variant[data-sku-code="'+skus[i].code+'"]'),variant&&(variant.value=skus[i].id,u.enableElement(variant),0==i&&e.exports.selectVariant(variant))}))},getInventory:function(e,t){a.get("/api/skus/"+e+"?fields[skus]=inventory").then(function(n){sku=n.data.data,u.updateAvailabilityMessage(sku.attributes.inventory),sku.attributes.inventory.available?(u.updateAddToBagSKU(e,t),u.enableAddToBag()):u.disableAddToBag()})},selectVariant:function(t){switch(t.tagName){case"INPUT":switch(t.type){case"radio":t.click();break;case"hidden":e.exports.getInventory(t.value,t.dataset.skuName)}break;case"OPTION":$select=t.parentNode,$select.value=t.value,$select.dispatchEvent(new Event("change"))}},createOrder:function(){return a.post("/api/orders",{data:{type:"orders",attributes:{shipping_country_code_lock:s.countryCode(),language_code:s.languageCode(),cart_url:s.cartUrl(),return_url:s.returnUrl(),privacy_url:s.privacyUrl(),terms_url:s.termsUrl()}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return c.setOrderToken(e.data.data.attributes.token),e.data.data})},refreshOrder:function(){c.getOrderToken()&&this.getOrder().then(function(e){e&&"placed"==e.attributes.status&&(c.deleteOrderToken(),u.clearShoppingBag())})},createLineItem:function(e,t,n,o){return a.post("/api/line_items",{data:{type:"line_items",attributes:{quantity:1,name:n,image_url:o,_update_quantity:1},relationships:{order:{data:{type:"orders",id:e}},item:{data:{type:"skus",id:t}}}}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},deleteLineItem:function(e){return a.delete("/api/line_items/"+e).then(function(e){return!0})},updateLineItem:function(e,t){return a.patch("/api/line_items/"+e,{data:{type:"line_items",id:e,attributes:t}},{headers:{"Content-Type":"application/vnd.api+json"}}).then(function(e){return e.data})},updateLineItemQty:function(e,t){api=this,api.updateLineItem(e,{quantity:t}).then(function(e){api.getOrder()}).catch(function(e){if(e.response)switch(e.response.status){case 422:u.displayShoppingBagUnavailableMessage()}})},updateShoppingBagItems:function(e){if(api=this,$shoppingBagItemsContainer=o.shoppingBagItemsContainer,$shoppingBagItemsContainer&&(normalized_order=r(e).get(["id","formatted_subtotal_amount","formatted_discount_amount","formatted_shipping_amount","formatted_payment_method_amount","formatted_total_tax_amount","formatted_total_amount_with_taxes","line_items.id","line_items.item_type","line_items.image_url","line_items.name","line_items.quantity","line_items.formatted_unit_amount","line_items.formatted_total_amount"])[0],normalized_order.line_items))for($shoppingBagItemsContainer.innerHTML="",i=0;i<normalized_order.line_items.length;i++)if(line_item=normalized_order.line_items[i],"skus"==line_item.item_type&&($shoppingBagItemTemplate=o.shoppingBagItemTemplate,$shoppingBagItemTemplate)){for($shoppingBagItem=c.getElementFromTemplate($shoppingBagItemTemplate),$shoppingBagItemImage=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-image"),$shoppingBagItemImage.src=line_item.image_url,$shoppingBagItemName=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-name"),$shoppingBagItemName.innerHTML=line_item.name,$shoppingBagItemQtyContainer=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-qty-container"),$qtySelect=document.createElement("select"),$qtySelect.dataset.lineItemId=line_item.id,qty=1;qty<=10;qty++)$option=document.createElement("option"),$option.value=qty,$option.text=qty,qty==line_item.quantity&&($option.selected=!0),$qtySelect.appendChild($option);$qtySelect.addEventListener("change",function(e){api.updateLineItemQty(this.dataset.lineItemId,this.value)}),$shoppingBagItemQtyContainer.appendChild($qtySelect),$shoppingBagItemUnitAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-unit-amount"),$shoppingBagItemUnitAmount.innerHTML=line_item.formatted_unit_amount,$shoppingBagItemTotalAmount=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-total-amount"),$shoppingBagItemTotalAmount.innerHTML=line_item.formatted_total_amount,$shoppingBagItemRemove=$shoppingBagItem.querySelector(".clayer-shopping-bag-item-remove"),$shoppingBagItemRemove.dataset.lineItemId=line_item.id,$shoppingBagItemRemove.addEventListener("click",function(e){e.preventDefault(),api.deleteLineItem(this.dataset.lineItemId).then(function(e){api.getOrder()})}),$shoppingBagItemsContainer.appendChild($shoppingBagItem)}},getOrder:function(){return api=this,a.get("/api/orders?include=line_items&filter[token]="+c.getOrderToken()).then(function(e){if(e.data.data.length>0)return api.updateShoppingBagItems(e.data),u.hideShoppingBagUnavailableMessage(),u.updateShoppingBagSummary(e.data.data[0]),u.updateShoppingBagCheckout(e.data),0==e.data.data[0].attributes.skus_count&&u.clearShoppingBag(),e.data.data[0]})}}},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}}},function(e,t,n){"use strict";var o=n(0),i=n(21),a=n(23),r=n(24),s=n(25),c=n(9),u="undefined"!=typeof window&&window.btoa&&window.btoa.bind(window)||n(26);e.exports=function(e){return new Promise(function(t,p){var l=e.data,d=e.headers;o.isFormData(l)&&delete d["Content-Type"];var f=new XMLHttpRequest,g="onreadystatechange",h=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in f||s(e.url)||(f=new window.XDomainRequest,g="onload",h=!0,f.onprogress=function(){},f.ontimeout=function(){}),e.auth){var m=e.auth.username||"",y=e.auth.password||"";d.Authorization="Basic "+u(m+":"+y)}if(f.open(e.method.toUpperCase(),a(e.url,e.params,e.paramsSerializer),!0),f.timeout=e.timeout,f[g]=function(){if(f&&(4===f.readyState||h)&&(0!==f.status||f.responseURL&&0===f.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in f?r(f.getAllResponseHeaders()):null,o={data:e.responseType&&"text"!==e.responseType?f.response:f.responseText,status:1223===f.status?204:f.status,statusText:1223===f.status?"No Content":f.statusText,headers:n,config:e,request:f};i(t,p,o),f=null}},f.onerror=function(){p(c("Network Error",e,null,f)),f=null},f.ontimeout=function(){p(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",f)),f=null},o.isStandardBrowserEnv()){var v=n(27),b=(e.withCredentials||s(e.url))&&e.xsrfCookieName?v.read(e.xsrfCookieName):void 0;b&&(d[e.xsrfHeaderName]=b)}if("setRequestHeader"in f&&o.forEach(d,function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete d[t]:f.setRequestHeader(t,e)}),e.withCredentials&&(f.withCredentials=!0),e.responseType)try{f.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&f.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&f.upload&&f.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){f&&(f.abort(),p(e),f=null)}),void 0===l&&(l=null),f.send(l)})}},function(e,t,n){"use strict";var o=n(22);e.exports=function(e,t,n,i,a){var r=new Error(e);return o(r,t,n,i,a)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,n){const o=n(3),i=n(5),a=n(1);o.defaults.baseURL=i.baseUrl(),o.defaults.headers.common.Accept="application/vnd.api+json",o.interceptors.request.use(function(e){return e.headers.Authorization="Bearer "+a.getAccessTokenCookie(),e},function(e){return Promise.reject(e)}),o.interceptors.response.use(function(e){return e},function(e){return 401===e.response.status&&function(){if(navigator.cookieEnabled)return!0;document.cookie="cookietest=1";var e=-1!=document.cookie.indexOf("cookietest=");return document.cookie="cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT",e}()&&null==a.getAccessTokenRetryLockCookie()?(a.setAccessTokenRetryLockCookie(),o.post("/oauth/token",{grant_type:"client_credentials",client_id:i.clientId(),scope:"market:"+i.marketId()}).then(function(e){return a.setAccessTokenCookie(e.data.access_token,e.data.expires_in),e.data.access_token}).then(function(t){return e.config.headers.Authorization="Bearer "+t,o.request(e.config)})):Promise.reject(e)})},function(e,t,n){var o,i,a;i=[],void 0===(a="function"==typeof(o=function(){function e(o,i){if(!(this instanceof e)){var a=new e(o);return i?a.get(i):a}if("string"==typeof o&&(o=JSON.parse(o)),!o||!o.data)throw new Error("Invalid json api normalizer input");var r,s,c,u;this.dataset=o,this.isCollection=t(o.data),this.haystack=(r=o.included,s=this.isCollection?o.data:[o.data],c=[],n(u=r||[],function(e){c.push(e.type+"@"+e.id)}),n(s,function(e){c.indexOf(e.type+"@"+e.id)<0&&u.push(e)}),u)}function t(e){return e instanceof Array}function n(e,n,o){if(t(e))for(var i=e.length,a=0;a<i;a++)n.call(o,e[a],a);else for(var r in e)e.hasOwnProperty(r)&&n.call(o,r,e[r])}function o(e,t,o){var i=[];return n(e,function(e,n){i.push(t.call(o,e,n))}),i}function i(i,s,c){var u={};return n(i,function(n,i){if(i)u[n]=function(e,n,i,s){var c=i.relationships&&i.relationships[e]&&i.relationships[e].data,u=c&&r(c,s);return t(u)?o(u,function(e){return a(n,e,s)}):u?a(n,u,s):void 0}(n,i,s,c);else{var p=s.relationships&&s.relationships[n]&&s.relationships[n].data;if(p){var l=r(p,c);u[n]=l?new e({data:l,included:c}):void 0}else u[n]=function(e,t){return["id","type"].indexOf(e)>=0?t[e]:t.attributes[e]}(n,s)}}),u}function a(t,n,o){return s.call(new e({data:n,included:o}),t)}function r(e,i){var a=[],r=t(e)?o(e,function(e){return e.type+"@"+e.id}):[e.type+"@"+e.id];return n(i,function(e){r.indexOf(e.type+"@"+e.id)>=0&&a.push(e)}),0===a.length?void 0:1!==a.length||t(e)?a:a[0]}function s(e){return this.isCollection?o(this.dataset.data,function(t){return i(e,t,this.haystack)},this):i(e,this.dataset.data,this.haystack)}return e.prototype.get=function(e){var i,a,r=s.call(this,(i=t(e)?e:[e],a={},n(i,function(e){var t=e.split(".");t.length>1?function e(t,n){for(var o in n)n.hasOwnProperty(o)&&("object"==typeof n[o]&&null!==n[o]?(void 0===t[o]&&(t[o]={}),e(t[o],n[o])):t[o]=n[o]);return t}(a,function(e){for(var t={},n=t,o=e.length,i=0;i<o;i++)n=n[e[i]]=n[e[i]]||(i+1===o?void 0:{});return t}(t)):a[e]=void 0}),a));return this.isCollection?t(e)?r:o(r,function(t){return t[e]}):t(e)?r:r[e]},e})?o.apply(t,i):o)||(e.exports=a)},function(e,t,n){const o=n(2),i=n(1),a=n(13);e.exports={enableElement:function(e){e&&e.classList.remove("disabled")},disableElement:function(e){e&&e.classList.add("disabled")},setElementHTML(e,t,n){el=e.querySelector(t),el&&(el.innerHTML=n)},displayElement:function(e){e&&(e.style.display="block")},hideElement:function(e){e&&(e.style.display="none")},updatePrices:function(e){for(k=0;k<e.length;k++)priceAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .amount'),priceAmount&&(priceAmount.innerHTML=e[k].prices[0].formatted_amount),priceCompareAmount=document.querySelector('[data-sku-code="'+e[k].code+'"] > .compare-at-amount'),priceCompareAmount&&e[k].prices[0].compare_at_amount_cents>e[k].prices[0].amount_cents&&(priceCompareAmount.innerHTML=e[k].prices[0].formatted_compare_at_amount)},updateAddToBagSKU:function(e,t){$addToBag=o.addToBag,$addToBag&&($addToBag.dataset.skuId=e,$addToBag.dataset.skuName=t)},enableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.enableElement($addToBag)},disableAddToBag:function(){$addToBag=o.addToBag,$addToBag&&this.disableElement($addToBag)},updateAvailabilityMessage:function(e){$container=o.availabilityMessageContainer,$container&&(first_level=i.getInventoryFirstAvailableLevel(e),first_level.quantity>0?(dlt=first_level.delivery_lead_times[0],qty=first_level.quantity,minDays=dlt.min.days,maxDays=dlt.max.days,shippingMethodName=dlt.shipping_method.name,shippingMethodPrice=dlt.shipping_method.formatted_price_amount,this.displayAvailableMessage(qty,minDays,maxDays,shippingMethodName,shippingMethodPrice)):this.displayUnavailableMessage())},updateShoppingBagSummary:function(e){$shoppingBagItemsCount=o.shoppingBagItemsCount,$shoppingBagItemsCount&&($shoppingBagItemsCount.innerHTML=e.attributes.skus_count),$shoppingBagTotal=o.shoppingBagTotal,$shoppingBagTotal&&($shoppingBagTotal.innerHTML=e.attributes.formatted_total_amount_with_taxes),$shoppingBagSubtotal=o.shoppingBagSubtotal,$shoppingBagSubtotal&&($shoppingBagSubtotal.innerHTML=e.attributes.formatted_subtotal_amount),$shoppingBagShipping=o.shoppingBagShipping,$shoppingBagShipping&&($shoppingBagShipping.innerHTML=e.attributes.formatted_shipping_amount),$shoppingBagPayment=o.shoppingBagPayment,$shoppingBagPayment&&($shoppingBagPayment.innerHTML=e.attributes.formatted_payment_method_amount),$shoppingBagTaxes=o.shoppingBagTaxes,$shoppingBagTaxes&&($shoppingBagTaxes.innerHTML=e.attributes.formatted_total_tax_amount),$shoppingBagDiscount=o.shoppingBagDiscount,$shoppingBagDiscount&&($shoppingBagDiscount.innerHTML=e.attributes.formatted_discount_amount)},updateShoppingBagCheckout:function(e){$shoppingBagCheckout=o.shoppingBagCheckout,$shoppingBagCheckout&&(normalized_order=a(e).get(["line_items.id","checkout_url"])[0],normalized_order.line_items?(this.enableElement($shoppingBagCheckout),$shoppingBagCheckout.href=normalized_order.checkout_url):($shoppingBagCheckout.href="",this.disableElement($shoppingBagCheckout)))},displayAvailableMessage:function(e,t,n,a,r){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageAvailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),this.setElementHTML($el,".clayer-availability-message-available-qty",e),this.setElementHTML($el,".clayer-availability-message-available-min-days",t),this.setElementHTML($el,".clayer-availability-message-available-max-days",n),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-name",a),this.setElementHTML($el,".clayer-availability-message-available-shipping-method-price",r),$container.innerHTML="",$container.appendChild($el)))},displayUnavailableMessage:function(){$container=o.availabilityMessageContainer,$container&&($tmp=o.availabilityMessageUnavailableTemplate,$tmp&&($el=i.getElementFromTemplate($tmp),$container.innerHTML="",$container.appendChild($el)))},toggleShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.toggle("open"),$main=o.main,$main&&$main.classList.toggle("open")},openShoppingBag:function(){$shoppingBagContainer=o.shoppingBagContainer,$shoppingBagContainer&&$shoppingBagContainer.classList.add("open"),$main=o.main,$main&&$main.classList.remove("open")},clearShoppingBag:function(){o.shoppingBagItemsContainer&&(o.shoppingBagItemsContainer.innerHTML="")},displayShoppingBagUnavailableMessage:function(){this.displayElement(o.shoppingBagUnavailableMessage)},hideShoppingBagUnavailableMessage:function(){this.hideElement(o.shoppingBagUnavailableMessage)}}},function(e,t,n){function o(){const o=n(6),i=n(36);n(1);t.init=function(){o.getPrices(),o.getVariants(),i.setVariantSelect(),i.setAddToShoppingBag(),i.setShoppingBagToggle(),o.refreshOrder()},window.commercelayer=e.exports,e.exports.init()}console.log(document.readyState),"loading"==document.readyState?document.addEventListener("readystatechange",function(e){"interactive"==document.readyState&&o()}):document.addEventListener("DOMContentLoaded",function(e){o()})},function(e,t,n){"use strict";var o=n(0),i=n(7),a=n(18),r=n(4);function s(e){var t=new a(e),n=i(a.prototype.request,t);return o.extend(n,a.prototype,t),o.extend(n,t),n}var c=s(r);c.Axios=a,c.create=function(e){return s(o.merge(r,e))},c.Cancel=n(11),c.CancelToken=n(33),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(34),e.exports=c,e.exports.default=c},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}
/*!

@@ -3,0 +3,0 @@ * Determine if an object is a Buffer

{
"name": "commercelayer",
"version": "1.5.1",
"version": "1.5.2",
"description": "The Official Commerce Layer JS library",

@@ -5,0 +5,0 @@ "main": "./src/main.js",

@@ -19,2 +19,4 @@ function commercelayer() {

console.log(document.readyState)
if (document.readyState == 'loading') {

@@ -27,3 +29,2 @@ document.addEventListener('readystatechange', function(event) {

} else {
console.log(document.readyState)
document.addEventListener('DOMContentLoaded', function(event) {

@@ -30,0 +31,0 @@ commercelayer()

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc