{"version":3,"file":"Progressive_Form_Collapse.CBCUIp9T.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/XXYdZZqvHqOR55HSaGQ4/XFeVgRbGHBwOXPAhUOTn/Progressive_Form_Collapse.js"],"sourcesContent":["/**\n * CollapsibleFormStack — Framer Code Override\n *\n * Collapses a Stack to show only the email field until the email is filled.\n * Once the email input has a value, the stack animates to full height (auto).\n *\n * Usage:\n *   1. Apply `withTrackEmail` override to the Email component inside the Stack.\n *   2. Apply `withCollapsibleStack` override to the Stack component.\n *\n * Collapsed height is measured from the DOM via data-framer-name=\"Email\"\n * (Framer sets this attribute on all named components automatically).\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{createElement as _createElement}from\"react\";import{useLayoutEffect,useState}from\"react\";// ============================================================================\n// SHARED STATE\n// Singleton — both HOCs are in the same file so module scope is shared.\n// emailHeight: 0 means \"not yet measured\".\n// ============================================================================\nlet state={emailFilled:false,emailHeight:0};const listeners=new Set;function setState(patch){state={...state,...patch};listeners.forEach(fn=>fn());}// ============================================================================\n// OVERRIDES\n// ============================================================================\n// Basic email format check: something@something.something\nfunction isValidEmail(value){return/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value.trim());}/**\n * Apply to the Email input inside the Stack.\n *\n * Expands the stack when the field contains a valid email address,\n * collapses it again when the value becomes invalid or empty.\n */export function withTrackEmail(Component){return function TrackEmailWrapper(props){const handleValue=value=>{setState({emailFilled:isValidEmail(value)});};return /*#__PURE__*/_jsx(Component,{...props,onValueChange:v=>{handleValue(v);if(typeof props.onValueChange===\"function\"){props.onValueChange(v);}},onChange:e=>{handleValue(typeof e===\"string\"?e:e?.target?.value??\"\");if(typeof props.onChange===\"function\"){props.onChange(e);}}});};}/**\n * Apply to the Stack that wraps the form fields.\n *\n * Uses useLayoutEffect (fires before browser paint) to:\n * - Find [data-framer-name=\"Email\"] in the DOM — Framer adds this automatically\n *   to all named components, no ref forwarding needed.\n * - Measure offsetTop + offsetHeight = bottom edge of email field relative to Stack.\n * - Reset parentElement.scrollTop = 0 so the top of the stack is visible.\n *\n * Renders with visibility:hidden until measured (prevents full-height flash).\n * Uses initial={false} so framer-motion jumps to the animate value on mount\n * with no entrance animation.\n */export function withCollapsibleStack(Component){return function CollapsibleStackWrapper(props){const[,forceUpdate]=useState(0);useLayoutEffect(()=>{// Subscribe to email-fill state changes for future re-renders.\nconst update=()=>forceUpdate(n=>n+1);listeners.add(update);// All DOM mutations are committed before useLayoutEffect fires,\n// so querySelector finds the element immediately.\nconst emailEl=document.querySelector('[data-framer-name=\"Email\"]');if(emailEl){// offsetTop = distance from Stack top (includes any padding/gap).\n// offsetHeight = height of the email field itself.\nconst h=emailEl.offsetTop+emailEl.offsetHeight;if(h>0){// Mutate directly and call forceUpdate once (avoids double render\n// that would happen if we went through setState → listeners).\nstate={...state,emailHeight:h};forceUpdate(n=>n+1);}// Reset scroll on the Stack element so the email field (top) is\n// visible, not the button area (bottom).\nif(emailEl.parentElement){emailEl.parentElement.scrollTop=0;}}return()=>{listeners.delete(update);};},[]);const{emailFilled,emailHeight}=state;// Hold invisible until measured so the user never sees the full-height stack.\n// useLayoutEffect fires before paint, so this is a zero-frame flash in practice.\nif(emailHeight===0){return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style??{},visibility:\"hidden\"}});}return /*#__PURE__*/_createElement(Component,{...props,// key forces a fresh framer-motion mount after measurement so that\n// initial={{ height: emailHeight }} is actually applied — without it,\n// framer-motion would animate from the previous (full) height down to\n// emailHeight, causing the unwanted collapse-on-load animation.\nkey:\"collapsible-measured\",initial:{height:emailHeight},animate:{height:emailFilled?\"auto\":emailHeight},transition:{duration:.4,ease:[.4,0,.2,1]},style:{...props.style??{},overflow:\"hidden\",justifyContent:\"flex-start\"}});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withTrackEmail\":{\"type\":\"reactHoc\",\"name\":\"withTrackEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCollapsibleStack\":{\"type\":\"reactHoc\",\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