{
  "version": 3,
  "sources": ["ssg:https://framer.com/m/Prefab-EventSymbol-StIR.js@yScBVQP1siE1M9GNONGi", "ssg:https://framerusercontent.com/modules/BRYawhxUI88IbJSGof88/KsKT6uqjt6Nf6VbxD2C0/Prefab_Form.js"],
  "sourcesContent": ["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{withCSS,RenderTarget}from\"framer\";const _eventSymbol=props=>{const{variant}=props;function GetBannerType(){switch(variant){case\"error\":return\"prefab-error\";case\"warning\":return\"prefab-warning\";default:return null;}}return /*#__PURE__*/_jsx(\"div\",{...props,className:`prefab-util-event`,children:props.children});};const EventSymbol=withCSS(_eventSymbol,[`.prefab-util-event{\n        background-color:#e5dbff;\n        border:1px dashed #7048e8;\n        display:flex;\n        font-size:4px;\n        align-items:center;\n        justify-content:center;\n        gap:4px;\n        color:#7048e8;\n        text-align:center;\n    }`]);/**\n * @framerSupportedLayoutWidth auto-prefers-fixed\n * @framerSupportedLayoutHeight auto-prefers-fixed\n */export default function Prefabs_Symbol(props){return /*#__PURE__*/_jsx(_Fragment,{children:RenderTarget.current()==\"CANVAS\"&&/*#__PURE__*/_jsx(EventSymbol,{style:props.style,\"aria-hidden\":RenderTarget.current()!=\"CANVAS\",children:/*#__PURE__*/_jsx(\"svg\",{width:\"15\",height:\"15\",viewBox:\"0 0 15 15\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M8.69667 0.0403541C8.90859 0.131038 9.03106 0.354857 8.99316 0.582235L8.0902 6.00001H12.5C12.6893 6.00001 12.8625 6.10701 12.9472 6.27641C13.0319 6.4458 13.0136 6.6485 12.8999 6.80001L6.89997 14.8C6.76167 14.9844 6.51521 15.0503 6.30328 14.9597C6.09135 14.869 5.96888 14.6452 6.00678 14.4178L6.90974 9H2.49999C2.31061 9 2.13748 8.893 2.05278 8.72361C1.96809 8.55422 1.98636 8.35151 2.09999 8.2L8.09997 0.200038C8.23828 0.0156255 8.48474 -0.0503301 8.69667 0.0403541ZM3.49999 8.00001H7.49997C7.64695 8.00001 7.78648 8.06467 7.88148 8.17682C7.97648 8.28896 8.01733 8.43723 7.99317 8.5822L7.33027 12.5596L11.5 7.00001H7.49997C7.353 7.00001 7.21347 6.93534 7.11846 6.8232C7.02346 6.71105 6.98261 6.56279 7.00678 6.41781L7.66968 2.44042L3.49999 8.00001Z\",fill:\"currentColor\",\"fill-rule\":\"evenodd\",\"clip-rule\":\"evenodd\"})})})});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Prefabs_Symbol\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto-prefers-fixed\",\"framerSupportedLayoutHeight\":\"auto-prefers-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Prefab_EventSymbol.map", "// MIT License\n// Copyright \u00A9 Framer Prefabs & Contributors\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useRef,useEffect}from\"react\";import{ControlType,addPropertyControls}from\"framer\";import Prefab_EventSymbol from\"https://framer.com/m/Prefab-EventSymbol-StIR.js@yScBVQP1siE1M9GNONGi\";//TODO: Add support for MailChimp\nconst mailchimpRegex=/^https?:\\/\\/([^\\/]+)[^\\?]+\\??(.+)$/;const parseMailChimpUrl=url=>{var ref;const[,domain,parameters]=(ref=url.replace(\"&amp;\",\"&\").match(mailchimpRegex))!==null&&ref!==void 0?ref:[null,null,null];return[domain,new URLSearchParams(parameters)];};/**\n * @framerSupportedLayoutWidth auto-prefer-fixed\n * @framerSupportedLayoutHeight auto-prefer-fixed\n */export default function Prefab_Form(props){const{style,service,action,uid,onSuccess,onError,onDefault,onSending,resetAfter,timeout}=props;const[isValid,setIsValid]=useState([]);const[formData,setFormData]=useState([]);//Ref of this form to send DOM events\nconst formRef=useRef();//Sends out a custom event that it the form has been submited.\nasync function handleSubmit(e){e.preventDefault();if(formRef.current){const event=new CustomEvent(`formSubmit-${uid}`,{detail:{data:\"Form Submitted\"},bubbles:true});//Send event\nformRef.current.dispatchEvent(event);// Initialize an object to hold form data\nlet formObject={};const formControls=document.querySelectorAll(`[form=\"${uid}\"]:not(button[type=\"submit\"]):not(button[type=\"reset\"])`);//Create form Object\nfor(let i=0;i<formControls.length;i++){var _formControls_i,_formControls_i1;const key=(_formControls_i=formControls[i])===null||_formControls_i===void 0?void 0:_formControls_i.name;const value=(_formControls_i1=formControls[i])===null||_formControls_i1===void 0?void 0:_formControls_i1.value;if(key&&value){formObject[key]=value;}}// Check if all form controls have been validated.\nconst allControlsValidated=formControls.length===Object.keys(isValid).length&&Object.values(isValid).every(value=>value===true);if(allControlsValidated){// TODO: Support Mailchimp submission\nif(service==\"mailChimp\"){AttemptChimp();}else{AttemptSubmit(formObject);}}else{// Not all controls are validated yet\n}}}async function AttemptSubmit(formObject){onSending&&onSending();try{//If custom validation check if all are valid otherwise proceed\nconst allTrue=Object.values(isValid).every(value=>value===true);if(allTrue&&isValid.length!=0){//Get all form data\n//Sends an event that a valid submit was made\nconst validSubmitEvent=new CustomEvent(`formValidSubmit-${uid}`,{detail:{data:formObject},bubbles:true});//Send event\nif(formRef.current){formRef.current.dispatchEvent(validSubmitEvent);}if(action){const response=await fetch(action,{method:\"POST\",headers:{\"Content-Type\":\"application/json\",Accept:\"application/json\"},body:JSON.stringify(formObject)});if(response.ok){onSuccess&&onSuccess();if(resetAfter){setTimeout(()=>{onDefault&&onDefault();},timeout*1e3);}}else{throw Error(response.status);}}else{onSuccess&&onSuccess();if(resetAfter){setTimeout(()=>{onDefault&&onDefault();handleReset();},timeout*1e3);}}}}catch(error){console.error(\"Submission failed:\",error);//TODO: Handle Error\nonError&&onError();if(resetAfter){setTimeout(()=>{onDefault&&onDefault();handleReset();},timeout*1e3);}}}async function AttemptChimp(){//TODO Add mailChimp support\n}//Sends Reset event specfic to this form via its ID. Any control listening will reset.\nfunction handleReset(){onDefault&&onDefault();const event=new CustomEvent(`formReset-${uid}`,{detail:{state:\"default\"},bubbles:true});if(formRef.current){formRef.current.dispatchEvent(event);}}useEffect(()=>{//Will listen to validation event from inputs\n//Events coming from inputs must include name & validation True:False\nconst handleValidation=event=>{const validationItem={[event.detail.name]:event.detail.validation};setIsValid(currentErrors=>({...currentErrors,...validationItem}));};//Set up listener\ndocument.addEventListener(`formValidate-${uid}`,handleValidation);//Clean up\nreturn()=>{document.removeEventListener(`formValidate-${uid}`,handleValidation);};},[]);return /*#__PURE__*/_jsx(\"form\",{style:props.style,noValidate:true,ref:formRef,onReset:handleReset,id:uid?uid:undefined,onSubmit:handleSubmit,children:/*#__PURE__*/_jsx(Prefab_EventSymbol,{})});}addPropertyControls(Prefab_Form,{uid:{title:\"ID\",type:ControlType.String},onDefault:{type:ControlType.EventHandler},onSending:{type:ControlType.EventHandler},onSuccess:{type:ControlType.EventHandler},onError:{type:ControlType.EventHandler},service:{type:ControlType.Enum,options:[\"formSpark\",\"formSpree\",\"custom\"],optionTitles:[\"Form Spark\",\"Form Spree\",\"Custom\"]},action:{type:ControlType.String},resetAfter:{type:ControlType.Boolean,description:\"Optional Reset form after a submission (Successful or Error)\"},timeout:{hidden:props=>!props.resetAfter,type:ControlType.Number,description:\"Units in seconds\",defaultValue:2}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Prefab_Form\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Prefab_Form.map"],
  "mappings": "kGAA0G,IAAMA,EAAaC,GAAO,CAAC,GAAK,CAAC,QAAAC,CAAO,EAAED,EAAM,SAASE,GAAe,CAAC,OAAOD,EAAQ,CAAC,IAAI,QAAQ,MAAM,eAAe,IAAI,UAAU,MAAM,iBAAiB,QAAQ,OAAO,IAAK,CAAC,CAAC,OAAoBE,EAAK,MAAM,CAAC,GAAGH,EAAM,UAAU,oBAAoB,SAASA,EAAM,QAAQ,CAAC,CAAE,EAAQI,EAAYC,EAAQN,EAAa,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAUpa,CAAC,EAGW,SAARO,EAAgCN,EAAM,CAAC,OAAoBG,EAAKI,EAAU,CAAC,SAASC,EAAa,QAAQ,GAAG,UAAuBL,EAAKC,EAAY,CAAC,MAAMJ,EAAM,MAAM,cAAcQ,EAAa,QAAQ,GAAG,SAAS,SAAsBL,EAAK,MAAM,CAAC,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAA6B,SAAsBA,EAAK,OAAO,CAAC,EAAE,+uBAA+uB,KAAK,eAAe,YAAY,UAAU,YAAY,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CCJtqC,SAARM,EAA6BC,EAAM,CAAC,GAAK,CAAC,MAAAC,EAAM,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,CAAE,EAAE,CAAC,CAAC,EAAsBG,EAAK,OAAO,CAAC,MAAMtC,EAAM,MAAM,WAAW,GAAK,IAAIgB,EAAQ,QAAQgB,EAAY,GAAG5B,GAAQ,OAAU,SAASc,EAAa,SAAsBoB,EAAKC,EAAmB,CAAC,CAAC,CAAC,CAAC,CAAE,CAACC,EAAoBzC,EAAY,CAAC,IAAI,CAAC,MAAM,KAAK,KAAK0C,EAAY,MAAM,EAAE,UAAU,CAAC,KAAKA,EAAY,YAAY,EAAE,UAAU,CAAC,KAAKA,EAAY,YAAY,EAAE,UAAU,CAAC,KAAKA,EAAY,YAAY,EAAE,QAAQ,CAAC,KAAKA,EAAY,YAAY,EAAE,QAAQ,CAAC,KAAKA,EAAY,KAAK,QAAQ,CAAC,YAAY,YAAY,QAAQ,EAAE,aAAa,CAAC,aAAa,aAAa,QAAQ,CAAC,EAAE,OAAO,CAAC,KAAKA,EAAY,MAAM,EAAE,WAAW,CAAC,KAAKA,EAAY,QAAQ,YAAY,8DAA8D,EAAE,QAAQ,CAAC,OAAOzC,GAAO,CAACA,EAAM,WAAW,KAAKyC,EAAY,OAAO,YAAY,mBAAmB,aAAa,CAAC,CAAC,CAAC",
  "names": ["_eventSymbol", "props", "variant", "GetBannerType", "p", "EventSymbol", "withCSS", "Prefabs_Symbol", "l", "RenderTarget", "Prefab_Form", "props", "style", "service", "action", "uid", "onSuccess", "onError", "onDefault", "onSending", "resetAfter", "timeout", "isValid", "setIsValid", "ye", "formData", "setFormData", "formRef", "pe", "handleSubmit", "e", "event", "formObject", "formControls", "i", "_formControls_i", "_formControls_i1", "key", "value", "AttemptChimp", "AttemptSubmit", "validSubmitEvent", "response", "handleReset", "error", "ue", "handleValidation", "validationItem", "currentErrors", "p", "Prefabs_Symbol", "addPropertyControls", "ControlType"]
}
