{"version":3,"file":"Redirector.BYcxRUMU.mjs","names":["useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/TgulFwQIZtIkQbQKYeSf/wHIg7VKqjBFl9hCl3kXg/Redirector.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useCallback}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";const invisibleStyle={opacity:0,pointerEvents:\"none\",display:\"block\",position:\"absolute\",width:0,height:0,overflow:\"hidden\"};/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 0\n * @framerIntrinsicHeight 0\n * @framerSupportedLayoutWidth relative\n * @framerSupportedLayoutHeight relative\n */export default function AutoRedirect({autoRedirect,url,fallbackUrl,delay,inView=true}){const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const linkRef=useRef(null);const fallbackLinkRef=useRef(null);const timerRef=useRef(null);const redirectedRef=useRef(false);/** Stop redirect timer */const stopTimer=useCallback(()=>{if(timerRef.current){clearTimeout(timerRef.current);timerRef.current=null;}},[]);/** Perform redirect */const performRedirect=useCallback(()=>{if(redirectedRef.current||typeof window===\"undefined\")return;redirectedRef.current=true;// Метод 1: Пробуем кликнуть по скрытой ссылке (SPA переход для Framer)\nif(linkRef.current&&url){try{linkRef.current.click();return;// Если клик прошел успешно, выходим\n}catch(e){console.warn(\"Primary link click failed, trying fallback\",e);}}// Метод 2: Если основной URL не сработал, пробуем fallback\nif(fallbackUrl){if(fallbackLinkRef.current){fallbackLinkRef.current.click();}else{window.location.assign(fallbackUrl);}}else if(!url){console.error(\"Redirect failed: No URL provided\");}},[url,fallbackUrl]);/** Start redirect timer */const startTimer=useCallback(()=>{stopTimer();timerRef.current=setTimeout(performRedirect,delay*1e3);},[delay,performRedirect,stopTimer]);/** Setup IntersectionObserver for inView behavior */useEffect(()=>{if(typeof window===\"undefined\"||!containerRef.current||!autoRedirect)return;redirectedRef.current=false;if(!inView){startTimer();return;}const observer=new IntersectionObserver(([entry])=>{if(entry.isIntersecting){startTimer();}else{stopTimer();}},{threshold:.1});observer.observe(containerRef.current);return()=>{observer.disconnect();stopTimer();};},[autoRedirect,inView,startTimer,stopTimer]);if(isStatic)return /*#__PURE__*/_jsx(\"div\",{style:invisibleStyle,\"aria-hidden\":\"true\"});return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:invisibleStyle,\"aria-hidden\":\"true\",children:[url&&/*#__PURE__*/_jsx(\"a\",{ref:linkRef,href:url,style:{display:\"none\"}}),fallbackUrl&&/*#__PURE__*/_jsx(\"a\",{ref:fallbackLinkRef,href:fallbackUrl,style:{display:\"none\"}})]});}AutoRedirect.displayName=\"Redirector\";addPropertyControls(AutoRedirect,{autoRedirect:{type:ControlType.Boolean,title:\"Auto Redirect\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},url:{type:ControlType.Link,title:\"├ URL\",defaultValue:\"\",hidden:({autoRedirect})=>!autoRedirect},fallbackUrl:{type:ControlType.Link,title:\"├ Fallback URL\",defaultValue:\"\",hidden:({autoRedirect})=>!autoRedirect},delay:{type:ControlType.Number,title:\"├ Delay\",defaultValue:5,min:0,step:1,unit:\"sec\",displayStepper:true,hidden:({autoRedirect})=>!autoRedirect},inView:{type:ControlType.Boolean,title:\"├ In View\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\",hidden:({autoRedirect})=>!autoRedirect,description:\"Trigger delay only when visible.\\n———\\nMade by *[arkuš.design](https://framer.link/S5pisEA)*\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AutoRedirect\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"relative\",\"framerDisableUnlink\":\"* @framerIntrinsicWidth 0\",\"framerSupportedLayoutWidth\":\"relative\",\"framerIntrinsicHeight\":\"0\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Redirector.map"],"mappings":"qNAMG,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