{"version":3,"file":"TrackingButton.DExD2QER.mjs","names":["useState","startTransition"],"sources":["https:/framerusercontent.com/modules/oO32ybxKmjv32HTGMnHb/bRY9OEWPVRyjfZJ25nfH/TrackingButton.js"],"sourcesContent":["// Button with Google Sheets tracking via URL parameters\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,startTransition}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function TrackingButton(props){const{label=\"Click Me\",redirectUrl=\"https://example.com\",googleScriptUrl=\"\",buttonId=\"button-1\",backgroundColor=\"#0099FF\",textColor=\"#FFFFFF\",hoverColor=\"#0077CC\",font,borderRadius=8,padding=\"12px 24px\",testMode=false}=props;const[isHovered,setIsHovered]=useState(false);const[isLoading,setIsLoading]=useState(false);const handleClick=async e=>{e.preventDefault();if(typeof window===\"undefined\")return;const urlParams=new URLSearchParams(window.location.search);const name=testMode?\"check check\":urlParams.get(\"Name\")||\"\";const phone=testMode?\"check check\":urlParams.get(\"Phone\")||\"\";const jobTitle=testMode?\"check check\":urlParams.get(\"Job Title\")||\"\";console.log(\"Button clicked:\",{name,phone,jobTitle,buttonId,testMode});startTransition(()=>setIsLoading(true));try{if(googleScriptUrl){const params=new URLSearchParams({Name:name,Phone:phone,\"Job Title\":jobTitle,buttonId,timestamp:new Date().toISOString()});const fullUrl=`${googleScriptUrl}?${params.toString()}`;console.log(\"Sending to Google Sheets:\",fullUrl);await fetch(fullUrl,{method:\"GET\",mode:\"no-cors\"});console.log(\"Request sent successfully\");}else{console.warn(\"No Google Script URL provided\");}if(testMode){alert(\"Test data sent! Check your Google Sheet.\\nData: \"+JSON.stringify({name,phone,jobTitle,buttonId}));startTransition(()=>setIsLoading(false));return;}const redirectUrlObj=new URL(redirectUrl);if(name)redirectUrlObj.searchParams.set(\"Name\",name);if(phone)redirectUrlObj.searchParams.set(\"Phone\",phone);if(jobTitle)redirectUrlObj.searchParams.set(\"Job Title\",jobTitle);console.log(\"Redirecting to:\",redirectUrlObj.toString());setTimeout(()=>{window.location.href=redirectUrlObj.toString();},500);}catch(error){console.error(\"Tracking error:\",error);if(testMode){alert(\"Error sending data: \"+error.message);startTransition(()=>setIsLoading(false));return;}const redirectUrlObj=new URL(redirectUrl);if(name)redirectUrlObj.searchParams.set(\"Name\",name);if(phone)redirectUrlObj.searchParams.set(\"Phone\",phone);if(jobTitle)redirectUrlObj.searchParams.set(\"Job Title\",jobTitle);window.location.href=redirectUrlObj.toString();}};return /*#__PURE__*/_jsx(\"button\",{onClick:handleClick,onMouseEnter:()=>startTransition(()=>setIsHovered(true)),onMouseLeave:()=>startTransition(()=>setIsHovered(false)),disabled:isLoading,style:{...props.style,position:\"relative\",backgroundColor:isHovered?hoverColor:backgroundColor,color:textColor,border:\"none\",borderRadius,padding,cursor:isLoading?\"wait\":\"pointer\",transition:\"all 0.2s ease\",opacity:isLoading?.7:1,transform:isHovered?\"scale(1.05)\":\"scale(1)\",...font,display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:isLoading?\"Processing...\":label});}addPropertyControls(TrackingButton,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Click Me\"},testMode:{type:ControlType.Boolean,title:\"Test Mode\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\",description:\"Send 'check check' test data without redirecting\"},redirectUrl:{type:ControlType.String,title:\"Redirect URL\",defaultValue:\"https://example.com\",placeholder:\"https://example.com/page\"},googleScriptUrl:{type:ControlType.String,title:\"Google Script URL\",defaultValue:\"\",placeholder:\"Paste your Apps Script web app URL\",displayTextArea:true},buttonId:{type:ControlType.String,title:\"Button ID\",defaultValue:\"button-1\",description:\"Unique identifier for this button\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#0099FF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#0077CC\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"16px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:50,step:1},padding:{type:ControlType.String,title:\"Padding\",defaultValue:\"12px 24px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TrackingButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TrackingButton.map"],"mappings":"+LAIG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,WAAW,cAAY,sBAAsB,kBAAgB,GAAG,WAAS,WAAW,kBAAgB,UAAU,YAAU,UAAU,aAAW,UAAU,OAAK,eAAa,EAAE,UAAQ,YAAY,WAAS,IAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAsvD,OAAoB,EAAK,SAAS,CAAC,QAAtwD,KAAM,IAAG,CAAoB,GAAnB,EAAE,gBAAgB,CAAW,IAAS,OAAY,OAAO,IAAM,EAAU,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAO,EAAK,EAAS,cAAc,EAAU,IAAI,OAAO,EAAE,GAAS,EAAM,EAAS,cAAc,EAAU,IAAI,QAAQ,EAAE,GAAS,EAAS,EAAS,cAAc,EAAU,IAAI,YAAY,EAAE,GAAG,QAAQ,IAAI,kBAAkB,CAAC,OAAK,QAAM,WAAS,WAAS,WAAS,CAAC,CAAC,MAAoB,EAAa,GAAK,CAAC,CAAC,GAAG,CAAC,GAAG,EAAgB,CAA4H,IAAM,EAAQ,GAAG,EAAgB,GAA/I,IAAI,gBAAgB,CAAC,KAAK,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