1import{N as C,K as O,j as e,a9 as ne,a7 as re,r as g,d as P,aZ as W}from"./vendor-99f70dcc.js";import{M as ce}from"./ModalHeader-d4b78689.js";import{ba as ie,av as a,aw as X,o as ee,q as E,p as R,af as V,c as te,m as M,H as ae,e as Y,J as G,u as oe,x as de,ax as ue,ay as me,I as _e,an as he}from"./index-4aa601a2.js";import{u as se,a as Se}from"./hooks-ac487861.js";import{C as ve}from"./CheckoutProductCard-ada5a1c7.js";import{a as be}from"./Header-7cc81d50.js";import{V as fe,M as ye}from"./ModalFooter-e5f19aeb.js";import"./truncateSlots-6f4e1624.js";const pe="_root_y1bkl_1",xe="_label_y1bkl_4",ke="_slider_y1bkl_8",je="_slide_y1bkl_8",De="_productImg_y1bkl_23",ge="_productName_y1bkl_37",we="_productCount_y1bkl_48",B={root:pe,label:xe,slider:ke,slide:je,productImg:De,productName:ge,productCount:we},H=(c,o=0)=>ne(Date.now())+re(o)>c,Ne=({currentItems:c,unavailableProducts:o})=>{const{t:s}=O();if(!o.length)return null;const n=c.length-o.length,t=n>1?s("slotSelection:items",{count:n}):s("slotSelection:item");return e.jsxs("div",{className:B.root,children:[e.jsx("p",{className:B.label,children:s("slotSelection:availableProductsForSlot",{expression:t})}),e.jsx(ie,{sliderClassName:B.slider,slideClassName:B.slide,spaceBetween:4,slidesPerViewProp:"auto",children:c.map(i=>{const r=o.some(l=>l.sku===i.sku);return e.jsx(ve,{offer:i,disabled:r},i.id)})})]})},Ie=C(Ne),Ce="_slotDate_ji4b3_2",$e="_slotDateLabel_ji4b3_10",Te="_checked_ji4b3_23",q={slotDate:Ce,slotDateLabel:$e,checked:Te},Me=({timeStamp:c,isDisabled:o,isChecked:s,onChange:n})=>{const t=g.useId(),{day:i}=se({timeStamp:c});if(!a.slotSelectionModalStore.selectedOrder)throw new Error("Order not found");return e.jsxs("li",{className:q.slotDate,children:[e.jsx("input",{"data-radio":"date",type:"radio",value:c,id:t,name:"date",checked:s,onChange:({target:l})=>{n(l.value)},disabled:o}),e.jsx("label",{htmlFor:t,className:P([q.slotDateLabel,s&&q.checked]),children:i})]})},Pe=C(Me),Fe="_dateSelector_1cfxz_14",Le={dateSelector:Fe},Ae=({timeStamps:c,selectedDate:o,onDateChange:s,deliverySlots:n})=>{const t=c.map(i=>{var r;return e.jsx(Pe,{timeStamp:i,onChange:s,isChecked:o===i,isDisabled:!((r=n[i])!=null&&r.length)},i)});return e.jsx("div",{className:Le.dateSelector,children:t})};C(Ae);const Ee="_slotItem_757qf_2",Oe="_checked_757qf_22",Be="_slotLabel_757qf_28",We="_slotItemContent_757qf_37",Re="_timeBlock_757qf_43",Ve="_timeRange_757qf_47",qe="_minOrderAmount_757qf_51",He="_deliveryFee_757qf_55",ze="_freeDelivery_757qf_60",I={slotItem:Ee,checked:Oe,slotLabel:Be,slotItemContent:We,timeBlock:Re,timeRange:Ve,minOrderAmount:qe,deliveryFee:He,freeDelivery:ze},Ye=({slot:c,isSelected:o,onSelect:s,priceWithoutDelivery:n})=>{const{t}=O(),{locale:i}=X(),{timeFormat:r}=ee(),{schedule_slot_id:l,delivery_min_time:d,delivery_max_time:u,delivery_price:y,order_amount_threshold:w,free_delivery_threshold:j}=c,v=a.slotSelectionModalStore.selectedSlot,p=E.selectedCartItems.filter(({sku:S})=>v==null?void 0:v.itemsIds.includes(S)),x=a.isDeliverTogether?p.filter(S=>{var T;const{count:N,sellableWarehouses:k,backorderLeadTime:$}=S;return Number(k[`${(T=R.etaCalculation)==null?void 0:T.warehouse.code}`]||"0")>=N&&R.isExpressAvailableNow?!1:H(d,$)}):[],_=()=>{const S=+M.convertPenceToPounds(y),N=+M.convertPenceToPounds(j),k=+M.convertPenceToPounds(w??0),$=S===0||N<=n;return{minOrderAmount:k>0?k:null,deliveryFee:$?null:S,isFreeDelivery:$}},{minOrderAmount:m,deliveryFee:b,isFreeDelivery:h}=_(),f=()=>{s(l,x.length>0)};return e.jsxs("label",{htmlFor:l,className:P([I.slotItem,o&&I.checked]),children:[e.jsxs("div",{className:I.slotLabel,children:[e.jsx("input",{type:"radio",name:"time",id:l,checked:o,onChange:f}),e.jsx("div",{className:I.slotItemContent,children:e.jsxs("div",{className:I.timeBlock,children:[e.jsxs("div",{className:I.timeRange,children:[W(new Date(d*1e3),r,{locale:i})," - ",W(new Date(u*1e3),r,{locale:i})]}),m&&e.jsx("div",{className:I.minOrderAmount,children:t("checkout:minimumOrderValue",{price:V(m)})})]})}),!te.hasNewLogistics&&e.jsx("span",{className:P([I.deliveryFee,h&&I.freeDelivery]),children:h?t("checkout:deliveryFree"):V(b)})]}),e.jsx(Ie,{currentItems:p,unavailableProducts:x})]})},Ge=C(Ye),Je="_slotList_ejtk8_2",Ke={slotList:Je},Ue=({selectedDate:c,selectedSlotId:o,deliverySlots:s,onSlotSelect:n,priceWithoutDelivery:t})=>{var i;return e.jsx("ul",{className:Ke.slotList,children:c&&((i=s[c])==null?void 0:i.map(r=>e.jsx(Ge,{slot:r,isSelected:r.schedule_slot_id===o,onSelect:n,priceWithoutDelivery:t},r.schedule_slot_id)))})};C(Ue);const Ze=()=>{const{closeModal:c}=ae(),{deliverySlots:o,currentDelivery:s}=Se(),n=a.slotSelectionModalStore.v3WarehouseId,t=!!n,i=()=>{t&&a.slotSelectionModalStore.setV3Context(null),c()},r=Object.keys(o).filter(_=>{var m;return!!((m=o[_])!=null&&m.length)}),[l,d]=g.useState(r[0]),[u,y]=g.useState(),[w,j]=g.useState(!1);return g.useEffect(()=>{if(u||l)return;const _=()=>{r[0]&&d(r[0])};if(t){const f=E.v3RouteSelection.find(N=>N.warehouse_id===n),S=f!=null&&f.slot_delivery_details?a.slotSelectionModalStore.getSlotByIdAndDate(f.slot_delivery_details.schedule_slot_id,`${f.slot_delivery_details.current_date}`):void 0;S?d(`${S.current_date*1e3}`):_();return}const m=s==null?void 0:s.slot;if(!m){_();return}const b=a.slotSelectionModalStore.getSlotByIdAndDate(m.schedule_slot_id,`${m.current_date}`),h=b?`${b.current_date*1e3}`:void 0;if(!h||!r.includes(h)){_();return}d(h)},[]),{selectedDate:l,selectedSlotId:u,shouldSplitSlot:w,timeStamps:r,deliverySlots:o,currentDelivery:s,setSelectedDate:d,setSelectedSlotId:y,onChangeSlotId:(_,m=!1)=>{j(m),y(_)},handleSelectSlot:()=>{var m,b,h;if(!l||!u)throw new Error("Something went wrong");if(t&&n){const f=(m=o[l])==null?void 0:m.find(N=>N.schedule_slot_id===u),S=f?f.current_date:Math.floor(Number(l)/1e3);E.selectV3Slot(n,u,S),i(),Y.track(G.DELIVERY_METHOD_SELECTED,{type:"Slot"});return}if(!a.deliveries||!s)throw new Error("Something went wrong");if(((b=s.slotDeliveryDetails)==null?void 0:b.scheduleSlotId)===u&&`${(((h=s.slotDeliveryDetails)==null?void 0:h.currentDate)??0)*1e3}`===l){a.slotSelectionModalStore.removeAutomaticDelivery(u),a.slotSelectionModalStore.setSelectedSlot(null,null),i();return}a.slotSelectionModalStore.updateDelivery(u,l),i(),a.slotSelectionModalStore.setSelectedSlot(null,null),Y.track(G.DELIVERY_METHOD_SELECTED,{type:"Slot"})},handleSplit:()=>{var b;if(t){i();return}if(!a.deliveries||!s)throw new Error("Something went wrong");if(!l||!u)throw new Error("Something went wrong");const _=(b=o[l])==null?void 0:b.find(h=>h.schedule_slot_id===u);if(E.selectedCartItems.filter(({backorderLeadTime:h})=>H(_.delivery_min_time,h)).length&&a.isMultipleDeliveriesAvailable&&a.isDeliverTogether){a.slotSelectionModalStore.setSelectedSlotForSplit(u),a.switchDeliverTogether(),i();return}}
1,setShouldSplitSlot:j,closeModal:i}},Qe="_root_pzgl8_2",Xe="_submitBtn_pzgl8_12",J={root:Qe,submitBtn:Xe},et=({shouldSplitSlot:c,handleSelectSlot:o,handleSplit:s,selectedSlotId:n,handleCloseModal:t})=>{const{isMobile:i}=oe(),{t:r}=O(),[l,d]=g.useState(!1),u=()=>{if(!n){d(!0);return}(c?s:o)()},y=()=>{d(!1)};return g.useEffect(()=>{n&&d(!1)},[n]),i?e.jsx(ye,{onBack:t,primaryAction:{text:r("confirm"),onClick:u},validationTooltip:{show:l,message:r("selectTimeSlot"),onClose:y}}):e.jsx("div",{className:J.root,children:e.jsx(fe,{title:r("selectTimeSlot"),open:l,onClose:y,children:e.jsx(de,{variant:"primary",className:J.submitBtn,onClick:u,children:a.isPickupSelected?r("checkout:pickupByThisTime"):r("deliverByThisTime")})})})},tt=C(et),ot="_root_oco26_1",st="_selected_oco26_10",K={root:ot,selected:st},le=g.forwardRef(({timeStamp:c,onClick:o,selected:s},n)=>{const{day:t}=se({timeStamp:c});return e.jsx("div",{className:P([K.root,s&&K.selected]),role:"tab",tabIndex:-1,onClick:o,ref:n,children:t})});le.displayName="DateItem";const lt="_root_17jmn_2",nt="_inner_17jmn_23",U={root:lt,inner:nt},rt=({timeStamps:c,selectedDate:o,setSelectedDate:s})=>{const n=g.useRef(new Map),t=l=>()=>{s(l)},i=l=>d=>{if(!d){n.current.delete(l);return}n.current.set(l,d)},r=()=>{const l={"--indicator-position":0};if(!o)return l;const d=n.current.get(o);return d?{"--indicator-position":`${d.offsetLeft}px`,"--indicator-width":`${d.offsetWidth}px`}:l};return e.jsx("div",{className:U.root,children:e.jsx("div",{className:U.inner,style:r(),children:c.map(l=>e.jsx(le,{timeStamp:l,onClick:t(l),selected:l===o,ref:i(l)},l))})})},ct="_root_kemis_2",it="_available_kemis_12",at="_preview_kemis_15",dt="_image_kemis_25",ut="_count_kemis_41",mt="_title_kemis_53",F={root:ct,available:it,preview:at,image:dt,count:ut,title:mt},Z=({cartItem:c,available:o})=>e.jsxs("div",{className:P([F.root,o&&F.available]),children:[e.jsxs("div",{className:F.preview,children:[e.jsxs("span",{className:F.count,children:["x",c.count]}),e.jsx(ue,{src:c.previewImageThumb,srcParams:{width:72,height:72},srcSetParams:me,alt:"",className:F.image,loading:"lazy"})]}),e.jsx("div",{className:F.title,children:c.name})]}),_t="_root_7bxi1_2",ht={root:_t},St=({unavailableProducts:c,currentItems:o})=>{const s=c.map(t=>t.id);if(!s.length)return null;const n=o.filter(t=>!s.includes(t.id));return e.jsxs("div",{className:ht.root,children:[n.map(t=>e.jsx(Z,{cartItem:t,available:!0},t.id)),c.map(t=>e.jsx(Z,{cartItem:t,available:!1},t.id))]})},vt="_root_9bl2b_2",bt="_inner_9bl2b_9",ft="_selected_9bl2b_26",yt="_timeWr_9bl2b_29",pt="_time_9bl2b_29",xt="_minOrderAmount_9bl2b_41",kt="_unavailableLabel_9bl2b_45",jt="_deliveryFee_9bl2b_49",Dt="_free_9bl2b_54",gt="_selectedMark_9bl2b_57",D={root:vt,inner:bt,selected:ft,timeWr:yt,time:pt,minOrderAmount:xt,unavailableLabel:kt,deliveryFee:jt,free:Dt,selectedMark:gt},wt=({slot:c,priceWithoutDelivery:o,onSelect:s,isSelected:n})=>{const{t}=O(),{locale:i}=X(),{timeFormat:r}=ee(),{schedule_slot_id:l,delivery_min_time:d,delivery_max_time:u,delivery_price:y,order_amount_threshold:w,free_delivery_threshold:j}=c,v=a.slotSelectionModalStore.selectedSlot,p=E.selectedCartItems.filter(({sku:k})=>v==null?void 0:v.itemsIds.includes(k)),x=a.isDeliverTogether?p.filter(k=>{var z;const{count:$,sellableWarehouses:L,backorderLeadTime:T}=k;return Number(L[`${(z=R.etaCalculation)==null?void 0:z.warehouse.code}`]||"0")>=$&&R.isExpressAvailableNow?!1:H(d,T)}):[],_=()=>{const k=+M.convertPenceToPounds(y),$=+M.convertPenceToPounds(j),L=+M.convertPenceToPounds(w??0),T=k===0||$<=o;return{minOrderAmount:L>0?L:null,deliveryFee:T?null:k,isFreeDelivery:T}},{minOrderAmount:m,deliveryFee:b,isFreeDelivery:h}=_(),f=()=>{s(l,x.length>0)},S=p.length-x.length,N=S>1?t("slotSelection:items",{count:S}):t("slotSelection:item");return e.jsxs("div",{className:P([D.root,n&&D.selected]),role:"button",tabIndex:-1,onClick:f,children:[e.jsxs("div",{className:D.inner,children:[e.jsxs("div",{className:D.timeWr,children:[e.jsxs("span",{className:D.time,children:[W(new Date(d*1e3),r,{locale:i})," - ",W(new Date(u*1e3),r,{locale:i})]}),m&&e.jsx("span",{className:D.minOrderAmount,children:t("checkout:minimumOrderValue",{price:V(m)})}),x.length>0&&e.jsx("span",{className:D.unavailableLabel,children:t("slotSelection:availableProductsForSlot",{expression:N})})]}),te.hasNewLogistics?n&&e.jsx(_e,{type:"check",size:20,className:D.selectedMark}):e.jsx("div",{className:P([D.deliveryFee,h&&D.free]),children:h?!a.isPickupSelected&&t("checkout:deliveryFree"):V(b)})]}),e.jsx(St,{currentItems:p,unavailableProducts:x})]})},Nt=C(wt),It="_root_1i1b8_2",Ct="_inner_1i1b8_15",Q={root:It,inner:Ct},$t=({selectedSlotId:c,selectedDate:o,onSlotSelect:s,priceWithoutDelivery:n,deliverySlots:t})=>{var i;return e.jsx("div",{className:Q.root,children:e.jsx("div",{className:Q.inner,children:o&&((i=t[o])==null?void 0:i.map(r=>e.jsx(Nt,{slot:r,priceWithoutDelivery:n,onSelect:s,isSelected:r.schedule_slot_id===c},`${r.schedule_slot_id}${r.current_date}`)))})})},Tt=C($t),Mt="_root_k4wb8_2",Pt="_header_k4wb8_17",Ft="_container_k4wb8_33",Lt="_body_k4wb8_42",A={root:Mt,header:Pt,container:Ft,body:Lt},At=()=>{const{t:c}=O(),{isMobile:o}=oe(),{selectedDate:s,selectedSlotId:n,handleSelectSlot:t,handleSplit:i,shouldSplitSlot:r,setSelectedDate:l,onCh
1angeSlotId:d,timeStamps:u,deliverySlots:y,closeModal:w,currentDelivery:j}=Ze(),v=()=>{w()},p=!!a.slotSelectionModalStore.v3WarehouseId;if(g.useEffect(()=>{!j&&!p&&w()},[j,p]),!j&&!p)return null;const x=a.slotSelectionModalStore.selectedOrder;if(!x)return null;const _=+M.convertPenceToPounds(x.paid_without_delivery);return e.jsx(he,{isShow:!0,className:A.root,onBackdropDismiss:v,children:e.jsx("div",{className:A.root,children:e.jsxs("div",{className:A.container,children:[e.jsx("div",{className:A.header,children:e.jsx(ce,{variant:o?"dark":"default",size:"S",title:c(a.isPickupSelected?"checkout:selectPickupTime":"checkout:setTimeSlot"),onClose:o?void 0:v})}),e.jsxs(be,{className:A.body,children:[e.jsx(rt,{timeStamps:u,selectedDate:s,setSelectedDate:l}),e.jsx(Tt,{deliverySlots:y,selectedDate:s,selectedSlotId:n,onSlotSelect:d,priceWithoutDelivery:_})]}),e.jsx(tt,{selectedSlotId:n,shouldSplitSlot:r,handleSplit:i,handleSelectSlot:t,handleCloseModal:v})]})})})},Yt=C(At);export{Yt as default}; 2//# sourceMappingURL=ModalSlotsSelectDateV3-3458e482.js.map
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.