!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function e(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{u(r.next(e))}catch(e){o(e)}}function s(e){try{u(r.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))}function t(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&i[3]>o[1])){a.label=o[1];break}if(6===o[0]&&i[1]>a.label){a.label=i[1],i=o;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}var n,r=new Uint8Array(16);function i(){if(!n&&!(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(r)}var o=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function a(e){return"string"==typeof e&&o.test(e)}for(var s=[],u=0;256>u;++u)s.push((u+256).toString(16).substr(1));function c(e,t,n){var r=(e=e||{}).random||(e.rng||i)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;16>o;++o)t[n+o]=r[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(s[e[t+0]]+s[e[t+1]]+s[e[t+2]]+s[e[t+3]]+"-"+s[e[t+4]]+s[e[t+5]]+"-"+s[e[t+6]]+s[e[t+7]]+"-"+s[e[t+8]]+s[e[t+9]]+"-"+s[e[t+10]]+s[e[t+11]]+s[e[t+12]]+s[e[t+13]]+s[e[t+14]]+s[e[t+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n}(r)}var l=function(){return{get:function(e){var t=("; "+document.cookie).split("; "+e+"=");if(2===t.length)return t.pop().split(";").shift()}}},d=function(e){return{get:function(t){return e.getItem(t)},set:function(t,n){e.setItem(t,n)},remove:function(t){e.removeItem(t)},clear:function(){e.clear()}}},p=function(){var e,t=document.cookie.split("; ").find((function(e){return e.includes("BOM-CART_ID")}));if(void 0!==t){var n=t.split("BOM-CART_ID=")[1];if(void 0!==n){var r=void 0;try{r=atob(n)}catch(e){r=n}e=r.split("/")[r.split("/").length-1].split("?")[0]}}return e},f=function(e){return e.includes("allbirds")?6048e5:864e5},m=function(){var e={};return window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,(function(t,n,r){return e[n.toLowerCase()]=r,""})),e},v="weareallbirds.myshopify.com",g=function(e){return"wearebombas.com".split(",").includes(e)},y=function(e){return!!e&&(e.includes("/cart/add")||e.includes("/cart/change")||e.includes("/cart/update"))};function h(e,t,n,r){void 0===r&&(r=1e3);var i=t.map((function(t){return e.get(t)}));setInterval((function(){var r,o,a=t.map((function(t){return e.get(t)}));if(o=a,!(Array.isArray(r=i)&&Array.isArray(o)&&(null==r?void 0:r.length)===(null==o?void 0:o.length)&&(null==r?void 0:r.every((function(e,t){return e===(null==o?void 0:o[t])})))))try{n()}finally{i=a}}),r)}var b=function(e){try{return JSON.parse(e)}catch(e){return console.warn(e),{}}},w=function(n,r,i,o){return e(void 0,void 0,void 0,(function(){var e,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:e=""+(o||"https://prod-consumer-app.integrations-itbl.co")+n,t.label=1;case 1:return t.trys.push([1,7,,8]),[4,fetch(e,r)];case 2:if(a=t.sent(),s=a.status,u=a.statusText,a.ok)return[3,3];throw Error("An error has occured when making request to "+e+". Response status is "+s+" "+u);case 3:return t.trys.push([3,5,,6]),[4,a.json()];case 4:return function(e){try{JSON.parse(JSON.stringify(e))}catch(e){return!1}return!0}(c=t.sent())&&"function"==typeof i&&i(c),[3,6];case 5:return t.sent(),[3,6];case 6:return[3,8];case 7:return t.sent(),[3,8];case 8:return[2]}}))}))},S=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,I=function(e){return S.test((e+"").toLowerCase())},T="login",k="logout",_="productView",C=function(e){return null==e},E=function(n,r,i){var o=i.currentUrl,a=i.customerId,s={updateSession:function(){var e=n.get("session_id"),t={marketingFields:s.getMarketingValues(),shop:v,createdAt:Date.now()};C(a)||a+""===n.get("customerId")||(n.set("customerId",a),t.customerId=a+""),C(e)||w("/sessions/"+e,{method:"PUT",body:JSON.stringify(t)})},createEvent:function(e){var t={type:e,source:v,sessionId:n.get("session_id"),payload:{url:o,marketingFields:s.getMarketingValues()}};w("/events/custom",{method:"POST",body:JSON.stringify(t)})},getMarketingValues:function(){for(var e=["iterableEmailCampaignId","iterableEndUserId","iterableMessageId","iterableTemplateId"],t={},n=e.length,i=0;n>i;i++)t[e[i]]=r.get(e[i]);return r.get("iterableTemplateIdTemp")&&(t.iterableTemplateId=r.get("iterableTemplateIdTemp")),r.get("iterableEmailCampaignIdTemp")&&(t.iterableEmailCampaignId=r.get("iterableEmailCampaignIdTemp")),t},logout:function(){s.createEvent(k),n.set("session_id",c()),s.checkCartToken()},login:function(r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return n.get("session_id")?[3,2]:(n.set("session_id",c()),[4,s.checkCartToken()]);case 1:t.sent(),t.label=2;case 2:return e={type:T,source:v,sessionId:n.get("session_id"),payload:{email:r,url:window.location.href}},w("/events/custom",{method:"POST",body:JSON.stringify(e)}),[2]}}))}))},setSessionAlias:function(){var e=n.get("session_id"),t=n.get("cart_token")||p()||r.get("cart");t&&w("/sessions/"+e+"/alias",{method:"POST",body:JSON.stringify({alias:t,shop:v})})},checkCartToken:function(){return e(this,void 0,void 0,(function(){var r,i=this;return t(this,(function(o){switch(o.label){case 0:return g(v)?void 0===(r=p())?[3,2]:(n.set("cart_token",r),[4,s.setSessionAlias()]):[3,3];case 1:o.sent(),o.label=2;case 2:return[3,5];case 3:return[4,w("/cart.js",{method:"GET"},(function(r){return e(i,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return r.item_count>0?(n.set("cart_token",r.token),[4,s.setSessionAlias()]):[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}),"https://"+window.location.hostname)];case 4:o.sent(),o.label=5;case 5:return[2]}}))}))}};return s},A=function(){var n,r,i;console.log("Tracking script 1.0.15 - April 26, 2024 18:57:22");var o=null;"undefined"!=typeof customer_id?o=customer_id:(console.warn("Iterable Connector: customer_id is not defined."),o=null===(i=null===(r=null===(n=window.ShopifyAnalytics)||void 0===n?void 0:n.meta)||void 0===r?void 0:r.page)||void 0===i?void 0:i.customerId);var a=window.location.href,s=m(),u=s.iterable_campaign,p=/^campaign_\d*$/.test(s.utm_campaign)?(s.utm_campaign||"").split("_")[1]:"",g=s.iterable_template,w=s.utm_userid,S=new Date;S.setTime(S.getTime()+f(v));var T="expires="+S.toUTCString();g&&(document.cookie="iterableTemplateIdTemp="+g+"; path=/;"+T);var k=u||p;k&&(document.cookie="iterableEmailCampaignIdTemp="+k+"; path=/;"+T),w&&(document.cookie="iterableUserId="+w+"; path=/;"+T);var C=d(localStorage),A=l();C.get("session_id")||C.set("session_id",c());var q=E(C,A,{currentUrl:a,customerId:o});(A.get("cart")||A.get("BOM-CART_ID"))&&C.get("session_id")&&q.setSessionAlias(),q.updateSession();h(A,["iterableEmailCampaignId","iterableEmailCampaignIdTemp","iterableEndUserId","iterableMessageId","iterableTemplateId","iterableTemplateIdTemp"],q.updateSession),setTimeout((function(){var e,t=null===(e=null==a?void 0:a.split("?"))||void 0===e?void 0:e[0];(null==t?void 0:t.includes("/products/"))&&q.createEvent(_)}),1e3);var O=window.fetch;window.fetch=function(){for(var n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];return e(void 0,void 0,void 0,(function(){var e,r,i,o,a,s,u,c;return t(this,(function(t){switch(t.label){case 0:return r=n[1],o=(null==(i="string"==typeof(e=n[0])?e:(null==e?void 0:e.url)||"")?void 0:i.includes("/identity/sign-in"))||(null==i?void 0:i.includes("/identity/create")),a="",o&&"string"==typeof(null==r?void 0:r.body)&&"object"==typeof(s=b((null==r?void 0:r.body)||"{}"))&&null!==s&&(a=s.email),[4,O(e,r)];case 1:return u=t.sent(),(c=u.ok)&&y(i)&&q.checkCartToken(),c&&o&&a&&I(a)&&q.login(a),c&&(null==i?void 0:i.includes("/identity/sign-out"))&&q.logout(),[2,u]}}))}))},XMLHttpRequest.prototype.realSend=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.send=function(e){this.addEventListener("load",(function(){y(this.responseURL)&&q.checkCartToken()}),!1),this.realSend(e)};var R=document.querySelector('a[href="/account/logout"]');R&&R.addEventListener("click",q.logout);var M=function(e){var t=e.target.querySelector("input#CustomerEmail")||e.target.querySelector("input#customer_email")||e.target.querySelector('input[name="customer[email]"]')||e.target.querySelector('input[type="email"]'),n=t?t.value:"";n&&I(n)&&q.login(n)};(function(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;o>i;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))})([],document.querySelectorAll("form"),!0).forEach((function(e){var t=e.querySelector("input#CustomerEmail")||e.querySelector("input#customer_email")||e.querySelector('input[name="customer[email]"]')||e.querySelector('input[type="email"]'),n=e.querySelector("input#CustomerPassword")||e.querySelector("input#customer_password")||e.querySelector('input[name="customer[password]"]')||e.querySelector('input[type="password"]');t&&n&&e.addEventListener("submit",M)}))};"loading"!==document.readyState?A():document.onreadystatechange=function(){"interactive"===document.readyState&&A()}}));