1import{f as y}from"./esnext-vendor.7EcvH7tF.js";import{aJ as b,aK as S,n as C,Q as T,a2 as I,aw as k,aL as w,aH as x,r as G}from"./utilities-previous.BNOUhCqt.js";import{ap as B,ad as D}from"./hydrate.CvWSYK3c.js";import{p as A,s as P,c as N,a as E}from"./EstimatedDeliveryContent.Dh3d0XR_.js";function F(t){if(t===void 0)return;if(typeof t=="number")return{lower:t,upper:t};const{lower:n,upper:e}=t;if(!(n===void 0||e===void 0))return{lower:n,upper:e}}function $(t){let n,e;for(const{estimatedTimeInTransit:o}of t){const i=F(o);if(!i)return;n=n===void 0?i.lower:Math.min(n,i.lower),e=e===void 0?i.upper:Math.max(e,i.upper)}if(!(n===void 0||e===void 0))return n===e?n:{lower:n,upper:e}}function H({line:t,localShopId:n,marketDrivenShippingEnabled:e,remoteShopsConfigMap:o,remoteMerchandiseDetails:i}){const s=b(t,i,n);if(s===n)return e;const r=o?.get(s);return r?r.marketDrivenShippingEnabled:t.methods.some(d=>!!S(d))}function K(t,n){if(!t)return`unresolved:${n}`;const e=t.deliveryPresentationGroupToken;return e?`token:${e}`:`no-token:${n}:${t.handle}`}function f(t){const n=new Map;return t.forEach(({line:e,method:o},i)=>{const s=K(o,e.id??`index-${i}`);let r=n.get(s);r||(r={key:s,methods:[],merchandiseLines:[],mergedTimeInTransit:void 0,availableOn:e.availableOn},n.set(s,r)),o&&r.methods.push(o),e.targetMerchandiseLines&&r.merchandiseLines.push(...e.targetMerchandiseLines)}),[...n.values()].map(e=>({...e,merchandiseLines:B(e.merchandiseLines),mergedTimeInTransit:$(e.methods)}))}function Q(t){const n=t.map(o=>({line:o,method:C(o)})),e=n.filter(g);return{groups:f(e),nonShippableCount:n.length-e.length}}function g({line:t,method:n}){return n?n.methodType==="SHIPPING"||n.methodType==="LOCAL":t.methods.length===0||t.methods.some(({methodType:e})=>e==="SHIPPING"||e==="LOCAL")}function V(t){return{...t,included:!0}}function W(t,n){return[...t.filter(e=>!n(e)),...t.filter(n)]}function j(){const{shop:{id:t,marketDrivenShippingEnabled:n,remoteShopsConfigMap:e}}=T(),{deliveryNext:o,remoteMerchandiseDetails:i}=I(),{parts:s}=k();return y(()=>{const r={includedMethods:new Set,total:void 0,presentsConsolidatedShipping:!1,groups:[]},d=o.value;if(!d||d.status!=="filled")return r;const{oneTimePurchaseLines:u}=D(w(d).filter(x));if(u.length<2)return r;const c=(a,l)=>G({line:a,method:l,localShopId:t,marketDrivenShippingEnabled:n,remoteShopsConfigMap:e,remoteMerchandiseDetails:i.value}),h=u.some(a=>H({line:a,localShopId:t,marketDrivenShippingEnabled:n,remoteShopsConfigMap:e,remoteMerchandiseDetails:i.value}));if(!h)return r;const v=A(s.deliveryLines.value),p=P(u,v),m=p.filter(a=>!!a.method),L=m.length===u.length?N(m.map(({line:a,method:l})=>({...l,amountCombinabilityToken:c(a,l)}))):void 0,M=f(p.filter(g));return{includedMethods:E(u,p,c),total:L,presentsConsolidatedShipping:h,groups:M}})}export{V as a,Q as b,f as c,g as i,$ as m,W as o,K as s,j as u};
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.