{"version":3,"file":"OpenClosebot.CIaMBRIS.mjs","names":["React.useRef","React.useCallback"],"sources":["https:/framerusercontent.com/modules/C2yxqnrMjD2iZ67U5dZo/DmdGhGH8gn9sdkNnJ0uL/OpenClosebot.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{forwardRef}from\"react\";function clickClosebotButton(){if(typeof window===\"undefined\"||typeof document===\"undefined\")return false;const chatButton=document.querySelector(\"button.cb-btn\");if(chatButton instanceof HTMLElement){chatButton.click();return true;}return false;}export function OpenClosebot(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const retryTimeoutRef=React.useRef(null);const clearRetryTimeout=React.useCallback(()=>{if(retryTimeoutRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(retryTimeoutRef.current);retryTimeoutRef.current=null;}},[]);React.useEffect(()=>clearRetryTimeout,[clearRetryTimeout]);const openClosebot=React.useCallback(()=>{if(clickClosebotButton())return;if(typeof window===\"undefined\")return;clearRetryTimeout();retryTimeoutRef.current=window.setTimeout(()=>{retryTimeoutRef.current=null;clickClosebotButton();},300);},[clearRetryTimeout]);const handleClick=React.useCallback(event=>{if(event?.preventDefault)event.preventDefault();if(typeof props.onClick===\"function\"){props.onClick(event);}openClosebot();},[openClosebot,props]);const handleKeyDown=React.useCallback(event=>{if(typeof props.onKeyDown===\"function\"){props.onKeyDown(event);}if(event.defaultPrevented)return;if(event.key===\"Enter\"||event.key===\" \"){event.preventDefault();openClosebot();}},[openClosebot,props]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClick,onKeyDown:handleKeyDown});});}\nexport const __FramerMetadata__ = {\"exports\":{\"OpenClosebot\":{\"type\":\"reactHoc\",\"name\":\"OpenClosebot\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./OpenClosebot.map"],"mappings":"qJAAqG,SAAS,GAAqB,CAAC,GAAU,IAAS,QAAa,OAAO,S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