{"version":3,"file":"withConditionalRedirect.DAzgsf8a.mjs","names":[],"sources":["https:/framerusercontent.com/modules/c1j4i0GkCSlzOrwgkm4F/a99mnF2dy8kPztFwC707/withConditionalRedirect.js"],"sourcesContent":["// withConditionalRedirect.tsx\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,forwardRef}from\"react\";// === Exact destinations ===\nconst CORPORATE_URL=\"https://www.tiffanyuman.com/career-growth-masterclass-thank-you-icp\";const OTHER_URL=\"https://www.tiffanyuman.com/career-growth-masterclass-thank-you-nicp\";// preserve query params (UTMs)\nfunction withQuery(baseUrl){const dest=new URL(baseUrl);const current=new URL(window.location.href);current.searchParams.forEach((v,k)=>dest.searchParams.set(k,v));return dest.href;}export function withConditionalRedirect(Component){return /*#__PURE__*/forwardRef((props,ref)=>{useEffect(()=>{const form=document.querySelector('form[data-framer-name=\"Industry\"]')??document.querySelector(\"form.framer-form\");if(!form)return;if(form.dataset.redirectAttached===\"1\")return;form.dataset.redirectAttached=\"1\";// Find the industry dropdown\nconst industrySelect=form.querySelector('[name=\"industry\"]')??form.querySelector('[name=\"Industry\"]')??form.querySelector('select[data-framer-name*=\"industry\" i]')??form.querySelector(\"select\");// Find the salary dropdown\nconst salarySelect=form.querySelector('[name=\"salary\"]')??form.querySelector('[name=\"Salary\"]')??form.querySelector('select[data-framer-name*=\"salary\" i]');// Make both fields required\nif(industrySelect){industrySelect.setAttribute(\"required\",\"true\");// Add visual indicator for required field\nconst label=form.querySelector(`label[for=\"${industrySelect.id}\"]`)||industrySelect.closest(\".framer-form-field\")?.querySelector(\"label\");if(label&&!label.textContent?.includes(\"*\")){label.innerHTML=label.innerHTML+' <span style=\"color: red;\">*</span>';}}if(salarySelect){salarySelect.setAttribute(\"required\",\"true\");// Add visual indicator for required field\nconst label=form.querySelector(`label[for=\"${salarySelect.id}\"]`)||salarySelect.closest(\".framer-form-field\")?.querySelector(\"label\");if(label&&!label.textContent?.includes(\"*\")){label.innerHTML=label.innerHTML+' <span style=\"color: red;\">*</span>';}}const validateIndustrySelection=()=>{if(!industrySelect){console.warn(\"Industry dropdown not found\");return false;}const value=industrySelect.value?.trim();// Check if no option is selected or default/placeholder option is selected\nif(!value||value===\"\"||value===\"Select an option\"||value===\"Choose...\"||industrySelect.selectedIndex<=0){// Show browser validation message\nindustrySelect.setCustomValidity(\"Please select your industry\");industrySelect.reportValidity();// Focus the dropdown\nindustrySelect.focus();// Add visual feedback\nindustrySelect.style.borderColor=\"red\";setTimeout(()=>{industrySelect.style.borderColor=\"\";},3e3);return false;}// Clear any previous validation message\nindustrySelect.setCustomValidity(\"\");return true;};const validateSalarySelection=()=>{if(!salarySelect){console.warn(\"Salary dropdown not found\");return false;}const value=salarySelect.value?.trim();// Check if no option is selected or default/placeholder option is selected\nif(!value||value===\"\"||value===\"Select an option\"||value===\"Choose...\"||salarySelect.selectedIndex<=0){// Show browser validation message\nsalarySelect.setCustomValidity(\"Please select your salary range\");salarySelect.reportValidity();// Focus the dropdown\nsalarySelect.focus();// Add visual feedback\nsalarySelect.style.borderColor=\"red\";setTimeout(()=>{salarySelect.style.borderColor=\"\";},3e3);return false;}// Clear any previous validation message\nsalarySelect.setCustomValidity(\"\");return true;};const decideDest=()=>{const industryChoice=industrySelect?.value?.toLowerCase().trim()||\"\";const salaryChoice=salarySelect?.value?.toLowerCase().trim()||\"\";// ONLY send to ICP page if BOTH conditions are met\nif(industryChoice.startsWith(\"corporate\")&&salaryChoice.startsWith(\"more than $125,000\")){return withQuery(CORPORATE_URL);}// All other combinations go to NICP page\nreturn withQuery(OTHER_URL);};// Clear validation message when user makes a selection\nif(industrySelect){industrySelect.addEventListener(\"change\",()=>{industrySelect.setCustomValidity(\"\");industrySelect.style.borderColor=\"\";});}if(salarySelect){salarySelect.addEventListener(\"change\",()=>{salarySelect.setCustomValidity(\"\");salarySelect.style.borderColor=\"\";});}const onSubmit=e=>{console.log(\"Form submit intercepted\");// Validate both fields\nif(!validateIndustrySelection()){console.log(\"Industry validation failed - preventing submission\");e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();return false;}if(!validateSalarySelection()){console.log(\"Salary validation failed - preventing submission\");e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();return false;}const dest=decideDest();form.dataset.redirectDest=dest;console.log(\"Form validated, will redirect to:\",dest);// Set a longer timeout to ensure Framer processes the form first\nsetTimeout(()=>{if(form.dataset.redirectDone!==\"1\"){console.log(\"Executing redirect to:\",dest);window.location.assign(dest);}},1500);};// Attach to multiple event types to catch all submission attempts\nform.addEventListener(\"submit\",onSubmit,true)// Capture phase\n;form.addEventListener(\"submit\",onSubmit,false)// Bubble phase\n;// Also listen for click on submit buttons\nconst submitButtons=form.querySelectorAll('button[type=\"submit\"], input[type=\"submit\"], button:not([type])');submitButtons.forEach(button=>{button.addEventListener(\"click\",e=>{if(!validateIndustrySelection()||!validateSalarySelection()){e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();return false;}},true);});const mo=new MutationObserver(()=>{const text=(form.textContent||\"\").toLowerCase();if(text.includes(\"thank you\")||text.includes(\"success\")||form.querySelector('[role=\"status\"], [aria-live]')||form.querySelector(\".framer-form-success\")){const dest=form.dataset.redirectDest||withQuery(OTHER_URL);form.dataset.redirectDone=\"1\";console.log(\"Success message detected, redirecting to:\",dest);window.location.assign(dest);}});mo.observe(form,{childList:true,subtree:true,characterData:true});return()=>{mo.disconnect();form.removeEventListener(\"submit\",onSubmit,true);form.removeEventListener(\"submit\",onSubmit,false);submitButtons.forEach(button=>{button.removeEventListener(\"click\",onSubmit,true);});};},[]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withConditionalRedirect\":{\"type\":\"reactHoc\",\"name\":\"withConditionalRedirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./withConditionalRedirect.map"],"mappings":"0MAGA,SAAS,EAAU,EAAQ,CAAC,IAAM,EAAK,IAAI,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