{"version":3,"file":"RealityShowVotingRedirect.Cvkhpuf1.mjs","names":["__esmMin","init_npm_react_18_3_1","window","ce","init_jsx_runtime","J","c","init_ssg_sandbox_shims","init_framer_DcxuU94H","RenderTarget","withRealityBioScroll","Component","props","init_RealityShowBioScroll","votingStateEndpoint","hostname","votingDestination","value","body","path","pathname","VOTING","CLOSED","createVotingNavigationMonitor","owners","generation","navigating","timer","controller","clear","canRun","doc","recentNavigation","stamp","win","HANDOFF_KEY","schedule","load","requestGeneration","requestController","timeout","response","destination","visibilityChanged","released","withVotingStateRedirect","monitor","init_RealityShowVotingRedirect"],"sources":["https:/framerusercontent.com/modules/QdIByAM1Xq4BaAvPkjp5/A1xuNUehuV7XWqHHyUgJ/RealityShowBioScroll.js","https:/framerusercontent.com/modules/WNzJUClvC8ekLFrxS8no/2Yo84iZbnl2VFx5EIt91/RealityShowVotingRedirect.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef}from\"react\";// Let these native scroll panels handle wheel/touch gestures themselves.\n// The site's Lenis smooth-scroll handler otherwise cancels gestures in overlays.\nexport function withRealityBioScroll(Component){return /*#__PURE__*/forwardRef((props,ref)=>/*#__PURE__*/_jsx(Component,{...props,ref:ref,\"data-lenis-prevent\":\"\"}));}\nexport const __FramerMetadata__ = {\"exports\":{\"withRealityBioScroll\":{\"type\":\"reactHoc\",\"name\":\"withRealityBioScroll\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RealityShowBioScroll.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";import{RenderTarget}from\"framer\";const VOTING=\"/belezagarantida\";const CLOSED=\"/belezagarantida-votacao-encerrada\";const HANDOFF_KEY=\"bg-voting-navigation-at\";export function votingStateEndpoint(hostname){const stage=[\"welcome-slide-694452.framer.app\",\"welcome-slide-694452--audit-event-calendar-vn9t6tzxb.framer.app\"].includes(hostname);return`https://beleza-garantida-voting-${stage?\"staging\":\"api\"}.marketingbelguerra.workers.dev/api/v1/voting/state`;}export function votingDestination(pathname,body){const value=body;if(!value||value.success!==true||typeof value.isOpen!==\"boolean\")return null;const path=pathname.replace(/\\/$/,\"\");if(path===VOTING&&!value.isOpen)return CLOSED;if(path===CLOSED&&value.isOpen)return VOTING;return null;}// One monitor shared across responsive instances. It never reads or changes layout.\nexport function createVotingNavigationMonitor(win,doc){let owners=0,generation=0,navigating=false;let timer;let controller;const clear=()=>{clearTimeout(timer);timer=undefined;};const canRun=()=>owners>0&&!doc.hidden&&!navigating;function recentNavigation(){try{const stamp=Number(win.sessionStorage.getItem(HANDOFF_KEY));return stamp>0&&Date.now()-stamp<3e4;}catch{return false;}}function schedule(){clear();if(canRun())timer=setTimeout(()=>void load(),15e3);}async function load(){clear();if(!canRun()||controller)return;// Avoid immediate reversal while the previous server state expires.\nif(recentNavigation()){schedule();return;}const requestGeneration=generation;const requestController=new AbortController;controller=requestController;const timeout=setTimeout(()=>requestController.abort(),8e3);try{const response=await win.fetch(votingStateEndpoint(win.location.hostname),{signal:requestController.signal,cache:\"no-store\",credentials:\"omit\",redirect:\"error\",headers:{Accept:\"application/json\"}});if(!response.ok)return;const destination=votingDestination(win.location.pathname,await response.json());if(destination&&canRun()&&generation===requestGeneration&&!requestController.signal.aborted){try{win.sessionStorage.setItem(HANDOFF_KEY,String(Date.now()));}catch{}navigating=true;win.location.replace(destination);}}catch{}finally{clearTimeout(timeout);if(controller===requestController)controller=undefined;if(canRun())schedule();}}function visibilityChanged(){generation++;clear();controller?.abort();if(!doc.hidden){if(controller)schedule();else void load();}}return{subscribe(){owners++;if(owners===1){navigating=false;doc.addEventListener(\"visibilitychange\",visibilityChanged);void load();}let released=false;return()=>{if(released)return;released=true;if(--owners===0){generation++;clear();controller?.abort();doc.removeEventListener(\"visibilitychange\",visibilityChanged);}};}};}let monitor;export function withVotingStateRedirect(Component){return /*#__PURE__*/forwardRef((props,ref)=>{useEffect(()=>{if(typeof window===\"undefined\"||RenderTarget.current()===RenderTarget.canvas)return;const path=window.location.pathname.replace(/\\/$/,\"\");if(path!==VOTING&&path!==CLOSED)return;monitor??=createVotingNavigationMonitor(window,document);return monitor.subscribe();},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref});});}\nexport const __FramerMetadata__ = {\"exports\":{\"votingDestination\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createVotingNavigationMonitor\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"votingStateEndpoint\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withVotingStateRedirect\":{\"type\":\"reactHoc\",\"name\":\"withVotingStateRedirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RealityShowVotingRedirect.map"],"mappings":"A,yLAEA,SAAgBU,EAAqB,EAAU,CAAC,MAAoB,iBAAY,EAAM,IAAmB,gBAAKC,EAAU,CAAC,GAAGC,EAAU,MAAI,qBAAqB,EAAE,CAAC,CAAC,CAAE,C,4CCF6E,SAAgBE,EAAoB,EAAS,CAAsI,MAAM,mCAA/H,CAAC,kCAAkC,iEAAiE,CAAC,CAAC,SAASC,CAAuD,EAAE,UAAU,MAAM,oDAAqD,CAAC,SAAgBC,EAAkB,EAAS,EAAK,CAAC,IAAMC,EAAMC,EAAK,GAAG,CAACD,GAAOA,EAAM,UAAU,IAAM,OAAOA,EAAM,QAAS,UAAU,OAAO,KAAK,IAAME,EAAKC,EAAS,QAAQ,MAAM,EAAE,EAA6F,OAAxFD,IAAOE,GAAQ,CAACJ,EAAM,OAAcK,EAAUH,IAAOG,GAAQL,EAAM,OAAcI,EAAc,IAAK,CACtzB,SAAgBE,EAA8B,EAAI,EAAI,CAAC,IAAIC,EAAO,EAAEC,EAAW,EAAEC,EAAW,GAAUC,EAAUC,EAAiBC,MAAU,CAAC,aAAaF,CAAK,EAAE,EAA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