!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t255||(r=e.charCodeAt(c++))>255||(o=e.charCodeAt(c++))>255)throw new TypeError("invalid character found");i+=f[(t=n<<16|r<<8|o)>>18&63]+f[t>>12&63]+f[t>>6&63]+f[63&t]}return a?i.slice(0,a-3)+"===".substring(a):i};function h(){return window.crypto?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function v(){return(new Date).getTime().toString()}function g(){return{aid:"spangle_landing_page",lang:"en-US",tna:"sp1",p:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?"app":"web",page:document.title,sid:(e=c(d),e||(e=h()),a(d,e,365),e),url:window.location.href,exid:"test_landing_page",refr:window.location.href,referrer:document.referrer||"",user_agent:navigator.userAgent||""};var e}function y(e){return{e_n:e.eventName,e_id:e.eventId||h(),e_ts:v()}}function _(){return{sp_abtg:c("spangle_ab_test_new"),sp_abtu:c("spangle_ab_test_uuid")||""}}function w(){return{sh_s:c("_shopify_s")||"",sh_y:c("_shopify_y")||""}}function m(e){var t=e.productId,n=e.eventType;if(t){var r={product_id:t.toString(),click_type:n,timestamp:v()},o=c(u);try{o?(o=JSON.parse(atob(o))).push(r):o=[r],o.length>5&&o.shift(),a(u,l(JSON.stringify(o)),1)}catch(e){}}}function x(e){return{p_catagory:e.category||"",p_currency:e.currency||"",p_id:e.productId||"",p_sku_id:e.skuId||"",p_name:e.productName||"",p_price:e.price?Number(e.price):null,p_quantity:e.quantity?Number(e.quantity):null}}function b(e){return{duid:"",u_mail:e.userMail||"",u_customer_id:e.userCustomerId||"",u_visit_id:e.userVisitId||"",u_registered_id:e.userRegisteredId?e.userRegisteredId.toString():""}}var I,P,T,S,B=n("clientId"),O=n("spanglePageViewExecuted"),N=n("sendBeaconPath"),k=n("sendBeaconBlobType"),A=n("sendData"),j=function(){function t(e){Object.defineProperty(this,A,{value:C}),Object.defineProperty(this,B,{writable:!0,value:void 0}),Object.defineProperty(this,O,{writable:!0,value:!1}),Object.defineProperty(this,N,{writable:!0,value:"https://k6bl6z3j1m.execute-api.us-east-1.amazonaws.com/spangle/publishEvents"}),Object.defineProperty(this,k,{writable:!0,value:"application/json"}),r(this,B)[B]=function(e){return l(e)}(e.clientId),r(this,N)[N]=e.sendBeaconPath||r(this,N)[N],r(this,k)[k]=e.sendBeaconBlobType||r(this,k)[k]}var n=t.prototype;return n.trackPageView=function(t){if(!r(this,O)[O]){r(this,O)[O]=!0;var n=e({},g(),y({eventName:"page_view",eventId:t.eventId}),_(),b(t),w(),{orgid:r(this,B)[B]});r(this,A)[A](n)}},n.parseSearchParams=function(e){var t=new URL(e).searchParams;return{q:t.get("q"),category:t.get("category")}},n.trackProductView=function(t){var n=e({},g(),y({eventName:i,eventId:t.eventId}),_(),b(t),x(t),w(),{orgid:r(this,B)[B]});r(this,A)[A](n),m({productId:t.productId||t.skuId,eventType:i})},n.trackProductListView=function(t){var n=this.parseSearchParams(window.location.href),o=e({},g(),y({eventName:"product_list_view",eventId:t.eventId}),_(),b(t),w(),{orgid:r(this,B)[B],s_k:n.q,p_catagory:t.category||n.category||"",v_products:t.productIds});r(this,A)[A](o)},n.trackAddToCart=function(t){var n=e({},g(),y({eventName:o,eventId:t.eventId}),_(),b(t),x(t),w(),{orgid:r(this,B)[B]});r(this,A)[A](n),m({productId:t.productId,eventType:o})},n.trackRemoveFromCart=function(t){var n=e({},g(),y({eventName:"remove_from_cart",eventId:t.eventId}),_(),b(t),x(t),w(),{orgid:r(this,B)[B]});r(this,A)[A](n)},n.trackPurchase=function(t){var n,o=e({},g(),y({eventName:"purchase",eventId:t.eventId}),_(),b(t),{o_id:(n=t).orderId||"",o_currency:n.orderCurrency||"",o_promo_code:n.orderPromoCode||"",o_discount:n.orderDiscount,o_shipping:n.orderShipping,o_products:n.orderProducts||[],o_subtotal:n.orderSubtotal,o_tax:n.orderTax},w(),{orgid:r(this,B)[B]});r(this,A)[A](o)},t}();function C(e){!function(e){var t=e.data,n=e.path,r=e.blobType,o=void 0===r?"text/plain":r;try{var i=new Blob([JSON.stringify(t)],{type:o});navigator&&navigator.sendBeacon&&i.size<=65500?navigator.sendBeacon(n,i):function(e,t,n,r,o,i){void 0===r&&(r=null),void 0===o&&(o=0),void 0===i&&(i=1e3);var a=new XMLHttpRequest;!function e(c){a.open("POST",t,!0),a.onreadystatechange=function(){4===a.readyState&&(200===a.status?r&&r(a.responseText):c>0?setTimeout((function(){e(c-1)}),i):console.error("Request failed after "+o+" retries."))},a.setRequestHeader("Content-Type","application/json"),a.send(JSON.stringify(n))}(o)}(0,n,t)}catch(e){}}({data:e,path:r(this,N)[N],blobType:r(this,k)[k]})}T=void 0===(P=(I={clientId:"STEVEMADDEN".toLowerCase(),sendBeaconBlobType:"text/plain"}).windowPixelName)?"SpanglePixel":P,S=new j({clientId:I.clientId,sendBeaconPath:I.sendBeaconPath,sendBeaconBlobType:I.sendBeaconBlobType}),window[T]?(window[T]&&window[T].queue&&window[T].queue.forEach((function(e){S[e[0]].apply(S,e.slice(1))})),window[T].callMethod=function(e){return S[e].apply(S,Array.prototype.slice.call(arguments,1))}):window[T]=S}));