{"version":3,"file":"Form.DiDUaElJ.mjs","names":["useState","useRef","useState"],"sources":["https:/framerusercontent.com/modules/LCISGuPgK3yvuMxxhNw7/kvvDcS7nAXyBwxppHFiP/Checkbox.js","https:/framerusercontent.com/modules/udjfhx4jb3wHMqmUHPM2/T02oXOlcNDa4Rl0J4pzq/Form.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\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 *//**\n * @framerDisableUnlink\n */function Checkbox({native,item,checkedComponent,uncheckedComponent,onChange,name,label,layout,selected}){const defaultStyles={cursor:\"pointer\",display:\"flex\",gap:8,alignItems:\"start\",height:\"100%\",width:\"auto\",margin:0,padding:0};const[selectedValue,setSelectedValue]=useState(selected);const[labelStyle,setLabelStyle]=useState(defaultStyles);const handleChange=(e,value)=>{if(!native){e.preventDefault();}setSelectedValue(selectedValue?false:value);};const setFocusStyles=()=>{setLabelStyle({...defaultStyles,outline:\"1px solid var(--token-92aaba62-0189-4281-8a12-a59deebb62b8)\",outlineOffset:\"1px\"});};const removeFocusStyles=()=>{setLabelStyle(defaultStyles);};const getCustomComponent=()=>{if(native){return null;}else{return selectedValue?checkedComponent:uncheckedComponent;}};return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:layout.direction,justifyContent:layout.distribute,alignItems:layout.align,flexWrap:layout.wrap?\"wrap\":\"nowrap\",gap:layout.gap},children:[/*#__PURE__*/_jsx(\"input\",{type:\"Checkbox\",name:name,value:item.value,checked:selectedValue,onChange:e=>handleChange(e,item.value),style:{padding:0,margin:0,display:!native?\"none\":\"block\"}}),getCustomComponent(),/*#__PURE__*/_jsx(\"label\",{onClick:e=>handleChange(e,item.value),htmlFor:name,style:{...labelStyle,lineHeight:\"1rem\"},children:/*#__PURE__*/_jsx(\"span\",{id:`label-${item.value}`,style:{...label,lineHeight:\"1rem\",padding:0,margin:0},children:item.label})})]});}// Define default props to prevent errors when properties are not set\nCheckbox.defaultProps={item:{},checkedComponent:undefined,uncheckedComponent:undefined,name:\"radio-group\",label:{},layout:{},selected:null};// Define property controls which allow users to configure this component in Framer\naddPropertyControls(Checkbox,{native:{type:ControlType.Boolean},name:{type:ControlType.String,title:\"Name\",description:\"Unique name for the radio group\",defaultValue:\"radio-group\"},label:{type:ControlType.Object,title:\"Label\",description:\"Style of the labels\",controls:{fontFamily:{type:ControlType.String,defaultValue:\"Geist Regular\",title:\"Font Family\"},color:{type:ControlType.Color,defaultValue:\"#ffffff\"},fontSize:{type:ControlType.Number,defaultValue:14,title:\"Font Size\"}}},item:{type:ControlType.Object,title:\"Value\",controls:{label:{type:ControlType.String,defaultValue:\"Label\"},value:{type:ControlType.String,defaultValue:\"value\"}}},selected:{type:ControlType.String,description:\"Pass in the same value from the \\n item object in order to pre select it.\"},layout:{type:ControlType.Object,title:\"Layout\",controls:{direction:{type:ControlType.Enum,defaultValue:\"row\",displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",options:[\"row\",\"column\"],optionTitles:[\"Row\",\"Col\"]},distribute:{type:ControlType.Enum,defaultValue:\"start\",displaySegmentedControl:false,segmentedControlDirection:\"vertical\",options:[\"start\",\"center\",\"end\",\"space-between\",\"space-around\",\"space-evenly\"],optionTitles:[\"Start\",\"Center\",\"End\",\"Space between\",\"Space around\",\"Space evenly\"]},align:{type:ControlType.Enum,defaultValue:\"start\",displaySegmentedControl:false,segmentedControlDirection:\"vertical\",options:[\"start\",\"center\",\"end\"],optionTitles:[\"Start\",\"Center\",\"End\"]},wrap:{type:ControlType.Boolean,defaultValue:true,title:\"Wrap\"},gap:{type:ControlType.Number,displayStepper:true,step:1,title:\"Gap\"}}},checkedComponent:{type:ControlType.ComponentInstance,title:\"Checked\",hidden:props=>props.native},uncheckedComponent:{type:ControlType.ComponentInstance,title:\"Unchecked\",hidden:props=>props.native}});export default Checkbox;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Checkbox\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Checkbox.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect,useRef,useState}from\"react\";const useFormStore=createStore({pass:null,confirmPass:null,error:null,email:null});export function formSubmitOverride(Component){return props=>{useEffect(()=>{// Get the form element\nconst form=document.querySelector(\"form\");if(!form)return;const handleSubmit=async event1=>{// prevent default\nevent1.preventDefault();const formData=new FormData(event1.currentTarget);const email=formData.get(\"email\");const password=formData.get(\"password\");// perform other actions in addition to the default form-submit\ntry{// Make the webhook call\nconst response=await fetch(\"https://hook.eu2.make.com/vhn1k4b1mxi2z9atpjlewsuhkynicnun\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({email,password})});const data=await response.json();if(!response.ok){event1.preventDefault()// Prevent Framer form submission on error\n;console.error(\"login failed:\",data.error);// You could dispatch a custom event here to show error state\nreturn;}// save auth-token and metadata\nif(data&&data.access_token){window.localStorage.setItem(\"supa-token\",data.access_token);window.localStorage.setItem(\"supa-refresh-token\",data.refresh_token);window.localStorage.setItem(\"user-data\",JSON.stringify(data.user.user_metadata));window.localStorage.setItem(\"email-confirmed\",data.user.email_confirmed_at);console.dir(data);}setTimeout(()=>{window.location.href=\"/dashboard\";},100);// Form will continue submission to Framer Forms endpoint\n}catch(error){event1.preventDefault()// Prevent Framer form submission on error\n;console.error(\"Error during login:\",error);// You could dispatch a custom event here to show error state\n}};form.addEventListener(\"submit\",handleSubmit);// Cleanup\nreturn()=>{form.removeEventListener(\"submit\",handleSubmit);};},[]);return /*#__PURE__*/_jsx(Component,{...props});};}export function refreshSession(Component){return props=>{const handleSubmit=async refreshToken=>{const response=await fetch(\"https://hook.eu2.make.com/xq9et6sh7wxbhlvysedv9agojdtan6xk\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({refresh_token:refreshToken})});const data=await response.json();if(!response.ok){event.preventDefault()// Prevent Framer form submission on error\n;console.error(\"login failed:\",data.error);// You could dispatch a custom event here to show error state\nreturn;}// save auth-token and metadata\nif(data&&data.access_token){window.localStorage.setItem(\"supa-token\",data.access_token);window.localStorage.setItem(\"supa-refresh-token\",data.refresh_token);window.localStorage.setItem(\"user-data\",JSON.stringify(data.user.user_metadata));}};useEffect(()=>{const refreshToken=localStorage.getItem(\"supa-refresh-token\");if(refreshToken){handleSubmit(refreshToken);}else{window.location.href=\"/login\";}},[]);//\nreturn /*#__PURE__*/_jsx(Component,{...props});};}export function confirmationURL(Component){return props=>{const inputRef=useRef(null);const[store,setStore]=useFormStore();const[accessToken,setAccessToken]=useState(null);function parseConfirmationUrl(){// Get the confirmation_url from query params\nconst queryParams=new URLSearchParams(window.location.search);const encodedUrl=queryParams.get(\"confirmation_url\");if(!encodedUrl){throw new Error(\"No confirmation URL found in query parameters\");}// Decode the URL\nconst decodedUrl=decodeURIComponent(encodedUrl);// Parse the decoded URL\nconst url=new URL(decodedUrl);const verifyParams=new URLSearchParams(url.search);// Return the parsed parameters\nreturn{confirmationUrl:decodedUrl,accessToken:verifyParams.get(\"token\"),type:verifyParams.get(\"type\"),redirectTo:verifyParams.get(\"redirect_to\"),token:queryParams.get(\"token\"),email:queryParams.get(\"email\")};}// Usage example:\nuseEffect(()=>{try{// If URL is like: /confirm-signup?confirmation_url=https%3A%2F%2Fexample.com%2F%23access_token%3Dxyz...\nconst{confirmationUrl,accessToken,redirectTo,type,token:localAccessToken,email}=parseConfirmationUrl();if(localAccessToken){setAccessToken(localAccessToken);setStore({email:email});}}catch(error){console.error(\"Error parsing confirmation URL:\",error.message);}},[]);useEffect(()=>{// add the value from the url to the input control\nif(accessToken){if(document.querySelector('input[name=\"token\"]')){const input=document.querySelector('input[name=\"token\"]');input.value=accessToken;}}},[accessToken]);return /*#__PURE__*/_jsx(Component,{ref:inputRef,...props,value:accessToken});};}/**\n * disable input and add a default value\n */export function disabledInput(Component){return props=>{const[store,setStore]=useFormStore();useEffect(()=>{if(store.email){if(document.querySelector('input[name=\"token\"]')){const input=document.querySelector('input[name=\"email\"]');input.value=store.email;}}},[store]);return /*#__PURE__*/_jsx(Component,{...props,disabled:\"disabled\"});};}/**\n * Make the input mask the password\n */export function asPassword(Component){return props=>{return /*#__PURE__*/_jsx(Component,{...props,type:\"password\"});};}export function logPassword(Component){return props=>{const[store,setStore]=useFormStore();const ref=useRef(null);const storePass=e=>{setStore({pass:e.currentTarget.value});};useEffect(()=>{if(ref.current){const inputElement=ref.current.querySelector(\"input\");inputElement.addEventListener(\"blur\",storePass);}return()=>{if(ref.current){const inputElement=ref.current.querySelector(\"input\");inputElement.removeEventListener(\"blur\",storePass);}};},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref,type:\"password\"});};}export function checkPassword(Component){return props=>{const[store,setStore]=useFormStore();const ref=useRef(null);const storePass=e=>{setStore({confirmPass:e.currentTarget.value});};useEffect(()=>{if(ref.current){const inputElement=ref.current.querySelector(\"input\");inputElement.addEventListener(\"blur\",storePass);}return()=>{if(ref.current){const inputElement=ref.current.querySelector(\"input\");inputElement.removeEventListener(\"blur\",storePass);}};},[]);useEffect(()=>{if(store.pass&&store.confirmPass){if(store.pass!==store.confirmPass){setStore({error:true});}else{setStore({error:null});}}},[store.pass,store.confirmPass]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref,type:\"password\"});};}export function showError(Component){return props=>{const[store,setStore]=useFormStore();const ref=useRef(null);const[visibility,setVisibility]=useState(\"none\");useEffect(()=>{if(store.error){setVisibility(\"block\");}else{setVisibility(\"none\");}},[store.error]);return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,display:visibility},ref:ref});};}export function submitButtonOverride(Component){return props=>{const[store,setStore]=useFormStore();const getVariant=()=>{if(store.error)return\"Disabled\";return\"Default\";};return /*#__PURE__*/_jsx(Component,{...props,variant:getVariant()});};}export function showUserInfo(Component){return props=>{const[store,setStore]=useFormStore();const[userName,setUserName]=useState(null);useEffect(()=>{const data=localStorage.getItem(\"user-data\");if(data){const parsedData=JSON.parse(data);setUserName(`${parsedData.first_name} ${parsedData.last_name}`);}},[store]);return /*#__PURE__*/_jsx(Component,{...props,text:userName});};}export function userVerified(Component){return props=>{const[store,setStore]=useFormStore();const[verified,setVerified]=useState(null);useEffect(()=>{const data=localStorage.getItem(\"email-confirmed\");if(data){setVerified(data);console.log(data,data);}},[store]);return /*#__PURE__*/_jsx(Component,{...props,style:{opacity:verified?1:0}});};}export function logout(Component){return props=>{const onLogout=()=>{localStorage.removeItem(\"email-confirmed\");localStorage.removeItem(\"supa-token\");localStorage.removeItem(\"supa-refresh-token\");localStorage.removeItem(\"user-data\");window.location.href=\"/login\";};return /*#__PURE__*/_jsx(Component,{...props,onClick:onLogout});};}\nexport const __FramerMetadata__ = {\"exports\":{\"formSubmitOverride\":{\"type\":\"reactHoc\",\"name\":\"formSubmitOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"checkPassword\":{\"type\":\"reactHoc\",\"name\":\"checkPassword\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asPassword\":{\"type\":\"reactHoc\",\"name\":\"asPassword\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showError\":{\"type\":\"reactHoc\",\"name\":\"showError\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"submitButtonOverride\":{\"type\":\"reactHoc\",\"name\":\"submitButtonOverride\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"userVerified\":{\"type\":\"reactHoc\",\"name\":\"userVerified\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"logPassword\":{\"type\":\"reactHoc\",\"name\":\"logPassword\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"confirmationURL\":{\"type\":\"reactHoc\",\"name\":\"confirmationURL\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showUserInfo\":{\"type\":\"reactHoc\",\"name\":\"showUserInfo\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"refreshSession\":{\"type\":\"reactHoc\",\"name\":\"refreshSession\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"disabledInput\":{\"type\":\"reactHoc\",\"name\":\"disabledInput\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"logout\":{\"type\":\"reactHoc\",\"name\":\"logout\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Form.map"],"mappings":"wYAQG,SAAS,EAAS,CAAC,SAAO,OAAK,mBAAiB,qBAAmB,WAAS,OAAK,QAAM,SAAO,WAAS,CAAC,CAAC,IAAM,EAAc,CAAC,OAAO,UAAU,QAAQ,OAAO,IAAI,EAAE,WAAW,QAAQ,OAAO,OAAO,MAAM,OAAO,OAAO,EAAE,QAAQ,EAAE,CAAM,CAAC,EAAc,EAAiB,CAACE,EAAS,GAAe,CAAC,EAAW,EAAc,CAACA,EAAS,GAAqB,GAAc,EAAE,IAAQ,CAAK,GAAQ,EAAE,iBAAkB,EAAiB,EAAc,GAAM,EAAQ,EAA2N,MAA2B,EAAe,KAAkB,EAAc,EAAiB,EAAsB,OAAoB,EAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,OAAO,cAAc,EAAO,UAAU,eAAe,EAAO,WAAW,WAAW,EAAO,MAAM,SAAS,EAAO,KAAK,OAAO,SAAS,IAAI,EAAO,IAAI,CAAC,SAAS,CAAc,EAAK,QAAQ,CAAC,KAAK,WAAgB,OAAK,MAAM,EAAK,MAAM,QAAQ,EAAc,SAAS,GAAG,EAAa,EAAE,EAAK,OAAO,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAS,EAAc,QAAP,OAAe,CAAC,EAAE,IAAkC,E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