{"version":3,"file":"Modal_Trigger.COhMZaVJ.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/gJlYddUQE4fyi82INjMH/UDgfsK95pjGkhzph9N7e/Modal_Trigger.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useCallback,useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerDisableUnlink\n * @framerSupportedLayoutHeight any\n */// To use ModalTrigger, drop it within the component (probably a button) that triggers opening of the modal.\n// It should be nested one level down such that it is a direct child of the button component.\n// To avoid ModalTrigger taking up space in the viewport, set its position to absolute on the canvas.\n// To avoid users keyboard tab selecting the the click Trigger, set the trigger layer's Tab-index to -1.\nconst AGE_GATE_DECISION_SESSION_KEY=\"neft_age_gate_decided_this_session\";const hasAgeGateDecisionThisSession=()=>{if(typeof window===\"undefined\")return false;try{return window.sessionStorage.getItem(AGE_GATE_DECISION_SESSION_KEY)===\"true\";}catch(e){return false;}};const markAgeGateDecisionThisSession=()=>{if(typeof window===\"undefined\")return;try{window.sessionStorage.setItem(AGE_GATE_DECISION_SESSION_KEY,\"true\");}catch(e){// Silently fail if sessionStorage is not available\n}};const isAgeRestrictedPath=()=>{if(typeof window===\"undefined\")return false;return window.location.pathname===\"/age-restricted\";};const isElementVisible=element=>{if(!(element instanceof HTMLElement))return false;if(typeof window===\"undefined\")return false;const style=window.getComputedStyle(element);if(style.display===\"none\"||style.visibility===\"hidden\"||style.opacity===\"0\"){return false;}const rect=element.getBoundingClientRect();return rect.width>0&&rect.height>0;};const findLikelyAgeGateContainerFromButton=button=>{const overlayRoot=button.closest('[role=\"dialog\"], [aria-modal=\"true\"], [data-framer-modal], .framer-overlay, .framer-modal');if(overlayRoot)return overlayRoot;let current=button.parentElement;while(current){if(!isElementVisible(current)){current=current.parentElement;continue;}const rect=current.getBoundingClientRect();if(rect.width>=window.innerWidth*.6&&rect.height>=window.innerHeight*.4){return current;}current=current.parentElement;}return null;};const attemptCloseAgeGateOverlayFallback=yesButtonElement=>{if(typeof document===\"undefined\"||typeof window===\"undefined\")return;const currentYes=document.getElementById(\"popup-btn-yes\");if(!currentYes||!isElementVisible(currentYes))return;const container=findLikelyAgeGateContainerFromButton(yesButtonElement);const closeCandidate=container?.querySelector('[aria-label*=\"close\" i], [data-dismiss], [data-close], button[class*=\"close\" i], [role=\"button\"][aria-label*=\"close\" i]');if(closeCandidate){closeCandidate.dispatchEvent(new MouseEvent(\"click\",{bubbles:true,cancelable:true,button:0}));}else{document.dispatchEvent(new KeyboardEvent(\"keydown\",{key:\"Escape\",bubbles:true,cancelable:true}));document.dispatchEvent(new KeyboardEvent(\"keyup\",{key:\"Escape\",bubbles:true,cancelable:true}));}window.setTimeout(()=>{const yesStillVisible=isElementVisible(document.getElementById(\"popup-btn-yes\"));if(!yesStillVisible)return;const liveContainer=findLikelyAgeGateContainerFromButton(document.getElementById(\"popup-btn-yes\"));if(!liveContainer)return;liveContainer.setAttribute(\"aria-hidden\",\"true\");liveContainer.style.pointerEvents=\"none\";liveContainer.style.visibility=\"hidden\";liveContainer.style.opacity=\"0\";liveContainer.style.display=\"none\";},120);};/**\n * @framerIntrinsicHeight 0\n * @framerIntrinsicWidth 0\n */export default function ModalTrigger({showOnMouseLeave,delayConfig,scrollConfig}){const[hasBeenTriggered,setHasBeenTriggered]=useState(false);const triggerRef=useRef(null);const noRedirectScheduledRef=useRef(false);// Event listeners added in the effect call don't have access to state\n// updates, so we'll use a ref and set both ref.current and state\n// in _setHasBeenTriggered.\nconst stateRef=useRef(hasBeenTriggered);const _setHasBeenTriggered=newState=>{stateRef.current=newState;setHasBeenTriggered(newState);};const showModal=useCallback(node=>{if(stateRef.current)return;if(isAgeRestrictedPath())return;if(hasAgeGateDecisionThisSession())return;simulateClick(node);_setHasBeenTriggered(true);},[]);const triggerOnMouseOut=useCallback(node=>e=>{// You can remove conditions if you'd prefer that the pop-up isn't\n    // triggered by the mouse leaving certain edges of the viewport.\n    if(// Top\n    e.clientY<=0||// Left\n    e.clientX<=0||// Right\n    e.clientX>=window.innerWidth||// Bottom\n    e.clientY>=window.innerHeight){showModal(node);}},[showModal]);// Listen for mouse leaving the viewport if showOnMouseLeave is true\nuseEffect(()=>{const triggerNode=triggerRef.current;if(triggerNode){if(showOnMouseLeave){window.addEventListener(\"mouseout\",triggerOnMouseOut(triggerNode));return()=>window.removeEventListener(\"mouseout\",triggerOnMouseOut(triggerNode));}}return;},[triggerOnMouseOut,showOnMouseLeave,showModal]);// Initialize a timer if showOnDelay is true\nuseEffect(()=>{const triggerNode=triggerRef.current;if(triggerNode){if(delayConfig.showOnDelay){const delay=setTimeout(()=>showModal(triggerNode),delayConfig.delaySeconds*1e3);return()=>clearTimeout(delay);}}return;},[delayConfig.showOnDelay,delayConfig.delaySeconds,showModal]);// Listen for clicks on the button and disable our triggers\n// if the button has been clicked\nuseEffect(()=>{const triggerNode=triggerRef.current;if(triggerNode){const preventTriggers=()=>_setHasBeenTriggered(true);const button=triggerNode.parentElement?.parentElement;if(button){button.addEventListener(\"keyup\",preventTriggers);button.addEventListener(\"mouseup\",preventTriggers);return()=>{button.removeEventListener(\"keyup\",preventTriggers);button.removeEventListener(\"mouseup\",preventTriggers);};}}return;},[]);// Listen for Yes/No decisions without interfering with Framer's own handlers.\nuseEffect(()=>{if(!hasBeenTriggered)return;let focusInterval=null;const fallbackTimeouts=[];const trapFocus=e=>{if(e.key!==\"Tab\")return;const yesButton=document.getElementById(\"popup-btn-yes\");const noButton=document.getElementById(\"popup-btn-no\");if(!yesButton||!noButton)return;const firstElement=yesButton;const lastElement=noButton;const activeElement=document.activeElement;if(e.shiftKey&&activeElement===firstElement){e.preventDefault();lastElement.focus();}else if(!e.shiftKey&&activeElement===lastElement){e.preventDefault();firstElement.focus();}};const handleDecisionCapture=e=>{if(!e.isTrusted)return;const target=e.target;if(!target)return;const yesButton=target.closest(\"#popup-btn-yes\");const noButton=target.closest(\"#popup-btn-no\");if(!yesButton&&!noButton)return;markAgeGateDecisionThisSession();if(yesButton){const timeoutId=window.setTimeout(()=>{attemptCloseAgeGateOverlayFallback(yesButton);},100);fallbackTimeouts.push(timeoutId);}if(noButton&&!isAgeRestrictedPath()&&!noRedirectScheduledRef.current){noRedirectScheduledRef.current=true;window.setTimeout(()=>{window.location.href=\"/age-restricted\";},0);}};document.addEventListener(\"keydown\",trapFocus);document.addEventListener(\"click\",handleDecisionCapture,true);// Focus Yes once buttons are mounted (non-blocking, no event cancellation).\nlet attempts=0;focusInterval=window.setInterval(()=>{attempts+=1;const yesButton=document.getElementById(\"popup-btn-yes\");if(yesButton){yesButton.focus();if(focusInterval!==null){window.clearInterval(focusInterval);focusInterval=null;}return;}if(attempts>=12&&focusInterval!==null){window.clearInterval(focusInterval);focusInterval=null;}},100);return()=>{document.removeEventListener(\"keydown\",trapFocus);document.removeEventListener(\"click\",handleDecisionCapture,true);if(focusInterval!==null){window.clearInterval(focusInterval);}for(const timeoutId of fallbackTimeouts){window.clearTimeout(timeoutId);}};},[hasBeenTriggered]);// Listen for scroll if showOnScrollToPercentage is true\nuseEffect(()=>{if(scrollConfig.showOnScrollToPercentage){const initialYCoordBottomOfViewport=window.scrollY+window.innerHeight;const triggerNode=triggerRef.current;const body=document.querySelector(\"body\");if(triggerNode&&body){const scrollListener=()=>{const scrollPositionOfBottomOfViewport=window.scrollY+window.innerHeight;const triggerPoint=body.scrollHeight*scrollConfig.scrollPercentage/100;if(scrollPositionOfBottomOfViewport>=triggerPoint&&// Don't trigger if the user started below the trigger point\n// (this could happen after a refresh)\ninitialYCoordBottomOfViewport<triggerPoint){showModal(triggerNode);}};window.addEventListener(\"scroll\",scrollListener);return()=>window.removeEventListener(\"scroll\",scrollListener);}}return;},[scrollConfig.showOnScrollToPercentage,scrollConfig.scrollPercentage,showModal]);// It would be nice to aria-hide the container that Framer\n// wraps this in, but that would only be possible on the canvas\n// and it's not!\nreturn /*#__PURE__*/_jsx(\"div\",{ref:triggerRef,\"aria-hidden\":\"true\"});}// If this component breaks, it could be because Framer has decided to not wrap\n// code components in containers anymore. If that's the case, access\n// node.parentElement instead of node.parentElement.parentElement\nconst simulateClick=node=>{if(node.parentElement?.parentElement){const button=node.parentElement.parentElement;button.dispatchEvent(new FocusEvent(\"focus\"));button.dispatchEvent(new KeyboardEvent(\"keydown\",{key:\"Enter\"}));button.dispatchEvent(new KeyboardEvent(\"keyup\",{key:\"Enter\"}));}};addPropertyControls(ModalTrigger,{showOnMouseLeave:{type:ControlType.Boolean,title:\"MouseLeave\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},delayConfig:{type:ControlType.Object,title:\"Delay\",buttonTitle:\"Configure\",controls:{showOnDelay:{type:ControlType.Boolean,title:\"Trigger\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},delaySeconds:{type:ControlType.Number,title:\"Seconds\",defaultValue:10,min:0,max:300,step:5,displayStepper:true,unit:\" s\"}}},scrollConfig:{type:ControlType.Object,title:\"Scroll\",buttonTitle:\"Configure\",controls:{showOnScrollToPercentage:{type:ControlType.Boolean,title:\"Trigger\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},scrollPercentage:{type:ControlType.Number,title:\"Scroll %\",defaultValue:50,min:0,max:100,step:1,displayStepper:true,unit:\" %\"}}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ModalTrigger\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"0\",\"framerIntrinsicWidth\":\"0\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Modal_Trigger.map"],"mappings":"6MAYG,SAAwB,EAAa,CAAC,mBAAiB,cAAY,gBAAc,CAAC,GAAK,CAAC,EAAiB,GAAqBA,EAAS,EAAK,EAAQ,EAAWC,EAAO,IAAI,EAAQ,EAAuBA,EAAO,EAAK,EAGlN,EAASA,EAAO,CAAgB,EAAQ,EAAqB,GAAU,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