import{useRef as e,useEffect as l}from"react";let t=({defaultValue:t,selectedSellingPlan:n,setSelectedSellingPlan:r,sellingPlanOptions:a})=>{let u=e(!0);l(()=>{if(u.current){if(!n){let e=t||a[0]?.value||"";e&&r(e)}u.current=!1;return}if(n){let e=a.some(e=>e.value===n);if(!e&&a.length>0){let e=t||a[0]?.value||"";e&&r(e)}}},[t,a,n,r]);let i=n||t||a[0]?.value||"";return{selectedValue:i,handleSellingPlanChange:e=>{r(e)}}};export{t as useSellingPlanChange};
