/*!For license information please see widget.js.LICENSE.txt*/var lsNetvisioGTM;(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{setCustomer:()=>d});function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(){i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},a="function"==typeof Symbol?Symbol:{},l=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function d(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(t){d=function(t,e,n){return t[e]=n}}function s(t,e,n,i){var r=e&&e.prototype instanceof p?e:p,a=Object.create(r.prototype),l=new j(i||[]);return o(a,"_invoke",{value:S(t,n,l)}),a}function v(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var m={};function p(){}function _(){}function h(){}var f={};d(f,l,(function(){return this}));var g=Object.getPrototypeOf,y=g&&g(g(x([])));y&&y!==e&&r.call(y,l)&&(f=y);var w=h.prototype=p.prototype=Object.create(f);function b(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function i(o,a,l,c){var u=v(t[o],t,a);if("throw"!==u.type){var d=u.arg,s=d.value;return s&&"object"==n(s)&&r.call(s,"__await")?e.resolve(s.__await).then((function(t){i("next",t,l,c)}),(function(t){i("throw",t,l,c)})):e.resolve(s).then((function(t){d.value=t,l(d)}),(function(t){return i("throw",t,l,c)}))}c(u.arg)}var a;o(this,"_invoke",{value:function(t,n){function r(){return new e((function(e,r){i(t,n,e,r)}))}return a=a?a.then(r,r):r()}})}function S(t,e,n){var i="suspendedStart";return function(r,o){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw o;return{value:void 0,done:!0}}for(n.method=r,n.arg=o;;){var a=n.delegate;if(a){var l=I(a,n);if(l){if(l===m)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var c=v(t,e,n);if("normal"===c.type){if(i=n.done?"completed":"suspendedYield",c.arg===m)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i="completed",n.method="throw",n.arg=c.arg)}}}function I(t,e){var n=e.method,i=t.iterator[n];if(void 0===i)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,I(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var r=v(i,t.iterator,e.arg);if("throw"===r.type)return e.method="throw",e.arg=r.arg,e.delegate=null,m;var o=r.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,m):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,m)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function x(t){if(t){var e=t[l];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return _.prototype=h,o(w,"constructor",{value:h,configurable:!0}),o(h,"constructor",{value:_,configurable:!0}),_.displayName=d(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,d(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},b(k.prototype),d(k.prototype,c,(function(){return this})),t.AsyncIterator=k,t.async=function(e,n,i,r,o){void 0===o&&(o=Promise);var a=new k(s(e,n,i,r),o);return t.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},b(w),d(w,u,"Generator"),d(w,l,(function(){return this})),d(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var i in e)n.push(i);return n.reverse(),function t(){for(;n.length;){var i=n.pop();if(i in e)return t.value=i,t.done=!1,t}return t.done=!0,t}},t.values=x,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,i){return a.type="throw",a.arg=t,e.next=n,i&&(e.method="next",e.arg=void 0),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var l=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(l&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(l){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),O(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;O(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:x(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),m}},t}function r(t,e,n,i,r,o,a){try{var l=t[o](a),c=l.value}catch(t){return void n(t)}l.done?e(c):Promise.resolve(c).then(i,r)}function o(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function a(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?o(Object(n),!0).forEach((function(e){l(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function l(t,e,i){return(e=function(t){var e=function(t,e){if("object"!==n(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!==n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===n(e)?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function u(t){var e="; ".concat(document.cookie).split("; ".concat(t,"="));if(2===e.length)return e.pop().split(";").shift()}function d(t){console.log("🚀 ~ file: index.js:42 ~ setCustomer ~ customer:",t)}Promise.all([fetch("".concat("https://sp.stapecdn.com","/widget/setting?shop=").concat("kingswarehouse.com.au","&shop_id=").concat("25449124"),{method:"GET"}).then((function(t){return t.json()})),fetch("/cart.js").then((function(t){return t.json()}))]).then((function(t){var e,n,o,l=(o=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o,a,l=[],c=!0,u=!1;try{if(o=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(l.push(i.value),l.length!==e);c=!0);}catch(t){u=!0,r=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw r}}return l}}(n,o)||function(t,e){if(t){if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),d=l[0],s=l[1];console.log("+++++++++++lsNet_2.0.11+++++++++++++");var v=d.generate,m=d.data_layer,p=d.webhook;if(window.dataLayer=window.dataLayer||[],null!=d&&null!==(e=d.generate)&&void 0!==e&&e.insert_gtm_snipper){var _=document.createElement("script"),h=(null==v?void 0:v.is_custom_domain)&&(null==v?void 0:v.custom_domain)||"https://www.googletagmanager.com",f=null!=v&&v.is_custom_domain&&null!=v&&v.custom_domain&&null!=v&&v.is_custom_loaded&&null!=v&&v.custom_loaded?((null==v?void 0:v.gtm_id)||"").replace("GTM-","").trim():(null==v?void 0:v.gtm_id)||"",g=(null==v?void 0:v.is_custom_loaded)&&(null==v?void 0:v.custom_loaded)||"gtm",y=Boolean((null==v?void 0:v.is_custom_domain)&&(null==v?void 0:v.custom_domain)&&(null==v?void 0:v.is_custom_loaded)&&(null==v?void 0:v.custom_loaded));if(v.is_cookie_keeper&&null!=v&&v.is_custom_loaded){var w='!function(){"use strict";function l(e){for(var t=e,r=0,n=document.cookie.split(";");r<n.length;r++){var o=n[r].split("=");if(o[0].trim()===t)return o[1]}}function s(e){return localStorage.getItem(e)}function u(e){return window[e]}function d(e,t){e=document.querySelector(e);return t?null==e?void 0:e.getAttribute(t):null==e?void 0:e.textContent}var e=window,t=document,r="script",n="dataLayer",o="{{WEB_GTM_ID}}",a="{{DOMAIN}}",i="",c="{{CONTAINER_ID}}",E="cookie",I=["_y","_shopify_y"],v="",g=!1;try{var g=!!E&&(m=navigator.userAgent,!!(m=new RegExp("Version/([0-9._]+)(.*Mobile)?.*Safari.*").exec(m)))&&16.4<=parseFloat(m[1]),A="stapeUserId"===E,f=g&&!A?function(e,t,r){void 0===t&&(t="");var n={cookie:l,localStorage:s,jsVariable:u,cssSelector:d},t=Array.isArray(t)?t:[t];if(e&&n[e])for(var o=n[e],a=0,i=t;a<i.length;a++){var c=i[a],c=r?o(c,r):o(c);if(c)return c}else console.warn("invalid uid source",e)}(E,I,v):void 0;g=g&&(!!f||A)}catch(e){console.error(e)}var m=e,E=(m[n]=m[n]||[],m[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"}),t.getElementsByTagName(r)[0]),I="dataLayer"===n?"":"&l="+n,v=f?"&bi="+encodeURIComponent(f):"",A=t.createElement(r),e=g?"kp"+c:c,n=!g&&i?i:a;A.async=!0,A.src=n+"/"+e+".js?st="+o+I+v,null!=(f=E.parentNode)&&f.insertBefore(A,E)}();'.replace("{{DOMAIN}}",h).replace("{{WEB_GTM_ID}}",f).replace("{{CONTAINER_ID}}",g);_.innerHTML=w}else{var b="(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='{{DOMAIN}}/{{CONTAINER_ID}}.js?".concat(y?"st":"id","='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','{{WEB_GTM_ID}}');").replace("{{DOMAIN}}",h).replace("{{WEB_GTM_ID}}",f).replace("{{CONTAINER_ID}}",g);_.innerHTML=b}document.head.appendChild(_)}var k={product_added_to_cart:"add_to_cart_stape",cart_viewed:"view_cart_stape",product_removed_from_cart:"remove_from_cart_stape",collection_viewed:"view_collection_stape",search_submitted:"search_submitted_stape",checkout_completed:"purchase_stape",product_viewed:"view_item_stape"};setInterval((function(){try{var t=localStorage.getItem("stape_events");t&&(t=JSON.parse(t),Object.keys(t).forEach((function(e){var n=a({},t[e]);null!=m&&m.log_event&&console.log("🚀 ~ Object.keys ~ event:",n);var i=function(t){var e,n,i,r,o,a,l,c,u,d,s,v,m,p,_,h,f,g,y,w,b,k,S,I,L,O,j,x,E,D,R,V,q,A,P,T,N,C,M,G,F,H,U,B,X,J,W,z,Y,$,K,Q,Z,tt,et,nt={};return null!==(e=t.data)&&void 0!==e&&null!==(n=e.checkout)&&void 0!==n&&null!==(i=n.totalPrice)&&void 0!==i&&i.hasOwnProperty("amount")&&(nt.value=t.data.checkout.totalPrice.amount.toString(),nt.cart_total=t.data.checkout.totalPrice.amount.toString(),nt.currency=t.data.checkout.totalPrice.currencyCode,nt.cart_quantity=t.data.checkout.lineItems.length),"checkout_completed"==t.name&&(nt.tax=t.data.checkout.totalTax.amount,nt.shipping=t.data.checkout.shippingLine.price.amount,nt.transaction_id=t.data.checkout.order.id,nt.coupon=null===(r=t.data.checkout)||void 0===r||null===(o=r.discountApplications[0])||void 0===o?void 0:o.title,nt.discount=null===(a=t.data.checkout)||void 0===a||null===(l=a.discountApplications[0])||void 0===l?void 0:l.title,nt.discount_amount=null===(c=t.data.checkout)||void 0===c||null===(u=c.discountApplications[0])||void 0===u||null===(d=u.value)||void 0===d?void 0:d.amount,nt.discount_percentage=null===(s=t.data.checkout)||void 0===s||null===(v=s.discountApplications[0])||void 0===v||null===(m=v.value)||void 0===m?void 0:m.percentage,nt.sub_total=t.data.checkout.subtotalPrice.amount),"collection_viewed"==t.name&&(nt.collection_id=null==t||null===(p=t.data)||void 0===p||null===(_=p.collection)||void 0===_?void 0:_.id,nt.item_list_name=null==t||null===(h=t.data)||void 0===h||null===(f=h.collection)||void 0===f?void 0:f.title,nt.currency=null===(g=t.data.collection.productVariants[0])||void 0===g||null===(y=g.price)||void 0===y?void 0:y.currencyCode),"search_submitted"==t.name&&(nt.search_term=null==t||null===(w=t.data)||void 0===w||null===(b=w.searchResult)||void 0===b?void 0:b.query,nt.currency=null==t||null===(k=t.data)||void 0===k||null===(S=k.searchResult)||void 0===S||null===(I=S.productVariants[0])||void 0===I||null===(L=I.price)||void 0===L?void 0:L.currencyCode),"cart_viewed"==t.name&&(nt.value=null==t||null===(O=t.data)||void 0===O||null===(j=O.cart)||void 0===j||null===(x=j.cost)||void 0===x||null===(E=x.totalAmount)||void 0===E?void 0:E.amount.toString(),nt.currency=null==t||null===(D=t.data)||void 0===D||null===(R=D.cart)||void 0===R||null===(V=R.cost)||void 0===V||null===(q=V.totalAmount)||void 0===q?void 0:q.currencyCode),"product_viewed"==t.name&&(nt.value=null==t||null===(A=t.data)||void 0===A||null===(P=A.productVariant)||void 0===P||null===(T=P.price)||void 0===T?void 0:T.amount.toString(),nt.currency=null==t||null===(N=t.data)||void 0===N||null===(C=N.productVariant)||void 0===C||null===(M=C.price)||void 0===M?void 0:M.currencyCode),"product_added_to_cart"==t.name&&(nt.value=null==t||null===(G=t.data)||void 0===G||null===(F=G.cartLine)||void 0===F||null===(H=F.merchandise)||void 0===H||null===(U=H.price)||void 0===U?void 0:U.amount.toString(),nt.currency=null==t||null===(B=t.data)||void 0===B||null===(X=B.cartLine)||void 0===X||null===(J=X.merchandise)||void 0===J||null===(W=J.price)||void 0===W?void 0:W.currencyCode),"product_removed_from_cart"==t.name&&(nt.value=null==t||null===(z=t.data)||void 0===z||null===(Y=z.cartLine)||void 0===Y||null===($=Y.merchandise)||void 0===$||null===(K=$.price)||void 0===K?void 0:K.amount.toString(),nt.currency=null==t||null===(Q=t.data)||void 0===Q||null===(Z=Q.cartLine)||void 0===Z||null===(tt=Z.merchandise)||void 0===tt||null===(et=tt.price)||void 0===et?void 0:et.currencyCode),nt}(n);i.items=function(t){var e,n,i,r,o,a,l,c,u,d,s,v,m,p,_,h,f,g,y=[];if(null!==(e=t.data)&&void 0!==e&&null!==(n=e.checkout)&&void 0!==n&&n.lineItems)for(var w=0;w<t.data.checkout.lineItems.length;w++){var b,k,S,I,L,O;y.push({item_id:t.data.checkout.lineItems[w].variant.product.id,item_sku:t.data.checkout.lineItems[w].variant.sku,item_variant:t.data.checkout.lineItems[w].variant.id,item_name:t.data.checkout.lineItems[w].variant.product.title,variant_name:t.data.checkout.lineItems[w].variant.title,item_category:t.data.checkout.lineItems[w].variant.product.type,item_brand:t.data.checkout.lineItems[w].variant.product.vendor,item_url:null===(b=t.data.checkout.lineItems[w].variant.product)||void 0===b?void 0:b.url,price:t.data.checkout.lineItems[w].variant.price.amount,imageURL:null===(k=t.data.checkout.lineItems[w])||void 0===k||null===(S=k.variant)||void 0===S||null===(I=S.image)||void 0===I?void 0:I.src,discount:null!==(L=t.data.checkout.lineItems[w].discountAllocations[0])&&void 0!==L&&null!==(O=L.amount)&&void 0!==O&&O.amount?t.data.checkout.lineItems[w].discountAllocations[0].amount.amount:null,quantity:t.data.checkout.lineItems[w].quantity})}if(null!==(i=t.data)&&void 0!==i&&null!==(r=i.cartLine)&&void 0!==r&&r.merchandise&&y.push({item_id:t.data.cartLine.merchandise.product.id,item_sku:t.data.cartLine.merchandise.sku,item_variant:t.data.cartLine.merchandise.id,item_name:t.data.cartLine.merchandise.product.title,variant_name:t.data.cartLine.merchandise.title,item_category:t.data.cartLine.merchandise.product.type,item_brand:t.data.cartLine.merchandise.product.vendor,item_url:null===(v=t.data.cartLine.merchandise.product)||void 0===v?void 0:v.url,price:t.data.cartLine.merchandise.price.amount,imageURL:null===(m=t.data.cartLine.merchandise)||void 0===m||null===(p=m.image)||void 0===p?void 0:p.src,quantity:t.data.cartLine.quantity}),null!==(o=t.data)&&void 0!==o&&o.productVariant&&(y.push({item_id:t.data.productVariant.product.id,item_sku:t.data.productVariant.sku,item_variant:t.data.productVariant.id,item_name:t.data.productVariant.product.title,variant_name:t.data.productVariant.title,item_category:t.data.productVariant.product.type,price:t.data.productVariant.price.amount,item_brand:t.data.productVariant.product.vendor,imageURL:null===(_=t.data.productVariant)||void 0===_||null===(h=_.image)||void 0===h?void 0:h.src,item_url:null===(f=t.data.productVariant)||void 0===f||null===(g=f.product)||void 0===g?void 0:g.url,quantity:"1"}),console.log(y)),null!==(a=t.data)&&void 0!==a&&null!==(l=a.collection)&&void 0!==l&&l.productVariants)for(var j=Math.min(10,t.data.collection.productVariants.length),x=0;x<j;x++){var E,D,R,V;y.push({item_id:t.data.collection.productVariants[x].product.id,item_sku:t.data.collection.productVariants[x].sku,item_variant:t.data.collection.productVariants[x].id,item_name:t.data.collection.productVariants[x].product.title,variant_name:t.data.collection.productVariants[x].title,item_category:t.data.collection.productVariants[x].product.type,item_brand:t.data.collection.productVariants[x].product.vendor,price:t.data.collection.productVariants[x].price.amount,imageURL:null===(E=t.data.collection.productVariants[x])||void 0===E||null===(D=E.image)||void 0===D?void 0:D.src,item_url:null===(R=t.data.collection.productVariants[x])||void 0===R||null===(V=R.product)||void 0===V?void 0:V.url,index:x+1})}if(null!==(c=t.data)&&void 0!==c&&null!==(u=c.searchResult)&&void 0!==u&&u.productVariants)for(var q=Math.min(10,t.data.searchResult.productVariants.length),A=0;A<q;A++){var P,T,N,C;y.push({item_id:t.data.searchResult.productVariants[A].product.id,item_sku:t.data.searchResult.productVariants[A].sku,item_variant:t.data.searchResult.productVariants[A].id,item_name:t.data.searchResult.productVariants[A].product.title,variant_name:t.data.searchResult.productVariants[A].title,item_category:t.data.searchResult.productVariants[A].product.type,item_brand:t.data.searchResult.productVariants[A].product.vendor,price:t.data.searchResult.productVariants[A].price.amount,imageURL:null===(P=t.data.searchResult.productVariants[A])||void 0===P||null===(T=P.image)||void 0===T?void 0:T.src,item_url:null===(N=t.data.searchResult.productVariants[A])||void 0===N||null===(C=N.product)||void 0===C?void 0:C.url,index:A+1})}if(null!==(d=t.data)&&void 0!==d&&null!==(s=d.cart)&&void 0!==s&&s.lines)for(var M=0;M<t.data.cart.lines.length;M++){var G,F,H,U;y.push({item_id:t.data.cart.lines[M].merchandise.product.id,item_sku:t.data.cart.lines[M].merchandise.sku,item_variant:t.data.cart.lines[M].merchandise.id,item_name:t.data.cart.lines[M].merchandise.product.title,variant_name:t.data.cart.lines[M].merchandise.title,item_category:t.data.cart.lines[M].merchandise.product.type,item_brand:t.data.cart.lines[M].merchandise.product.vendor,item_url:null===(G=t.data.cart.lines[M].merchandise)||void 0===G||null===(F=G.product)||void 0===F?void 0:F.url,price:t.data.cart.lines[M].merchandise.price.amount,imageURL:null===(H=t.data.cart.lines[M].merchandise)||void 0===H||null===(U=H.image)||void 0===U?void 0:U.src,quantity:t.data.cart.lines[M].quantity})}return y}(n);var r={event:k[n.name],user_data:n.user_data,ecommerce:i,ecomm_pagetype:n.ecomm_pagetype};if(r.event){if(m.ecommerce?dataLayer.push({ecommerce:null}):delete r.ecommerce,"purchase_stape"==r.event){if(p.send_webhook&&p.url&&p.purchase_webhook){var o={fbc:u("fbc"),fbp:u("fbp"),FPGCLAW:u("FPGCLAW"),_gcl_aw:u("_gcl_aw"),ttclid:u("ttclid")};fetch(p.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a(a({},r),{},{cookies:o}))})}m.checkout_extensibility||m.ecommerce&&dataLayer.push(r)}else{try{delete r.user_data.lifetime_orders,delete r.user_data.new_customer}catch(t){}m.ecommerce&&dataLayer.push(r)}null!=m&&m.log_event&&console.log("🚀 ~ Object.keys ~ eventData:",r,dataLayer)}else null!=m&&m.log_event&&console.log("🚀 ~ Object.keys ~ eventData:",r,dataLayer);delete t[e],localStorage.setItem("stape_events",JSON.stringify(t))})))}catch(t){console.log("🚀 ~ file: index.js:99 ~ setInterval ~ error:",t)}}),500),setTimeout((function(){localStorage.getItem("stape_events")||(console.log("event old push tag"),function(){try{var t,e,n,o,l=function(t){try{if(["purchase_stape","begin_checkout_plus_stape"].includes(null==t?void 0:t.event)&&(window.dataLayer||[]).some((function(e){return(null==e?void 0:e.event)==(null==t?void 0:t.event)})))return void console.log("Not creted event");window.dataLayer.push(t)}catch(e){window.dataLayer.push(t)}},c=location.pathname;localStorage.getItem("cartToken")!=s.token&&c.indexOf("/checkouts")<0&&localStorage.setItem("cartToken",s.token),window.lsData||(window.lsData={});var d={};if(null!==(t=window)&&void 0!==t&&null!==(e=t.lsData)&&void 0!==e&&e.customer&&null!==(n=window)&&void 0!==n&&null!==(o=n.lsData)&&void 0!==o&&o.customer.email&&null!=m&&m.user_data){var v=window.lsData.customer||{};d.user_data={email:v.email,first_name:v.first_name,last_name:v.last_name,customer_id:v.customer_id},localStorage.getItem("customerLoginId")||(localStorage.setItem("customerLoginId",v.customer_id),localStorage.getItem("customerRegisterId")&&localStorage.getItem("customerRegisterId")==v.customer_id?l({event:"login",user_data:d.user_data}):(localStorage.setItem("customerRegisterId",v.customer_id),l({event:"sign_up",user_data:d.user_data})))}else c.indexOf("/checkouts/")<0&&localStorage.removeItem("customerLoginId");if(m.ecommerce||m.user_data){var _=function(){var t,e,n,i,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"begin_checkout_stape";if(null!==(t=window)&&void 0!==t&&null!==(e=t.lsData)&&void 0!==e&&e.cart||null!==(n=window)&&void 0!==n&&null!==(i=n.lsData)&&void 0!==i&&i.checkout){m.ecommerce&&l({ecommerce:null});var o=void 0;if(m.ecommerce){var c,u,s,v,p,_,h,f,g,y=(null===(c=window)||void 0===c||null===(u=c.lsData)||void 0===u?void 0:u.cart)||(null===(s=window)||void 0===s||null===(v=s.lsData)||void 0===v?void 0:v.checkout)||{},w=[];if(null!==(p=window)&&void 0!==p&&null!==(_=p.lsData)&&void 0!==_&&_.cart)w=((null===(g=window.lsData.cart)||void 0===g?void 0:g.items)||[]).map((function(t){return{item_id:t.product_id+"",item_sku:t.sku,item_name:t.product_title,item_brand:t.vendor,item_category:t.product_type,item_variant:t.variant_id+"",price:t.price/100,quantity:t.quantity}}));else if(null!==(h=window)&&void 0!==h&&null!==(f=h.lsData)&&void 0!==f&&f.checkout){var b;w=((null===(b=window.lsData.checkout)||void 0===b?void 0:b.line_items)||[]).map((function(t){return{item_id:t.item_id+"",item_sku:t.item_sku,item_name:t.item_name,item_brand:t.item_brand,item_category:t.item_category,item_variant:t.item_variant+"",price:t.price,quantity:t.quantity}}))}o={cart_total:y.total_price/100,currency:window.lsData.currency||y.currency,cart_quantity:y.item_count,items:w}}l(a(a({},d),{},{ecommerce:o,event:r}))}},h=function(){var t,e=(t=i().mark((function t(e){var n,r,o,c,u,s,v;return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch(window.Shopify.routes.root+"cart.js").then((function(t){return t.json()})).then((function(t){return t}));case 3:n=t.sent,window.lsData.cart=n||{},r=parseInt(localStorage.getItem("cartForStape")||0),localStorage.getItem("cartToken")!=n.token&&localStorage.setItem("cartToken",n.token),o=(n&&n.items||[]).find((function(t){return((null==e?void 0:e.items)||[]).some((function(e){return e.quantity!=t.quantity}))||!((null==e?void 0:e.items)||[]).some((function(e){return e.id==t.id}))})),c=(e&&e.items||[]).find((function(t){return(n&&(null==n?void 0:n.items)||[]).some((function(e){return e.quantity!=t.quantity}))||!((null==n?void 0:n.items)||[]).some((function(e){return e.id==t.id}))})),o||c?(m.ecommerce&&l({ecommerce:null}),u=o||c,s=void 0,m.ecommerce&&(s={currency:window.lsData.currency,items:[{item_id:u.product_id,item_sku:u.sku,item_name:u.product_title,item_brand:u.vendor,item_category:u.product_type,item_variant:u.variant_id+"",price:u.price/100,quantity:u.quantity}]}),v="add_to_cart_stape",(null==o?void 0:o.id)==(null==c?void 0:c.id)&&(v=o.quantity<c.quantity?"remove_from_cart_stape":"add_to_cart_stape"),!o&&c&&(v="remove_from_cart_stape"),l(a(a({},d),{},{ecommerce:s,event:v}))):setTimeout((function(){r<5&&(localStorage.setItem("cartForStape",r+1),h(e))}),500),t.next=15;break;case 12:t.prev=12,t.t0=t.catch(0),console.log("🚀 ~ file: index.js:418 ~ equelCart ~ error:",t.t0);case 15:case"end":return t.stop()}}),t,null,[[0,12]])})),function(){var e=this,n=arguments;return new Promise((function(i,o){var a=t.apply(e,n);function l(t){r(a,i,o,l,c,"next",t)}function c(t){r(a,i,o,l,c,"throw",t)}l(void 0)}))});return function(t){return e.apply(this,arguments)}}();if(c.indexOf("/cart")>-1){m.ecommerce&&l({ecommerce:null});var f=void 0;if(m.ecommerce){var g,y,w=(null===(g=window)||void 0===g||null===(y=g.lsData)||void 0===y?void 0:y.cart)||{};f={cart_total:w.total_price/100,currency:window.lsData.currency,cart_quantity:w.item_count,items:((null==w?void 0:w.items)||[]).map((function(t){return{item_id:t.product_id+"",item_sku:t.sku,item_name:t.product_title,item_brand:t.vendor,item_category:t.product_type,item_variant:t.variant_id+"",price:t.price/100,quantity:t.quantity}}))}}l(a(a({},d),{},{ecommerce:f,event:"view_cart_stape"}))}if(c.indexOf("/collections/")>-1){var b,k;m.ecommerce&&l({ecommerce:null});var S,I=(null===(b=window.lsData)||void 0===b?void 0:b.collection)||[],L=(null===(k=window.lsData)||void 0===k?void 0:k.collection_title)||"",O=void 0;m.ecommerce&&(O={currency:null===(S=window.lsData)||void 0===S?void 0:S.currency,item_list_name:L,items:(I||[]).map((function(t){return{item_name:t.title,item_id:t.id,item_sku:t.variants&&t.variants[0]&&t.variants[0].sku?t.variants[0].sku:"",price:(t.price/100).toFixed(2),item_variant:t.variants[0].id+""}}))}),l(a(a({},d),{},{ecommerce:O,event:"view_collection_stape"}))}if(c.indexOf("/products/")>-1){var j;m.ecommerce&&l({ecommerce:null});var x,E,D,R=(null===(j=window.lsData)||void 0===j?void 0:j.product)||{},V=void 0;m.ecommerce&&(V={currency:null===(x=window.lsData)||void 0===x||null===(E=x.cart)||void 0===E?void 0:E.currency,items:[{item_name:R.title,item_id:null==R||null===(D=R.id)||void 0===D?void 0:D.toString(),item_sku:R.variants&&R.variants[0]&&R.variants[0].sku?R.variants[0].sku:"",item_brand:R.vendor,item_category:R.type,price:(R.price/100).toFixed(2),item_variant:R.variants&&R.variants[0]?R.variants[0].id+"":""}]}),l(a(a({},d),{},{ecommerce:V,event:"view_item_stape"}))}if(c.indexOf("/checkouts")>-1&&location.href.indexOf("step=payment_method")>-1){var q,A,P,T,N,C,M,G,F,H,U,B,X,J,W,z,Y,$,K,Q,Z,tt=(null===(q=window)||void 0===q||null===(A=q.lsData)||void 0===A?void 0:A.checkout)||{},et=(null===(P=window)||void 0===P||null===(T=P.lsData)||void 0===T?void 0:T.customer)||{};d.event="payment_info_stape",m.ecommerce&&l({ecommerce:null}),m.user_data&&(d.user_data={email:tt.email,first_name:(null==tt||null===(N=tt.shipping_address)||void 0===N?void 0:N.first_name)||(null==tt||null===(C=tt.billing_address)||void 0===C?void 0:C.first_name)||"",last_name:(null==tt||null===(M=tt.shipping_address)||void 0===M?void 0:M.last_name)||(null==tt||null===(G=tt.billing_address)||void 0===G?void 0:G.last_name)||"",phone:(null==tt||null===(F=tt.shipping_address)||void 0===F?void 0:F.phone)||(null==tt||null===(H=tt.billing_address)||void 0===H?void 0:H.phone)||"",country:(null==tt||null===(U=tt.shipping_address)||void 0===U?void 0:U.country_code)||(null==tt||null===(B=tt.billing_address)||void 0===B?void 0:B.country_code)||"",region:(null==tt||null===(X=tt.shipping_address)||void 0===X?void 0:X.province)||(null==tt||null===(J=tt.billing_address)||void 0===J?void 0:J.province)||"",city:(null==tt||null===(W=tt.shipping_address)||void 0===W?void 0:W.city)||(null==tt||null===(z=tt.billing_address)||void 0===z?void 0:z.city)||"",street:(null==tt||null===(Y=tt.shipping_address)||void 0===Y?void 0:Y.street)||(null==tt||null===($=tt.shipping_address)||void 0===$?void 0:$.address1)||(null==tt||null===(K=tt.billing_address)||void 0===K?void 0:K.address1)||"",zip:(null==tt||null===(Q=tt.shipping_address)||void 0===Q?void 0:Q.zip)||(null==tt||null===(Z=tt.billing_address)||void 0===Z?void 0:Z.zip)||"",customer_id:(null==et?void 0:et.id)||(null==tt?void 0:tt.customer_id)||""}),m.ecommerce&&(d.ecommerce={currency:null==tt?void 0:tt.currency,cart_total:(null==tt?void 0:tt.total_price)/100,cart_quantity:tt.item_count,items:(null==tt?void 0:tt.line_items)||[]}),l(a({},d))}var nt=window.fetch;window.fetch=function(t,e){var n=t+"";try{if("/cart/add"==n||"/cart/change"==n||"/cart/add.js"==n||"/cart/change.js"==n||0==n.indexOf("/cart/update.js")){var i,r,o=(null===(i=window)||void 0===i||null===(r=i.lsData)||void 0===r?void 0:r.cart)||{};localStorage.setItem("oldCartStape",JSON.stringify(o))}}catch(t){console.log("🚀 ~ file: index.js:356 ~ .then ~ error:",t)}return nt(t,e)},function(t){var e,n;XMLHttpRequest.callbacks?XMLHttpRequest.callbacks.push(t):(XMLHttpRequest.callbacks=[t],e=XMLHttpRequest.prototype.send,XMLHttpRequest.prototype.send=function(){var t;if(null!==(t=XMLHttpRequest)&&void 0!==t&&t.callbacks&&XMLHttpRequest.callbacks.length)for(n=0;n<XMLHttpRequest.callbacks.length;n++)XMLHttpRequest.callbacks[n](this);e.apply(this,arguments)})}((function(t){if("/cart/add.js"==t._url||"/cart/change.js"==t._url){var e=window.lsData.cart||{};localStorage.setItem("oldCartStape",JSON.stringify(e))}})),document.addEventListener("submit",(function(t){if(t.target.action.indexOf("/cart/add")>-1){var e=window.lsData.cart||{};localStorage.setItem("oldCartStape",JSON.stringify(e))}else t.target.action.indexOf("/cart")>-1&&_()})),window.location.href.includes("/checkout")&&!localStorage.getItem("begin_checkout_plus_stape")?(localStorage.setItem("begin_checkout_plus_stape","true"),_("begin_checkout_plus_stape")):localStorage.removeItem("begin_checkout_plus_stape"),setInterval((function(){var t=localStorage.getItem("oldCartStape");if(t)try{t=JSON.parse(t),localStorage.removeItem("oldCartStape"),localStorage.setItem("cartForStape",0),h(t)}catch(t){}}),500)}if(c.indexOf("/thank_you")>-1){var it,rt,ot,at,lt=(null===(it=window)||void 0===it||null===(rt=it.Shopify)||void 0===rt?void 0:rt.checkout)||{},ct=(null===(ot=window)||void 0===ot||null===(at=ot.lsData)||void 0===at?void 0:at.customer)||{};m.ecommerce&&l({ecommerce:null});var ut,dt,st,vt,mt,pt,_t,ht,ft,gt,yt,wt,bt,kt,St,It,Lt,Ot,jt={event:"purchase_stape"};if(m.user_data&&(jt.user_data={email:lt.email||(null==lt||null===(ut=lt.billing_address)||void 0===ut?void 0:ut.email)||(null==lt||null===(dt=lt.shipping_address)||void 0===dt?void 0:dt.email),first_name:(null==ct?void 0:ct.first_name)||(null==lt||null===(st=lt.billing_address)||void 0===st?void 0:st.first_name)||(null==lt||null===(vt=lt.shipping_address)||void 0===vt?void 0:vt.first_name),last_name:(null==ct?void 0:ct.last_name)||(null==lt||null===(mt=lt.billing_address)||void 0===mt?void 0:mt.last_name)||(null==lt||null===(pt=lt.shipping_address)||void 0===pt?void 0:pt.last_name),phone:(null==ct?void 0:ct.phone)||(null==lt||null===(_t=lt.billing_address)||void 0===_t?void 0:_t.phone)||(null==lt||null===(ht=lt.shipping_address)||void 0===ht?void 0:ht.phone),country:(null==lt||null===(ft=lt.billing_address)||void 0===ft?void 0:ft.country_code)||(null==lt||null===(gt=lt.shipping_address)||void 0===gt?void 0:gt.country_code),region:"US"==lt.billing_address.country_code?null==lt||null===(yt=lt.billing_address)||void 0===yt?void 0:yt.province_code:null==lt||null===(wt=lt.billing_address)||void 0===wt?void 0:wt.province,city:(null==lt||null===(bt=lt.billing_address)||void 0===bt?void 0:bt.city)||(null==lt||null===(kt=lt.shipping_address)||void 0===kt?void 0:kt.city),street:(null==lt||null===(St=lt.billing_address)||void 0===St?void 0:St.address1)||(null==lt||null===(It=lt.shipping_address)||void 0===It?void 0:It.address1),zip:(null==lt||null===(Lt=lt.billing_address)||void 0===Lt?void 0:Lt.zip)||(null==lt||null===(Ot=lt.shipping_address)||void 0===Ot?void 0:Ot.zip),customer_id:(null==ct?void 0:ct.id)||(null==lt?void 0:lt.customer_id)}),m.ecommerce){var xt,Et,Dt,Rt,Vt,qt,At=null===(xt=window)||void 0===xt||null===(Et=xt.Shopify)||void 0===Et?void 0:Et.shop;jt.ecommerce={transaction_id:null==lt?void 0:lt.order_id,affiliation:At,value:null==lt?void 0:lt.total_price,tax:null==lt?void 0:lt.total_tax,shipping:(null==lt||null===(Dt=lt.shipping)||void 0===Dt?void 0:Dt.price)||(null==lt||null===(Rt=lt.shipping_rate)||void 0===Rt?void 0:Rt.price),discount_amount:null==lt||null===(Vt=lt.discount)||void 0===Vt?void 0:Vt.amount,discount:null==lt||null===(qt=lt.discount)||void 0===qt?void 0:qt.code,currency:null==lt?void 0:lt.currency,items:((null==lt?void 0:lt.line_items)||[]).map((function(t){return{item_id:t.product_id,item_sku:t.sku,item_name:t.title,item_brand:t.vendor,item_variant:t.variant_id+"",price:t.price,quantity:t.quantity}}))}}(m.ecommerce||m.user_data)&&l(a({},jt));try{var Pt=jt.user_data.customer_id;!localStorage.getItem("customerLoginId")&&Pt&&(localStorage.setItem("customerLoginId",Pt),localStorage.getItem("customerRegisterId")&&localStorage.getItem("customerRegisterId")==Pt?l({event:"login",user_data:jt.user_data}):(localStorage.setItem("customerRegisterId",Pt),l({event:"sign_up",user_data:jt.user_data})))}catch(t){}if(p.send_webhook&&p.url&&p.purchase_webhook){var Tt={fbc:u("fbc"),fbp:u("fbp"),FPGCLAW:u("FPGCLAW"),_gcl_aw:u("_gcl_aw"),ttclid:u("ttclid")};fetch(p.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a(a({},jt),{},{cookies:Tt,cart_id:localStorage.getItem("cartToken")}))})}}}catch(t){console.log("🚀 ~ setEventOldScript ~ error:",t)}}())}),1e3)})).catch((function(t){console.log("🚀 ~ file: index.js ~ line 184 ~ ]).then ~ err",t)})),lsNetvisioGTM=e})();