/*! For license information please see perfit.js.LICENSE.txt */ !function(){var e={213:function(e,t,r){var n=r(924).default;function i(){"use strict";e.exports=i=function(){return t},e.exports.__esModule=!0,e.exports.default=e.exports;var t={},r=Object.prototype,o=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},c=s.iterator||"@@iterator",u=s.asyncIterator||"@@asyncIterator",p=s.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function d(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,o=Object.create(i.prototype),s=new O(n||[]);return a(o,"_invoke",{value:E(e,r,s)}),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=d;var h={};function y(){}function v(){}function g(){}var b={};l(b,c,(function(){return this}));var m=Object.getPrototypeOf,w=m&&m(m(C([])));w&&w!==r&&o.call(w,c)&&(b=w);var _=g.prototype=y.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function r(i,a,s,c){var u=f(e[i],e,a);if("throw"!==u.type){var p=u.arg,l=p.value;return l&&"object"==n(l)&&o.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,s,c)}),(function(e){r("throw",e,s,c)})):t.resolve(l).then((function(e){p.value=e,s(p)}),(function(e){return r("throw",e,s,c)}))}c(u.arg)}var i;a(this,"_invoke",{value:function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}})}function E(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=f(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function k(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var i=f(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,h;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function P(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(P,this),this.reset(!0)}function C(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r=0;--n){var i=this.tryEntries[n],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var s=o.call(i,"catchLoc"),c=o.call(i,"finallyLoc");if(s&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),I(r),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;I(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:C(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}e.exports=i,e.exports.__esModule=!0,e.exports.default=e.exports},924:function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},264:function(e,t,r){var n=r(213)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}function t(t){var r=function(t,r){if("object"!==e(t)||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r);if("object"!==e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"===e(r)?r:String(r)}function n(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var o,a,s,c={API_BASE:"https://webhooks.myperfit.net/track",API_REGISTER_DOMAIN:"https://webhooks.myperfit.net/events/domains/generic/all/3a2e8954/3e2a1161",API_PUSH_SUBSCRIPTION:"https://webhooks.myperfit.net/events/push/generic/subscription/4rt3tmrgre/f5518f90",OPTIN_RULES_API:"https://optinrules.myperfit.net/optinrules/public",app:"",source:"",trackCartUpdates:!1,loadOptinRules:!0},u=function(){return function(e){for(var t=1;t-1&&(n=(r={},window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi,(function(e,t,n){return r[t]=n,n})),r)[e]),n}function l(e){for(var t=e+"=",r=document.cookie.split(";"),n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"vtex"===c.source&&(e.product_id=e.product_id||w.getPageProductId(),e.category_id=e.category_id||w.getPageCategoryId()),(e.product_id||e.category_id)&&(t&&(o=!1),o&&e.product_id===o.product_id&&e.category_id===o.category_id||b(e))}function b(e){a&&clearInterval(a),o={product_id:e.product_id||void 0,category_id:e.category_id||void 0},s=0,m(),x()&&(a=setInterval(m,5e3))}function m(){f("visit",v(v({},o),{},{customer_id:_.customerId||void 0,contact_id:_.contactId||void 0,email:_.email||void 0,visitor_id:_.visitorId,secs_lapsed:5*s,timestamp:(new Date).toISOString()})),++s>5&&(clearInterval(a),o=null)}var w={getPageProductId:function(){var e,t,r,n;if(dataLayer)return(null===(e=dataLayer.find((function(e){return"Product"===e.pageCategory})))||void 0===e?void 0:e.productId)||(null===(t=dataLayer.find((function(e){return"productDetail"==e.event})))||void 0===t||null===(r=t.ecommerce.detail)||void 0===r||null===(n=r.products[0])||void 0===n?void 0:n.id)},getPageCategoryId:function(){var e,t;if(dataLayer)return(null===(e=dataLayer.find((function(e){return"Product"===e.pageCategory})))||void 0===e?void 0:e.productCategoryId)||(null===(t=dataLayer.find((function(e){return"categoryView"==e.event})))||void 0===t?void 0:t.categoryId)},getUserEmail:function(){var e,t,r;if(dataLayer)return(null===(e=dataLayer.find((function(e){return e.visitorLoginState})))||void 0===e||null===(t=e.visitorContactInfo)||void 0===t?void 0:t[0])||(null===(r=dataLayer.find((function(e){return"userData"==e.event})))||void 0===r?void 0:r.userId)},listenUrlChanges:function(){try{var e=function(){setTimeout((function(){S(),g({},!1)}),2e3)};window.addEventListener("pushstate",e),window.addEventListener("popstate",e)}catch(e){console.error("Perfit: could not attach to listen url changes")}}},_={contactId:null,customerId:null,email:null,visitorId:null};function S(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"vtex"===c.source&&(e.email=e.email||w.getUserEmail()),e.customer_id&&(_.customerId=e.customer_id),e.email&&(_.email=e.email),E()}function x(){return _.contactId||_.customerId||_.email}function E(){localStorage.setItem("perfit-session",JSON.stringify(_))}function k(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function P(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){k(o,n,i,a,s,"next",e)}function s(e){k(o,n,i,a,s,"throw",e)}a(void 0)}))}}var I=r(264),O=r.n(I),C="PerfitDebugMode",K=!1;function U(e){if(K){for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;ie.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&(c.privateKey=s[1]),e.abrupt("return",c);case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function W(e,t){return J.apply(this,arguments)}function J(){return(J=P(O().mark((function e(t,r){var n,i,o,a,s,c,u,p;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[],e.next=3,crypto.subtle.exportKey("jwk",t);case 3:if(i=e.sent,o=M(i.x),a=M(i.y),(s=new Uint8Array(65)).set([4],0),s.set(o,1),s.set(a,33),n.push(s),!r){e.next=16;break}return e.next=14,crypto.subtle.exportKey("jwk",r);case 14:c=e.sent,n.push(M(c.d));case 16:return e.next=18,Promise.all(n);case 18:return u=e.sent,p={publicKey:u[0]},u.length>1&&(p.privateKey=u[1]),e.abrupt("return",p);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(){return crypto.getRandomValues(new Uint8Array(16))}var F={publicKey:"BDd3_hVL9fZi9Ybo2UUzA284WG5FZR30_95YeZJsiApwXKpNcF1rRPF3foIiBHXRdJI2Qhumhf6_LFTeZaNndIo",privateKey:"xKZKYRNdFFn8iQIF2MH54KTfUHwH105zBdzMR7SI3xI"},q=(new URLSearchParams(window.location.search).get("backend"),function(){function e(){j(this,e)}var t;return L(e,null,[{key:"createVapidAuthHeader",value:(t=P(O().mark((function e(t,r,n,i){var o,a,s,c,u,p,l,d,f,h,y;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=2;break}return e.abrupt("return",Promise.reject(new Error("Audience must be the origin of the server")));case 2:if(n){e.next=4;break}return e.abrupt("return",Promise.reject(new Error("Subject must be either a mailto or http link")));case 4:return"number"!=typeof i&&(i=Math.floor(Date.now()/1e3+43200)),o=M(t.publicKey),a=M(t.privateKey),r=new URL(r).origin,s={typ:"JWT",alg:"ES256"},c={aud:r,exp:i,sub:n},u=new TextEncoder("utf-8"),p=D(u.encode(JSON.stringify(s)))+"."+D(u.encode(JSON.stringify(c))),l={kty:"EC",crv:"P-256",x:D(o.subarray(1,33)),y:D(o.subarray(33,65)),d:D(a)},e.next=15,crypto.subtle.importKey("jwk",l,{name:"ECDSA",namedCurve:"P-256"},!0,["sign"]);case 15:return d=e.sent,e.next=18,crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},d,u.encode(p));case 18:return f=e.sent,h=p+"."+D(new Uint8Array(f)),y=D(o),e.abrupt("return",{Authorization:"WebPush ".concat(h),"Crypto-Key":"p256ecdsa=".concat(y)});case 22:case"end":return e.stop()}}),e)}))),function(e,r,n,i){return t.apply(this,arguments)})}]),e}()),z=function(){function e(t){j(this,e),this._ikm=t}var t;return L(e,[{key:"sign",value:(t=P(O().mark((function e(t){var r;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,crypto.subtle.importKey("raw",this._ikm,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);case 2:return r=e.sent,e.abrupt("return",crypto.subtle.sign("HMAC",r,t));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}(),Y=function(){function e(t,r){j(this,e),this._ikm=t,this._salt=r,this._hmac=new z(r)}var t;return L(e,[{key:"generate",value:(t=P(O().mark((function e(t,r){var n,i,o,a;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new Uint8Array(t.byteLength+1)).set(t,0),n.set(new Uint8Array(1).fill(1),t.byteLength),e.next=5,this._hmac.sign(this._ikm);case 5:return i=e.sent,o=new z(i),e.next=9,o.sign(n);case 9:return a=e.sent,e.abrupt("return",a.slice(0,r));case 11:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),e}(),Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};j(this,e),this._b64ServerKeys=t.serverKeys,this._b64Salt=t.salt,this._b4VapidKeys=t.vapidKeys}var t,r,n,i,o,a,s,c;return L(e,[{key:"getServerKeys",value:function(){return this._b64ServerKeys?H(M(this._b64ServerKeys.publicKey),M(this._b64ServerKeys.privateKey)):e.generateServerKeys()}},{key:"getSalt",value:function(){return this._b64Salt?M(this._b64Salt):V()}},{key:"getVapidKeys",value:function(){return this._b4VapidKeys?this._b4VapidKeys:F}},{key:"getRequestDetails",value:(c=P(O().mark((function e(t,r){var n,i,o,a,s;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,q.createVapidAuthHeader(this.getVapidKeys(),t.endpoint,"mailto:simple-push-demo@gauntface.co.uk");case 2:return n=e.sent,e.next=5,this.encryptPayload(t,r);case 5:return i=e.sent,o=null,(a={}).TTL=60,i?(o=i.cipherText,a.Encryption="salt=".concat(i.salt),a["Crypto-Key"]="dh=".concat(i.publicServerKey),a["Content-Encoding"]="aesgcm"):a["Content-Length"]=0,n&&Object.keys(n).forEach((function(e){a[e]?a[e]="".concat(a[e],"; ").concat(n[e]):a[e]=n[e]})),s={headers:a,endpoint:t.endpoint},o&&(s.body=o),e.abrupt("return",s);case 14:case"end":return e.stop()}}),e,this)}))),function(e,t){return c.apply(this,arguments)})},{key:"encryptPayload",value:(s=P(O().mark((function e(t,r){var n,i,o,a,s,c,u,p,l,d,f;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r&&0!==r.trim().length){e.next=2;break}return e.abrupt("return",Promise.resolve(null));case 2:return n=this.getSalt(),e.next=5,this.getServerKeys();case 5:return i=e.sent,e.next=8,W(i.publicKey);case 8:return o=e.sent,e.next=11,this._generateEncryptionKeys(t,n,i);case 11:return a=e.sent,e.next=14,crypto.subtle.importKey("raw",a.contentEncryptionKey,"AES-GCM",!0,["decrypt","encrypt"]);case 14:return s=e.sent,a.contentEncryptionCryptoKey=s,c=new Uint8Array(2),u=new TextEncoder("utf-8"),p=u.encode(r),(l=new Uint8Array(c.byteLength+p.byteLength)).set(c,0),l.set(p,c.byteLength),d={name:"AES-GCM",tagLength:128,iv:a.nonce},e.next=26,crypto.subtle.encrypt(d,a.contentEncryptionCryptoKey,l);case 26:return f=e.sent,e.abrupt("return",{cipherText:f,salt:D(n),publicServerKey:D(o.publicKey)});case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_generateEncryptionKeys",value:(a=P(O().mark((function e(t,r,n){var i,o,a,s,c,u,p;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([this._generatePRK(t,n),this._generateCEKInfo(t,n),this._generateNonceInfo(t,n)]);case 2:return i=e.sent,o=i[0],a=i[1],s=i[2],c=new Y(o,r),u=new Y(o,r),e.next=10,Promise.all([c.generate(a,16),u.generate(s,12)]);case 10:return p=e.sent,e.abrupt("return",{contentEncryptionKey:p[0],nonce:p[1]});case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return a.apply(this,arguments)})},{key:"_generateContext",value:(o=P(O().mark((function e(t,r){var n,i,o,a,s,c,u,p,l;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H(t.getKey("p256dh"));case 2:return n=e.sent,i={clientPublicKey:n.publicKey,serverPublicKey:r.publicKey},e.next=6,Promise.all([W(i.clientPublicKey),W(i.serverPublicKey)]);case 6:return o=e.sent,a={clientPublicKey:o[0].publicKey,serverPublicKey:o[1].publicKey},s=new TextEncoder("utf-8"),c=s.encode("P-256"),u=new Uint8Array(1).fill(0),(p=new Uint8Array(2))[0]=0,p[1]=a.clientPublicKey.byteLength,(l=new Uint8Array(2))[0]=0,l[1]=a.serverPublicKey.byteLength,e.abrupt("return",B([c,u,p,a.clientPublicKey,l,a.serverPublicKey]));case 18:case"end":return e.stop()}}),e)}))),function(e,t){return o.apply(this,arguments)})},{key:"_generateCEKInfo",value:(i=P(O().mark((function e(t,r){var n,i,o,a;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new TextEncoder("utf-8"),i=n.encode("Content-Encoding: aesgcm"),o=new Uint8Array(1).fill(0),e.next=5,this._generateContext(t,r);case 5:return a=e.sent,e.abrupt("return",B([i,o,a]));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"_generateNonceInfo",value:(n=P(O().mark((function e(t,r){var n,i,o,a;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new TextEncoder("utf-8"),i=n.encode("Content-Encoding: nonce"),o=new Uint8Array(1).fill(0),e.next=5,this._generateContext(t,r);case 5:return a=e.sent,e.abrupt("return",B([i,o,a]));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_generatePRK",value:(r=P(O().mark((function e(t,r){var n,i,o,a;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getSharedSecret(t,r);case 2:return n=e.sent,i=new TextEncoder("utf-8"),o=i.encode("Content-Encoding: auth\0"),a=new Y(n,t.getKey("auth")),e.abrupt("return",a.generate(o,32));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_getSharedSecret",value:(t=P(O().mark((function e(t,r){var n,i;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H(t.getKey("p256dh"));case 2:if((n=e.sent).publicKey instanceof CryptoKey){e.next=5;break}throw new Error("The publicKey must be a CryptoKey.");case 5:return i={name:"ECDH",namedCurve:"P-256",public:n.publicKey},e.abrupt("return",crypto.subtle.deriveBits(i,r.privateKey,256));case 7:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})}],[{key:"generateServerKeys",value:function(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"])}}]),e}(),X=function(){function e(){j(this,e)}var t;return L(e,null,[{key:"createVapidAuthHeader",value:(t=P(O().mark((function e(t,r,n,i){var o,a,s,c,u,p,l,d,f,h,y;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=2;break}return e.abrupt("return",Promise.reject(new Error("Audience must be the origin of the server")));case 2:if(n){e.next=4;break}return e.abrupt("return",Promise.reject(new Error("Subject must be either a mailto or http link")));case 4:return"number"!=typeof i&&(i=Math.floor(Date.now()/1e3+43200)),o=M(t.publicKey),a=M(t.privateKey),r=new URL(r).origin,s={typ:"JWT",alg:"ES256"},c={aud:r,exp:i,sub:n},u=new TextEncoder("utf-8"),p=D(u.encode(JSON.stringify(s)))+"."+D(u.encode(JSON.stringify(c))),l={kty:"EC",crv:"P-256",x:D(o.subarray(1,33)),y:D(o.subarray(33,65)),d:D(a)},e.next=15,crypto.subtle.importKey("jwk",l,{name:"ECDSA",namedCurve:"P-256"},!0,["sign"]);case 15:return d=e.sent,e.next=18,crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},d,u.encode(p));case 18:return f=e.sent,h=p+"."+D(new Uint8Array(f)),y=D(o),e.abrupt("return",{Authorization:"vapid t=".concat(h,", k=").concat(y)});case 22:case"end":return e.stop()}}),e)}))),function(e,r,n,i){return t.apply(this,arguments)})}]),e}(),$=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};j(this,e),this._b64ServerKeys=t.serverKeys,this._b64Salt=t.salt,this._b4VapidKeys=t.vapidKeys}var t,r,n,i,o,a,s;return L(e,[{key:"getServerKeys",value:function(){return this._b64ServerKeys?H(M(this._b64ServerKeys.publicKey),M(this._b64ServerKeys.privateKey)):e.generateServerKeys()}},{key:"getSalt",value:function(){return this._b64Salt?M(this._b64Salt):V()}},{key:"getVapidKeys",value:function(){return this._b4VapidKeys?this._b4VapidKeys:F}},{key:"getRequestDetails",value:(s=P(O().mark((function e(t,r){var n,i,o,a,s,c,u;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=X,i=t.endpoint,e.next=4,n.createVapidAuthHeader(this.getVapidKeys(),t.endpoint,"mailto:simple-push-demo@gauntface.co.uk");case 4:return o=e.sent,e.next=7,this.encryptPayload(t,r);case 7:return a=e.sent,s=null,(c={}).TTL=60,a?(s=a.cipherText,c["Content-Encoding"]="aes128gcm"):c["Content-Length"]=0,o&&Object.keys(o).forEach((function(e){c[e]=o[e]})),u={headers:c,endpoint:i},s&&(u.body=s),e.abrupt("return",u);case 16:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"encryptPayload",value:(a=P(O().mark((function e(t,r){var n,i,o,a,s,c,u,p,l,d,f,h;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r&&0!==r.trim().length){e.next=2;break}return e.abrupt("return",Promise.resolve(null));case 2:return n=this.getSalt(),e.next=5,this.getServerKeys();case 5:return i=e.sent,e.next=8,W(i.publicKey);case 8:return o=e.sent,e.next=11,this._generateEncryptionKeys(t,n,i);case 11:return a=e.sent,e.next=14,crypto.subtle.importKey("raw",a.contentEncryptionKey,"AES-GCM",!0,["decrypt","encrypt"]);case 14:return s=e.sent,a.contentEncryptionCryptoKey=s,c=new TextEncoder("utf-8"),u=c.encode(r),(p=new Uint8Array(1)).fill(0),p[0]=2,l=B([u,p]),d={name:"AES-GCM",tagLength:128,iv:a.nonce},e.next=26,crypto.subtle.encrypt(d,a.contentEncryptionCryptoKey,l);case 26:return f=e.sent,e.next=29,this._addEncryptionContentCodingHeader(f,i,n);case 29:return h=e.sent,e.abrupt("return",{cipherText:h,salt:D(n),publicServerKey:D(o.publicKey)});case 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"_addEncryptionContentCodingHeader",value:(o=P(O().mark((function e(t,r,n){var i,o,a,s,c;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,W(r.publicKey);case 2:return i=e.sent,o=new Uint8Array([0,0,16,0]),(a=new Uint8Array(1))[0]=i.publicKey.byteLength,s=[n,o,a,i.publicKey,new Uint8Array(t)],c=B(s),e.abrupt("return",c.buffer);case 9:case"end":return e.stop()}}),e)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"_generateEncryptionKeys",value:(i=P(O().mark((function e(t,r,n){var i,o,a,s,c,u,p;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([this._generatePRK(t,n),this._generateCEKInfo(t,n),this._generateNonceInfo(t,n)]);case 2:return i=e.sent,o=i[0],a=i[1],s=i[2],c=new Y(o,r),u=new Y(o,r),e.next=10,Promise.all([c.generate(a,16),u.generate(s,12)]);case 10:return p=e.sent,e.abrupt("return",{contentEncryptionKey:p[0],nonce:p[1]});case 12:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return i.apply(this,arguments)})},{key:"_generateCEKInfo",value:function(){return B([new TextEncoder("utf-8").encode("Content-Encoding: aes128gcm"),new Uint8Array(1).fill(0)])}},{key:"_generateNonceInfo",value:function(){return B([new TextEncoder("utf-8").encode("Content-Encoding: nonce"),new Uint8Array(1).fill(0)])}},{key:"_generatePRK",value:(n=P(O().mark((function e(t,r){var n,i,o;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getSharedSecret(t,r);case 2:return n=e.sent,e.next=5,this._getKeyInfo(t,r);case 5:return i=e.sent,o=new Y(n,t.getKey("auth")),e.abrupt("return",o.generate(i,32));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_getSharedSecret",value:(r=P(O().mark((function e(t,r){var n,i;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H(t.getKey("p256dh"));case 2:if((n=e.sent).publicKey instanceof CryptoKey){e.next=5;break}throw new Error("The publicKey must be a CryptoKey.");case 5:return i={name:"ECDH",namedCurve:"P-256",public:n.publicKey},e.abrupt("return",crypto.subtle.deriveBits(i,r.privateKey,256));case 7:case"end":return e.stop()}}),e)}))),function(e,t){return r.apply(this,arguments)})},{key:"_getKeyInfo",value:(t=P(O().mark((function e(t,r){var n,i;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new TextEncoder("utf-8"),e.next=3,W(r.publicKey);case 3:return i=e.sent,e.abrupt("return",B([n.encode("WebPush: info"),new Uint8Array(1).fill(0),new Uint8Array(t.getKey("p256dh")),i.publicKey]));case 5:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})}],[{key:"generateServerKeys",value:function(){return crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-256"},!0,["deriveBits"])}}]),e}();function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(t);try{for(r.s();!(e=r.n()).done;){var n=e.value;switch(n){case"aes128gcm":return new $;case"aesgcm":return new Z;default:console.warn("Unknown content encoding: ".concat(n))}}}catch(e){r.e(e)}finally{r.f()}throw console.error("Failed to find a known encoding: ",t),new Error("Unable to find a known encoding")}}]),e}(),te=function(){function e(t,r,n){j(this,e),this._stateChangeCb=t,this._subscriptionUpdate=r,this._publicApplicationKey=M(n),this._state={UNSUPPORTED:{id:"UNSUPPORTED",interactive:!1,pushEnabled:!1},INITIALISING:{id:"INITIALISING",interactive:!1,pushEnabled:!1},PERMISSION_DENIED:{id:"PERMISSION_DENIED",interactive:!1,pushEnabled:!1},PERMISSION_GRANTED:{id:"PERMISSION_GRANTED",interactive:!0},PERMISSION_PROMPT:{id:"PERMISSION_PROMPT",interactive:!0,pushEnabled:!1},ERROR:{id:"ERROR",interactive:!1,pushEnabled:!1},STARTING_SUBSCRIBE:{id:"STARTING_SUBSCRIBE",interactive:!1,pushEnabled:!0},SUBSCRIBED:{id:"SUBSCRIBED",interactive:!0,pushEnabled:!0},STARTING_UNSUBSCRIBE:{id:"STARTING_UNSUBSCRIBE",interactive:!1,pushEnabled:!1},UNSUBSCRIBED:{id:"UNSUBSCRIBED",interactive:!0,pushEnabled:!1}},"serviceWorker"in navigator?"PushManager"in window?"showNotification"in ServiceWorkerRegistration.prototype?this.init():this._stateChangeCb(this._state.UNSUPPORTED,"Showing Notifications from a service worker is not available on this browser"):this._stateChangeCb(this._state.UNSUPPORTED,"PushManager not available on this browser"):this._stateChangeCb(this._state.UNSUPPORTED,"Service worker not available on this browser")}var t,r,n,i;return L(e,[{key:"init",value:(i=P(O().mark((function e(){return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.serviceWorker.ready;case 2:this._stateChangeCb(this._state.INITIALISING),this.setUpPushPermission();case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_permissionStateChange",value:function(e){switch(e){case"denied":this._stateChangeCb(this._state.PERMISSION_DENIED);break;case"granted":this._stateChangeCb(this._state.PERMISSION_GRANTED);break;case"default":this._stateChangeCb(this._state.PERMISSION_PROMPT);break;default:console.error("Unexpected permission state: ",e)}}},{key:"setUpPushPermission",value:(n=P(O().mark((function e(){var t,r;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this._permissionStateChange(Notification.permission),e.next=4,navigator.serviceWorker.ready;case 4:return t=e.sent,e.next=7,t.pushManager.getSubscription();case 7:if(r=e.sent,this._subscriptionUpdate(r),r){e.next=11;break}return e.abrupt("return");case 11:this._stateChangeCb(this._state.SUBSCRIBED),e.next=18;break;case 14:e.prev=14,e.t0=e.catch(0),console.error("setUpPushPermission() ",e.t0),this._stateChangeCb(this._state.ERROR,e.t0);case 18:case"end":return e.stop()}}),e,this,[[0,14]])}))),function(){return n.apply(this,arguments)})},{key:"subscribeDevice",value:(r=P(O().mark((function e(){var t,r;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._stateChangeCb(this._state.STARTING_SUBSCRIBE),e.prev=1,e.t0=Notification.permission,e.next="denied"===e.t0?5:"granted"===e.t0?6:7;break;case 5:throw new Error("Push messages are blocked.");case 6:return e.abrupt("break",9);case 7:return e.next=9,new Promise((function(e,t){Notification.requestPermission((function(r){"granted"!==r&&t(new Error("Bad permission result")),e()}))}));case 9:return e.prev=9,e.next=12,navigator.serviceWorker.ready;case 12:return t=e.sent,e.next=15,t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:this._publicApplicationKey});case 15:r=e.sent,this._stateChangeCb(this._state.SUBSCRIBED),this._subscriptionUpdate(r),e.next=24;break;case 20:e.prev=20,e.t1=e.catch(9),console.error("subscribeDevice() ",e.t1),this._stateChangeCb(this._state.ERROR,e.t1);case 24:e.next=30;break;case 26:e.prev=26,e.t2=e.catch(1),console.error("subscribeDevice() ",e.t2),this._permissionStateChange(Notification.permission);case 30:case"end":return e.stop()}}),e,this,[[1,26],[9,20]])}))),function(){return r.apply(this,arguments)})},{key:"unsubscribeDevice",value:(t=P(O().mark((function e(){var t,r;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._stateChangeCb(this._state.STARTING_UNSUBSCRIBE),e.prev=1,e.next=4,navigator.serviceWorker.ready;case 4:return t=e.sent,e.next=7,t.pushManager.getSubscription();case 7:if(r=e.sent){e.next=12;break}return this._stateChangeCb(this._state.UNSUBSCRIBED),this._subscriptionUpdate(null),e.abrupt("return");case 12:return e.next=14,r.unsubscribe();case 14:e.sent||console.warn("We were unable to unregister from push"),this._stateChangeCb(this._state.UNSUBSCRIBED),this._subscriptionUpdate(null),e.next=23;break;case 20:e.prev=20,e.t0=e.catch(1),console.error("Error thrown while revoking push notifications. Most likely because push was never registered",e.t0);case 23:case"end":return e.stop()}}),e,this,[[1,20]])}))),function(){return t.apply(this,arguments)})}]),e}(),re=function(){function e(){j(this,e),this._encryptionHelper=ee.generateHelper(),this._stateChangeListener=this._stateChangeListener.bind(this),this._subscriptionUpdate=this._subscriptionUpdate.bind(this),this._pushClient=new te(this._stateChangeListener,this._subscriptionUpdate,F.publicKey)}var t;return L(e,[{key:"subscribe",value:(t=P(O().mark((function e(){return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pushClient.subscribeDevice();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"registerServiceWorker",value:function(){var e=this;"serviceWorker"in navigator?navigator.serviceWorker.register("/sw.js").then((function(e){console.debug("serviceWorker registered")})).catch((function(t){console.error(t),e.showErrorMessage("Unable to Register SW","Sorry this demo requires a service worker to work and it failed to install - sorry :(")})):this.showErrorMessage("Service Worker Not Supported","Sorry this demo requires service worker support in your browser. Please try this demo in Chrome or Firefox Nightly.")}},{key:"_stateChangeListener",value:function(e,t){switch(console.log("_stateChangeListener",e),e.id){case"UNSUPPORTED":this.showErrorMessage("Push Not Supported",t);break;case"ERROR":this.showErrorMessage("Ooops a Problem Occurred",t)}}},{key:"_subscriptionUpdate",value:function(e){if(this._currentSubscription=e,e){var t=JSON.parse(JSON.stringify(e));console.log("subscriptionUpdate",t),function(e){fetch(c.API_PUSH_SUBSCRIPTION,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:c.app,subscription:e,contact:{email:_.email||void 0,contact_id:_.contactId||void 0},topic:"transactional",device:"desktop"})})}({endpoint:t.endpoint,p256dh:t.keys.p256dh,auth:t.keys.auth})}}},{key:"toHex",value:function(e){return(t=new Uint8Array(e),function(e){if(Array.isArray(e))return T(e)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||R(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){return e.toString(16).padStart(2,"0")})).join(" ");var t}},{key:"showErrorMessage",value:function(e,t){console.error(e,t)}}]),e}();function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ie(e){for(var t=1;t0&&n.trigger_count>=e.trigger_options.max_displays||n.last_triggered&&e.trigger_options.interval_days>0&&(new Date).getTime()=e.trigger_mode_options.scroll&&(Ee(e),ge(e.id,"triggered"),document.removeEventListener("scroll",t,!1))}),!1)}(e)}}function ye(e){e.trigger_mode_options.delay>0&&we(e.optin_id).then((function(){xe(e)})),setTimeout((function(){se?ye(e):(Ee(e),ge(e.id,"triggered"))}),1e3*e.trigger_mode_options.delay)}function ve(){try{ce=JSON.parse(localStorage.getItem(oe)||"{}")}catch(e){ce={}}}function ge(e,t){ve(),ce[e]||(ce[e]=ie({},ue)),"triggered"===t?(ce[e].trigger_count++,ce[e].last_triggered=(new Date).getTime()):"submitted"===t&&(ce[e].success=!0),localStorage.setItem(oe,JSON.stringify(ce))}function be(){return me.apply(this,arguments)}function me(){return(me=P(O().mark((function e(){var t,r;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.next=2;break;case 2:return e.prev=2,t="".concat(c.OPTIN_RULES_API,"?account=").concat(c.app),A()&&(t+="&ts=".concat((new Date).getTime())),e.next=7,fetch(t,{method:"GET",headers:{"Content-Type":"application/json","X-Account":c.app}});case 7:if((r=e.sent).ok){e.next=10;break}throw new Error("fetch error: "+t);case 10:return e.next=12,r.json();case 12:return e.abrupt("return",e.sent.data);case 15:return e.prev=15,e.t0=e.catch(2),console.error("Perfit: could not load optin configuration",e.t0),e.abrupt("return",[]);case 19:case"end":return e.stop()}}),e,null,[[2,15]])})))).apply(this,arguments)}function we(e){return _e.apply(this,arguments)}function _e(){return(_e=P(O().mark((function e(t){var r,n,i,o;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!window.PerfitOptIn||!window.PerfitOptIn[t]){e.next=2;break}return e.abrupt("return");case 2:if(!t.startsWith("push")){e.next=5;break}return ke(t),e.abrupt("return");case 5:return r=window.document,(n=r.createElement("div")).id="optin-".concat(t),n.dataset.type="popup",n.dataset.mode="manual",r.body.appendChild(n),i=new Promise((function(e){var n=r.createElement("link");n.rel="stylesheet",n.type="text/css",n.href="https://optin.myperfit.com/res/css/".concat(c.app,"/").concat(t,".css"),n.onload=e,r.body.appendChild(n)})),o=new Promise((function(e){var n=r.createElement("script");n.type="text/javascript",n.charset="utf-8",n.src="https://optin.myperfit.com/res/js/".concat(c.app,"/").concat(t,".js"),n.onload=e,r.body.appendChild(n)})),e.abrupt("return",Promise.all([i,o]));case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Se(e){se||window.PerfitOptIn[e].open()}function xe(e){window.PerfitOptIn[e.optin_id].setCallbacks({submitted:function(){U("submitted "+e.optin_id),ge(e.id,"submitted")},closed:function(){U("closed "+e.optin_id),se=!1},opened:function(){U("opened "+e.optin_id),se=!0}})}function Ee(e){window.PerfitOptIn&&window.PerfitOptIn[e.optin_id]?Se(e.optin_id):we(e.optin_id).then((function(){xe(e),Se(e.optin_id)}))}function ke(e){window.PerfitOptIn||(window.PerfitOptIn=[]),window.PerfitOptIn[e]={open:function(){if(x()){var e=function(){if(console.debug("Setting up push."),navigator.serviceWorker){if("PushManager"in window){var e=new re;return e.registerServiceWorker(),e}console.warn("Push is not supported in this browser.")}else console.warn("Service workers are not supported in this browser.")}();e&&setTimeout((function(){e.subscribe()}),1e3)}},close:function(){},setCallbacks:function(){},form:void 0,config:void 0}}var Pe="perfit-cart";function Ie(){d(Pe,"",-1)}var Oe=function(){var e=P(O().mark((function e(t){return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.account,e.abrupt("return",[{onsite_id:"onsite_cldvoehor00060d24ziwulk3y",account:"test20220128",name:"Multiple steps",enabled:!0,priority:1,trigger_options:{url:".*",interval_days:1,max_displays:3,stop_on_success:!1},trigger_mode:"delayed",trigger_mode_options:{delay:1},created:"2024-03-13T00:00:00Z"},{onsite_id:"onsite_cldvoehor00060d24ziwul123",account:"test20220128",name:"Modal Fijo",enabled:!0,priority:1,trigger_options:{element_id:"montar-aqui",url:".*",interval_days:1,max_displays:3,stop_on_success:!1},trigger_mode:"delayed",trigger_mode_options:{delay:1},created:"2024-03-13T00:00:00Z"}]);case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ce={},Ke=function(e){var t=document.createElement("iframe");t.src="https://onsite.myperfit.net?perfitOnsiteId=".concat(e.onsite_id),t.id=e.onsite_id,t.style.height="0px",t.style.width="0px",t.style.display="none",Ce[e.onsite_id]={reference:t,rule:e},document.body.appendChild(t)},Ue={identify:S,visit:g,cart:function(){var e,t,r,n,i,o,a,s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],u=arguments.length>1?arguments[1]:void 0;if(s&&s.length){var p=l(Pe),h={cart:[]};try{p&&(h=JSON.parse(p))}catch(e){console.error("Perfit: invalid cart cookie"),Ie()}u&&(null===(e=h)||void 0===e?void 0:e.cartId)!=u&&(Ie(),h={cart:[]}),d(Pe,JSON.stringify({cart:s,cartId:u}),7),(null===(t=h)||void 0===t||null===(r=t.cart)||void 0===r||!r.length)&&s.length>0?x()&&f("cart-init",{cart:s,cart_id:u,customer_id:_.customerId||void 0,contact_id:_.contactId||void 0,email:_.email||void 0,visitor_id:_.visitorId,timestamp:(new Date).toISOString()}):null!==(n=h)&&void 0!==n&&null!==(i=n.cart)&&void 0!==i&&i.length&&(null===(o=h)||void 0===o||null===(a=o.cart)||void 0===a?void 0:a.length)!=s.length&&c.trackCartUpdates&&x()&&f("cart-update",{cart:s,cart_id:u,customer_id:_.customerId||void 0,contact_id:_.contactId||void 0,email:_.email||void 0,visitor_id:_.visitorId,timestamp:(new Date).toISOString()})}else Ie()},showPopup:function(e){var t,r=e.id;if(r){var n=(null===(t=e.options)||void 0===t?void 0:t.timeout)||0;we(r).then((function(){var t,i;null!==(t=e.options)&&void 0!==t&&t.callbacks&&window.PerfitOptIn[r].setCallbacks(null===(i=e.options)||void 0===i?void 0:i.callbacks),setTimeout((function(){Se(r)}),n)}))}},initRules:function(e){e&&pe(e)},setDebug:function(e){K=e,localStorage.setItem(C,JSON.stringify(K)),U("Debug mode enabled")},registerOrigin:h,loadOnsites:function(){var e=P(O().mark((function e(){var t;return O().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=u(),window.addEventListener("message",(function(e){var t=e.data;if(t.eventId){var r=Ce[t.onsiteId];if(r){if("perfit_onsite_set_styles"===t.eventId)return(n=r.reference).style.height="initial",n.style.width="initial",n.style.display="initial",n.style.position="initial",n.style.inset="initial",n.style.zIndex="initial",void Object.entries(t.styles).forEach((function(e){var t,n,i=(n=2,function(e){if(Array.isArray(e))return e}(t=e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(t,n)||R(t,n)||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.")}()),o=i[0],a=i[1];r.reference.style[o]=a}));var n;if("perfit_onsite_mounted"!==t.eventId)"perfit_onsite_close"!==t.eventId||r.reference.remove();else{var i,o=null===(i=r.rule.trigger_options)||void 0===i?void 0:i.element_id;if(o){var a,s,c=document.getElementById(o);if(!c)return;if(null===(a=r.reference.parentNode)||void 0===a?void 0:a.isEqualNode(c))return void(null===(s=r.reference.contentWindow)||void 0===s||s.postMessage({eventId:"perfit_onsite_set_rule",data:r.rule},"*"));null==c||c.appendChild(r.reference)}else{var u;null===(u=r.reference.contentWindow)||void 0===u||u.postMessage({eventId:"perfit_onsite_set_rule",data:r.rule},"*")}}}}})),e.next=4,Oe({account:t.app});case 4:e.sent.forEach((function(e){Ke(e)}));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()};function Ae(){var e,t;if(null!==(e=window.Perfit)&&void 0!==e&&null!==(t=e.q)&&void 0!==t&&t.length){var r=window.Perfit.q.shift();if(r){var n=r[0],i=r[1];Ue[n]?Ue[n](i):console.warn("Perfit: invalid command '".concat(n,"'"))}}}!function(){if(function(){try{K=JSON.parse(localStorage.getItem(C)||"false")}catch(e){K=!1}}(),U("Debug mode enabled"),window.perfitSettings){var e=window.perfitSettings;"string"==typeof e.app&&""!==e.app?-1!==["pow","vtex","tiendanube","mshops","tray","wbuy","custom"].indexOf(e.source)?(function(e){var t=e.app,r=e.source,n=e.trackCartUpdates,i=e.loadOptinRules;t&&(c.app=t),r&&(c.source=r),void 0!==n&&(c.trackCartUpdates=n),void 0!==i&&(c.loadOptinRules=i)}(e),function(){!function(){try{var e=JSON.parse(localStorage.getItem("perfit-session"));_.contactId=e.contactId,_.customerId=e.customerId,_.email=e.email,_.visitorId=e.visitorId}catch(e){}}(),_.visitorId||(_.visitorId="".concat(c.app,"-").concat(c.source,"-").concat(Math.random().toString(36).replace(/[^a-z]+/g,""),"-").concat((new Date).getTime().toString(36)),_.visitorId.endsWith("0")&&h());var e=p("pc",!1)||p("pcid",!1);e&&(_.contactId=e),E()}(),u().loadOptinRules&&pe(),function(){if(!window.Perfit||!window.Perfit.q){var e=function e(){e.c(arguments)};e.q=[],e.c=function(t){e.q.push(t)},window.Perfit=e}}(),setInterval(Ae,300),"vtex"===e.source&&w.listenUrlChanges()):console.error("Perfit: invalid perfitSettings.source"):console.error("Perfit: missing perfitSettings.app")}else console.error("Perfit: missing perfitSettings")}()}()}();