{"version":3,"file":"FC_GlobalSmartModalTrigger.aST2R9GA.mjs","names":["useState","e"],"sources":["https:/framerusercontent.com/modules/yyrJsFTT8Nc4QDjkS3EG/w6FTnbKuQdNJPtyPqVgl/FC_GlobalSmartModalTrigger.js"],"sourcesContent":["/*\n * Framer Commerce\n * Confidential and Proprietary - All Rights Reserved\n * Unauthorized use, reproduction, distribution, or disclosure of this\n * source code or any related information is strictly prohibited.\n *\n * This software is the exclusive property of Framer Commerce (\"Company\").\n * It is considered highly confidential and proprietary information.\n *\n * Any use, copying, modification, distribution, or sharing of this software,\n * in whole or in part, without the express written permission of the Company\n * is strictly prohibited and may result in legal action.\n *\n * DISCLAIMER: This software does not provide any express or\n * implied warranties, including, but not limited to, the implied warranties\n * of merchantability and fitness for a particular purpose. In no event shall\n * Framer Commerce be liable for any direct, indirect, incidental, special,\n * exemplary, or consequential damages (including, but not limited to, procurement\n * of substitute goods or services; loss of use, data, or profits; or business\n * interruption) however caused and on any theory of liability, whether in\n * contract, strict liability, or tort (including negligence or otherwise)\n * arising in any way out of the use of this software, even if advised of\n * the possibility of such damage.\n *\n * Any unauthorized possession, use, copying, distribution, or dissemination\n * of this software will be considered a breach of confidentiality and may\n * result in legal action.\n *\n * For inquiries, contact:\n * Framer Commerce\n * Email: hello@framercommerce.com\n *\n * © 2025 Butter Supply Inc. All Rights Reserved.\n */import{jsx as _jsx}from\"react/jsx-runtime\";import React,{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n */export default function FC_GlobalSmartModalTrigger({componentInstance,identifier=\"defaultModal\",whenOpen=true}){// Check if we're in Framer canvas\nconst isFramerCanvas=!window?.shopXtools;const[isModalOpen,setIsModalOpen]=useState(false);// Listen for modal state changes\nuseEffect(()=>{if(isFramerCanvas)return;const handleModalOpen=event=>{if(event.detail.key===identifier){setIsModalOpen(true);}};const handleModalClose=event=>{if(event.detail.key===identifier){setIsModalOpen(false);}};window.addEventListener(\"modal_opened\",handleModalOpen);window.addEventListener(\"modal_closed\",handleModalClose);return()=>{window.removeEventListener(\"modal_opened\",handleModalOpen);window.removeEventListener(\"modal_closed\",handleModalClose);};},[isFramerCanvas,identifier]);const handleClick=e=>{if(isFramerCanvas)return;if(e){e.preventDefault();e.stopPropagation();}// First, set this modal as the current one\nwindow.dispatchEvent(new CustomEvent(\"force_show_modal\",{detail:{key:identifier}}));};// In canvas, always show\n// In browser:\n// - Always show when modal is closed\n// - When modal is open: show if whenOpen is true, hide if whenOpen is false\nif(!isFramerCanvas&&isModalOpen&&!whenOpen)return null;const content=Array.isArray(componentInstance)?componentInstance[0]:componentInstance;if(!content||!/*#__PURE__*/React.isValidElement(content)){return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#666\",fontSize:\"14px\"},children:\"Connect Instance\"});}return /*#__PURE__*/_jsx(\"div\",{style:{height:\"100%\",width:\"100%\"},children:/*#__PURE__*/React.cloneElement(content,{style:{...content.props?.style||{},width:\"100%\",height:\"100%\"},onClick:e=>{handleClick(e);if(content.props?.onClick){content.props.onClick(e);}},role:\"button\",tabIndex:0,onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \"){e.preventDefault();handleClick();}},\"aria-label\":`Open ${identifier} modal`})});}// Add Framer property controls\naddPropertyControls(FC_GlobalSmartModalTrigger,{componentInstance:{type:ControlType.ComponentInstance,title:\"Component\",description:\"Connect to your design on canvas\"},identifier:{type:ControlType.String,title:\"Identifier\",defaultValue:\"defaultModal\",description:\"Unique identifier matching the target Smart Modal\"},whenOpen:{type:ControlType.Boolean,title:\"When Open\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\",description:\"Button visibility when Smart Modal is open.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FC_GlobalSmartModalTrigger\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"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