let postIntegrationStatus=(e,t)=>{},executeWithRetry=(t,e,o,r={})=>{const a={maxRetries:5,retryInterval:2e3,enableLogging:!1,...r};let i=0;const n=()=>{if(e())try{o()}catch(e){a.enableLogging&&console.error(t+" execution failed:",e)}else i{var i=window.md_int_list[r.id];let n=!1;if(!i)return!1;0===Number(r.variant)&&(r.variant="Control");var d=Object.keys(i);if(d.length)for(let e=0;e"undefined"!=typeof _hsq&&_hsq,()=>{try{_hsq.push(["trackCustomBehavioralEvent",{name:a,properties:r}]),postIntegrationStatus(t,null)}catch(e){console.error("Error calling Hubspot integration:",e)}}),"mixpanel"===t&&executeWithRetry(t,()=>"undefined"!=typeof mixpanel&&mixpanel&&"function"==typeof mixpanel.track,()=>{try{mixpanel.track(a,r),postIntegrationStatus(t,r)}catch(e){console.error("Error calling Mixpanel integration:",e)}}),"amplitude"===t&&executeWithRetry(t,()=>"undefined"!=typeof amplitude&&litude&&"function"==typeof amplitude.track,()=>{try{amplitude.track(a,r),postIntegrationStatus(t,r)}catch(e){console.error("Error calling Amplitude integration:",e)}}),"klaviyo"===t&&executeWithRetry(t,()=>"undefined"!=typeof klaviyo&&"function"==typeof klaviyo.track||window._learnq,()=>{try{"undefined"!=typeof klaviyo&&"function"==typeof klaviyo.track?klaviyo.track(a,r):window._learnq&&(window._learnq=window._learnq||[],window._learnq.push(["track",a,r])),postIntegrationStatus(t,r)}catch(e){console.error("Error calling Klaviyo integration:",e)}});let e={event:a,test_id:r.id,test_name:r.name,test_variant:r.variant,timestamp:r.timestamp,uuid:window._h_uuid};if("segment"===t&&executeWithRetry(t,()=>"undefined"!=typeof analytics&&analytics,()=>{try{o.mode&&1===Number(o.mode)?(analytics.track(a,r),postIntegrationStatus(t,r)):o.mode&&2===Number(o.mode)?analytics.identify(e):o.mode&&3===Number(o.mode)&&(analytics.track(a,r),analytics.identify(e),postIntegrationStatus(t,r))}catch(e){console.error("Error calling Segment integration:",e)}}),"http_webhook"===t&&(r.endpoint=o.endpoint,r.method=o.method,r.uuid=window._h_uuid,r.key=window._h_key,r.type="mida_conversion"===a?"conversion":"visit",o.status)){try{mida.fetch("/integration/webhook","POST",r,()=>{})}catch(e){console.error(e)}postIntegrationStatus(t,r)}"mc"===t&&executeWithRetry(t,()=>"function"==typeof window.clarity,()=>{try{window.clarity("set",a,`${a}_${r.id}_`+r.variant),postIntegrationStatus(t,`${a}_${r.id}_`+r.variant)}catch(e){console.error("Error calling Microsoft Clarity integration:",e)}}),"hotjar"===t&&executeWithRetry(t,()=>"function"==typeof window.hj||!0,()=>{try{window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)},hj("event",a+"_"+r.id),hj("event",`${a}_${r.id}_`+r.variant),postIntegrationStatus(t,a+("_"+r.id))}catch(e){console.error("Error calling Hotjar integration:",e)}},{maxRetries:5}),"cio"===t&&executeWithRetry(t,()=>"undefined"!=typeof _cio&&"function"==typeof _cio.track||window.cio&&"function"==typeof window.cio.track,()=>{try{"undefined"!=typeof _cio&&"function"==typeof _cio.track?_cio.track(a,r):window.cio&&"function"==typeof window.cio.track&&window.cio.track(a,r),postIntegrationStatus(t,r)}catch(e){console.error("Error calling Customer.io integration:",e)}}),"contentsquare"===t&&executeWithRetry(t,()=>!0,()=>{try{window._uxa=window._uxa||[],window._uxa.push(["trackDynamicVariable",{key:a,value:JSON.stringify({test_id:r.id,test_name:r.name,variant:r.variant,timestamp:r.timestamp})}]),postIntegrationStatus(t,r)}catch(e){console.error("Error calling ContentSquare integration:",e)}},{maxRetries:5})}}catch(e){console.error("Error in window.executeIntegration:",e)}return!0},{}),firedPageviewTests=new Set;mida.fetch("/integration/enabled/"+window._h_key,"GET",null,e=>{try{var i,n=JSON.parse(e);let t=!1,o=!1,r=!1,a=!1;if(n&&n.length){for(let e=0;ewindow.mpw(),2e3)}catch(e){console.error("Error in Mida pageview tracking:",e)}if(a&&"undefined"!=typeof analytics&&"function"==typeof analytics.on&&analytics.on("track",function(e,t,o){window.mdq?window.mdq.push(["track",e,t]):mida.track(e,t)}),r&&"undefined"!=typeof amplitude&&"function"==typeof amplitude.logEvent){const m=amplitude.logEvent;amplitude.logEvent=function(e,t){return window.mdq?window.mdq.push(["track",e,t]):mida.track(e,t),m.apply(amplitude,arguments)}}if(o){if("undefined"!=typeof klaviyo&&"function"==typeof klaviyo.track){const c=klaviyo.track;klaviyo.track=function(e,t,o){try{window.mdq?window.mdq.push(["track",e,t]):"undefined"!=typeof mida&&"function"==typeof mida.track&&mida.track(e,t)}catch(e){console.warn("Mida tracking error (Klaviyo continues):",e)}return c.apply(klaviyo,arguments)}}if(window._learnq&&Array.isArray(window._learnq)){const s=window._learnq.push;window._learnq.push=function(){var e,t,o=Array.prototype.slice.call(arguments);try{0{try{var t=JSON.parse(e);t&&t.length&&t.forEach(e=>{var t={id:Number(e.test_id),name:e.test_name,variant:0===e.variant_id?"Control":e.variant_id,uuid:window._h_uuid,timestamp:+new Date};firedPageviewTests.has(e.test_id)||(window.executeIntegration(t,"mida_pageview")&&firedPageviewTests.add(e.test_id),e.complete&&window.executeIntegration(t,"mida_conversion"))})}catch(e){console.error("Error processing test exposure data:",e)}});else{const r=JSON.parse(localStorage.getItem("_abcache"))||[];r.length&&Object.entries(t).forEach(([t,e])=>{var o=r.find(e=>e&&e.test_id&&e.test_id.toString()===t);o&&(o={id:Number(t),name:o.test_name,variant:"0"===e.vaId.toString()?"Control":e.vaId,uuid:e.uuid,timestamp:+new Date},firedPageviewTests.has(t)||(window.executeIntegration(o,"mida_pageview")&&firedPageviewTests.add(t),e.complete&&window.executeIntegration(o,"mida_conversion")))})}}catch(e){console.error("Error in Mida event tracking:",e)}};var referrerDomain=document.referrer?new URL(document.referrer).hostname:"",isExternalReferrer=referrerDomain&&referrerDomain!==window.location.hostname,midaRedirectExists=mida.getCookie("mida_redirect");(isExternalReferrer||midaRedirectExists)&&window.mpw(!0);