{"version":3,"file":"CopyEmailButton.pJKfG4_L.mjs","names":["useState","useRef","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/ZajOnz9UV9HXMSYw1bVo/CQXSrJjnz5zelyXnKze9/CopyEmailButton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useCallback,useEffect,useMemo,useRef,useState,startTransition}from\"react\";/**\n * @framerIntrinsicWidth 220\n * @framerIntrinsicHeight 44\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CopyEmailButton(props){const{email=\"hello@company.com\",label=\"Copy email\",copiedLabel=\"Copied\",errorLabel=\"Copy failed\",copiedDurationMs=1200,font,backgroundColor=\"#FFFFFF\",backgroundHoverColor=\"#F5F5F5\",textColor=\"#000000\",textHoverColor=\"#000000\",border,borderHoverColor=\"#CCCCCC\",borderRadius=\"12px\",padding=\"12px 16px\",shadow=\"0 6px 18px rgba(0,0,0,0.10)\",disabled=false,style}=props;const isStatic=useIsStaticRenderer();const[hovered,setHovered]=useState(false);const[state,setState]=useState(\"idle\");const timerRef=useRef(null);useEffect(()=>{return()=>{if(timerRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(timerRef.current);timerRef.current=null;}};},[]);const canCopy=useMemo(()=>{if(disabled)return false;if(!email||!email.trim())return false;return true;},[disabled,email]);const copyText=useCallback(async text=>{if(typeof window===\"undefined\")return false;try{const nav=window.navigator;if(nav?.clipboard?.writeText){await nav.clipboard.writeText(text);return true;}}catch{// fall through to legacy path\n}try{const ta=document.createElement(\"textarea\");ta.value=text;ta.setAttribute(\"readonly\",\"\");ta.style.position=\"fixed\";ta.style.top=\"-9999px\";ta.style.left=\"-9999px\";ta.style.opacity=\"0\";document.body.appendChild(ta);ta.focus();ta.select();const ok=document.execCommand(\"copy\");document.body.removeChild(ta);return ok;}catch{return false;}},[]);const handleClick=useCallback(async()=>{if(!canCopy)return;if(timerRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(timerRef.current);timerRef.current=null;}const ok=await copyText(email);startTransition(()=>setState(ok?\"copied\":\"error\"));if(typeof window!==\"undefined\"){timerRef.current=window.setTimeout(()=>{startTransition(()=>setState(\"idle\"));timerRef.current=null;},Math.max(250,copiedDurationMs));}},[canCopy,copyText,email,copiedDurationMs]);const labelText=useMemo(()=>{if(state===\"copied\")return copiedLabel;if(state===\"error\")return errorLabel;return label;},[state,label,copiedLabel,errorLabel]);const bg=useMemo(()=>{if(!canCopy)return backgroundColor;if(hovered)return backgroundHoverColor;return backgroundColor;},[canCopy,hovered,backgroundColor,backgroundHoverColor]);const fg=useMemo(()=>{if(!canCopy)return textColor;if(hovered)return textHoverColor;return textColor;},[canCopy,hovered,textColor,textHoverColor]);const effectiveBorder=useMemo(()=>{if(!border)return border;if(!canCopy)return border;if(!hovered)return border;return{...border,borderColor:borderHoverColor};},[border,canCopy,hovered,borderHoverColor]);const isFullWidth=!!style&&style.width===\"100%\";const isFullHeight=!!style&&style.height===\"100%\";return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",minWidth:\"max-content\",minHeight:\"max-content\"},children:/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:isStatic?undefined:handleClick,onMouseEnter:isStatic?undefined:()=>{startTransition(()=>setHovered(true));},onMouseLeave:isStatic?undefined:()=>{startTransition(()=>setHovered(false));},onFocus:isStatic?undefined:()=>{// keep hover styles on keyboard focus\nstartTransition(()=>setHovered(true));},onBlur:isStatic?undefined:()=>{startTransition(()=>setHovered(false));},disabled:!canCopy||isStatic,\"aria-label\":`Copy email ${email}`,style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",minWidth:\"max-content\",minHeight:\"max-content\",boxSizing:\"border-box\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",gap:10,cursor:canCopy&&!isStatic?\"pointer\":\"not-allowed\",userSelect:\"none\",WebkitTapHighlightColor:\"transparent\",background:bg,color:fg,padding,borderRadius,...effectiveBorder??{},boxShadow:shadow,transition:\"background-color 160ms ease, color 160ms ease, border-color 160ms ease\",opacity:canCopy?1:.6,outline:\"none\",...font},children:/*#__PURE__*/_jsx(\"span\",{style:{minWidth:\"max-content\",whiteSpace:\"nowrap\",overflow:\"hidden\",textOverflow:\"ellipsis\",lineHeight:\"normal\"},children:labelText})})});}addPropertyControls(CopyEmailButton,{email:{type:ControlType.String,title:\"Email\",defaultValue:\"hello@company.com\",placeholder:\"name@domain.com\"},label:{type:ControlType.String,title:\"Text\",defaultValue:\"Copy email\"},copiedLabel:{type:ControlType.String,title:\"Copied Text\",defaultValue:\"Copied\"},errorLabel:{type:ControlType.String,title:\"Error Text\",defaultValue:\"Copy failed\"},copiedDurationMs:{type:ControlType.Number,title:\"Copied Duration\",defaultValue:1200,min:250,max:6e3,step:50,unit:\"ms\"},disabled:{type:ControlType.Boolean,title:\"Disabled\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},backgroundColor:{type:ControlType.Color,title:\"Button\",defaultValue:\"#FFFFFF\"},backgroundHoverColor:{type:ControlType.Color,title:\"Button Hover\",defaultValue:\"#F5F5F5\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},textHoverColor:{type:ControlType.Color,title:\"Text Hover\",defaultValue:\"#000000\"},border:{type:ControlType.Border,title:\"Border\",optional:true,defaultValue:{borderWidth:1,borderStyle:\"solid\",borderColor:\"#EEEEEE\"}},borderHoverColor:{type:ControlType.Color,title:\"Border Hover\",defaultValue:\"#CCCCCC\"},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"12px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"12px 16px\"},shadow:{type:ControlType.BoxShadow,title:\"Shadow\",defaultValue:\"0 6px 18px rgba(0,0,0,0.10)\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyEmailButton\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"220\",\"framerIntrinsicHeight\":\"44\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyEmailButton.map"],"mappings":"mOAMG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,oBAAoB,QAAM,aAAa,cAAY,SAAS,aAAW,cAAc,mBAAiB,KAAK,OAAK,kBAAgB,UAAU,uBAAqB,UAAU,YAAU,UAAU,iBAAe,UAAU,SAAO,mBAAiB,UAAU,eAAa,OAAO,UAAQ,YAAY,SAAO,8BAA8B,WAAS,GAAM,SAAO,EAAY,EAAS,GAAqB,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,OAAO,CAAO,EAASC,EAAO,KAAK,CAAC,UAAyB,CAAI,EAAS,UAAU,MAAa,IAAS,SAAa,EAAO,aAAa,EAAS,QAAQ,CAAC,EAAS,QAAQ,OAAU,EAAE,CAAC,CAAC,IAAM,EAAQC,MAAsC,EAAtB,GAAyB,CAAC,GAAO,CAAC,EAAM,MAAM,EAA4B,CAAC,EAAS,EAAM,CAAC,CAAO,EAASC,EAAY,KAAM,IAAM,CAAC,GAAU,IAAS,OAAY,MAAO,GAAM,GAAG,CAAC,IAAM,EAAI,EAAO,UAAU,GAAG,GAAK,WAAW,UAA+C,OAApC,MAAM,EAAI,UAAU,UAAU,EAAK,CAAQ,QAAY,EAC1gC,GAAG,CAAC,IAAM,EAAG,SAAS,cAAc,WAAW,CAAC,EAAG,MAAM,EAAK,EAAG,aAAa,WAAW,GAAG,CAA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