{"version":3,"file":"WithApplyClick.BYNBbFLK.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/PCPDHK6uyPykr2ww7f6J/nsNo1NcYubueg5oVqTr1/WithApplyClick.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useRef}from\"react\";const UTM_KEYS=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_content\",\"utm_term\",// GA4-specific keys; utm_id is required to join imported ad-cost data\n\"utm_id\",\"utm_source_platform\",\"utm_creative_format\"];const APP_URL=\"https://app.rocketcash.in/auth/otp\";// Fallback source for direct/organic traffic; an incoming utm_source wins.\nconst DEFAULT_UTM_SOURCE=\"web_rocket_site\";export function withApplyClick(Component){return props=>{// Fire-once guard: onTap and onClick can BOTH fire for a single tap,\n// so dedupe across invocations (a per-handler flag would not).\nconst firingRef=useRef(false);const handleClick=event=>{event?.preventDefault?.();if(firingRef.current)return;firingRef.current=true;// Reset so the button still works if navigation somehow doesn't occur.\nsetTimeout(()=>{firingRef.current=false;},2e3);// Step 3: build the destination first, so the redirect never\n// depends on gtag succeeding. Forward the UTMs present in the URL.\nconst current=new URLSearchParams(window.location.search);const target=new URL(APP_URL);for(const key of UTM_KEYS){const value=current.get(key);if(value)target.searchParams.set(key,value);}// Default utm_source for direct/organic traffic; preserve an\n// incoming utm_source when the landing URL already carries one.\nif(!target.searchParams.has(\"utm_source\")){target.searchParams.set(\"utm_source\",DEFAULT_UTM_SOURCE);}// Navigate at most once (callback OR timeout, whichever fires first).\nlet navigated=false;const go=()=>{if(navigated)return;navigated=true;window.location.href=target.toString();};// Step 2: fire apply_click, then navigate from the callback so the\n// hit is dispatched before unload. transport_type 'beacon' lets a\n// dispatched hit survive unload; the setTimeout guarantees the\n// redirect even if gtag is slow, blocked, or not yet loaded.\nconst gtag=window.gtag;if(typeof gtag===\"function\"){gtag(\"event\",\"apply_click\",{event_callback:go,event_timeout:500,transport_type:\"beacon\"});setTimeout(go,600);}else{go();}};// Attach both onTap (Framer/Motion's canonical event) and onClick.\n// The firingRef guard above dedupes if both fire for one tap.\nreturn /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick,onTap:handleClick});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withApplyClick\":{\"type\":\"reactHoc\",\"name\":\"withApplyClick\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithApplyClick.map"],"mappings":"gIAE2C,SAAgB,EAAe,EAAU,CAAC,MAAO,IAAO,CAEnG,IAAM,EAAUA,EAAO,EAAK,EAAQ,EAAY,GAAO,CAA2B,GAA1B,GAAO,iBAAiB,EAAK,EAAU,QAAQ,OAAO,EAAU,QAAQ,GAChI,eAAe,CAAC,EAAU,QAAQ,EAAM,EAAE,GAAG,EAE7C,IAAM,EAAQ,IAAI,gBAAgB,EAAO,SAAS,MAAM,EAAQ,EAAO,IAAI,IAAI,CAAO,EAAE,IAAI,IAAM,KAAO,EAAS,CAAC,IAAM,EAAM,EAAQ,IAAI,CAAG,EAAK,GAAM,EAAO,aAAa,IAAI,EAAI,CAAK,CAAE,CAExL,EAAO,aAAa,IAAI,YAAY,GAAG,EAAO,aAAa,IAAI,aAAa,CAAkB,EAClG,IAAI,EAAU,GAAY,MAAO,CAAI,IAAiB,EAAU,GAAK,EAAO,SAAS,KAAK,EAAO,SAAS,EAAE,EAItG,EAAK,EAAO,KAAQ,OAAO,GAAO,YAAY,EAAK,QAAQ,cAAc,CAAC,eAAe,EAAG,cAAc,IAAI,eAAe,QAAQ,CAAC,EAAE,WAAW,EAAG,GAAG,GAAQ,EAAG,CAAG,EAE7K,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAM,QAAQ,EAAY,MAAM,CAAW,CAAC,CAAE,CAAE,2BAhB7C,IAA0B,EAAO,EAAS,CAAC,aAAa,aAAa,eAAe,cAAc,WAC5I,SAAS,sBAAsB,qBAAqB,EAAQ,EAAQ,qCAC9D,EAAmB"}