{"version":3,"file":"FA_PurchaseButton.CWcsQJSm.mjs","names":["useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/yBdhiXG1AbZNodh1E1IS/PFyIH3yH0oU5zVKnYdQn/FA_PurchaseButton.js"],"sourcesContent":["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{cloneElement,useState}from\"react\";import{apiFeux}from\"https://framerusercontent.com/modules/SLx2xfWAXovN7llsgFwe/zGZcVWqyj4kDVq0Ilffn/api.js\";/**\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerSupportedLayoutType any\n *\n */export default function FA_PurchaseButton({children,productId,price}){const[isLoading,setIsLoading]=useState(false);console.log(children);const onSubmit=()=>{setIsLoading(true);if(!productId){alert(\"Missing productId\");return;}apiFeux.fetchWithBearer(`/members/create-checkout-session/${productId}`,\"POST\",{priceBillingInterval:price}).then(responseBody=>{setIsLoading(false);window.open(responseBody.sessionUrl,\"_self\");}).catch(err=>{setIsLoading(false);if(err.redirect_url)window.location.href=err.redirect_url;});setIsLoading(false);};const containerStyle={width:\"100%\",height:\"100%\",objectFit:\"cover\"};const childElement=Array.isArray(children)?children[0]:children;const component=childElement?/*#__PURE__*/cloneElement(childElement,{...childElement.props,style:{...childElement.props.style,...containerStyle},onClick:onSubmit}):null;return /*#__PURE__*/_jsx(_Fragment,{children:component});}FA_PurchaseButton.displayName=\"FA Purchase Button\";addPropertyControls(FA_PurchaseButton,{children:{type:ControlType.ComponentInstance,title:\"Button\"},productId:{type:ControlType.String,title:\"Product or Subscription ID\"},price:{type:ControlType.Enum,title:\"Price variation\",defaultValue:1,description:\"When is one-time price, no price variation applies.\",displaySegmentedControl:true,segmentedControlDirection:\"vertical\",options:[1,0],optionTitles:[\"Monthly\",\"Yearly\"]}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FA_PurchaseButton\",\"slots\":[\"children\"],\"annotations\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