{"version":3,"file":"Modal_Trigger.C1icL-eo.mjs","names":["useState","useRef","useCallback","__esmMin","init_ssg_sandbox_shims","ne","window","_e","c","init_jsx_runtime","ce","init_npm_react_18_3_1","de","init_framer_Bf4_tcb2","addPropertyControls","ControlType","ModalTrigger","hasBeenTriggered","setHasBeenTriggered","triggerRef","stateRef","_setHasBeenTriggered","newState","showModal","simulateClick","node","triggerOnMouseOut","e","triggerNode","showOnMouseLeave","delayConfig","delay","preventTriggers","button","scrollConfig","initialYCoordBottomOfViewport","body","scrollListener","scrollPositionOfBottomOfViewport","triggerPoint","init_Modal_Trigger"],"sources":["https:/framerusercontent.com/modules/gzlOp32jiotI41qoKAWR/ywWcjLixWUOKtCQdWR5F/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 * @framerIntrinsicHeight 0\n * @framerIntrinsicWidth 0\n */export default function ModalTrigger({showOnMouseLeave,delayConfig,scrollConfig}){const[hasBeenTriggered,setHasBeenTriggered]=useState(false);const triggerRef=useRef(null);// 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;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){var _triggerNode_parentElement;const preventTriggers=()=>_setHasBeenTriggered(true);const button=(_triggerNode_parentElement=triggerNode.parentElement)===null||_triggerNode_parentElement===void 0?void 0:_triggerNode_parentElement.parentElement;if(button){button.addEventListener(\"keyup\",preventTriggers);button.addEventListener(\"mouseup\",preventTriggers);return()=>{window.removeEventListener(\"keyup\",preventTriggers);window.removeEventListener(\"mouseup\",preventTriggers);};}}return;},[]);// 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=>{var _node_parentElement;if((_node_parentElement=node.parentElement)===null||_node_parentElement===void 0?void 0:_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\":{\"framerIntrinsicHeight\":\"0\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"0\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Modal_Trigger.map"],"mappings":"A,6MAGG,SAAwBgB,EAAa,CAAC,mBAAiB,cAAY,gBAAc,CAAC,GAAK,CAACC,EAAiBC,GAAqBlB,EAAS,EAAK,EAAQmB,EAAWlB,EAAO,IAAI,EAGvKmB,EAASnB,EAAOgB,CAAgB,EAAQI,EAAqB,GAA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