{"version":3,"file":"PricingTypes.sslU5X4j.mjs","names":[],"sources":["https:/framerusercontent.com/modules/PRd4Hy7OUweY3BCIo4TX/Dj0cfeymUn93990iPtzp/PricingTypes.js"],"sourcesContent":["import{ControlType}from\"framer\";export const SUBSCRIPTION_TYPE_CONTROL={type:ControlType.Enum,defaultValue:\"monthly\",displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",options:[\"monthly\",\"yearly\"],optionTitles:[\"Monthly\",\"Yearly\"]};export const ADDON_CONTROL={type:ControlType.Object,controls:{id:{type:ControlType.String,title:\"Addon ID\",defaultValue:\"addon-1\"},name:{type:ControlType.String,title:\"Addon Name\",defaultValue:\"WiFi\"},description:{type:ControlType.String,title:\"Description\",defaultValue:\"High-speed internet access\"},readMoreUrl:{type:ControlType.String,title:\"Read More URL\",defaultValue:\"\"},infoDetail:{type:ControlType.String,title:\"Detail Info\",defaultValue:\"\"},price:{type:ControlType.Object,title:\"Addon Price\",controls:{monthly:{type:ControlType.Number,title:\"Monthly\",defaultValue:10},yearly:{type:ControlType.Number,title:\"Yearly\",defaultValue:100}}},showPrice:{type:ControlType.Boolean,title:\"Show Addon Price\",defaultValue:true},activationPrice:{type:ControlType.Object,title:\"Activation Price\",controls:{monthly:{type:ControlType.Number,title:\"Monthly\",defaultValue:5},yearly:{type:ControlType.Number,title:\"Yearly\",defaultValue:0}}},chargebeeId:{type:ControlType.Object,title:\"Addon Chargebee IDs\",controls:{monthly:{type:ControlType.String,title:\"Monthly\",defaultValue:\"\"},yearly:{type:ControlType.String,title:\"Yearly\",defaultValue:\"\"}}},activationChargebeeId:{type:ControlType.Object,title:\"Addon Activation Chargebee IDs\",controls:{monthly:{type:ControlType.String,title:\"Monthly\",defaultValue:\"\"},yearly:{type:ControlType.String,title:\"Yearly\",defaultValue:\"\"}}},addonDependencies:{type:ControlType.Array,title:\"Dependencies\",control:{type:ControlType.String},defaultValue:[]}}};export const PLAN_DETAILS_CONTROLS={price:{type:ControlType.Object,title:\"Price\",controls:{monthly:{type:ControlType.Number,title:\"Monthly Price\",defaultValue:50},yearly:{type:ControlType.Number,title:\"Yearly Price\",defaultValue:500}}},activationPrice:{type:ControlType.Object,title:\"Activation Price\",controls:{monthly:{type:ControlType.Number,title:\"Monthly Activation\",defaultValue:100},yearly:{type:ControlType.Number,title:\"Yearly Activation\",defaultValue:1e3}}},addons:{type:ControlType.Array,title:\"Add-ons\",control:ADDON_CONTROL}};export const PLAN_CONTROL={type:ControlType.Object,controls:{id:{type:ControlType.String,title:\"Plan ID\",defaultValue:\"plan-1\"},name:{type:ControlType.String,title:\"Plan Name\",defaultValue:\"Small Plan\"},seats:{type:ControlType.Array,title:\"Seats\",control:{type:ControlType.Number},defaultValue:[1,5]},chargebeeId:{type:ControlType.Object,title:\"Plan Chargebee IDs\",controls:{monthly:{type:ControlType.String,title:\"Monthly\",defaultValue:\"\"},yearly:{type:ControlType.String,title:\"Yearly\",defaultValue:\"\"}}},...PLAN_DETAILS_CONTROLS,showPrice:{type:ControlType.Boolean,title:\"Show Plan Price\",defaultValue:true}}};export function checkoutReducer(state,action){switch(action.type){case\"CHECKOUT/SET_PLAN\":return{...state,selectedPlan:action.payload,selectedAddons:[]};case\"CHECKOUT/TOGGLE_SUBSCRIPTION_TYPE\":return{...state,subscriptionType:state.subscriptionType===\"monthly\"?\"yearly\":\"monthly\"};case\"CHECKOUT/TOGGLE_ADDON\":{const toggledAddon=action.payload;const isSelected=state.selectedAddons.some(a=>a.id===toggledAddon.id);// 👉 SE LO SELEZIONO\nif(!isSelected){const dependenciesToAdd=toggledAddon.addonDependencies??[];const updatedAddons=[...state.selectedAddons,toggledAddon,...dependenciesToAdd.filter(depId=>!state.selectedAddons.some(a=>a.id===depId)).map(depId=>state.selectedPlan?.addons.find(a=>a.id===depId)).filter(Boolean)];return{...state,selectedAddons:updatedAddons};}else{const planAddons=state.selectedPlan?.addons??[];const dependentIds=findAllDependents(toggledAddon.id,planAddons);const updatedSelectedAddons=state.selectedAddons.filter(addon=>addon.id!==toggledAddon.id&&!dependentIds.includes(addon.id));return{...state,selectedAddons:updatedSelectedAddons};}}default:return state;}}/**\n * Trova ricorsivamente tutti gli addon che dipendono da un certo addon.\n */function findAllDependents(removedAddonId,allPlanAddons){const visited=new Set;const queue=[removedAddonId];while(queue.length>0){const currentId=queue.shift();const directDependents=allPlanAddons.filter(addon=>addon.addonDependencies?.includes(currentId));for(const dep of directDependents){if(!visited.has(dep.id)){visited.add(dep.id);queue.push(dep.id);}}}return Array.from(visited);}\nexport const __FramerMetadata__ = {\"exports\":{\"Plan\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PLAN_DETAILS_CONTROLS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"CheckoutAction\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"checkoutReducer\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PLAN_CONTROL\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"ADDON_CONTROL\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SubscriptionType\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"Price\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"CheckoutState\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"SUBSCRIPTION_TYPE_CONTROL\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"PlanDetails\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"Addon\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PricingTypes.map"],"mappings":"sGAAk0F,SAAgB,EAAgB,EAAM,EAAO,CAAC,OAAO,EAAO,KAAd,CAAoB,IAAI,oBAAoB,MAAM,CAAC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