1import{i as u,r as t}from"./chunk-DnjdbM49.js";import{c as s,n as c,o as m}from"./chunk-BIrIC3bm.js";import{t as l}from"./chunk-78A-kxvz.js";import{c as N$1}from"./chunk-BK5cI4Fm.js";import{Gt as n}from"./main-TMFE65WZ.js";import{C as C$1}from"./chunk-CP8jVq-R.js";function F(e,r=[]){if(!e)return null;if(e.Number)return e.Number;let t=r.reduce((n,i)=>(i.Values.forEach(o=>{n[o.Id]=o}),n),{});return e.Attributes?.map(n=>t[n]?.Number)?.filter(Boolean).join(`-`)??null}function A(e,r){if(e.length!==r.length)return!1;let t=[...r];return e.every(n=>{let i=t.findIndex(o=>l(n,o));return i===-1?!1:(t.splice(i,1),!0)})}function T(e){return e.PreferredPrice==null?e:u(t({},e),{Cost:e.PreferredPrice,DiscountPercent:m(e.Price,e.PreferredPrice)})}function h(e){return e.map(T)}function C(e,r){return e!=null&&r!=null&&(A(e.Prices,h(r.Prices))===!1||(e.Description||``)!==(r.Description||``)||(e.PriceIncludes||``)!==(r.PriceIncludes||``))}function v(e,r){let t$1=C(e,r);return e&&r&&t$1?u(t({},e),{Prices:h(r.Prices),Description:r.Description,PriceIncludes:r.PriceIncludes}):null}function V(e){if(!e.length)return 0;let r=C$1(n(e));return Math.min(...r.map(t=>{let n=t.Prices[0]?.Quantity;return n?N$1(n)?n.From:n:0}))}function L(e,r){let t=Object.keys(e).map(Number);if(!t.length)return 0;let n=t.filter(i=>r[i]).map(i=>{let o=e[i];return o.IsUndefined?0:typeof o.Quantity==`number`?o.Quantity:o.Quantity&&`From`in o.Quantity?o.Quantity.From:0});return n.length?Math.min(...n):0}function M(e,r){let t=e.Prices||[],n=r.Prices||[];return t.length!==n.length?!0:t.some((i,o)=>{let u=n[o];return i.Price!==u.Price||i.Cost!==u.Cost||i.DiscountPercent!==u.DiscountPercent})}var N={IsVisible:!0,Sequence:0,DiscountCode:``,IsUndefined:!1,Quantity:{From:1,To:Number.MAX_SAFE_INTEGER}};var p={IsVisible:!0,Sequence:0,PriceIncludes:``,UsageLevel:`NONE`,AttributeMap:[],AttributeTypes:[],AttributeByTypes:{}};function O(e,r,t$2,n){return u(t({},N),{Price:e,Cost:r,DiscountPercent:n??0,CurrencyCode:t$2??`USD`})}function U(e,r,t$3){return u(t({},e),{Description:`${e.Description},${t$3??``}`,Attributes:[...e.Attributes??[],r]})}function k(e){return u(t({},p),{Id:s(`price-grid`),Description:` `,Prices:e,Attributes:[0]})}function E(e,r,t$4){return u(t({},p),{Id:s(`price-grid-${t$4??``}`),Description:t$4??``,Prices:e,Attributes:[r]})}function B(e,r){let t$5=e.map(i=>i.Attributes).reduce((i,o)=>[...i??[],...o??[]],[]),n=r.map(i=>u(t({},i),{Attributes:i.Attributes?.filter(o=>!t$5?.includes(o))})).filter(i=>(i.Attributes?.length??0)>0);return[...e,...n]}function q(e,r){return u(t({},e),{Prices:e.Prices.map(t$6=>{let n=t$6?.Price??0,i=t$6?.Cost??0,o=m(n,i),u$1=i+r;return u(t({},t$6),{Cost:u$1,Price:c(u$1,o)})})})}function P(e){let r=e.Quantity;return N$1(r)?r.To:typeof r==`number`?r:null}function D(e){let r=e.Quantity;return N$1(r)&&r.From===r.To}function b(e,r){if(!e?.length)return{IsUndefined:!0};let t=Number.isFinite(r)&&r>0?r:0,n=e.find(u=>P(u)===null);if(n)return n;let i=e.find(u=>{if(D(u))return t===P(u);let d=P(u);return d!==null&&t<=d});if(i)return i;let o=e.reduce((u,d)=>{let R=P(u)??0;return(P(d)??0)>=R?d:u},e[0]);return D(o)?{IsUndefined:!0}:o}function y(e){return(e??[]).reduce((r,t)=>(r[t.Id]=t,r),{})}function w(e,r){let{PresentationId:t,PresentationProductId:n}=e??{},{Id:i,PriceGrids:o}=r??{};return!t||!n||!o?.length||i!==n?null:y(o)}function a(e,r){return e?r?e.Cost??0:e.PreferredPrice||e.Cost||0:0}function Q(e,r,t){let n=e?.[t];if(n)return{grid:n,isPresentationLinked:!0};let i=r[t];return i?{grid:i,isPresentationLinked:!1}:null}function S(e,r,t,n){let i=Q(e,r,t);if(!i)return null;let o=b(i.grid.Prices,n);return o.IsUndefined?null:{cost:a(o,i.isPresentationLinked),price:o.Price??0}}function j(e,r,t,n,i){let o=Q(e,r,t);return o?o.grid.Prices.some(u=>!u.IsUndefined&&a(u,o.isPresentationLinked)===n&&(u.Price??0)===i):!1}export{w as _,L as a,S as c,a as d,b as f,v as g,q as h,F as i,U as l,k as m,C as n,M as o,j as p,E as r,O as s,B as t,V as u,y as v};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.