{"version":3,"file":"WithSelectOption.DPpGLGdS.mjs","names":["useStore","useState","useRef","useState","useCallback","ls","uuidv4","ls"],"sources":["https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/ftgW8Q7kwsJ58edTFOUF/KV96rfbdKnDtqDBXbNjX/WithForm.js","https:/framerusercontent.com/modules/CWpvrNSeC1P89Ev0NBi7/iWyur80zgA3MEEvrs51w/WithSelectOption.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useRef,useEffect,useCallback}from\"react\";import ls from\"local-storage\";import{v4 as uuidv4}from\"uuid\";import{createStore}from\"https://framer.com/m/framer/store.js@^0.3.0\";function Grid({children,style}){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"grid\",gridAutoFlow:\"row\",gridTemplateColumns:\"1fr\",justifyContent:\"start\",gridRowGap:24,...style},children:children});}function Headline({children,h=3}){const style={color:\"#202020\",fontFamily:\"Satoshi, sans-serif\",fontSize:\"40px\",fontWeight:400,lineHeight:\"48px\",margin:\"0 0 22px 0\"};if(h===1){return /*#__PURE__*/_jsx(\"h1\",{style:{...style,fontSize:56,lineHeight:\"64px\"},children:children});}return /*#__PURE__*/_jsx(\"h3\",{style:style,children:children});}function Text({children,style}){return /*#__PURE__*/_jsx(\"p\",{style:{color:\"#202020\",fontFamily:\"Satoshi, sans-serif\",fontSize:\"18px\",fontWeight:500,lineHeight:\"32px\",margin:0,...style},children:children});}export const dig=(o,sArg)=>{let s=Array.isArray(sArg)?sArg.join(\".\"):String(sArg);s=s.replace(/\\[(\\w+)\\]/g,\".$1\")// convert indexes to properties\n;s=s.replace(/^\\./,\"\")// strip a leading dot\n;const a=s.split(\".\");if(a?.length>0){for(let i=0,n=a?.length;i<n;++i){const k=a?.[i];if(o&&k in o){o=o[k];}else{return;}}}return o;};export function ignoreKeys(d,keys){const copy={...d};keys.forEach(key=>delete copy[key]);return copy;}export function setNested(obj,path,value){let schema=obj;const pList=path.split(\".\");const len=pList.length;for(let i=0;i<len-1;i++){const elem=pList[i];if(!schema.hasOwnProperty(elem)||typeof schema[elem]!==\"object\"||schema[elem]===null){schema[elem]={};}schema=schema[elem];}const lastKey=pList[len-1];const valuePrev=schema[lastKey];if(Array.isArray(value)&&Array.isArray(valuePrev)){schema[lastKey]=valuePrev.concat(value);}else{schema[lastKey]=value;}return obj;}function selectKeys(obj,keys,opts){return keys.reduce((acc,key)=>{if(key in(obj??{})||opts?.include_blanks){let val=dig(obj??{},key);if(opts?.trim&&typeof val===\"string\"){val=val.trim();}return setNested(acc,key,val);}return acc;},{});}const TRACKING_URL=\"\";const useStore=createStore();class SessionTracker{getSessionUUID(){if(typeof window===\"undefined\"||!window.localStorage){// throw new Error(\"localStorage is not available\")\nconsole.log(\"localStorage is not available, but it’s okay because it’s available when the page is live\");}// @ts-ignore\nconst uuid=ls.get(this.STORAGE_KEY)??uuidv4();// @ts-ignore\nls.set(this.STORAGE_KEY,uuid);return uuid;}constructor(){_define_property(this,\"STORAGE_KEY\",\"__planeswalker_power_level\");}}export const sessionTracker=new SessionTracker;const BASE_URL=\"https://cluster.mage.ai/mageai-3345-dev/api\";const PIPELINE_URL=`${BASE_URL}/pipeline_schedules/2/pipeline_runs/bc39d5eb595c4775a0c1c163d68f77f4`;export function withFormSubmitEnter(Component){return props=>{const ref=useRef(null);const[isSubmitting,setIsSubmitting]=useState(false);const handleSubmit=useCallback(async event=>{event.preventDefault();setIsSubmitting(true);const form=ref.current;if(!form){console.error(`No form found for ${ref.current}`);setIsSubmitting(false);return;}const formData=new FormData(form);const payload={};formData.forEach((value,key)=>{payload[key]=value;});try{await window.fetch(PIPELINE_URL,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({product:payload})}).then(async response=>{if(!response.ok){throw new Error(\"Network response was not ok\");}const data=await response.json();window.location.href=`/rooms?uuid=${data?.pipeline_run?.id}`;}).catch(error=>{console.error(\"ERROR\",error);throw error;});}catch(error){console.error(\"Form submission error:\",error);}finally{setIsSubmitting(false);}},[]);useEffect(()=>{if(ref.current){const form=ref.current;form?.addEventListener(\"submit\",handleSubmit);return()=>{form?.removeEventListener(\"submit\",handleSubmit);};}},[handleSubmit]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref,disabled:isSubmitting,isSubmitting:isSubmitting,className:[props.className,\"form-demo\",isSubmitting?\"submitting\":\"\"].filter(Boolean).join(\" \")});};}export function withSubmit(Component){return props=>{const ref=useRef(null);const[isSubmitting,setIsSubmitting]=useState(false);const handleSubmit=useCallback(async event=>{event.preventDefault();setIsSubmitting(true);const payload=ls.get(\"form\");// console.log(\"PPPPPPPPPPPPPPPPPPP\", payload)\ntry{await window.fetch(PIPELINE_URL,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({product:payload})}).then(async response=>{if(!response.ok){throw new Error(\"Network response was not ok\");}const data=await response.json();window.location.href=`/rooms?uuid=${data?.pipeline_run?.id}`;}).catch(error=>{console.error(\"ERROR\",error);throw error;});}catch(error){console.error(\"Form submission error:\",error);}finally{setIsSubmitting(false);}},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:ref,disabled:isSubmitting,isSubmitting:isSubmitting,onClick:handleSubmit,className:[props.className,\"form-demo\",isSubmitting?\"submitting\":\"\"].filter(Boolean).join(\" \")});};}\nexport const __FramerMetadata__ = {\"exports\":{\"ignoreKeys\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSubmit\":{\"type\":\"reactHoc\",\"name\":\"withSubmit\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withFormSubmitEnter\":{\"type\":\"reactHoc\",\"name\":\"withFormSubmitEnter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"dig\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"setNested\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"sessionTracker\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WithForm.map","import{jsx as _jsx}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{motion}from\"framer\";import ls from\"local-storage\";// Learn more: https://www.framer.com/developers/overrides/\nconst useStore=createStore({});function extractTextFromChildren(children){if(!children){return\"\";}// If children is a string, return it directly\nif(typeof children===\"string\"){return children;}// If children is an array, recursively extract text from each child\nif(Array.isArray(children)){return children.reduce((acc,child)=>{return acc.concat(extractTextFromChildren(child));},[]);}// If children is a React element, extract text from its children\nif(children.props&&children.props.children){return extractTextFromChildren(children.props.children);}// For other types (numbers, etc.)\nreturn typeof children===\"string\"?String(children||\"\"):\"\";}export function withSelect(Component){return props=>{const uuid=extractTextFromChildren(props.children??[])?.filter?.(Boolean)?.[0];const[data,setData]=useStore();console.log(uuid,data);return /*#__PURE__*/_jsx(motion.div,{initial:\"unselected\",animate:uuid===data?.product?\"selected\":\"unselected\",variants:{selected:{borderColor:\"#FFB673\"},unselected:{borderColor:\"transparent\"}},style:{border:\"2px solid\",borderRadius:10},children:/*#__PURE__*/_jsx(Component,{...props,onClick:e=>{e.preventDefault();e.stopPropagation();// console.log(uuid)\nsetData(prev=>{const val={...prev,...ls.get(\"form\"),product:uuid};ls.set(\"form\",val);console.log(ls.get(\"form\"));return val;});}})});};}export function withSelectStyle(Component){return props=>{const key=\"style\";const uuid=extractTextFromChildren(props.children??[])?.filter?.(Boolean)?.[0];const[data,setData]=useStore();// console.log(uuid, data)\nreturn /*#__PURE__*/_jsx(motion.div,{initial:\"unselected\",animate:uuid===data?.[key]?\"selected\":\"unselected\",variants:{selected:{borderColor:\"#FFB673\"},unselected:{borderColor:\"transparent\"}},style:{border:\"2px solid\",borderRadius:10},children:/*#__PURE__*/_jsx(Component,{...props,onClick:e=>{e.preventDefault();e.stopPropagation();// console.log(uuid)\nsetData(prev=>{const val={...prev,...ls.get(\"form\"),[key]:uuid};ls.set(\"form\",val);// console.log(ls.get(\"form\"))\nreturn val;});}})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withSelect\":{\"type\":\"reactHoc\",\"name\":\"withSelect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSelectStyle\":{\"type\":\"reactHoc\",\"name\":\"withSelectStyle\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerM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