"use strict";const extractVariantId=t=>t?t.includes("/ProductVariant/")?t.split("/ProductVariant/")[1]||"":t:"",extractProductId=t=>t?t.includes("/Product/")?t.split("/Product/")[1]||"":t:"",extractSellingPlanSettings=({sellingPlansSetting:t,currentVariant:e,product:i,isFromEvent:a=!1})=>{let r={sourceApp:void 0,group:void 0,defaultOptions:void 0};if(!t)return r;if(a&&e?.id){let a,r;if(i&&"baseID"in i&&i.baseID?(a=extractProductId(i.baseID),r=Object.keys(t)[0]):a="data"===(r=Object.keys(t)[0])&&t[r]?Object.keys(t[r])[0]:r,a){let i="data"===r?t.data:t[a],d="data"===r?i[a]:i;if(d){let t=extractVariantId(e.id?.toString()||""),i=extractVariantId(e.baseID||""),a=Object.keys(d).find(a=>a===e.id?.toString()||a===e.baseID||a===t||a===i||e.id?.toString()===a||e.baseID===a||e.id?.toString().includes(a)||e.baseID?.includes(a)||a.includes(t)||a.includes(i));if(a&&d[a]){let t=d[a];return{sourceApp:t?.sourceApp,group:t?.group,defaultOptions:t?.defaultOption}}}}}return r};exports.extractSellingPlanSettings=extractSellingPlanSettings;
