(function(){const d={Purchase:{ga4:"purchase",meta:"Purchase",tiktok:"CompletePayment"},AddToCart:{ga4:"add_to_cart",meta:"AddToCart",tiktok:"AddToCart"},InitiateCheckout:{ga4:"begin_checkout",meta:"InitiateCheckout",tiktok:"InitiateCheckout"},CompleteRegistration:{ga4:"sign_up",meta:"CompleteRegistration",tiktok:"CompleteRegistration"},ViewContent:{ga4:"view_item",meta:"ViewContent",tiktok:"ViewContent"},Lead:{ga4:"generate_lead",meta:"Lead",tiktok:"SubmitForm"},PageView:{ga4:null,meta:"PageView",tiktok:"PageView"}};function p(){return window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():"evt-"+Date.now()+"-"+Math.random().toString(36).slice(2,12)}function f(t){const e=Object.assign({},t);return t.contents&&(e.items=t.contents.map(n=>({item_id:n.id,quantity:n.quantity,price:n.item_price})),delete e.contents),e}function l(t){const e=Object.assign({},t);return t.contents&&(e.content_ids=t.contents.map(n=>n.id),e.contents=t.contents.map(n=>({id:n.id,quantity:n.quantity,item_price:n.item_price})),e.content_type="product"),e}function g(t){const e=Object.assign({},t);return t.contents&&(e.contents=t.contents.map(n=>({content_id:n.id,quantity:n.quantity,price:n.item_price}))),e}const k={Purchase:{titleCase:"Order Completed",snakeCase:"order_completed"},AddToCart:{titleCase:"Product Added",snakeCase:"product_added"},InitiateCheckout:{titleCase:"Checkout Started",snakeCase:"checkout_started"},CompleteRegistration:{titleCase:"Signed Up",snakeCase:"signed_up"},ViewContent:{titleCase:"Product Viewed",snakeCase:"product_viewed"},Lead:{titleCase:"Lead Generated",snakeCase:"lead_generated"},PageView:{titleCase:"Page Viewed",snakeCase:"page_viewed"}};function C(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/_/g," ").replace(/\s+/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function m(t){return t.replace(/([a-z])([A-Z])/g,"$1_$2").replace(/\s+/g,"_").toLowerCase()}function w(t,e){e=e||{};const n=window.procpTracking||{},o=k[t],a=o?o.titleCase:C(t),r=o?o.snakeCase:m(t);try{n.mixpanel&&window.mixpanel&&typeof window.mixpanel.track=="function"&&window.mixpanel.track(a,e)}catch(i){console.warn("[tracking] Mixpanel fan-out failed",i)}try{n.amplitude&&window.amplitude&&typeof window.amplitude.track=="function"&&window.amplitude.track(r,e)}catch(i){console.warn("[tracking] Amplitude fan-out failed",i)}try{n.posthog&&window.posthog&&typeof window.posthog.capture=="function"&&window.posthog.capture(r,e)}catch(i){console.warn("[tracking] PostHog fan-out failed",i)}try{n.firebase&&window.procpFirebaseAnalytics&&typeof window.firebaseLogEvent=="function"&&window.firebaseLogEvent(window.procpFirebaseAnalytics,r,e)}catch(i){console.warn("[tracking] Firebase fan-out failed",i)}try{n.segment&&window.analytics&&typeof window.analytics.track=="function"&&window.analytics.track(a,e)}catch(i){console.warn("[tracking] Segment fan-out failed",i)}}function s(t,e,n){if(!window.procpConsent||!window.procpConsent.marketing)return null;e=e||{};const o=d[t];if(!o)return console.warn("[tracking] Unknown event:",t),null;n=n||p();try{o.ga4&&typeof window.gtag=="function"&&window.gtag("event",o.ga4,Object.assign({},f(e),{event_id:n}))}catch(a){console.warn("[tracking] GA4 failed",a)}try{o.meta&&typeof window.fbq=="function"&&window.fbq("track",o.meta,l(e),{eventID:n})}catch(a){console.warn("[tracking] Meta failed",a)}try{o.tiktok&&typeof window.ttq<"u"&&typeof window.ttq.track=="function"&&window.ttq.track(o.tiktok,Object.assign({},g(e),{event_id:n}))}catch(a){console.warn("[tracking] TikTok failed",a)}return w(t,Object.assign({},e,{event_id:n})),n}function c(t,e){!window.procpConsent||!window.procpConsent.marketing||w(t,e||{})}window.procpTracking=window.procpTracking||{},window.procpTracking.track=s,window.procpTracking.fireCustomEvent=c,window.procpFireCustomEvent=c;function u(){if(!window.procpAutoEvent||typeof window.procpAutoEvent!="object")return;const t=window.procpAutoEvent;t.name&&(d[t.name]?window.procpAutoEventId=s(t.name,t.params||t.props||{},t.eventId||null):c(t.name,t.props||t.params||{}))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()})();
