/*! fastspring-builder 0.8.3 */ !function(){"use strict";function a(a){if(void 0===a||null===a)return!0;for(var b in a)if(a.hasOwnProperty(b))return!1;return JSON.stringify(a)===JSON.stringify({})}function b(a){if(g.debug||d.storage.getItem("debug")){var b=Array.prototype.slice.call(arguments);"string"==typeof a&&b.unshift("[FastSpring API] "+b.shift()),console.log.apply(console,b)}}function c(a){var b=Array.prototype.slice.call(arguments);"string"==typeof a&&b.unshift("[FastSpring API] "+b.shift()),(console.error||console.log).apply(console,b)}var d={merge:function(a,b){for(var c in b)if(b.hasOwnProperty(c))try{"products"===c?(a.products=a.products||[],a.products=a.products.concat(b.products)):"object"==typeof a[c]?a[c]=d.merge(a[c],b[c]):a[c]=b[c]}catch(d){a[c]=b[c]}return a},returnMeaningful:function(a){a.reverse();var b={},c=[];return a.forEach(function(a){b.hasOwnProperty(a.path)||(b[a.path]=!0,c.push(a))}),c},runCallback:function(a,b){"function"==typeof a&&a.apply(null,b)}},e=!0;try{window.localStorage.setItem("fs","fs"),window.localStorage.removeItem("fs")}catch(a){e=!1}Object.defineProperty(d,"storage",{get:function a(){return e&&"localStorage"in window?window.localStorage:(void 0===a.storage&&(a.storage={_data:{},setItem:function(a,b){return this._data[a]=String(b)},getItem:function(a){return this._data.hasOwnProperty(a)?this._data[a]:void 0},removeItem:function(a){return delete this._data[a]},clear:function(){return this._data={}}}),a.storage)}});var f={attach:function(){this.spinSVG.style.position="absolute",this.spinSVG.style.top="50%",this.spinSVG.style.marginTop="-50px",this.spinSVG.style.left="50%",this.spinSVG.style.marginLeft="-50px",this.spinSVG.style.zIndex="100000000000000",this.spinSVG.style.display="block",h.canvas.appendChild(this.spinSVG)},remove:function(){void 0!==this.spinSVG&&(this.spinSVG.style.display="none")}},g={assignAttributeValues:function(a){this.animateFader=a.getAttribute("data-animate-fader")||"true",this.beforeRequests=a.getAttribute("data-before-requests-callback"),this.afterRequests=a.getAttribute("data-after-requests-callback"),this.beforeMarkup=a.getAttribute("data-before-markup-callback"),this.afterMarkup=a.getAttribute("data-after-markup-callback"),this.decorateCallback=a.getAttribute("data-decorate-callback"),this.dataCallback=a.getAttribute("data-data-callback"),this.errorCallback=a.getAttribute("data-error-callback"),this.validationCallback=a.getAttribute("data-validation-callback"),this.markupHelpers=a.getAttribute("data-markup-helpers-callback"),this.popupClosed=a.getAttribute("data-popup-closed"),this.popupWebhookReceived=a.getAttribute("data-popup-webhook-received"),this.popupEventReceived=a.getAttribute("data-popup-event-received"),this.storefront=a.getAttribute("data-storefront"),this.debug="true"===a.getAttribute("data-debug"),this.aKey=a.getAttribute("data-access-key"),this.continuous="true"===a.getAttribute("data-continuous"),this.sblVersion=a.getAttribute("src")},init:function(){this.assignAttributeValues(k),this.checkoutMode="redirect",null===this.storefront.match(/pinhole/)&&null===this.storefront.match(/popup/)||(this.checkoutMode="popup"),null!==this.storefront.match(/inapp/)&&(this.checkoutMode="inapp"),b("Checkout mode:",this.checkoutMode),this.testMode=!1,/\.test\./.test(this.storefront)?this.testMode=!0:/(localhost:[^?]*\*)/.test(this.storefront)&&(this.testMode=!0),b("Test mode:",this.testMode),null!==this.aKey&&b("Access key:",this.aKey),"popup"===this.checkoutMode&&(f.spinSVG=document.createElement("img"),f.spinSVG.src="https://d1f8f9xcsvx3ha.cloudfront.net/pinhole/spin.svg"),this.sessionID=null,this.data={},this.finishSilently=!1,this.builder="/builder",this.requests=[],"inapp"!==this.checkoutMode&&h.checkURL(),this.parseInput(l),m=!0},continuousGet:function(){b(" -> Checking for existing session");var a=null,c=d.storage.getItem("fscSerial-"+this.storefront);return c&&(c=JSON.parse(c),c.hasOwnProperty("session")&&c.hasOwnProperty("expires")&&(a=c.session)),a},continuousStore:function(a){b(" <- Writing to storage:",a),d.storage.setItem("fscSerial-"+this.storefront,JSON.stringify(a))},continuousReset:function(){b(" <- Resetting session"),d.storage.removeItem("fscSerial-"+this.storefront),this.sessionID=null},updateSession:function(){b(" <- Updating session");var a={},c=d.storage.getItem("fscLatestSession-"+g.storefront),e=c?"https://"+this.storefront+this.builder+"/refresh/"+c:"https://"+this.storefront+this.builder+"/refresh/";this.chain({endpoint:e,method:"GET",payload:a,skipsession:!0})},parseInput:function(a,e){var f=this.sanitizeInput(a);if(b("Input: ",a,"Sanitized output:",f),a.hasOwnProperty("secure")&&(null===this.aKey?c("No access key found in payload"):a.secure.hasOwnProperty("payload")?this.testMode?a.secure.hasOwnProperty("key")?(f.accessKey=this.aKey,f.secureKey=a.secure.key,f.securePayload=a.secure.payload):(f.accessKey=this.aKey,d.merge(f,a.secure.payload)):a.secure.hasOwnProperty("key")?(f.accessKey=this.aKey,f.secureKey=a.secure.key,f.securePayload=a.secure.payload):c("No secure key found in payload"):c("No secure payload found in request")),a.hasOwnProperty("authenticate")){if(b("Found authentication payload",a.authenticate),null===this.aKey)return b("No access key found while authenticating user"),void d.runCallback(e);a.authenticate.hasOwnProperty("key")?this.authenticateUser(a.authenticate.payload,a.authenticate.key):this.authenticateUser(a.authenticate.payload)}if(a.hasOwnProperty("reset")&&this.continuousReset(),a.hasOwnProperty("clean")&&(o=!0),a.hasOwnProperty("session")?(this.sessionID=a.session,b("Session found in input:",this.sessionID)):this.continuous&&!this.sessionID&&(this.sessionID=this.continuousGet(),b("Continuous mode session:",this.sessionID)),a.hasOwnProperty("close")&&this.updateSession(),a.hasOwnProperty("checkout"))if("popup"===g.checkoutMode&&h.drawCanvas(),"true"!==a.checkout&&"false"!==a.checkout&&a.checkout.length>10){d.storage.setItem("fscLatestSession-"+this.storefront,a.checkout);var i="https://"+this.storefront+"/session/"+a.checkout;g.continueCheckoutWithURL(i,e)}else g.checkoutRedirect(f,e);else a.hasOwnProperty("authenticate")||this.loadProducts(f,e);this.flushChain(),l={}},chain:function(a){b(" >> Chaining request:",a),this.requests.push(a)},flushChain:function(){if(b("Is requests chain locked?",g.ajaxInProgress),!g.ajaxInProgress){if("function"==typeof window[this.beforeRequests]){b(" <- Calling ",this.beforeRequests);try{window[this.beforeRequests].call(null)}catch(a){c("Error in before-requests",a)}}b("Preparing to make requests:",JSON.stringify(this.requests)),this.nextRequest()}},nextRequest:function(){var a;if(void 0!==this.requests[0])a=this.requests.shift(),this.request(a.endpoint,a.method,a.payload,a.hasOwnProperty("skipsession"),a.callback);else if(b("Unlocking request chain"),g.ajaxInProgress=!1,"function"==typeof window[this.afterRequests]){b(" <- Calling ",this.afterRequests);try{window[this.afterRequests]()}catch(a){c("Error in data-after-requests-callback",a)}}},uninstall:function(){this.requests.splice(0,this.requests.length)},handleData:function(a,e){if(a=this.sanitize(a),void 0!==this.requests[0])return b("Running next request"),void d.runCallback(e,[a]);if(this.finishSilently)return b("Finishing silently and returning no data"),void d.runCallback(e,[a]);if("function"==typeof window[this.dataCallback]){b("<- Calling ",this.dataCallback);try{window[this.dataCallback](a)}catch(a){c("Error in data-callback",a)}}j.setData(a),d.runCallback(e,[a]),j.process(),this.data={}},handleSerial:function(a,c){if(this.sessionID!==a)return this.sessionID=a,this.expires=c,this.continuous&&(b("Storing session ID for continuity"),this.continuousStore({session:this.sessionID,expires:c})),b("New session ID:",this.sessionID),this.sessionID},sanitize:function(a){return delete a.serial,delete a.expires,g.groupsByProduct={},a.groups.forEach(function(a){a.selectables=!1,a.selectableReplacements=!1,a.selectableAdditions=!1,a.items.forEach(function(b){b.selectables=!1,b.selectableReplacements=!1,b.selectableAdditions=!1,b.selected||(a.selectables=!0,"add"===a.type&&(a.selectableAdditions=!0),"replace"===a.type&&(a.selectableReplacements=!0)),g.groupsByProduct[b.path]=this.driver,b.groups.forEach(function(a){a.items.forEach(function(b){b.selected||(a.selectables=!0,b.selectables=!0,"replace"===a.type&&(a.selectableReplacements=!0))},a),!0===a.selectables&&(b.selectables=!0),!0===a.selectableReplacements&&(b.selectableReplacements=!0),"options"===a.type&&(g.newGroupItemsNamed={},g.newGroupItems=[],a.items.forEach(function(a){g.newGroupItemsNamed[a.path]=a}),g.newGroupItemsNamed[this.path]=this,a.ordering.forEach(function(a){g.newGroupItems.push(g.newGroupItemsNamed[a])}),a.items=g.newGroupItems,g.newGroupItemsNamed={},g.newGroupItems=[])},b)},a)}),a.groups.forEach(function(a){a.driverType="storefront","add"===a.type&&g.groupsByProduct.hasOwnProperty(a.driver)&&(a.driverType="product",a.driverOrigin=g.groupsByProduct[a.driver])}),g.groupsByProduct={},a},sanitizeInput:function(a){var b={};return a.hasOwnProperty("coupon")&&(b.coupon=a.coupon),a.hasOwnProperty("postalCode")&&(b.postalCode=a.postalCode),a.hasOwnProperty("products")&&a.products.length>0&&(b.items=d.returnMeaningful(a.products)),a.hasOwnProperty("tags")&&(b.tags=a.tags),a.hasOwnProperty("paymentContact")&&(b.paymentContact=a.paymentContact),a.hasOwnProperty("recipient")&&(b.recipient=a.recipient),a.hasOwnProperty("country")&&(b.country=a.country),a.hasOwnProperty("language")&&(b.language=a.language),a.hasOwnProperty("taxId")&&(b.taxId=a.taxId),a.hasOwnProperty("paymentMethod")&&(b.paymentMethod=a.paymentMethod),a.hasOwnProperty("cartViewEnabled")&&(b.cartViewEnabled=a.cartViewEnabled),b},authenticateUser:function(a,c){var d,e;if(b("Authenticating user"),this.testMode)d=a,d.accessKey=this.aKey;else{if(!c)return void b("No secure key found while authenticating user");d={securePayload:a,accessKey:this.aKey,secureKey:c}}e="https://"+g.storefront+"/account/authenticate",d={data:JSON.stringify(d)},this.chain({endpoint:e,method:"POST",payload:d,skipsession:!0})},loadProducts:function(c,e){var f,h;b(" + Getting products"),h="https://"+g.storefront+g.builder;var i="POST",j=this.expires?this.expires<(new Date).getTime():null,k=d.storage.getItem("fscSerial-"+this.storefront)?JSON.parse(d.storage.getItem("fscSerial-"+this.storefront)).expires<(new Date).getTime():null;if(null==j&&k&&(j=k),a(c)||j)f={},this.sessionID||(i="GET");else{var l=null;if(-1!=this.sblVersion.indexOf("sbl")){var m=this.sblVersion.substring(this.sblVersion.indexOf("sbl"));l=m.substring(m.indexOf("/")+1,m.lastIndexOf("/"))}c.sblVersion=l,f={put:JSON.stringify(c)}}this.sessionID&&j&&(i="GET"),this.chain({endpoint:h,method:i,payload:f,callback:e})},checkoutRedirect:function(a,c){var e,f;b(" + Redirecting to checkout"),f="https://"+g.storefront+g.builder+"/finalize","popup"!==g.checkoutMode&&"inapp"!==g.checkoutMode||(a.origin=document.location.href);var h=d.storage.getItem("fscLatestSession-"+g.storefront);if(a){var i=null;if(-1!=this.sblVersion.indexOf("sbl")){var j=this.sblVersion.substring(this.sblVersion.indexOf("sbl"));i=j.substring(j.indexOf("/")+1,j.lastIndexOf("/"))}a.sblVersion=i,e={put:JSON.stringify(a)}}else e={};h&&(e.sessionId=h),this.chain({endpoint:f,method:"POST",payload:e,callback:c})},request:function(a,e,f,i,j){b("Locking requests chain"),g.ajaxInProgress=!0,this.sessionID&&!i&&(f.session=this.sessionID);var k=this.toQueryString(f);b(" > > > Making request to "+a+" ("+e+") with data:",k);try{var l=new XMLHttpRequest;l.open(e,a,!0),l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.setRequestHeader("Accept","application/json, text/javascript, */*; q=0.01"),l.onerror=function(){c("(!) Error received: ",l.status,l.responseText),g.runErrorCallback(l.status,l.responseText),d.runCallback(j,[!1]),g.nextRequest()},l.onreadystatechange=function(){4===l.readyState&&(l.status>=200&&l.status<400?g.successHandler(l,j):(c("(!) Error: Error received: ",l.status,l.responseText),"popup"===g.checkoutMode&&h.destroy(),g.runErrorCallback(l.status,l.responseText),d.runCallback(j,[!1]),g.nextRequest()))},l.send(k)}catch(a){c("Exception: ",a)}},runErrorCallback:function(a,d){if("function"==typeof window[g.errorCallback]){b(" <- Calling ",g.errorCallback);try{window[g.errorCallback](a,d)}catch(a){c("Error in error-callback",a)}}},runValidationCallback:function(a){if("function"==typeof window[g.validationCallback])try{window[g.validationCallback](a)}catch(a){c("Error in validation-callback",a)}},successHandler:function(a,c){var e;try{e=JSON.parse(a.responseText)}catch(b){return g.runErrorCallback(a.status,a.responseText),d.runCallback(c,[!1,a&&a.responseText])}b("Request is OK, returned data: ",e);var f=e.fields;for(var h in f)if(f[h].hasOwnProperty("valid")&&!f[h].valid){g.runValidationCallback(f);break}if(e.hasOwnProperty("url")&&!e.hasOwnProperty("serial")){d.runCallback(c,[e]),g.nextRequest(),b("Obtained redirection parameter",e.url);var i=e.url;return e.hasOwnProperty("session")&&d.storage.setItem("fscLatestSession-"+g.storefront,e.session),e.hasOwnProperty("serialCheckout")&&this.handleSerial(e.serialCheckout,e.expires),void g.continueCheckoutWithURL(i)}this.handleSerial(e.serial,e.expires),this.handleData(e,c),this.nextRequest()},toQueryString:function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+"="+encodeURIComponent(a[c]));return b.join("&")},continueCheckoutWithURL:function(a,e){if("function"==typeof window[g.decorateCallback]){b(" <- Calling ",g.decorateCallback);var f=window[g.decorateCallback](a);try{f&&f.length>0&&f.indexOf(a)>-1?a=f:c("data-decorate-callback Must return correct url")}catch(a){c(a)}}"popup"===g.checkoutMode&&/\/popup-/.test(a)?(!0===o&&g.continuousReset(),h.drawFrame(a)):(!0===o&&g.continuousReset(),window.location=a),d.runCallback(e)}},h={iframeId:"fsc-popup-frame",checkURL:function(){var a,b,c=/fsc:invoke:(session|complete)/g.exec(decodeURIComponent(document.location.search));if(c&&c.length>0&&("session"===c[1]||"complete"===c[1])&&(b=localStorage.getItem("fscLatestSession-"+g.storefront))){a="complete"===c[1]?b+"/complete":b;var d=setInterval(function(){"complete"===document.readyState&&(clearInterval(d),window.addEventListener("message",h.listener,!1),h.drawCanvas(),h.drawFrame("https://"+g.storefront+"/session/"+a))},100)}},listener:function(a){if(a.data.hasOwnProperty("fscPopupMessage")&&a.data.fscPopupMessage.hasOwnProperty("action")){var b=a.data.fscPopupMessage;"close"===b.action?(b.hasOwnProperty("orderReferences")?(h.popupClosedFunction(b.orderReferences),h.completed=!0):(h.popupClosedFunction(null),h.completed=!1),h.frame.close&&h.frame.close()):"event"===b.action&&b.hasOwnProperty("eventData")?h.publishEvent(b.eventData):"hook"===b.action&&b.hasOwnProperty("hookData")?h.hookEvent(b.hookData):"scroll"===b.action&&(document.body.scrollTop=0)}},popupClosedFunction:function(a){if("function"==typeof window[g.popupClosed]){b("Calling data-popup-closed callback");try{window[g.popupClosed](a)}catch(a){c("Error in data-popup-closed callback",a)}}a&&(localStorage.removeItem("fscLatestSession-"+g.storefront),localStorage.removeItem("fscSerial-"+g.storefront),g.sessionID=null),b("Popup Closed. Is there an order number?",a),h.destroy()},publishEvent:function(a){if(b("Event published",a),"function"==typeof window[g.popupEventReceived]){b(" <- Calling ",g.popupEventReceived);try{window[g.popupEventReceived](a)}catch(a){b(" -- Error in popup-event-received")}}},hookEvent:function(a){if(b("Hook published: ",a),"function"==typeof window[g.popupWebhookReceived]){b(" <- Calling ",g.popupWebhookReceived);try{window[g.popupWebhookReceived](a)}catch(a){b(" --Error in popup-webhook-received")}}},drawCanvas:function(){window.addEventListener("message",h.listener,!1),document.getElementById("fscCanvas")||(this.canvas=document.createElement("div"),this.canvas.id="fscCanvas",this.canvas.setAttribute("style","background: -webkit-linear-gradient(rgba(0,0,0,0.9), rgba(0,0,0,0.8)); background: -o-linear-gradient(rgba(0,0,0,0.9), rgba(0,0,0,0.8)); background: -moz-linear-gradient(rgba(0,0,0,0.9), rgba(0,0,0,0.8)); background: linear-gradient(rgba(0,0,0,0.9), rgba(0,0,0,0.8));"),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="fixed",this.canvas.style.top="0",this.canvas.style.left="0",this.canvas.style.zIndex="100000000000000",this.canvas.style.overflowY="scroll",this.canvas.style.webkitOverflowScrolling="touch",g.animateFader&&(this.canvas.style.transitionProperty="opacity",this.canvas.style.transitionDuration="0.5s",this.canvas.style.opacity="0"),document.body.appendChild(this.canvas),g.animateFader&&setTimeout(function(){document.getElementById("fscCanvas").style.opacity="1"},100)),f.attach()},drawFrame:function(a){b("Launching popup with URL",a),this.frame?(f.remove(),this.canvas.remove(),this.frame.location=a):document.getElementById(h.iframeId)?a.length>0&&(this.frame.location=a):(this.frame=document.createElement("iframe"),this.frame.id=h.iframeId,this.frame.setAttribute("name",h.iframeId),this.frame.width="100%",this.frame.height="100%",/iPhone|iPad|iPod/i.test(navigator.userAgent)?(this.frame.style.position="absolute",document.body.scrollTop=0):this.frame.style.position="fixed",this.frame.style.top="0",this.frame.style.left="0",this.frame.style.background="transparent",this.frame.style.zIndex="1000000000000000",this.frame.frameBorder=0,this.frame.setAttribute("background","transparent"),a.length>0&&this.frame.setAttribute("src",a),document.getElementById("fscCanvas")?document.getElementById("fscCanvas").appendChild(this.frame):document.body.appendChild(this.frame),document.body.setAttribute("data-overflow",document.body.style.overflow),document.body.style.overflow="hidden",this.frame.onload=function(){f.remove()})},destroy:function(){if(document.body.style.overflow=document.body.getAttribute("data-overflow"),document.body.removeAttribute("data-overflow"),f.remove(),window.removeEventListener("message",h.listener,!1),this.blur&&(this.blur.parentNode.removeChild(this.blur),this.blur=null),h.canvas){var a=0;g.animateFader&&(h.canvas.style.opacity="0",a=500),setTimeout(function(){h.frame&&h.frame.parentNode&&(h.frame.parentNode.removeChild(h.frame),h.frame=null),h.canvas&&h.canvas.parentNode&&(h.canvas.parentNode.removeChild(h.canvas),h.canvas=null)},a),setTimeout(function(){g.continuous&&!h.completed?q.builder.updateSession():q.builder.reset()},a)}}},i={push:function(a,c){!m||n?(l=d.merge(l,a),c&&b("Unexpected callback sent to push")):g.parseInput(a,c)},checkout:function(a,b){a&&a.length>10?i.push({checkout:a},b):i.push({checkout:!0},b)},promo:function(a,b){i.push({coupon:a},b)},postalCode:function(a,b){i.push({postalCode:a},b)},postalcode:function(a,b){i.push({postalCode:a},b)},taxId:function(a,b){i.push({taxId:a},b)},viewCart:function(a){i.push({cartViewEnabled:!0,checkout:!0},a)},payment:function(a,b){i.push({paymentMethod:a,checkout:!0},b)},update:function(a,b,c){i.push({products:[{path:a,quantity:parseInt(b,10)}]},c)},remove:function(a,b){i.push({products:[{path:a,quantity:0}]},b)},add:function(a,b){i.update(a,null,b)},recognize:function(){if(arguments.length>0){var a="function"==typeof arguments[arguments.length-1]&&arguments[arguments.length].pop(),b=["firstName","lastName","email","company","addressLine1","addressLine2","city","region","country","postalCode","phoneNumber"],c=arguments[0];"object"!=typeof c&&(c={},c.email=arguments[0],c.firstName=arguments.length>0&&arguments[1],c.lastName=arguments.length>1&&arguments[2]);var d={paymentContact:{}};for(var e in c)c.hasOwnProperty(e)&&~b.indexOf(e)&&(d.paymentContact[e]=c[e]);i.push(d,a)}},recognizeRecipients:function(){if(arguments.length>0){var a="function"==typeof arguments[arguments.length-1]&&arguments[arguments.length].pop(),b=["firstName","lastName","email","company","memo","phoneNumber"],c=["addressLine1","addressLine2","city","region","country","postalCode"],d=["address"],e=arguments[0],f={recipient:{}};for(var g in e)if(e.hasOwnProperty(g))if(~b.indexOf(g))f.recipient[g]=e[g];else if(~d.indexOf(g)){var h=e[g];f.recipient[g]={};for(var j in h)h.hasOwnProperty(j)&&~c.indexOf(j)&&(f.recipient[g][j]=h[j])}i.push(f,a)}},reset:function(a){i.push({reset:!0},a)},updateSession:function(a){i.push({close:!0},a)},clean:function(a){i.push({clean:!0},a)},secure:function(a,b,c){var d={secure:{payload:a}};b&&(d.secure.key=b),i.push(d,c)},authenticate:function(a,b,c){var d={authenticate:{payload:a}};b&&(d.authenticate.key=b),i.push(d,c)},tag:function(a,b,c){var d={tags:{}};if("object"==typeof a)for(var e in a)a.hasOwnProperty(e)&&(d.tags[e]=a[e]);else d.tags[a]=b;i.push(d,c)},country:function(a,b){i.push({country:a},b)},language:function(a,b){i.push({language:a},b)},_uninstall:function(){g.uninstall(),j.uninstall(),h.destroy();var a=document.querySelector("script#fsc-api");a.parentNode.removeChild(a),delete window._f,delete window.fastspring},Recompile:function(a,b,c){j.compileHandlebarsTemplate(a,b,c)}};["Add","Push","Authenticate","Checkout","Clean","Country","Language","Tag","Secure","Remove","Promo","Update","Recognize","Reset","PostalCode"].forEach(function(a){var b=a.toLowerCase();Object.defineProperty(i,a,{enumerable:!1,get:function(){return console.log("Warning: '"+a+"' is deprecated, please use '"+b+"' instead"),i[b]}})});var j={init:function(){if(this.isDynaCart=!1,this.ready=!0,this.listDriver=k.getAttribute("data-storefront").split(".")[0],this.$fscDynaContainers=document.querySelectorAll("[data-fsc-items-container]"),this.dynaListObjs=[],void 0!==this.$fscDynaContainers[0]){this.isDynaCart=!0;for(var a="",b="",c=this.$fscDynaContainers.length,d=0;d","").replace("

",""))})}),"function"==typeof window[g.beforeMarkup]){b(" <- Calling ",g.beforeMarkup);try{window[g.beforeMarkup]()}catch(a){c(" --Error in data-before-markup-callback")}}b("Doing markup with data:",this.data),this.isDynaCart?this.loadHandlebarsLib("handlebarScriptElm","https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.min.js",function(){if("function"==typeof window[g.markupHelpers]){b(" <- Calling ",g.markupHelpers);try{window[g.markupHelpers]()}catch(a){c(" --Error in data-after-markup-callback",a)}}this.handlebarTemplates=[];for(var a=0;a-1?c.addEventListener?(c.addEventListener("change",this.functions.Multiple,!1),this.unbinders.push({element:c,action:"change",fn:this.functions.Multiple})):c.attachEvent("change",this.functions.Multiple):c.addEventListener?(c.addEventListener("click",this.functions.Multiple,!1),this.unbinders.push({element:c,action:"click",fn:this.functions.Multiple})):c.attachEvent("click",this.functions.Multiple),a[b].parentNode.replaceChild(c,a[b])}},uninstall:function(){this.unbinders.forEach(function(a){a.element.removeEventListener(a.action,a.fn)})},Checkout:function(){var a=j.findValue("session");a.length<10?i.checkout():i.checkout(a)},PaypalCheckout:function(){i.payment("paypal")},Promo:function(){var a=j.findValue("promocode");i.promo(a)},PostalCode:function(){var a=j.findValue("postalcode");i.postalCode(a)},TaxId:function(){var a=j.findValue("taxid");i.taxId(a)},ViewCart:function(){i.viewCart()},Update:function(a){var b,c,d,e,f=a.getAttribute("data-fsc-item-path-value"),g=a.getAttribute("data-fsc-item-quantity-value"),h=a.getAttribute("data-fsc-quantity-src");if("input"!==a.tagName.toLowerCase()||"checkbox"!==a.type.toLowerCase()||a.checked){if(null!==g&&g>0)b=g;else if(null!==h&&h.length>0){if(c=document.getElementById(h),d=c.getAttribute("data-fsc-item-quantity-value"),null!==c)switch(e=c.tagName.toLowerCase(),!0){case"input"===e&&"checkbox"!==c.type.toLowerCase()||"select"===e:b=c.value;break;case"input"===e&&"checkbox"===c.type.toLowerCase()&&!c.checked:b=0;break;case"input"===e&&"checkbox"===c.type.toLowerCase()&&c.checked:b=1;break;case"null"!==d&&d>0:b=d;break;default:b=j.findValue("item-quantity",f)}}else b=a.hasOwnProperty("selectedIndex")&&a[a.selectedIndex].value>-1?a[a.selectedIndex].value:j.findValue("item-quantity",f);b=b||1}else b=0;i.update(f,b)},Add:function(a){var b=a.getAttribute("data-fsc-item-path-value");i.add(b)},Remove:function(a){var b=a.getAttribute("data-fsc-item-path-value");i.update(b,0)},Replace:function(a){var b=a.getAttribute("data-fsc-driver-item-path-value");i.update(b,0)},Recognize:function(){var a=j.findValue("firstname"),b=j.findValue("lastname"),c=j.findValue("email");i.recognize(c,a,b)},Reset:function(a){i.reset()},UpdateSession:function(a){i.updateSession()},Clean:function(){i.clean()},Multiple:function(a){var b=this.functions;n=!0;var c=a.getAttribute("data-fsc-action");c.indexOf(",")>-1?c.split(",").forEach(function(c){c=c.trim(),b.hasOwnProperty(c)&&b[c](a)}):(c=c.trim(),b.hasOwnProperty(c)&&b[c](a)),n=!1,g.parseInput(l)},findValue:function(a,b){var c,d;if(c=b?document.querySelectorAll("[data-fsc-"+a+"-value][data-fsc-item-path-value='"+b+"']"):document.querySelectorAll("[data-fsc-"+a+"-value]"),void 0!==c[0]){if(d=c[0],d.value)return d.value;if(d.innerHTML)return d.innerHTML}return""},parseAndPut:function(a){p=!1===a.selections;var c=this.parseProducts(a),d=this.parseProductsDyna(a),e=this.parseDynaOrderLevel(a);this.processDynaOrderLists(d,c,e),c.length>0?(b("Products:",c),this.processProducts(c)):b("No products found in response");var f=this.parseOrderLevel(a);!1!==f?(b("Top level items:",f),this.processOrderLevelItems(f)):b("No top level items found in response"),this.addEventHandlers()},parseProducts:function(a){for(var b=[],c=0;c0&&b},parseProductsDyna:function(a){var b={storefront:"storefront",offers:"offers"},c=function(a){this.raw=a.raw,this.setListType(this.raw.driver)};c.prototype.setListType=function(a){void 0===a?this.listType=b.storefront:a===j.listDriver||a.indexOf(j.listDriver)>-1?this.listType=b.storefront:a!==j.listDriver&&(this.listType=b.offers)},c.prototype.isStorefront=function(){return this.listType===b.storefront},c.prototype.isOffer=function(){return this.listType===b.offers};var d=a.groups.filter(function(a){return new c({raw:a}).isStorefront()}),e=a.groups.filter(function(a){return new c({raw:a}).isOffer()});return d=d.concat(e),d.length>0&&d},applyDynaFilter:function(a,b){var c,d,e,f={},g=[];return null!==b.filterList&&(b.filterList.split(";").forEach(function(a,b){d=a.split("="),f[d[0]]=d[1]}),g=a.filter(function(a){c=!0;for(var b in f)if(f.hasOwnProperty(b)){if(void 0===f[b]||null===f[b])return!0;if(e=f[b],"true"===f[b]&&(e=!0),"false"===f[b]&&(e=!1),"'"===f[b][0]){var d=f[b].length;e=f[b].substring(1,d-1)}else void 0!==window[e]&&(e=window[e]);if(a[b]!==e){c=!1;break}}return c})),g},parseOrderLevel:function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&"groups"!==c&&(b=b.concat({key:c,value:a[c]}));return b.length>0&&b},processOrderLevelItems:function(a){var c=this;Array.isArray(a)?a.forEach(function(a){c.processOrderLevelItem(a.key,a.value)}):b("Unexpected format of data")},processOrderLevelItem:function(a,c){var d,e=this;if("taxExemptionAllowed"===a){var f=document.querySelectorAll("[data-fsc-smartdisplay][data-fsc-order-taxid]");Array.prototype.forEach.call(f,function(a){a.style.display=c?"block":"none"})}if("availablePaymentMethods"===a){var g=document.querySelectorAll("[data-fsc-smartdisplay][data-fsc-order-paypal-available]");Array.prototype.forEach.call(g,function(a){-1!=c.indexOf("paypal")?a.style.display="block":a.style.display="none"})}if("selections"===a){var h=document.querySelectorAll("[data-fsc-selections-smartselect],[data-fsc-selections-smartdisplay],[data-fsc-selections-smartdisplay-inverse], [data-fsc-selections-hideifselections],[data-fsc-selections-showifselections],[data-fsc-selections-hideifnoselections],[data-fsc-selections-showifnoselections],[data-fsc-selections-smartdisable],[data-fsc-selections-smartdisable-inverse],[data-fsc-selections-disableifselections],[data-fsc-selections-disableifnoselectios],[data-fsc-selections-enableifselections],[data-fsc-selections-enableifnoselections]");if(null!==h)for(d=0;d0&&b},processDynaOrderLists:function(a,c,d){var e=this;if(Array.isArray(a)){for(var f=a.length,g=0;g",""),c=c.replace("

","")),c=c.toString().replace("

",""),c=c.replace("

",""),e=e.toLowerCase();var g=d.tagName.toLowerCase();"a"===g?"data-fsc-item-link"===e?(b("Setting href to",c,d),d.setAttribute("href",c)):d.innerHTML=c.toString():"input"===g?(b("Setting value to",c,d),d.value=c):"select"===g?d[c-1]&&d[c-1].setAttribute("selected",!0):"button"===g?(b("Setting value to",c,d),d.value=c):"img"===g?(b("Setting src to",c,d),d.setAttribute("src",c)):"div"===g||(a.indexOf("Value")>-1?(d.value="",d.setAttribute("data-fsc-item-"+a,c),d.innerHTML=c.toString()):d.innerHTML=c.toString());var h,i=["data-fsc-item-price","data-fsc-item-pricetotal"];b("do I run SmartDisplay for",a,f),void 0!==d.getAttribute("data-fsc-smartdisplay")&&null!==d.getAttribute("data-fsc-smartdisplay")&&i.indexOf(e)>-1&&(b("Agreed to run SmartDisplay for",a,f),null!==(h=""===d.getAttribute("data-fsc-smartdisplay")?d:document.querySelector("["+d.getAttribute("data-fsc-smartdisplay")+"]"))&&(f&&"show"===f?h.setAttribute("style","display: block"):h.setAttribute("style","display: none"))),d.hasAttribute("data-fsc-callback")&&"function"==typeof window[d.getAttribute("data-fsc-callback")]&&(b("Agreed to run CallBack function for",a,d.getAttribute("data-fsc-callback")),window[d.setAttribute("data-fsc-callback")](d,a,c))},displayDynaOrderLists:function(a,b,c){var d=document.querySelector("[data-fsc-items-container='"+c+"']");if(void 0!==b){var e=b(a);d.innerHTML=e}}};j.ready=!1,j.data=null;var k=document.querySelector("script#fsc-api"),l=window.fscSession||{},m=!1,n=!1,o=!1,p=!1;document.addEventListener("DOMContentLoaded",function(){j.init(),j.process()},!1),g.init();var q={};Object.defineProperty(q,"builder",{enumerable:!0,configurable:!0,get:function(){return i}}),Object.defineProperty(window,"fastspring",{enumerable:!0,configurable:!0,get:function(){return q}}),Object.defineProperty(window,"_f",{configurable:!0,get:function(){return console.log("Warning: '_f' is deprecated, please use 'fastspring.builder' instead"),i}})}();