{"version":3,"file":"PlanBuyButton.CFSgJ5fN.mjs","names":["useState","useRef","Spainner"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/xjkhQV5Ve1Xnoo6Rj6Wd/1HYFCHiMWT0CTSjAlmsu/Spainner.js","https:/framer.com/m/Spainner-9KnC2N.js@1HYFCHiMWT0CTSjAlmsu","https:/framerusercontent.com/modules/DvCVNCd3YiGLpgmb2iT1/IPLt6u8RFpiim9sosV1C/PlanBuyButton.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","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","import{jsx as _jsx}from\"react/jsx-runtime\";import{motion}from\"framer-motion\";export default function Spinner(){return /*#__PURE__*/_jsx(motion.svg,{width:\"14\",height:\"14\",viewBox:\"0 0 100 100\",animate:{rotate:360},transition:{duration:1,repeat:Infinity,ease:\"linear\"},children:/*#__PURE__*/_jsx(\"circle\",{cx:\"50\",cy:\"50\",r:\"35\",fill:\"none\",stroke:\"#FFF\",strokeWidth:\"10\",strokeLinecap:\"round\",strokeDasharray:\"164.9 56.9\"})});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Spinner\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Spainner.map","/*\n * Spainner\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/xjkhQV5Ve1Xnoo6Rj6Wd/1HYFCHiMWT0CTSjAlmsu/Spainner.js\"\nexport { default } from \"https://framerusercontent.com/modules/xjkhQV5Ve1Xnoo6Rj6Wd/1HYFCHiMWT0CTSjAlmsu/Spainner.js\"\n","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import Spainner from\"https://framer.com/m/Spainner-9KnC2N.js@1HYFCHiMWT0CTSjAlmsu\";const useButtonStore=createStore({loadingId:null});export default function PlanBuyButton(props){const[store,setStore]=useButtonStore();const timerRef=useRef(null);const controllerRef=useRef(null);const{text,price_id,plan,page,textColor,font,fontSize,background,padding,boxShadow,border,borderRadius}=props;const isLoading=store.loadingId===plan;const handleClickBuyPlanButton=async()=>{setStore({loadingId:plan});const storageName=`Track_${page}_${plan}`;const storagePlan=sessionStorage.getItem(storageName);if(storagePlan!==\"true\"){sessionStorage.setItem(storageName,\"true\");window.fbq(\"track\",\"InitiateCheckout\");window.fbq(\"track\",\"SKU_CLICK\",{plan,page});window.gtag(\"event\",\"click_plan\",{plan,page});}if(isLoading)return;const session_url=await getCheckoutUrl();const win=window.open(session_url,\"_blank\");const planTimer=setInterval(()=>{if(win.closed){clearInterval(planTimer);sessionStorage.removeItem(storageName);}},1200);if(timerRef.current){clearTimeout(timerRef.current);}timerRef.current=setTimeout(()=>{sessionStorage.removeItem(storageName);},5*60*1e3);};const getCheckoutUrl=async()=>{controllerRef.current?.abort();controllerRef.current=new AbortController;const url=\"https://ingetin-langgraph-602223151053.us-central1.run.app\";try{const response=await fetch(`${url}/api/checkout/session`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({price_id:price_id}),signal:controllerRef.current.signal});const{checkout_url}=await response.json();return checkout_url;}catch(error){if(error.name!==\"AbortError\"){console.error(error);}}finally{setStore(current=>({loadingId:current.loadingId===plan?null:current.loadingId}));}};return /*#__PURE__*/_jsxs(\"div\",{id:plan,\"data-framer-name\":\"Price Buy\",style:{display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:12,color:textColor,background,padding,boxShadow,textAlign:\"center\",fontSize,...border,borderRadius,fontFamily:\"Instrument Sans\",...font,cursor:\"pointer\"},onClick:handleClickBuyPlanButton,children:[isLoading?/*#__PURE__*/_jsx(Spainner,{}):null,/*#__PURE__*/_jsx(\"p\",{style:{margin:0},children:text})]});}addPropertyControls(PlanBuyButton,{text:{type:ControlType.String,defaultValue:\"Default\"},price_id:{type:ControlType.String},plan:{type:ControlType.String,defaultValue:\"Pro_Monthly\"},page:{type:ControlType.String},textColor:{type:ControlType.Color,defaultValue:\"#2E2F35\"},font:{type:ControlType.Font},fontSize:{type:ControlType.String},background:{type:ControlType.String,defaultValue:\"linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 100%)\"},padding:{type:ControlType.Padding},boxShadow:{type:ControlType.BoxShadow},border:{type:ControlType.Border},borderRadius:{type:ControlType.BorderRadius}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PlanBuyButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PlanBuyButton.map"],"mappings":"6QAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAW,EAAE,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,CAAC,CAAC,EACjJ,EAAa,QAAQ,GAAQ,EAAO,EAAW,CAAC,EAChD,SAAS,GAAU,CACnB,GAAK,CAAC,EAAM,GAAUA,EAAS,EAAW,CAK1C,OAHA,OACA,EAAa,IAAI,EAAS,KAAW,EAAa,OAAO,EAAS,EAAG,EAAE,CAAC,CACrE,GAAgB,GAAG,IAAM,GAAgB,CAAO,CAAC,EAAU,MAAM,EAAa,EAC3E,CAAC,EAAM,EAAc,CAAG,OAAO,mBAfC,IAAwC,qBEAD,SAAwB,GAAS,CAAC,OAAo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