import{e as M,w as Q}from"./vendor-vue-runtime-core-DwK6Ry68.js";const v=[{value:"no_discounts",label:"Default"},{value:"tiered_discounts",label:"All Units Pricing"},{value:"cumulative_discounts",label:"Tiered Pricing"},{value:"flat_rate_discounts",label:"Flat Unit Price per Range"}],h=i=>[{value:"percent",label:"%"},{value:"symbol",label:i},{value:"symbol_and_percent",label:`${i} & %`}],S=[{value:"outlined",label:"Outlined"},{value:"primary",label:"Primary"},{value:"solid",label:"Solid"}];function P(i,R,p){const b=M(()=>{if(!Array.isArray(i.pricingRanges)||!i.pricingRanges.length)return!0;const s=i.pricingRanges[i.pricingRanges.length-1],e=parseFloat(String(s.maxQty)),n=parseFloat(p());return!Number.isFinite(e)||!Number.isFinite(n)?!1:e<n});function N(s,e,n){var g;if(!Array.isArray(i.pricingRanges))return;const t=parseFloat(R()),r=parseFloat(p());let l=n&&((g=n.target)==null?void 0:g.value)!=null?n.target.value:i.pricingRanges[s][e],a=parseFloat(String(l));if(Number.isFinite(t)&&!isNaN(a)&&a<t&&(a=t),Number.isFinite(r)&&!isNaN(a)&&a>r&&(a=r),e==="maxQty"){const c=i.pricingRanges[s]||{},m=parseFloat(String(c.minQty));if(Number.isFinite(m)&&!isNaN(a)&&a<=m){const u=m+1;a=Number.isFinite(r)?Math.min(u,r):u}const o=s+1;if(i.pricingRanges[o]){let u=Number.isFinite(a)?a+1:m+1;Number.isFinite(r)&&(u=Math.min(u,r)),i.pricingRanges[o].minQty=u;const F=parseFloat(String(i.pricingRanges[o].maxQty));(!Number.isFinite(F)||F<u)&&(i.pricingRanges[o].maxQty=u)}}i.pricingRanges[s][e]=a}function y(){Array.isArray(i.pricingRanges)||(i.pricingRanges=[]);const s=parseFloat(R()),e=parseFloat(p());if(!i.pricingRanges.length){const a=Number.isFinite(e)?Math.min(e,10):10;i.pricingRanges.push({minQty:Number.isFinite(s)?s:0,maxQty:a,unitPrice:0});return}const n=i.pricingRanges[i.pricingRanges.length-1],t=parseFloat(String(n.maxQty))||0,r=t+1,l=Number.isFinite(e)?e:t+10;Number.isFinite(e)&&r>e||i.pricingRanges.push({minQty:r,maxQty:l,unitPrice:0})}function x(s){Array.isArray(i.pricingRanges)&&s>0&&i.pricingRanges.splice(s,1)}return Q(R,s=>{if(!Array.isArray(i.pricingRanges)||!i.pricingRanges.length)return;const e=parseFloat(String(s)),n=parseFloat(p());if(!Number.isFinite(e))return;i.pricingRanges[0].minQty=e;let t=parseFloat(String(i.pricingRanges[0].maxQty)),r=Number.isFinite(n)?Math.min(e+1,n):e+1;(!Number.isFinite(t)||t<r)&&(t=r),Number.isFinite(n)&&t>n&&(t=n),i.pricingRanges[0].maxQty=t;for(let l=1;l<i.pricingRanges.length;l++){const a=parseFloat(String(i.pricingRanges[l-1].maxQty));let g=Number.isFinite(a)?a+1:Number.isFinite(e)?e+1:0;Number.isFinite(n)&&(g=Math.min(g,n)),i.pricingRanges[l].minQty=g;let c=parseFloat(String(i.pricingRanges[l].maxQty)),m=Number.isFinite(n)?Math.min(g+1,n):g+1;(!Number.isFinite(c)||c<m)&&(c=m),Number.isFinite(n)&&c>n&&(c=n),i.pricingRanges[l].maxQty=c}}),{canAddPricingRange:b,clampPricingRange:N,addPricingRange:y,removePricingRange:x}}export{h as B,v as P,S as a,P as u};
//# sourceMappingURL=usePricingRanges-B_nIc7fb.js.map
