{"version":3,"file":"IntercomVisibility.B6OTdo-e.mjs","names":["useMemo"],"sources":["https:/framerusercontent.com/modules/mcfx6yN3q1r3pKM4Kucy/vYVtJ9epjrEY6B3bGUJT/IntercomVisibility.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useMemo}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";function injectIntercomFadeStyle(){try{const styleId=\"sc-intercom-fade-style\";if(document.getElementById(styleId))return;const style=document.createElement(\"style\");style.id=styleId;style.textContent=`\n            #intercom-container,\n            .intercom-lightweight-app,\n            .intercom-launcher-frame,\n            .intercom-launcher {\n                transition: opacity 220ms cubic-bezier(0.22, 0.61, 0.36, 1) !important;\n            }\n            html.sc-hide-intercom #intercom-container,\n            html.sc-hide-intercom .intercom-lightweight-app,\n            html.sc-hide-intercom .intercom-launcher-frame,\n            html.sc-hide-intercom .intercom-launcher,\n            html.sc-hide-intercom-manual #intercom-container,\n            html.sc-hide-intercom-manual .intercom-lightweight-app,\n            html.sc-hide-intercom-manual .intercom-launcher-frame,\n            html.sc-hide-intercom-manual .intercom-launcher {\n                opacity: 0 !important;\n                pointer-events: none !important;\n            }\n        `;document.head.appendChild(style);}catch{}}function setIntercomLauncherHidden(hidden){try{const IntercomFn=window.Intercom;if(typeof IntercomFn===\"function\"){IntercomFn(\"update\",{hide_default_launcher:hidden,hideDefaultLauncher:hidden});}}catch{}}function isMobile(){try{if(typeof window===\"undefined\")return false;const byUA=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent);const byMQ=window.matchMedia&&window.matchMedia(\"(max-width: 768px)\").matches;return byUA||byMQ;}catch{return false;}}export default function IntercomVisibilityController(props){const{action=\"hide\",delayMs=0,scope=\"both\",respectPreloader=true}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const deviceAllowed=useMemo(()=>{if(scope===\"both\")return true;if(scope===\"desktop\")return!isMobile();if(scope===\"mobile\")return isMobile();return true;},[scope]);useEffect(()=>{if(isCanvas)return;if(!deviceAllowed)return;injectIntercomFadeStyle();let timeout=null;let observer=null;let keepAlive=null;const applyHide=()=>{const html=document.documentElement;html.classList.add(\"sc-hide-intercom\");html.classList.add(\"sc-hide-intercom-manual\");setIntercomLauncherHidden(true);};const applyShow=()=>{const html=document.documentElement;html.classList.remove(\"sc-hide-intercom-manual\");html.classList.remove(\"sc-hide-intercom\");setIntercomLauncherHidden(false);};const run=()=>{const html=document.documentElement;const preloaderActive=html.classList.contains(\"sc-hide-intercom\");if(action===\"hide\"){applyHide();// Ensure persistence even if another script toggles the class (e.g., preloader finishing)\nobserver=new MutationObserver(()=>{const htmlNow=document.documentElement;const manual=htmlNow.classList.contains(\"sc-hide-intercom-manual\");const active=htmlNow.classList.contains(\"sc-hide-intercom\");if(manual&&!active){htmlNow.classList.add(\"sc-hide-intercom\");setIntercomLauncherHidden(true);}});observer.observe(document.documentElement,{attributes:true,attributeFilter:[\"class\"]});// Brief keep-alive to override late Intercom updates\nkeepAlive=window.setInterval(()=>setIntercomLauncherHidden(true),1e3);setTimeout(()=>{if(keepAlive){window.clearInterval(keepAlive);keepAlive=null;}},4e3);return;}// action === \"show\"\nif(respectPreloader&&preloaderActive){// wait until preloader (or other controller) releases the class\nobserver=new MutationObserver(()=>{const stillActive=html.classList.contains(\"sc-hide-intercom\")||html.classList.contains(\"sc-hide-intercom-manual\");if(!stillActive){applyShow();observer?.disconnect();observer=null;}});observer.observe(html,{attributes:true,attributeFilter:[\"class\"]});}else{applyShow();}};timeout=window.setTimeout(run,Math.max(0,Number(delayMs)||0));return()=>{if(timeout)window.clearTimeout(timeout);if(observer)observer.disconnect();if(keepAlive)window.clearInterval(keepAlive);};},[action,delayMs,scope,deviceAllowed,isCanvas,respectPreloader]);// Canvas placeholder for discoverability/debug\nif(isCanvas){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",background:\"transparent\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",fontSize:10,fontFamily:\"system-ui, -apple-system, sans-serif\",color:\"#888\",border:\"1px dashed rgba(0,0,0,0.1)\"},children:\"Intercom Visibility\"});}// Invisible controller at runtime\nreturn /*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",width:1,height:1,opacity:0,pointerEvents:\"none\",userSelect:\"none\",zIndex:-9999},\"aria-hidden\":\"true\"});}IntercomVisibilityController.displayName=\"Intercom Visibility Controller\";addPropertyControls(IntercomVisibilityController,{action:{type:ControlType.Enum,title:\"Action\",options:[\"hide\",\"show\"],optionTitles:[\"Hide\",\"Show\"],defaultValue:\"hide\"},delayMs:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,step:50,unit:\"ms\",displayStepper:true,description:\"Wait this long after page load before applying\"},scope:{type:ControlType.Enum,title:\"Scope\",options:[\"both\",\"desktop\",\"mobile\"],optionTitles:[\"Both\",\"Desktop\",\"Mobile\"],defaultValue:\"both\"},respectPreloader:{type:ControlType.Boolean,title:\"Respect Preloader\",defaultValue:true,description:\"Never override preloader while it is hiding Intercom\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"IntercomVisibilityController\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./IntercomVisibility.map"],"mappings":"wMAAiJ,SAAS,GAAyB,CAAC,GAAG,CAAC,IAAM,EAAQ,yBAAyB,GAAG,SAAS,eAAe,CAAO,EAAE,OAAO,IAAM,EAAM,SAAS,cAAc,OAAO,EAAE,EAAM,GAAG,EAAQ,EAAM,YAAY;;;;;;;;;;;;;;;;;;UAkB/U,SAAS,KAAK,YAAY,CAAK,CAAE,MAAM,CAAC,CAAC,CAAC,SAAS,EAA0B,EAAO,CAAC,GAAG,CAAC,IAAM,EAAW,EAAO,SAAY,OAAO,GAAa,YAAY,EAAW,SAAS,CAAC,sBAAsB,EAAO,oBAAoB,CAAM,CAAC,CAAG,MAAM,CAAC,CAAC,CAAC,SAAS,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