{"version":3,"file":"ZipInput.DP3xiFJj.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/chOc6IfrBq8BCh0oTyvq/shLkOC8vGvQW6JA1AJiP/ZipInput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/*────────────────── Load DM Sans (browser only) ──────────────────*/if(typeof window!==\"undefined\"&&typeof document!==\"undefined\"){const dmSans=document.createElement(\"link\");dmSans.href=\"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;600&display=swap\";dmSans.rel=\"stylesheet\";document.head.appendChild(dmSans);}/*────────────────── Component ──────────────────*/export default function ZipInput({placeholder,buttonText,buttonHeight,fontColor,disabledFontColor,inputName,buttonLayout,fieldGap,inputBorderColor,errorBorderColor=\"#E53935\",errorTextColor=\"#E53935\",requireZip,redirectUrl}){const[zip,setZip]=useState(\"\");const[isZipValid,setIsZipValid]=useState(false);const[hasError,setHasError]=useState(false);const showDesktop=buttonLayout===\"Desktop\";const showMobile=buttonLayout===\"Mobile\";/*────────────── Handlers ─────────────*/const handleChange=e=>{const v=e.target.value.replace(/\\D/g,\"\").slice(0,5);setZip(v);setIsZipValid(v.length===5);if(hasError)setHasError(false);};const handleSubmit=()=>{if(requireZip&&!isZipValid){setHasError(true);return;}if(typeof window!==\"undefined\"){if(isZipValid){localStorage.setItem(\"zipCode\",zip);}try{const currentUrl=new URL(window.location.href);const targetUrl=redirectUrl.startsWith(\"http\")?new URL(redirectUrl):new URL(redirectUrl,currentUrl.origin);// Merge current search params into target without overwriting existing ones\ncurrentUrl.searchParams.forEach((value,key)=>{if(!targetUrl.searchParams.has(key)){targetUrl.searchParams.append(key,value);}});// Preserve hash if target doesn't already define one\nif(!targetUrl.hash&&currentUrl.hash){targetUrl.hash=currentUrl.hash;}window.location.href=targetUrl.toString();}catch{// Fallback: best-effort concat\nconst{search,hash}=window.location;const safeSearch=search&&redirectUrl.includes(\"?\")?search.replace(/^\\?/,\"&\"):search;window.location.href=`${redirectUrl}${safeSearch}${hash}`;}}};/*────────────── Styles ─────────────*/const fieldWrap={display:\"flex\",flexDirection:showDesktop?\"row\":\"column\",alignItems:showDesktop?\"center\":\"stretch\",width:\"100%\",gap:showDesktop?`${fieldGap}px`:\"0px\"};const inputWrap={position:\"relative\",display:\"flex\",alignItems:\"center\",padding:\"1px\",border:`2px solid ${hasError?errorBorderColor:inputBorderColor}`,backgroundColor:\"white\",width:\"100%\",boxSizing:\"border-box\",transition:\"border-color .2s\"};const btnBase={padding:\"10px 20px\",margin:\"3px 0\",fontSize:\"16px\",backgroundColor:\"#F7C325\",border:\"none\",borderRadius:\"0px\",cursor:\"pointer\",height:buttonHeight,whiteSpace:\"nowrap\",fontFamily:\"DM Sans, sans-serif\",fontWeight:600,color:isZipValid||!requireZip?fontColor:disabledFontColor,transition:\"background-color .3s\"};const desktopBtn={...btnBase,display:showDesktop?\"block\":\"none\"};const mobileBtn={...btnBase,margin:\"4px 0 0 0\",display:showMobile?\"block\":\"none\"};// removed info message UI\n/*────────────── Render ─────────────*/return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\"},children:/*#__PURE__*/_jsxs(\"div\",{style:fieldWrap,children:[/*#__PURE__*/_jsxs(\"div\",{style:inputWrap,children:[/*#__PURE__*/_jsx(\"div\",{style:{width:20,height:20,position:\"absolute\",left:10},dangerouslySetInnerHTML:{__html:`\n                                <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\"\n                                     xmlns=\"http://www.w3.org/2000/svg\">\n                                  <path d=\"M9 21V13.6C9 13.0399 9 12.7599 9.109\n                                           12.546C9.20487 12.3578 9.35785 12.2049\n                                           9.54601 12.109C9.75993 12 10.04 12\n                                           10.6 12H13.4C13.9601 12 14.2401 12\n                                           14.454 12.109C14.6422 12.2049\n                                           14.7951 12.3578 14.891 12.546C15\n                                           12.7599 15 13.0399 15 13.6V21M2\n                                           9.5L11.04 2.72C11.3843 2.46181\n                                           11.5564 2.33271 11.7454 2.28294C11.9123\n                                           2.23902 12.0877 2.23902 12.2546\n                                           2.28295C12.4436 2.33271 12.6157\n                                           2.46181 12.96 2.72L22 9.5M4 8V17.8C4\n                                           18.9201 4 19.4802 4.21799 19.908C4.40974\n                                           20.2843 4.7157 20.5903 5.09202 20.782C5.51985\n                                           21 6.0799 21 7.2 21H16.8C17.9201 21\n                                           18.4802 21 18.908 20.782C19.2843 20.5903\n                                           19.5903 20.2843 19.782 19.908C20\n                                           19.4802 20 18.9201 20 17.8V8L13.92\n                                           3.44C13.2315 2.92361 12.8872\n                                           2.66542 12.5091 2.56589C12.1754 2.47804\n                                           11.8246 2.47804 11.4909 2.56589C11.1128\n                                           2.66542 10.7685 2.92361 10.08\n                                           3.44L4 8Z\" stroke=\"#757575\" stroke-width=\"1.5\"\n                                           stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n                                </svg>\n                            `}}),/*#__PURE__*/_jsx(\"input\",{name:inputName,type:\"text\",placeholder:placeholder,value:zip,onChange:handleChange,inputMode:\"numeric\",maxLength:5,style:{flex:1,padding:\"10px 12px 10px 40px\",fontSize:16,border:\"none\",fontFamily:\"DM Sans, sans-serif\",outline:\"none\"}})]}),/*#__PURE__*/_jsx(\"button\",{style:desktopBtn,onClick:handleSubmit,onMouseOver:e=>e.currentTarget.style.backgroundColor=\"#FFEB3B\",onMouseOut:e=>e.currentTarget.style.backgroundColor=\"#F7C325\",children:buttonText}),/*#__PURE__*/_jsx(\"button\",{style:mobileBtn,onClick:handleSubmit,onMouseOver:e=>e.currentTarget.style.backgroundColor=\"#f9ee8a\",onMouseOut:e=>e.currentTarget.style.backgroundColor=\"#F7C325\",children:buttonText})]})});}/*────────────────── Default Props ──────────────────*/ZipInput.defaultProps={placeholder:\"Enter ZIP Code\",buttonText:\"Get Quotes\",buttonHeight:45,fontColor:\"#102B49\",disabledFontColor:\"#102B49\",inputName:\"zip-input\",buttonLayout:\"Desktop\",fieldGap:10,inputBorderColor:\"#383838\",errorBorderColor:\"#E53935\",errorTextColor:\"#E53935\",requireZip:true,redirectUrl:\"/forms/roof_zip_form\"};/*────────────────── Property Controls ──────────────────*/addPropertyControls(ZipInput,{placeholder:{title:\"Placeholder\",type:ControlType.String},buttonText:{title:\"Button Text\",type:ControlType.String},fontColor:{title:\"Font Color\",type:ControlType.Color},disabledFontColor:{title:\"Disabled Font Color\",type:ControlType.Color},inputName:{title:\"Input Name\",type:ControlType.String},buttonLayout:{title:\"Button Layout\",type:ControlType.Enum,options:[\"Desktop\",\"Mobile\"],optionTitles:[\"Desktop Only\",\"Mobile Only\"],defaultValue:\"Desktop\"},buttonHeight:{title:\"Button Height (px)\",type:ControlType.Number,defaultValue:45,min:32,max:80,step:1,displayStepper:true},fieldGap:{title:\"Field Gap (px)\",type:ControlType.Number,defaultValue:10,min:0,max:48,step:1,displayStepper:true},inputBorderColor:{title:\"Border Color\",type:ControlType.Color,defaultValue:\"#383838\"},errorBorderColor:{title:\"Error Border\",type:ControlType.Color,defaultValue:\"#E53935\"},errorTextColor:{title:\"Error Text\",type:ControlType.Color,defaultValue:\"#E53935\"},requireZip:{title:\"Require ZIP to Continue\",type:ControlType.Boolean,defaultValue:true},redirectUrl:{title:\"Redirect URL\",type:ControlType.String,defaultValue:\"/forms/roof_zip_form\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ZipInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ZipInput.map"],"mappings":"iTAAggB,SAAwB,EAAS,CAAC,cAAY,aAAW,eAAa,YAAU,oBAAkB,YAAU,eAAa,WAAS,mBAAiB,mBAAiB,UAAU,iBAAe,UAAU,aAAW,eAAa,CAAC,GAAK,CAAC,EAAI,GAAQA,EAAS,GAAG,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAA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