{"version":3,"file":"EmailForm.DXcNPynC.mjs","names":["useState","useRef","useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/EoOhFa7ssLXW8f40DiWo/FiW4tdibvHgWAZXZLA6g/EmailForm.js"],"sourcesContent":["// Welcome to Code in Framer\n// Get Started: https://www.framer.com/developers/\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useCallback,useState,useRef}from\"react\";import{useFontControls,fontControls}from\"https://framer.com/m/framer/default-utils.js@^0.45.0\";/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function EmailForm(props){// This is a React component containing an Example component\n// - Replace <Example /> with your own code\n// - Find inspiration: https://www.framer.com/developers/\nconst promocode=window&&new URLSearchParams(window.location.search).get(\"promocode\")||\"\";const assetId=window&&new URLSearchParams(window.location.search).get(\"assetId\");const[state,setState]=useState({email:\"\",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,promocode});const ref=useRef();const[isLoading,setIsLoading]=useState(false);const[error,setError]=useState(null);const[isShowPromocode,setIsShowPromocode]=useState(Boolean(promocode));const handleShowPromocode=useCallback(e=>{e.preventDefault();setIsShowPromocode(true);},[]);const handleSubmit=useCallback(async e=>{e.preventDefault();const emailInput=ref.current;if(!emailInput||!emailInput.value||!emailInput.checkValidity()){setError(\"Невірний email\");return;}setIsLoading(true);setError(null);try{var _data_data_,_data_data;const response=await fetch(assetId?`https://api.uasystem.design/assets/${assetId}`:props.url,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(Object.fromEntries(Object.entries(state).filter(([key,value])=>value)))});if(response.ok){const{redirectUrl}=await response.json();if(!redirectUrl){return;}window.location=redirectUrl;return;}const data=await response.json();const message=data.data?((_data_data=data.data)===null||_data_data===void 0?void 0:(_data_data_=_data_data[0])===null||_data_data_===void 0?void 0:_data_data_.instancePath)===\"/email\"?\"Невірний email\":\"Сталася помилка. Спробуйте пізніше\":data.message;setError(message);}finally{setIsLoading(false);}},[state]);const handleChange=useCallback(e=>{setState(prevState=>({...prevState,[e.target.name]:e.target.value}));},[]);const errorFontStyles=useFontControls(props.error);const inputFontStyles=useFontControls(props.input);const buttonFontStyles=useFontControls(props.button);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{display:\"flex\",gap:props.gap,flexDirection:\"column\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:props.layout===\"horizontal\"?\"row\":\"column\",gap:props.gap},children:[/*#__PURE__*/_jsx(\"input\",{autoFocus:true,type:\"email\",name:\"email\",placeholder:props.input.placeholder,onChange:handleChange,style:{border:0,flex:1,...props.input,...inputFontStyles},ref:ref}),props.input.showPromocode&&/*#__PURE__*/_jsxs(_Fragment,{children:[!isShowPromocode&&/*#__PURE__*/_jsx(\"a\",{href:\"#\",onClick:handleShowPromocode,style:{color:props.input.color,fontSize:props.input.fontSize},children:props.input.promocodeLinkText}),isShowPromocode&&/*#__PURE__*/_jsx(\"input\",{type:\"text\",name:\"promocode\",placeholder:props.input.promocodePlaceholder,onChange:handleChange,style:{border:0,flex:1,...props.input,...inputFontStyles},value:state.promocode})]}),/*#__PURE__*/_jsx(\"style\",{children:` \n                    input:focus {\n                        outline: none;\n                    }\n                    ::placeholder { \n                        color: ${props.input.placeholderColor}; \n                    }`}),/*#__PURE__*/_jsx(\"button\",{disabled:isLoading,type:\"submit\",style:{cursor:\"pointer\",border:1,...props.button,...buttonFontStyles,borderRadius:props.input.borderRadius,boxShadow:props.button.shadow?`${props.button.shadow.shadowX}px ${props.button.shadow.shadowY}px ${props.button.shadow.shadowBlur}px ${props.button.shadow.shadowColor}`:null},children:isLoading?\"Обробка...\":props.button.label})]}),error&&/*#__PURE__*/_jsx(\"div\",{style:{...props.error,...errorFontStyles},children:error})]})});}const basePropertyControls={url:{title:\"URL\",type:ControlType.String,defaultValue:\"\"},layout:{title:\"Layout\",type:ControlType.Enum,displaySegmentedControl:true,options:[\"horizontal\",\"vertical\"]},button:{type:ControlType.Object,controls:{label:{title:\"Label\",type:ControlType.String,defaultValue:\"Button\"},backgroundColor:{title:\"Fill\",type:ControlType.Color,defaultValue:\"#333\"},borderRadius:{title:\"Radius\",type:ControlType.Number,defaultValue:16},color:{title:\"Text\",type:ControlType.Color,defaultValue:\"#fff\"},...fontControls,fontSize:{title:\"Font Size\",type:ControlType.Number,displayStepper:true,defaultValue:16},padding:{title:\"Padding\",type:ControlType.FusedNumber,toggleKey:\"paddingPerSide\",toggleTitles:[\"Padding\",\"Padding per side\"],defaultValue:16,valueKeys:[\"paddingTop\",\"paddingRight\",\"paddingBottom\",\"paddingLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},shadowObject:{type:ControlType.Object,title:\"Shadow\",optional:true,controls:{shadowColor:{title:\"Color\",type:ControlType.Color,defaultValue:\"rgba(0,0,0,0.25)\"},shadowX:{title:\"Shadow X\",type:ControlType.Number,min:-100,max:100,defaultValue:0},shadowY:{title:\"Shadow Y\",type:ControlType.Number,min:-100,max:100,defaultValue:2},shadowBlur:{title:\"Shadow B\",type:ControlType.Number,min:0,max:100,defaultValue:4}}}}},input:{type:ControlType.Object,controls:{placeholder:{title:\"Placeholder\",type:ControlType.String,defaultValue:\"Email\"},showPromocode:{title:\"Show promocode\",type:ControlType.Boolean,defaultValue:false},promocodePlaceholder:{title:\"Promocode placeholder\",type:ControlType.String,defaultValue:\"Promocode\"},promocodeLinkText:{title:\"Promocode link text\",type:ControlType.String,defaultValue:\"Have promocode\"},placeholderColor:{title:\" \",type:ControlType.Color,defaultValue:\"#0000004D\"},backgroundColor:{title:\"Fill\",type:ControlType.Color,defaultValue:\"#EBEBEB\"},color:{title:\"Text\",type:ControlType.Color,defaultValue:\"#000\"},...fontControls,fontSize:{title:\"Font Size\",type:ControlType.Number,displayStepper:true,defaultValue:16},padding:{title:\"Padding\",type:ControlType.FusedNumber,toggleKey:\"paddingPerSide\",toggleTitles:[\"Padding\",\"Padding per side\"],defaultValue:16,valueKeys:[\"paddingTop\",\"paddingRight\",\"paddingBottom\",\"paddingLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},borderRadius:{title:\"Radius\",type:ControlType.Number,defaultValue:16}}},error:{type:ControlType.Object,controls:{color:{type:ControlType.Color,defaultValue:\"#EE4444\"},...fontControls,fontSize:{title:\"Font Size\",type:ControlType.Number,displayStepper:true,defaultValue:16}}},gap:{title:\"Gap\",type:ControlType.Number,defaultValue:16}};addPropertyControls(EmailForm,basePropertyControls);\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmailForm\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EmailForm.map"],"mappings":"mcAQG,SAAwB,EAAU,EAAM,CAG3C,IAAM,EAAU,GAAQ,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAC,IAAI,YAAY,EAAE,GAAS,EAAQ,GAAQ,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAC,IAAI,UAAU,CAAM,CAAC,EAAM,GAAUA,EAAS,CAAC,MAAM,GAAG,SAAS,KAAK,gBAAgB,CAAC,iBAAiB,CAAC,SAAS,YAAU,CAAC,CAAO,EAAIC,GAAQ,CAAM,CAAC,EAAU,GAAcD,EAAS,GAAM,CAAM,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EAAgB,GAAoBA,EAAS,EAAQ,EAAW,CAAO,EAAoBE,EAAY,GAAG,CAAC,EAAE,gBAAgB,CAAC,EAAmB,GAAK,EAAG,EAAE,CAAC,CAAO,EAAaA,EAAY,KAAM,IAAG,CA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