var GA4_RS=function(e){"use strict";function t(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(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 n(e){for(var n=1;n{var t;const r=null===(t=window.RudderStackGlobals)||void 0===t?void 0:t.errorReporting;r&&e instanceof Error&&r.notify(e)},u=e=>{const t=[];return function(e,r){if("object"!=typeof r||null===r)return r;for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(r)?(s.debug(`Circular Reference detected for key: ${e}`),"[Circular Reference]"):(t.push(r),r)}},l=(e,t)=>{try{return JSON.stringify(e,u())}catch(e){return s.warn("Failed to convert the value to a JSON string."),null}},d=e=>e?0===Object.keys(e).length:(s.warn("input is undefined or null"),!0),p=(e,t,r)=>{let n;try{n=((e,t,r)=>{let n;try{n="string"==typeof e?e:e instanceof Error||e.message?e.message:l(e)}catch(e){n=""}if("object"==typeof(o=e)&&null!==o&&"target"in o){if(e.target&&"script"!==e.target.localName)return"";if(e.target.dataset&&(e.target.dataset.loader!==i||"true"!==e.target.dataset.isnonnativesdk))return"";if(n=`error in script loading:: src:: ${e.target.src} id:: ${e.target.id}`,"ad-block"===e.target.id)return r.page("RudderJS-Initiated","ad-block page request",{path:"/ad-blocked",title:n},r.sendAdblockPageOptions),""}var o;return`[handleError]:: "${n}"`})(e,0,r)}catch(t){s.error("[handleError] Exception:: ",t),s.error("[handleError] Original error:: ",l(e)),c(t)}n&&(s.error(n),(e=>!e.message||!a.some((t=>e.message.includes(t))))(e)&&c(e))},f="Google Analytics 4 (GA4)";function y(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var m,g,h,v,_,b,w={exports:{}},O={exports:{}};function A(){if(g)return m;g=1;var e=1e3,t=60*e,r=60*t,n=24*r,o=365.25*n;function s(e,t,r){if(!(e0)return function(s){if((s=String(s)).length>100)return;var i=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(s);if(!i)return;var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(i);if("number"===c&&!1===isNaN(i))return a.long?function(o){return s(o,n,"day")||s(o,r,"hour")||s(o,t,"minute")||s(o,e,"second")||o+" ms"}(i):function(o){if(o>=n)return Math.round(o/n)+"d";if(o>=r)return Math.round(o/r)+"h";if(o>=t)return Math.round(o/t)+"m";if(o>=e)return Math.round(o/e)+"s";return o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))},m}function E(){return h||(h=1,function(e,t){var r;function n(e){function n(){if(n.enabled){var e=n,o=+new Date,s=o-(r||o);e.diff=s,e.prev=r,e.curr=o,r=o;for(var i=new Array(arguments.length),a=0;a=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}(w,w.exports)),w.exports)("cookie");function t(){var e;try{e=document.cookie}catch(e){return"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e.stack||e),{}}return function(e){var t,r={},o=e.split(/ *; */);if(""==o[0])return r;for(var s=0;s0)return function(s){if((s=String(s)).length>100)return;var i=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(s);if(!i)return;var a=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return a*o;case"days":case"day":case"d":return a*n;case"hours":case"hour":case"hrs":case"hr":case"h":return a*r;case"minutes":case"minute":case"mins":case"min":case"m":return a*t;case"seconds":case"second":case"secs":case"sec":case"s":return a*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(i);if("number"===c&&!1===isNaN(i))return a.long?function(o){return s(o,n,"day")||s(o,r,"hour")||s(o,t,"minute")||s(o,e,"second")||o+" ms"}(i):function(o){if(o>=n)return Math.round(o/n)+"d";if(o>=r)return Math.round(o/r)+"h";if(o>=t)return Math.round(o/t)+"m";if(o>=e)return Math.round(o/e)+"s";return o+"ms"}(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))},S}function T(){return D||(D=1,function(e,t){var r;function n(e){function n(){if(n.enabled){var e=n,o=+new Date,s=o-(r||o);e.diff=s,e.prev=r,e.curr=o,r=o;for(var i=new Array(arguments.length),a=0;a=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(r())}(P,P.exports)),P.exports)("cookie");function t(){var e;try{e=document.cookie}catch(e){return"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e.stack||e),{}}return function(e){var t,r={},o=e.split(/ *; */);if(""==o[0])return r;for(var s=0;s=0;--o)n.push(t.slice(o).join("."));return n},n.cookie=r,t=e.exports=n}(U,U.exports)),U.exports);const M=y(q);function V(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function B(e){return function t(r){return 0===arguments.length||V(r)?t:e.apply(this,arguments)}}function G(e){return function t(r,n){switch(arguments.length){case 0:return t;case 1:return V(r)?t:B((function(t){return e(r,t)}));default:return V(r)&&V(n)?t:V(r)?B((function(t){return e(t,n)})):V(n)?B((function(t){return e(r,t)})):e(r,n)}}}function F(e){return function t(r,n,o){switch(arguments.length){case 0:return t;case 1:return V(r)?t:G((function(t,n){return e(r,t,n)}));case 2:return V(r)&&V(n)?t:V(r)?G((function(t,r){return e(t,n,r)})):V(n)?G((function(t,n){return e(r,t,n)})):B((function(t){return e(r,n,t)}));default:return V(r)&&V(n)&&V(o)?t:V(r)&&V(n)?G((function(t,r){return e(t,r,o)})):V(r)&&V(o)?G((function(t,r){return e(t,n,r)})):V(n)&&V(o)?G((function(t,n){return e(r,t,n)})):V(r)?B((function(t){return e(t,n,o)})):V(n)?B((function(t){return e(r,t,o)})):V(o)?B((function(t){return e(r,n,t)})):e(r,n,o)}}}const Y=Array.isArray||function(e){return null!=e&&e.length>=0&&"[object Array]"===Object.prototype.toString.call(e)};function J(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}function z(e,t,r){for(var n=0,o=r.length;n=0;)H(t=ee[r],e)&&!re(n,t)&&(n[n.length]=t),r-=1;return n})):B((function(e){return Object(e)!==e?[]:Object.keys(e)})),oe=B((function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)}));function se(e,t,r,n){var o=J(e);function s(e,t){return ie(e,t,r.slice(),n.slice())}return!z((function(e,t){return!z(s,t,e)}),J(t),o)}function ie(e,t,r,n){if(W(e,t))return!0;var o,s,i=oe(e);if(i!==oe(t))return!1;if("function"==typeof e["fantasy-land/equals"]||"function"==typeof t["fantasy-land/equals"])return"function"==typeof e["fantasy-land/equals"]&&e["fantasy-land/equals"](t)&&"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](e);if("function"==typeof e.equals||"function"==typeof t.equals)return"function"==typeof e.equals&&e.equals(t)&&"function"==typeof t.equals&&t.equals(e);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof e.constructor&&"Promise"===(o=e.constructor,null==(s=String(o).match(/^function (\w*)/))?"":s[1]))return e===t;break;case"Boolean":case"Number":case"String":if(typeof e!=typeof t||!W(e.valueOf(),t.valueOf()))return!1;break;case"Date":if(!W(e.valueOf(),t.valueOf()))return!1;break;case"Error":return e.name===t.name&&e.message===t.message;case"RegExp":if(e.source!==t.source||e.global!==t.global||e.ignoreCase!==t.ignoreCase||e.multiline!==t.multiline||e.sticky!==t.sticky||e.unicode!==t.unicode)return!1}for(var a=r.length-1;a>=0;){if(r[a]===e)return n[a]===t;a-=1}switch(i){case"Map":return e.size===t.size&&se(e.entries(),t.entries(),r.concat([e]),n.concat([t]));case"Set":return e.size===t.size&&se(e.values(),t.values(),r.concat([e]),n.concat([t]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=ne(e);if(c.length!==ne(t).length)return!1;var u=r.concat([e]),l=n.concat([t]);for(a=c.length-1;a>=0;){var d=c[a];if(!H(d,t)||!ie(t[d],e[d],u,l))return!1;a-=1}return!0}var ae=G((function(e,t){return ie(e,t,[],[])}));function ce(e){return"[object Object]"===Object.prototype.toString.call(e)}function ue(e,t,r){if(r||(r=new le),function(e){var t=typeof e;return null==e||"object"!=t&&"function"!=t}(e))return e;var n,o=function(t){var n=r.get(e);if(n)return n;for(var o in r.set(e,t),e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=ue(e[o],!0,r));return t};switch(oe(e)){case"Object":return o(Object.create(Object.getPrototypeOf(e)));case"Array":return o(Array(e.length));case"Date":return new Date(e.valueOf());case"RegExp":return n=e,new RegExp(n.source,n.flags?n.flags:(n.global?"g":"")+(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.sticky?"y":"")+(n.unicode?"u":"")+(n.dotAll?"s":""));case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return e.slice();default:return e}}var le=function(){function e(){this.map={},this.length=0}return e.prototype.set=function(e,t){var r=this.hash(e),n=this.map[r];n||(this.map[r]=n=[]),n.push([e,t]),this.length+=1},e.prototype.hash=function(e){var t=[];for(var r in e)t.push(Object.prototype.toString.call(e[r]));return t.join()},e.prototype.get=function(e){if(this.length<=180)for(var t in this.map)for(var r=this.map[t],n=0;n!(e=>void 0===e)(e),ve=(e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return de(t);const r=de(e);return t.forEach(((e,t)=>{r[t]=Array.isArray(e)||(e=>!(e=>null===e)(e)&&(e=>"object"==typeof e)(e)&&!Array.isArray(e))(e)?_e(r[t],e):e})),r},_e=(e,t)=>ge(ve,e,t);const be=new class{constructor(e){this.cOpts={},this.options(e),this.isSupportAvailable=this.checkSupportAvailability()}options(e={}){if(0===arguments.length)return this.cOpts;let t=`.${M(window.location.href)}`;return"."===t&&(t=null),this.cOpts=_e({maxage:31536e6,path:"/",domain:t,samesite:"Lax"},e),e.sameDomainCookiesOnly&&delete this.cOpts.domain,this.cOpts}set(e,t){try{return K(e,t,de(this.cOpts)),!0}catch(e){return s.error(e),!1}}get(e){return K(e)}remove(e){try{return K(e,null,de(this.cOpts)),!0}catch(e){return!1}}checkSupportAvailability(){const e="test_rudder_cookie";return this.set(e,!0),!!this.get(e)&&(this.remove(e),!0)}}({}),we={LOG:{value:0,method:console.log},INFO:{value:1,method:console.info},DEBUG:{value:2,method:console.debug},WARN:{value:3,method:console.warn},ERROR:{value:4,method:console.error}};class Oe{constructor(e,t){this.level=+t||we.ERROR.value,this.scope=e||""}setLogLevel(e){if(e&&"string"==typeof e){const t=e.toUpperCase();this.level=we[t]?we[t].value:this.level}}setScope(e){this.scope=e||this.scope}log(...e){this.logBase(e,we.LOG.value)}info(...e){this.logBase(e,we.INFO.value)}debug(...e){this.logBase(e,we.DEBUG.value)}warn(...e){this.logBase(e,we.WARN.value)}error(...e){this.logBase(e,we.ERROR.value)}logBase(e,t){if(this.level<=t){Object.values(we).find((e=>e.value===t)).method(...this.getLogData(e))}}getLogData(e){if(Array.isArray(e)&&e.length>0){let t="%c RS SDK";this.scope&&(t=`${t} - ${this.scope}`);t=`${t} %c ${e[0].trim()}`;const r=[];return r.push(t),r.push("font-weight: bold; background: black; color: white;"),r.push("font-weight: normal;"),r.push(...e.slice(1)),r}return e}}const Ae=["item_id","itemId","product_id","item_name","itemName","name","coupon","item_brand","itemBrand","brand","item_variant","itemVariant","variant","price","quantity","index","position","affiliation","discount","item_category","itemCategory","category","item_category2","item_category3","item_category4","item_category5","item_list_id","item_list_name","location_id"],Ee=[{sourceKeys:["product_id","itemId"],destKey:"item_id"},{sourceKeys:["name","itemName"],destKey:"item_name"},{sourceKeys:"coupon",destKey:"coupon"},{sourceKeys:["brand","itemBrand"],destKey:"item_brand"},{sourceKeys:["variant","itemVariant"],destKey:"item_variant"},{sourceKeys:"price",destKey:"price",metadata:{type:"toNumber"}},{sourceKeys:"quantity",destKey:"quantity",metadata:{type:"toNumber"}},{sourceKeys:"position",destKey:"index",metadata:{type:"toNumber"}},{sourceKeys:"affiliation",destKey:"affiliation"},{sourceKeys:"discount",destKey:"discount"},{sourceKeys:["category","itemCategory"],destKey:"item_category"},{sourceKeys:"item_category2",destKey:"item_category2"},{sourceKeys:"item_category3",destKey:"item_category3"},{sourceKeys:"item_category4",destKey:"item_category4"},{sourceKeys:"item_category5",destKey:"item_category5"},{sourceKeys:"item_list_id",destKey:"item_list_id"},{sourceKeys:"item_list_name",destKey:"item_list_name"},{sourceKeys:"location_id",destKey:"location_id"}],Ie={method:{sourceKeys:"properties.method",destKey:"method"},product_cart_shared_method:{sourceKeys:"properties.share_via",destKey:"method"},currency:{sourceKeys:"properties.currency",destKey:"currency",metadata:{defaultValue:"USD"}},value:{sourceKeys:["properties.total","properties.value","properties.revenue","properties.price"],destKey:"value",metadata:{type:"toNumber"}},product_add_or_remove_value:{sourceKeys:["properties.total","properties.value","properties.revenue",{operation:"multiplication",args:[{sourceKeys:"properties.price"},{sourceKeys:"properties.quantity",defaultVal:1}]}],destKey:"value",metadata:{type:"toNumber"}},search:{sourceKeys:"properties.query",destKey:"search_term"},list_id:{sourceKeys:"properties.list_id",destKey:"item_list_id"},list_name:{sourceKeys:"properties.category",destKey:"item_list_name"},creative_name:{sourceKeys:["properties.creative_name","properties.creative"],destKey:"creative_name"},creative_slot:{sourceKeys:["properties.creative_slot","properties.position"],destKey:"creative_slot"},promotion_id:{sourceKeys:"properties.promotion_id",destKey:"promotion_id"},promotion_name:{sourceKeys:["properties.promotion_name","properties.name"],destKey:"promotion_name"},coupon:{sourceKeys:"properties.coupon",destKey:"coupon"},payment_method:{sourceKeys:"properties.payment_method",destKey:"payment_type"},shipping_method:{sourceKeys:"properties.shipping_method",destKey:"shipping_tier"},order_id:{sourceKeys:"properties.order_id",destKey:"transaction_id"},shipping:{sourceKeys:"properties.shipping",destKey:"shipping",metadata:{type:"toNumber"}},tax:{sourceKeys:"properties.tax",destKey:"tax",metadata:{type:"toNumber"}},content_type:{sourceKeys:"properties.content_type",destKey:"content_type"},item_id:{sourceKeys:["properties.item_id","properties.product_id","properties.sku"],destKey:"item_id"},cart_shared_item_id:{sourceKeys:["properties.item_id","properties.cart_id"],destKey:"item_id"},url:{sourceKeys:["properties.url","context.page.url"],destKey:"page_location"},referrer:{sourceKeys:["properties.referrer","context.page.referrer"],destKey:"page_referrer"},title:{sourceKeys:["properties.title","context.page.title"],destKey:"page_title"}},Ke={LOGIN:{event:"login",mapping:[Ie.method]},SIGN_UP:{event:"sign_up",mapping:[Ie.method]},GENERATE_LEAD:{event:"generate_lead",mapping:[Ie.currency,n(n({},Ie.value),{},{required:!0})]},PRODUCTS_SEARCHED:{event:"search",mapping:[Ie.search]},PRODUCT_SEARCHED:{event:"search",mapping:[Ie.search]},PRODUCT_LIST_VIEWED:{event:"view_item_list",itemList:"YES",mapping:[Ie.list_id,Ie.list_name]},PROMOTION_VIEWED:{event:"view_promotion",itemList:"YES",mapping:[Ie.promotion_id,Ie.creative_slot,Ie.creative_name,Ie.promotion_name]},PROMOTION_CLICKED:{event:"select_promotion",itemList:"NO",mapping:[Ie.promotion_id,Ie.creative_slot,Ie.creative_name,Ie.promotion_name]},PRODUCT_CLICKED:{event:"select_item",item:"YES",mapping:[Ie.list_id,Ie.list_name]},PRODUCTS_CLICKED:{event:"select_item",item:"YES",mapping:[Ie.list_id,Ie.list_name]},PRODUCT_VIEWED:{event:"view_item",item:"YES",mapping:[Ie.currency,n(n({},Ie.value),{},{required:!0})]},PRODUCT_ADDED:{event:"add_to_cart",itemList:"NO",item:"YES",mapping:[Ie.currency,n(n({},Ie.product_add_or_remove_value),{},{required:!0})]},PRODUCT_REMOVED:{event:"remove_from_cart",itemList:"NO",item:"YES",mapping:[Ie.currency,n(n({},Ie.product_add_or_remove_value),{},{required:!0})]},CART_VIEWED:{event:"view_cart",itemList:"YES",mapping:[Ie.currency,n(n({},Ie.value),{},{required:!0})]},CHECKOUT_STARTED:{event:"begin_checkout",itemList:"YES",mapping:[Ie.currency,Ie.coupon,n(n({},Ie.value),{},{required:!0})]},PAYMENT_INFO_ENTERED:{event:"add_payment_info",itemList:"YES",mapping:[Ie.currency,Ie.coupon,Ie.payment_method,n(n({},Ie.value),{},{required:!0})]},CHECKOUT_STEP_COMPLETED:{event:"add_shipping_info",itemList:"YES",mapping:[Ie.currency,Ie.coupon,Ie.shipping_method,n(n({},Ie.value),{},{required:!0})]},ORDER_COMPLETED:{event:"purchase",itemList:"YES",mapping:[Ie.tax,Ie.coupon,Ie.shipping,Ie.currency,n(n({},Ie.value),{},{required:!0}),n(n({},Ie.order_id),{},{required:!0})]},ORDER_REFUNDED:{event:"refund",itemList:"NO",mapping:[Ie.tax,Ie.coupon,Ie.shipping,Ie.currency,n(n({},Ie.value),{},{required:!0}),n(n({},Ie.order_id),{},{required:!0})]},PRODUCT_ADDED_TO_WISHLIST:{event:"add_to_wishlist",itemList:"NO",item:"YES",mapping:[Ie.currency,n(n({},Ie.value),{},{required:!0})]},PRODUCT_SHARED:{event:"share",mapping:[Ie.item_id,Ie.content_type,Ie.product_cart_shared_method]},CART_SHARED:{event:"share",mapping:[Ie.content_type,Ie.cart_shared_item_id,Ie.product_cart_shared_method]},PAGE:{event:"page_view",mapping:[Ie.url,Ie.title,Ie.referrer]}},Se=[Ke.PRODUCT_CLICKED.event,Ke.PRODUCT_VIEWED.event,Ke.PRODUCT_ADDED.event,Ke.PRODUCT_REMOVED.event,Ke.PRODUCT_ADDED_TO_WISHLIST.event];for(var je=Object.defineProperty,De=(e,t)=>je(e,"name",{value:t,configurable:!0}),Ce=De((e=>null!==e&&"object"==typeof e),"isObject"),ke=De(((e,t,r)=>"function"==typeof r.join?r.join(e):e[0]+t+e[1]),"join"),xe=De(((e,t,r)=>"function"==typeof r.split?r.split(e):e.split(t)),"split"),Re=De(((e,t={},r)=>"function"!=typeof(null==r?void 0:r.isValid)||r.isValid(e,t)),"isValid"),Ue=De((e=>Ce(e)||"function"==typeof e),"isValidObject"),Pe=De(((e,t,r={})=>{if(Ce(r)||(r={default:r}),!Ue(e))return void 0!==r.default?r.default:e;"number"==typeof t&&(t=String(t));const n=Array.isArray(t),o="string"==typeof t,s=r.separator||".",i=r.joinChar||("string"==typeof s?s:".");if(!o&&!n)return e;if(void 0!==e[t])return Re(t,e,r)?e[t]:r.default;const a=n?t:xe(t,s,r),c=a.length;let u=0;do{let t=a[u];for("string"!=typeof t&&(t=String(t));t&&"\\"===t.slice(-1);)t=ke([t.slice(0,-1),a[++u]||""],i,r);if(void 0!==e[t]){if(!Re(t,e,r))return r.default;e=e[t]}else{let n=!1,o=u+1;for(;o{const r=e.length;for(let s=0;s{let r=!0;Object.keys(e).forEach((s=>{r=!1,Te(e[s],t?`${t}.${s}`:s,o,n)})),r&&(o[t]={})})(),n.delete(e),o)}function $e(e,t,r,n){const o=[],i=t||{};return Array.isArray(r)?r.forEach((t=>{const r=Pe(e,t);r&&(Object.keys(r).forEach((e=>{n.includes(e)||o.push(e)})),o.forEach((e=>{void 0!==r[e]&&(i[e]=Pe(r,e))})))})):"root"===r?(Object.keys(e).forEach((e=>{n.includes(e)||o.push(e)})),o.forEach((t=>{void 0!==e[t]&&(i[t]=Pe(e,t))}))):s.debug("unable to parse keys"),i}const qe=e=>he(e)&&(e=>null!==e)(e),Me=({message:e,operationObject:t})=>{const{operation:r,args:n}=t,o=n.map((t=>{const{sourceKeys:r,defaultVal:n}=t,o=Pe(e,r);return o||!1===o||0===o?o:n}));if(!o.every((e=>qe(e))))return null;let s=null;switch(r){case"multiplication":s=1;for(const e of o){if("number"!=typeof e)return null;s*=e}return s.toFixed(2);case"addition":s=0;for(const e of o){if("number"!=typeof e)return null;s+=e}return s.toFixed(2);default:return null}},Ve=(e,t)=>{let r=e;const n={jsonStringify:()=>{r=JSON.stringify(e)},jsonStringifyOnObject:()=>{"string"!=typeof e&&(r=JSON.stringify(e))},toString:()=>{r=String(e)},toNumber:()=>{r=Number(e)},toFloat:()=>{r=parseFloat(e)},toInt:()=>{r=parseInt(e,10)},toLower:()=>{r=e.toString().toLowerCase()},trim:()=>{"string"==typeof e&&(r=e.trim())},IsBoolean:()=>{r=!0,"boolean"!=typeof e&&(s.debug("Boolean value missing, so dropping it"),r=!1)}};if(t in n){(0,n[t])()}return r},Be=(e,t)=>{const r={};return Array.isArray(t)&&t.length>0&&t.forEach((t=>{const{sourceKeys:n,destKey:o,metadata:s}=t,i=((e,t)=>{if(!t)return e;const{type:r,defaultValue:n}=t;if(!qe(e))return n||e;let o=e;return r&&(Array.isArray(r)?r.forEach((e=>{o=Ve(o,e)})):o=Ve(o,r)),o})(((e,t)=>{if(Array.isArray(t)&&t.length>0){for(const r of t){let t;if(t="object"==typeof r?Me({message:e,operationObject:r}):Pe(e,r),t||!1===t||0===t)return t}return null}return"object"==typeof t?Me({message:e,operationObject:t}):Pe(e,t)})(e,n),s);(i||0===i||!1===i)&&o&&(r[o]=i)})),r};function Ge(e,t=".",r="normal"){const n={};let o;return function e(s,i,a=new Set){let c;if(a.has(s))n[i]="[Circular Reference]";else{if(a.add(s),Object(s)!==s)n[i]=s;else if(Array.isArray(s)){for(c=0,o=s.length;c{r=!1,e(s[n],i?`${i}${t}${n}`:n,a)})),r&&i&&(n[i]={})}a.delete(s)}}(e,""),n}const Fe=new Oe(f),Ye=e=>e.split(".").pop(),Je=e=>{const t={};if("object"==typeof e&&!Array.isArray(e)){return Object.keys(e).forEach((r=>{const n=e[r];("items"===r||"object"!=typeof n&&!(e=>"string"==typeof e&&fe(e.trim()))(n))&&(t[r]=n)})),t}return e},ze=(e,t,r)=>{let n={};return n=$e(e,n,t,r),d(n)||(n=Ge(n,"_","strict")),n},He=e=>{const t=[],{properties:r}=e;let o=null==r?void 0:r.products,s=!1;return"object"!=typeof o||Array.isArray(o)||(s=!0,o=[o]),Array.isArray(o)&&o.forEach(((r,o)=>{let i=Be(r,Ee);const a=$e(e,{},s?["properties.products"]:[`properties.products.${o}`],Ae);d(a)||(i=Je(n(n({},i),Ge(a,"_","strict")))),d(i)||t.push(i)})),t},We=e=>{const{properties:t}=e,r=[];if(t&&Object.keys(t).length>0){const e=Be(t,Ee);d(e)||r.push(e)}return r},Ze=(e,t)=>{const{event:r,mapping:o}=t;let s=Be(e,o);if(Array.isArray(o)&&o.length>0){if(o.some((e=>{return t=s[e.destKey],!(he(t)&&(e=>null!=e)(t)||!e.required)&&(Fe.error(`Missing required value from ${JSON.stringify(e.sourceKeys)}`),!0);var t})))return null}const{items:i,mapRootLevelPropertiesToGA4ItemsArray:a}=((e,t)=>{const{itemList:r,item:n}=t;let o=[],s=!1;return r&&n?(o=He(e),o&&o.length>0||(s=!0,o=We(e))):n?(s=!0,o=We(e)):r&&(o=He(e)),{items:o,mapRootLevelPropertiesToGA4ItemsArray:s}})(e,t),c=((e,t,r)=>{let n=t.reduce(((e,t)=>{const r=t.sourceKeys;return"string"==typeof r?e.push(Ye(r)):Array.isArray(r)&&r.forEach((t=>{"string"==typeof t&&e.push(Ye(t))})),e}),[]);return n.push("products"),e&&Se.includes(r)&&(n=n.concat(Ae)),n})(a,o,r),u=ze(e,["properties"],c);return i.length>0&&(s.items=i),d(u)||(s=n(n({},s),u)),s},Qe=(e,t)=>{const r=Ke[`${t.toUpperCase()}`],n=r?Ze(e,r):(e=>ze(e,["properties"],[]))(e);if(!n)return null;return{params:Je(n),event:r?r.event:t}},Xe=new Oe(f);return e.GA4=class{constructor(e,t,r){var n;t.logLevel&&Xe.setLogLevel(t.logLevel),this.name="GA4",this.clientId="",this.sessionId="",this.sessionNumber="",this.cookie=be,this.sendUserId=!0,this.analytics=t,this.measurementId=e.measurementId,this.debugView=e.debugView||!1,this.capturePageView=e.capturePageView||"rs",this.isHybridModeEnabled="hybrid"===e.connectionMode,this.piiPropertiesToIgnore=e.piiPropertiesToIgnore||[],this.extendPageViewParams=e.extendPageViewParams||!1,this.overrideClientAndSessionId=e.overrideClientAndSessionId||!1,this.sdkBaseUrl=(null!=(n=e.sdkBaseUrl)&&n.endsWith("/")?n.replace(/\/+$/,""):n)||"https://www.googletagmanager.com",this.serverContainerUrl=e.serverContainerUrl||null,this.isExtendedGa4_V2=e.isExtendedGa4_V2||!1,({shouldApplyDeviceModeTransformation:this.shouldApplyDeviceModeTransformation,propagateEventsUntransformedOnError:this.propagateEventsUntransformedOnError,destinationId:this.destinationId}=null!=r?r:{})}loadScript(e,t){window.dataLayer=window.dataLayer||[],window.gtag=window.gtag||function(){window.dataLayer.push(arguments)},window.gtag("js",new Date);const r={};var n,o,s;if(qe(this.serverContainerUrl)&&(r.server_container_url=this.serverContainerUrl),"rs"===this.capturePageView&&(r.send_page_view=!1),this.sendUserId=(n=this.analytics.loadOnlyIntegrations,null===(o=null==n||null===(s=n.GA4)||void 0===s?void 0:s.sendUserId)||void 0===o||o),this.sendUserId&&this.analytics.getUserId()&&(r.user_id=this.analytics.getUserId()),this.isHybridModeEnabled&&this.overrideClientAndSessionId)r.cookie_prefix="rs",r.client_id=this.analytics.getAnonymousId(),r.session_id=this.analytics.getSessionId();else if(!this.isExtendedGa4_V2){const e=this.cookie.get("rs_ga"),t=this.cookie.get("_ga"),n=this.measurementId.split("-"),o=this.cookie.get(`rs_ga_${n[1]}`);if(!t&&e&&o){const t=e.split("."),n=t.length>3?`${t[2]}.${t[3]}`:t[2],s=o.split(".")[2];n&&(r.client_id=n),s&&(r.session_id=s)}this.cookie.remove("rs_ga"),this.cookie.remove(`rs_ga_${n[1]}`)}this.debugView&&(r.debug_mode=!0),0===Object.keys(r).length?window.gtag("config",e):window.gtag("config",e,r),window.gtag("get",this.measurementId,"session_id",(e=>{this.sessionId=e})),window.gtag("get",this.measurementId,"client_id",(e=>{this.clientId=e})),window.gtag("get",this.measurementId,"session_number",(e=>{this.sessionNumber=e})),((e,t,r={})=>{try{if(document.getElementById(e))return;const n=document.createElement("script");n.src=t,n.async=void 0===r.async||r.async,n.type="text/javascript",n.id=e,!0!==r.skipDatasetAttributes&&(n.setAttribute("data-loader",i),void 0!==r.isNonNativeSDK&&n.setAttribute("data-isNonNativeSDK",r.isNonNativeSDK));const o=document.getElementsByTagName("head");if(o.length>0)o[0].insertBefore(n,o[0].firstChild);else{const e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(n,e)}}catch(e){p(e)}})("google-analytics 4",`${t}/gtag/js?id=${e}`)}init(){this.loadScript(this.measurementId,this.sdkBaseUrl)}isLoaded(){return!(!this.sessionId||!this.clientId)}isReady(){return this.isLoaded()}identify(e){const{message:t}=e,{traits:r}=t.context,o=((e,t)=>{const r=[],o={},s=t,i={};return e.length>0&&e.forEach((e=>{"string"==typeof e.piiProperty&&""!==e.piiProperty.trim()&&r.push(e.piiProperty.trim())})),Object.keys(s).forEach((e=>{const t=s[e];r.includes(e)?o[e]=null:i[e]=t})),n(n({},o),i)})(this.piiPropertiesToIgnore,r);if(Object.keys(o).length>0&&window.gtag("set","user_properties",o),this.sendUserId&&t.userId){const{userId:e}=t;window.gtag("config",this.measurementId,{user_id:e})}}track(e){if(this.isHybridModeEnabled)return;const{message:t}=e,r=(e=>{if(!e||"string"!=typeof e)return Fe.error("Event name is required and should be a string"),null;const t=e.trim().replace(/\s+/g,"_");return["click","error","scroll","form_start","form_submit","first_open","first_visit","app_remove","video_start","session_start","view_complete","file_download","video_progress","user_engagement","in_app_purchase","app_store_refund","app_store_subscription_cancel","app_store_subscription_renew"].includes(t)?(Fe.error(`Reserved event name ${t} is not allowed`),null):t})(null==t?void 0:t.event);if(!r)return void Xe.error("Event name is required");const n=Qe(t,r);if(!n)return;const{params:o,event:s}=n,i=this.addSendToAndMeasurementIdToPayload(o,e);window.gtag("event",s,i)}page(e){if("rs"===this.capturePageView){const{message:t}=e,{properties:r}=t;let o=Be(t,Ke.PAGE.mapping);o=this.addSendToAndMeasurementIdToPayload(o,e),this.extendPageViewParams?window.gtag("event","page_view",n(n({},function(e,t=""){return Te(e,t,{})}(r)),o)):window.gtag("event","page_view",o)}}group(e){if(this.isHybridModeEnabled)return;const{groupId:t,traits:r}=e.message;let o=r;o=this.addSendToAndMeasurementIdToPayload(o,e);const s=n({group_id:t},o);window.gtag("event","join_group",s)}addSendToAndMeasurementIdToPayload(e,t){const{message:r}=t,{userId:n}=r,o=e;return o.send_to=this.measurementId,this.sendUserId&&n&&(o.user_id=n),o}getDataForIntegrationsObject(){return{[f]:{clientId:this.clientId,sessionId:this.sessionId,sessionNumber:this.sessionNumber}}}getClientDetails(){return{clientId:this.clientId,sessionId:this.sessionId,sessionNumber:this.sessionNumber}}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({}); //# sourceMappingURL=GA4.min.js.map