{"version":3,"file":"OfferSignupForm_1.CjmauaVU.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/bwRz021EYSrSuSdGgf6l/r5QUsy6v9n57ddgLmQdo/OfferSignupForm_1.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import Checkbox from\"https://framer.com/m/Checkbox-6HGi.js@ZCBZmszzxeXzmj9ehrzn\";import CodablePrimaryButton from\"https://framer.com/m/CodablePrimaryButton-hjJA.js@nUxTef7NT42msFVh6UpB\";import PhoneInput from\"https://framer.com/m/PhoneInput-SnSe.js@Ryluk3eKNy5rQbe6I7D0\";import{spacing}from\"https://framer.com/m/Constants-e8LZ.js@WWFLc94a635DVsxeJKyF\";import{useState,useEffect}from\"react\";import{isValidPhoneNumber}from\"libphonenumber-js\";export default function OfferSignupForm(props){const[isSelected,setIsSelected]=useState(false);const[phoneNumber,setPhoneNumber]=useState(\"\");const[phoneError,setPhoneError]=useState(undefined);const[countryCode,setCountryCode]=useState(1);const[fetchedUrlParameters,setFetchedUrlParameters]=useState(false);useEffect(()=>{if(fetchedUrlParameters){return;}const phoneNumberUrlParameter=getPhoneNumberFromUrl();if(phoneNumberUrlParameter?.length>10){if(phoneNumberUrlParameter.startsWith(\"1\")){setCountryCode(1);}else if(phoneNumberUrlParameter.startsWith(\"44\")){setCountryCode(44);}setPhoneNumber(phoneNumberUrlParameter.slice(-10));}},[setFetchedUrlParameters,fetchedUrlParameters,setPhoneNumber]);const handleCheckboxChange=()=>{setIsSelected(!isSelected);};const handlePhoneNumberChange=number=>{setPhoneNumber(number);setPhoneError(undefined);};const handleCountryCodeChange=code=>{setCountryCode(code);};const onSubmit=()=>{const formattedPhoneNumber=\"+\"+countryCode+phoneNumber.replaceAll(\"-\",\"\");if(formattedPhoneNumber.length<12||!isValidPhoneNumber(formattedPhoneNumber)){setPhoneError(\"Please enter a valid phone number\");return;}// Start with the originating parameters\nconst parameters=new URLSearchParams(window.location.search);for(let key of parameters.keys()){// These keys must be removed from the originating parameters\n// The Framer set values take precedence\nif([\"phoneNumber\",\"smsMarketingOptInStatus\",\"redirectDestination\"].includes(key)){parameters.delete(key);}}const framerParameters=new URLSearchParams({phoneNumber:formattedPhoneNumber,partnerName:props.partnerName,promoName:props.promoName,smsMarketingOptInStatus:isSelected?\"true\":\"false\",redirectDestination:props.redirectDestination,membershipType:props.membershipType,userAudience:props.userAudience,utm_content:props.utmContent,utm_medium:props.utmMedium,utm_source:props.utmSource,utm_campaign:props.utmCampaign,utm_term:props.utmTerm,registration_referrer:window.document.referrer,registration_source:props.partnerName,eligibility:props.eligibility,eligibleMessageTemplate:props.messageTemplateEligible,ineligibleMessageTemplate:props.messageTemplateIneligible});for(let[key,val]of framerParameters.entries()){if(val){parameters.append(key,val);}}window.open(\"http://gopuff.com/partner-onboarding-magic-link-confirmation?\"+parameters,\"_self\");};return /*#__PURE__*/_jsxs(\"div\",{style:styles.container,children:[/*#__PURE__*/_jsx(PhoneInput,{onChange:handlePhoneNumberChange,error:phoneError,value:phoneNumber,onCountryCodeChange:handleCountryCodeChange,countryCode:countryCode}),/*#__PURE__*/_jsx(CodablePrimaryButton,{onClick:onSubmit,text:props.buttonText}),props.checkboxText.length>0&&/*#__PURE__*/_jsx(Checkbox,{selected:isSelected,onChange:handleCheckboxChange,text:props.checkboxText})]});}const styles={container:{display:\"flex\",flexDirection:\"column\",gap:spacing.s16,overflow:\"visible\"}};// Props\nOfferSignupForm.defaultProps={checkboxText:\"By submitting, you agree to messaging from Gopuff. Msg & data rates may apply.\",buttonText:\"Get your special offer\",partnerName:undefined,promoName:undefined,membershipType:undefined,userAudience:undefined};addPropertyControls(OfferSignupForm,{buttonText:{title:\"Button Text\",type:ControlType.String},checkboxText:{title:\"Checkbox Text\",type:ControlType.String},partnerName:{title:\"Partner Name\",type:ControlType.Enum,options:[\"Gopuff\",\"Apple\",\"Cash App\",\"Bilt\",\"JetBlue\",\"Goodtime Hotel\",\"NIFT\",\"NYC Apartments\",\"Warehouse Wine and Spirits\",\"BevMo\"]},promoName:{title:\"Promo Name\",type:ControlType.String},membershipType:{title:\"Membership Type\",type:ControlType.Enum,defaultValue:\"none\",options:[\"None\",\"FAM\",\"Student FAM\"]},userAudience:{title:\"User Audience\",type:ControlType.String},redirectDestination:{title:\"Redirect Destination\",type:ControlType.Enum,defaultValue:\"app\",options:[\"app\",\"web\"]},utmContent:{title:\"utm_content\",type:ControlType.String},utmMedium:{title:\"utm_medium\",type:ControlType.String},utmSource:{title:\"utm_source\",type:ControlType.String},utmCampaign:{title:\"utm_campaign\",type:ControlType.String},utmTerm:{title:\"utm_term\",type:ControlType.String},eligibility:{title:\"Eligibility\",type:ControlType.Enum,defaultValue:\"NO_ACCOUNT\",options:[\"NO_ACCOUNT\",\"NEWBIE\",\"ANYONE\"]},messageTemplateEligible:{title:\"Eligibile Message Template\",type:ControlType.String},messageTemplateIneligible:{title:\"Ineligible Message Template\",type:ControlType.String}});function getPhoneNumberFromUrl(){return new URLSearchParams(window.location.search).get(\"phoneNumber\");}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"OfferSignupForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./OfferSignupForm_1.map"],"mappings":"iXAAqiB,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAO,CAAC,EAAY,GAAgBA,EAAS,EAAE,EAAO,CAAC,EAAW,GAAeA,EAAS,IAAA,EAAS,EAAO,CAAC,EAAY,GAAgBA,EAAS,CAAC,EAAO,CAAC,EAAqB,GAAyBA,EAAS,EAAK,EAGiG,OAH/F,MAAc,CAAC,GAAG,EAAsB,OAAQ,IAAM,EAAwB,EAAsB,EAAK,GAAyB,OAAO,KAAO,EAAwB,WAAW,GAAG,EAAG,EAAe,CAAC,EAAW,EAAwB,WAAW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