PageSourceSearch

https://samugiken.com/_next/static/chunks/pages/checkout-d1f0c0fde9b867d9.js

js samugiken.com collected 2026-10-07 01:51:13 UTC 29,537 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2222],{1690:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/checkout",function(){return t(39929)}])},50706:function(e,s,t){"use strict";var a=t(52676),n=t(18060),i=t(29350),r=t(77471),l=t(21844),d=t(4948),o=t(78672),c=t(78051),u=t(75271),m=t(74563),x=t.n(m),p=t(30746);t(41877);let h={refId:"",firstName:"",lastName:"",phone:"",addressLine1:"",addressLine2:"",postcode:"",city:"",state:"",country:"Malaysia",isDefault:!1};s.Z=e=>{let{onFinish:s,form:t,loading:m,disabled:v,defaultAddressValue:f,defaultAddressLocked:j}=e,b=n.Z.useWatch("state",t),y=n.Z.useWatch("city",t),g=(0,p.Pz)(),N=(0,p.MC)(b),w=(0,p.Wy)(b,y);return(0,u.useEffect)(()=>{"boolean"==typeof f&&t.setFieldValue("isDefault",f)},[f,t]),(0,a.jsxs)(n.Z,{form:t,onFinish:s,layout:"vertical",initialValues:{...h,isDefault:null!=f?f:h.isDefault},children:[(0,a.jsxs)(i.Z,{gutter:16,children:[(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{name:"firstName",label:"First Name",rules:[{required:!0}],children:(0,a.jsx)(l.default,{})})}),(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{name:"lastName",label:"Last Name",rules:[{required:!0}],children:(0,a.jsx)(l.default,{})})})]}),(0,a.jsx)(i.Z,{gutter:16,children:(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{name:"phone",label:"Phone",rules:[{required:!0}],children:(0,a.jsx)(x(),{inputProps:{required:!0},country:"my",inputClass:"form-control",inputStyle:{width:"100%",borderRadius:"6px"},buttonStyle:{borderRadius:"6px 0px 0px 6px",backgroundColor:"#FFFFFF"}})})})}),(0,a.jsxs)(i.Z,{gutter:16,children:[(0,a.jsx)(r.Z,{xs:24,sm:24,children:(0,a.jsx)(n.Z.Item,{name:"addressLine1",label:"Address Line 1",rules:[{required:!0}],children:(0,a.jsx)(l.default,{})})}),(0,a.jsx)(r.Z,{xs:24,sm:24,children:(0,a.jsx)(n.Z.Item,{name:"addressLine2",label:"Address Line 2",children:(0,a.jsx)(l.default,{})})})]}),(0,a.jsxs)(i.Z,{gutter:16,children:[(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{label:"State",name:"state",rules:[{required:!0,message:"Please enter your state"}],children:(0,a.jsx)(d.default,{showSearch:!0,size:"large",options:g.map(e=>({label:e,value:e})),onChange:()=>{t.setFieldValue("city",void 0),t.setFieldValue("postcode",void 0)}})})}),(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{label:"City",name:"city",rules:[{required:!0,message:"Please enter your city"}],children:(0,a.jsx)(d.default,{showSearch:!0,size:"large",options:N.map(e=>({label:e,value:e})),disabled:!b,onChange:()=>{t.setFieldValue("postcode",void 0)}})})}),(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{label:"Postcode",name:"postcode",rules:[{required:!0,message:"Please enter your postcode"}],children:(0,a.jsx)(d.default,{showSearch:!0,size:"large",options:w.map(e=>({label:e,value:e})),disabled:!b||!y})})}),(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{label:"Country",name:"country",initialValue:"Malaysia",children:(0,a.jsx)(l.default,{disabled:!0,value:"Malaysia",size:"large"})})})]}),(0,a.jsx)(i.Z,{gutter:16,children:(0,a.jsx)(r.Z,{xs:24,sm:12,children:(0,a.jsx)(n.Z.Item,{layout:"horizontal",name:"isDefault",label:"Set as default address",valuePropName:"checked",children:(0,a.jsx)(o.Z,{disabled:j})})})}),s&&(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(c.ZP,{type:"primary",htmlType:"submit",loading:m,disabled:v,children:"Save"})})]})}},39929:function(e,s,t){"use strict";t.r(s),t.d(s,{__N_SSP:function(){return U},default:function(){return O}});var a=t(52676),n=t(46980),i=t(33561),r=t(75271),l=t(18060),d=t(9059),o=t(91709),c=t(78051),u=t(79406),m=t(69834),x=t(71030),p=t(56115),h=t(6443),v=t(75218);let f={name:"Samu Giken Pickup",addressLine1:"31, Jalan Metro Perdana Timur 10",addressLine2:"Kepong",city:"Kuala Lumpur",state:"Kuala Lumpur",postcode:"52100",country:"Malaysia",hours:"Mon-Fri 9am - 5pm, Sat 9am - 1pm",phone:"+60 12-336 6726"};var j=t(50706),b=t(76517),y=t(72818),g=t(51118),N=t(22127),w=t(46095),P=t(32623),Z=t.n(P),I=t(22903),E=t(21844),S=t(57285),F=t(33028),C=t(49734),k=t(92471),R=t(27610),L=t(47645),D=t(57065);function M(e){var s;let{checkoutSessionRefId:t,deliveryMethod:a="DELIVERY"}=e,n=(0,m.a)({queryKey:["available-coupons",t],queryFn:()=>(0,C.y6)({checkoutSessionRefId:t}).then(e=>e.data),staleTime:3e4}),i=e=>"PICKUP"===a&&"FREE_SHIPPING"===e.discountType,r=(null!==(s=n.data)&&void 0!==s?s:[]).filter(e=>e.canApply&&!i(e)).length;return{query:n,isBlockedForPickup:i,applicableCount:r}}let A=e=>{let{children:s}=e;return(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[s,(0,a.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-red-500"})]})};function _(e){var s;let{subtotal:t,items:n,appliedCoupons:i,onCouponApplied:l,onCouponRemoved:d,disabled:m,checkoutSessionRefId:x,shippingDiscount:p=0,deliveryMethod:h="DELIVERY",modalOpen:v,setModalOpen:f}=e,[j,y]=(0,r.useState)("available"),[g,P]=(0,r.useState)(""),[Z,I]=(0,r.useState)(!1),[S,F]=(0,r.useState)(null),[_,V]=(0,r.useState)(null),{query:q,isBlockedForPickup:T}=M({checkoutSessionRefId:x,deliveryMethod:h}),z=i.reduce((e,s)=>e+s.discount,0),U=async function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=e.trim().toUpperCase();
1if(!a){F("Please enter a voucher code");return}if(i.some(e=>e.code.toUpperCase()===a)){if(s)return;F("This voucher has already been applied");return}s?V(a):(I(!0),F(null));try{let e=await (0,C.hD)({couponCode:a,subtotal:t,items:n,appliedCouponCodes:i.map(e=>e.code)});if(e.data.valid&&e.data.coupon){if("PICKUP"===h&&"FREE_SHIPPING"===e.data.coupon.discountType){let e="Free shipping vouchers are not available for pickup orders";s?b.Am.error(e):F(e);return}let t={code:e.data.coupon.code,title:e.data.coupon.title,discountType:e.data.coupon.discountType,individualUseOnly:e.data.coupon.individualUseOnly,discount:e.data.estimatedDiscount||0};l(t),P(""),b.Am.success("Voucher applied!")}else{let t=e.data.error||"Invalid voucher code";s?b.Am.error(t):F(t)}}catch(t){var r,d;let e=(null==t?void 0:null===(d=t.response)||void 0===d?void 0:null===(r=d.data)||void 0===r?void 0:r.message)||(null==t?void 0:t.message)||"Failed to validate voucher";s||F(e),b.Am.error(e)}finally{V(null),I(!1)}},O=e=>{d(e),b.Am.info("Voucher removed")},K=e=>i.some(s=>s.code===e),Y=i.length>0,G=null===(s=q.data)||void 0===s?void 0:s.filter(e=>!e.unavailable),H=null==G?void 0:G.filter(e=>"FREE_SHIPPING"===e.discountType),W=null==G?void 0:G.filter(e=>"FREE_SHIPPING"!==e.discountType),B=(e,s)=>(0,a.jsxs)("div",{className:"space-y-3 max-h-[60vh] overflow-y-auto pr-1",children:[q.isLoading&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.Z,{active:!0,paragraph:{rows:2}}),(0,a.jsx)(k.Z,{active:!0,paragraph:{rows:2}})]}),!q.isLoading&&(null==e?void 0:e.length)===0&&(0,a.jsx)("div",{className:"py-8 text-center text-gray-400",children:s}),null==e?void 0:e.map(e=>{let s=K(e.code),t=_===e.code,n=T(e),i=e.canApply&&!n,r=n?"Not available for pickup orders":e.disabledReason;return(0,a.jsx)("div",{className:"rounded-2xl border p-4 transition-all ".concat(i||s?s?"border-emerald-200 bg-emerald-50/80":"border-neutral-200 bg-white shadow-[0_8px_24px_rgba(15,23,42,0.04)]":"border-neutral-200 bg-neutral-50 opacity-60"),children:(0,a.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:(0,a.jsx)("span",{className:"rounded-full px-2.5 py-1 text-xs font-semibold ".concat("FREE_SHIPPING"===e.discountType?"bg-sky-100 text-sky-700":"bg-emerald-100 text-emerald-700"),children:function(e){if("PERCENTAGE"===e.discountType){let s=e.percentMaxDiscount?" (max RM".concat(e.percentMaxDiscount.toFixed(2),")"):"";return"".concat(e.percentOff,"% OFF").concat(s)}if("FIXED"===e.discountType){var s;return"RM".concat(null===(s=e.amountOff)||void 0===s?void 0:s.toFixed(2)," OFF")}return e.shippingMaxDiscount&&e.shippingMaxDiscount>0?"FREE SHIPPING (up to RM".concat(e.shippingMaxDiscount.toFixed(2),")"):"FREE SHIPPING"}(e)})}),(0,a.jsx)("div",{className:"mt-3 text-sm font-semibold text-neutral-900",children:e.title||e.code}),e.title&&(0,a.jsx)("div",{className:"mt-1 font-mono text-xs text-neutral-400",children:e.code}),(0,a.jsxs)("div",{className:"flex flex-wrap mt-2 text-xs gap-x-3 gap-y-1 text-neutral-400",children:[e.minSubtotal&&(0,a.jsxs)("span",{children:["Min spend RM",e.minSubtotal.toFixed(2)]}),e.endsAt&&(0,a.jsxs)("span",{children:["Valid until"," ",new Date(e.endsAt).toLocaleDateString("en-MY",{day:"numeric",month:"short",year:"numeric"})]}),e.individualUseOnly&&(0,a.jsx)("span",{children:"Cannot stack"})]}),!i&&!s&&r&&(0,a.jsx)("div",{className:"mt-3 text-xs font-medium text-red-500",children:r})]}),(0,a.jsx)("div",{className:"shrink-0",children:s?(0,a.jsx)(c.ZP,{size:"small",onClick:()=>O(e.code),disabled:m,children:"Remove"}):(0,a.jsx)(R.Z,{title:i?void 0:r,children:(0,a.jsx)(c.ZP,{type:"primary",size:"small",loading:t,disabled:!i||m,onClick:()=>U(e.code,!0),children:"Apply"})})})]})},e.refId)})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",onClick:()=>!m&&f(!0),disabled:m,className:"w-full text-left transition-opacity bg-white border-none group disabled:cursor-not-allowed disabled:opacity-50",children:(0,a.jsx)("div",{className:"rounded-2xl border border-neutral-200 bg-white p-4 transition-all duration-200 hover:border-neutral-300 hover:shadow-[0_10px_24px_rgba(15,23,42,0.05)]",children:(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsx)("div",{className:"flex items-center justify-center h-11 w-11 shrink-0 rounded-2xl bg-neutral-100 text-neutral-700",children:(0,a.jsx)(N.Z,{size:22})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-lg font-semibold text-neutral-900",children:"Vouchers"}),(0,a.jsx)("div",{className:"mt-1 text-sm text-neutral-500",children:Y?"".concat(i.length," applied • Save RM").concat((z+p).toFixed(2)):"Select or enter a voucher co
1de"}),Y?(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mt-3",children:i.map(e=>(0,a.jsx)("div",{className:"rounded-full bg-neutral-100 px-3 py-1.5 text-xs font-medium text-neutral-700",children:e.code},e.code))}):null]}),(0,a.jsx)("div",{className:"flex items-center justify-center transition-colors rounded-full h-9 w-9 shrink-0 text-neutral-400 group-hover:text-neutral-700",children:(0,a.jsx)(w.Z,{size:18})})]})})}),(0,a.jsx)(u.Z,{title:"Vouchers",open:v,onCancel:()=>f(!1),footer:null,width:520,destroyOnClose:!0,children:(0,a.jsx)(L.Z,{activeKey:j,onChange:y,items:[{key:"available",label:(0,a.jsx)(A,{children:"Available Voucher"}),children:B(W,"No vouchers available right now")},{key:"shipping",label:(0,a.jsx)(A,{children:"Shipping Voucher"}),children:B(H,"No shipping vouchers available right now")},{key:"code",label:"Enter Code",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"p-4 border rounded-2xl border-neutral-200 bg-neutral-50",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,a.jsx)(E.default,{placeholder:"Enter voucher code",value:g,onChange:e=>{P(e.target.value.toUpperCase()),F(null)},onPressEnter:()=>U(g),disabled:m||Z,maxLength:32,className:"flex-1"}),(0,a.jsx)(c.ZP,{type:"primary",loading:Z,disabled:m||!g.trim(),onClick:()=>U(g),children:"Apply"})]})}),S&&(0,a.jsx)(o.Z,{message:S,type:"error",showIcon:!0,closable:!0,onClose:()=>F(null)}),Y&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-neutral-700",children:"Applied vouchers"}),(0,a.jsxs)("div",{className:"text-xs font-semibold text-emerald-600",children:["-RM",z.toFixed(2)]})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(e=>(0,a.jsxs)("div",{className:"flex items-center gap-3 px-3 py-3 bg-white border rounded-2xl border-neutral-200",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsx)("span",{className:"font-mono font-semibold text-neutral-800",children:e.code})}),e.title&&(0,a.jsx)("div",{className:"text-xs text-neutral-600",children:e.title}),(0,a.jsxs)("div",{className:"text-sm font-medium text-emerald-600",children:["-RM",e.discount.toFixed(2)]})]}),(0,a.jsx)(c.ZP,{type:"text",size:"small",icon:(0,a.jsx)(D.Z,{size:16}),onClick:()=>O(e.code),disabled:m,className:"text-gray-400 hover:text-red-500"})]},e.code))})]})]})}]})})]})}var V=t(5409);async function q(e){return await V.Z.post("/shipping/calculate",e)}var T=t(83214);let{TextArea:z}=E.default;var U=!0,O=e=>{let{user:s}=e;return(0,a.jsx)(n.Z,{user:s,whatsAppMobileBottomOffset:180,children:(0,a.jsx)(K,{})})};function K(){var e,s,t,n,P,E,k,R;let L=(0,i.useRouter)(),D=L.query.type,A=L.query.sessionId,[V,U]=(0,r.useState)("DELIVERY"),[O,K]=(0,r.useState)(!1),[Y,G]=(0,r.useState)(!1),[H,W]=(0,r.useState)(null),[B,X]=(0,r.useState)(null),[J,Q]=(0,r.useState)(""),[$,ee]=(0,r.useState)([]),[es,et]=(0,r.useState)(!1),[ea,en]=(0,r.useState)(0),[ei,er]=(0,r.useState)(0),[el,ed]=(0,r.useState)(0),[eo,ec]=(0,r.useState)(null),[eu,em]=(0,r.useState)(null),{applicableCount:ex}=M({checkoutSessionRefId:"session"===D?A:void 0,deliveryMethod:V});(0,r.useEffect)(()=>{D&&"cart"!==D&&"session"!==D&&L.replace("/cart"),"session"!==D||A||L.replace("/cart")},[D,A,L]);let ep=(0,m.a)({queryKey:["cart"],queryFn:()=>(0,S.dv)().then(e=>e.data),enabled:"cart"===D}),eh=(0,m.a)({queryKey:["checkout-session",A],queryFn:()=>(0,F.G)(A).then(e=>e.data),enabled:"session"===D&&!!A}),ev=(0,m.a)({queryKey:["my-addresses"],queryFn:()=>(0,v._z)().then(e=>e.data)});(0,r.useEffect)(()=>{if(ev.data&&null==H){let e=ev.data.find(e=>e.isDefault)||ev.data[0];e&&W(e.refId)}},[ev.data,H]);let ef=(0,x.D)({mutationFn:e=>(0,C.yq)({couponCodes:e,shippingFee:el,deliveryMethod:V,..."session"===D&&A?{checkoutSessionRefId:A}:{}}),onSuccess:e=>{var s;en(e.data.totalDiscount),er(null!==(s=e.data.estimatedShippingDiscount)&&void 0!==s?s:0),ee(s=>s.map((s,t)=>{var a;return{...s,discount:(null===(a=e.data.breakdown[t])||void 0===a?void 0:a.discount)||0}}))},onError:()=>{b.Am.error("Failed to recalculate discounts")}}),ej=(0,x.D)({mutationFn:q,onSuccess:e=>{ed(e.data.shippingFee),ec(e.data),em(null)},onError:e=>{var s,t;em((null===(t=e.response)||void 0===t?void 0:null===(s=t.data)||void 0===s?void 0:s.message)||"Failed to calculate shipping"),ed(0),ec(null)}}),eb=(0,r.useMemo)(()=>{var e;return"session"===D&&eh.data?[eh.data]:(null===(e=ep.data)||void 0===e?void 0:e.items)||[]},[D,eh.data,null===(e=ep.data)||void 0===e?void 0:e.items]),ey=e=>{var s,t,a,n,i,r,l,d;let o=Number(null!==(i=null==e?void 0:null===(s=e.variation)||void 0===s?void 0:s.discountedPrice)&&void 0!==i?i:0),c=Number(null!==(r=null==e?void 0:null===(t=e.variation)||void 0===t?void 0:t.price)&&void 0!==r?r:0),u=Number(null!==(l=null==e?void 0:null===(a=e.product)||void 0===a?void 0:a.discountedPrice)&&void 0!==l?l:0),m=Number(null!==(d=null==e?void 0:null===(n=e.product)||void 0===n?void 0:n.price)&&void 0!==d?d:0);return o>0?o:c>0?c:u>0?u:m},eg=(0,r.useMemo)(()=>eb.reduce((e,s)=>e+ey(s)*s.quantity,0),[eb]);(0,r.useEffect)(()=>
1{if("PICKUP"===V){ed(0),ec(null),em(null);return}if("DELIVERY"===V&&H){var e;let s=null===(e=ev.data)||void 0===e?void 0:e.find(e=>e.refId===H);if(!s)return;ej.mutate({deliveryMethod:"DELIVERY",shippingAddressSnapshot:{state:s.state,city:s.city,postcode:s.postcode},..."session"===D&&A?{checkoutSessionRefId:A}:{}})}},[V,H,ev.data,D,A]),(0,r.useEffect)(()=>{if("PICKUP"!==V||!$.some(e=>"FREE_SHIPPING"===e.discountType))return;let e=$.filter(e=>"FREE_SHIPPING"!==e.discountType);ee(e),er(0),e.length>0?ef.mutate(e.map(e=>e.code)):en(0),b.Am.info("Free shipping voucher removed for pickup orders")},[V]),(0,r.useEffect)(()=>{0!==$.length&&ef.mutate($.map(e=>e.code))},[el,V]);let eN=eg-ea+Math.max(0,el-ei),ew=(0,x.D)({mutationFn:async e=>(await (0,h.y)(e)).data,onSuccess:e=>{let{actionUrl:s,formData:t}=e;try{let e=document.createElement("form");e.method="POST",e.action=s,Object.entries(t).forEach(s=>{let[t,a]=s,n=document.createElement("input");n.type="hidden",n.name=t,n.value=String(a),e.appendChild(n)}),document.body.appendChild(e),e.submit()}catch(e){b.Am.error("Failed to initialize payment.")}},onError:e=>b.Am.error((0,T._g)(e))}),eP=(0,x.D)({mutationFn:async()=>{X(null);let e="DELIVERY"===V?(()=>{var e;let s=null===(e=ev.data)||void 0===e?void 0:e.find(e=>e.refId===H);if(!s)throw X("Address is required; please add one."),Error("Address required");return{deliveryMethod:"DELIVERY",shippingAddressSnapshot:{firstName:s.firstName,lastName:s.lastName,phone:s.phone,addressLine1:s.addressLine1,addressLine2:s.addressLine2||"",city:s.city,state:s.state,country:s.country||"Malaysia",postcode:s.postcode},note:J,couponCodes:$.map(e=>e.code)}})():{deliveryMethod:"PICKUP",note:J,couponCodes:$.map(e=>e.code)};return"session"===D?(0,p.m9)(A,e):(0,p.OU)(e)},onSuccess:e=>{let s=e.data.refId;ew.mutate(s)},onError:e=>{var s,t,a,n,i;let r=null!==(a=null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(s=t.data)||void 0===s?void 0:s.errors)&&void 0!==a?a:[];if(r.length>0){let e=r.map(e=>"".concat(e.productName,": ").concat(e.message)).join(", ");b.Am.error(e),X("Some items are no longer available. Please review your cart.")}else X((null==e?void 0:null===(i=e.response)||void 0===i?void 0:null===(n=i.data)||void 0===n?void 0:n.message)||"Failed to create order.")}}),eZ=(0,x.D)({mutationFn:e=>(0,v.p6)(e),onSuccess:e=>{ev.refetch(),W(e.data.id),G(!1)}}),[eI]=l.Z.useForm();if(!D||"cart"!==D&&"session"!==D||"session"===D&&!A)return L.replace("/cart"),null;let eE="session"===D?eh.isLoading:ep.isLoading;return eE||0!==eb.length?(0,a.jsxs)("div",{className:"px-4 pb-24 maxContainer md:pb-0",children:[(0,a.jsx)("div",{className:"flex items-center justify-between my-4 md:my-6",children:(0,a.jsx)("h1",{className:"text-2xl font-bold",children:"Checkout"})}),eE&&(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsx)(d.Z,{tip:"session"===D?"Loading...":"Loading cart..."})}),"session"===D&&(0,a.jsx)(o.Z,{type:"info",message:"Express Checkout",description:"You're using Buy Now - this purchase is separate from your shopping cart.",showIcon:!0,className:"mb-4"}),B&&(0,a.jsx)(o.Z,{type:"error",className:"mb-3",showIcon:!0,message:B}),(0,a.jsxs)("div",{className:"grid gap-6 md:grid-cols-[2fr_1fr]",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,a.jsxs)("div",{className:"p-4 bg-white border rounded-xl border-neutral-200",children:[(0,a.jsx)("div",{className:"mb-3 text-lg font-semibold",children:"Delivery"}),(0,a.jsx)("div",{className:"mb-1 text-neutral-500",children:"Select how you would like to receive your order."}),(0,a.jsxs)("div",{className:"flex items-center gap-6 p-4 bg-neutral-50 rounded-xl",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>U("DELIVERY"),className:"flex-1 border rounded-xl py-6 flex items-center justify-center gap-3 transition-colors ".concat("DELIVERY"===V?"border-neutral-800 bg-white":"border-neutral-200 hover:border-neutral-300"),"aria-pressed":"DELIVERY"===V,children:[(0,a.jsx)(y.Z,{size:28}),(0,a.jsx)("span",{className:"text-sm font-medium",children:"Delivery"})]}),(0,a.jsxs)("button",{type:"button",onClick:()=>U("PICKUP"),className:"flex-1 border rounded-xl py-6 flex items-center justify-center gap-3 transition-colors ".concat("PICKUP"===V?"border-neutral-800 bg-white":"border-neutral-200 hover:border-neutral-300"),"aria-pressed":"PICKUP"===V,children:[(0,a.jsx)(g.Z,{size:28}),(0,a.jsx)("span",{className:"text-sm font-medium",children:"Pick Up"})]})]})]}),"DELIVERY"===V?(0,a.jsxs)("div",{className:"p-4 bg-white border rounded-xl border-neutral-200",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("div",{className:"text-lg font-semibold",children:"Shipping Address"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(null!==(E=null===(s=ev.data)||void 0===s?void 0:s.length)&&void 0!==E?E:0)>0&&(0,a.jsx)(c.ZP,{type:"link",onClick:()=>K(!0),children:"Select address"}),(null!==(k=null===(t=ev.data)||void 0===t?void 0:t.length)&&void 0!==k?k:0)===0&&(0,a.jsx)(c.ZP,{type:"link",onClick:()=>G(!0),children:"Add address"})]})]}),ev.data&&ev.data.length>0?(0,a.jsx)("div",{className:"text-sm",children:(()=>{let e=ev.data.find(e=>e.refId===H)||ev.data[0];return e?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"font-medium break-words",children:[e.firstName," ",e.lastName," 
1(",e.phone,")"]}),(0,a.jsxs)("div",{className:"break-words",children:[e.addressLine1,e.addressLine2?", ".concat(e.addressLine2):""]}),(0,a.jsxs)("div",{className:"break-words",children:[e.postcode," ",e.city,", ",e.state]}),(0,a.jsx)("div",{className:"break-words",children:e.country||"Malaysia"})]}):null})()}):(0,a.jsx)("div",{className:"space-y-2",children:(0,a.jsx)(o.Z,{type:"warning",showIcon:!0,message:"No address found",description:"Please add a shipping address before proceeding."})})]}):(0,a.jsxs)("div",{className:"p-4 bg-white border rounded-xl border-neutral-200",children:[(0,a.jsx)("div",{className:"mb-2 text-lg font-semibold",children:"Pickup Location"}),(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsx)("div",{className:"font-medium",children:f.name}),(0,a.jsx)("div",{children:f.addressLine1}),f.addressLine2&&(0,a.jsx)("div",{children:f.addressLine2}),(0,a.jsxs)("div",{children:[f.postcode," ",f.city,","," ",f.state]}),(0,a.jsx)("div",{children:f.country}),(0,a.jsxs)("div",{children:["Hours: ",f.hours]}),(0,a.jsxs)("div",{children:["Phone: ",f.phone]})]})]}),(0,a.jsxs)("div",{className:"p-4 bg-white border rounded-xl border-neutral-200",children:[(0,a.jsx)("div",{className:"mb-2 text-lg font-semibold",children:"Order Notes"}),(0,a.jsx)(z,{placeholder:"Add a note for your order (optional)",value:J,onChange:e=>Q(e.target.value),rows:4,maxLength:500,showCount:!0})]}),(0,a.jsx)("div",{className:"p-4 bg-white border rounded-xl border-neutral-200",children:(0,a.jsx)(_,{subtotal:eg,shippingDiscount:ei,deliveryMethod:V,items:eb.map(e=>({productRefId:e.product.refId,quantity:e.quantity,unitPrice:ey(e)})),appliedCoupons:$,onCouponApplied:e=>{let s=[...$,e];ee(s),ef.mutate(s.map(e=>e.code))},onCouponRemoved:e=>{let s=$.filter(s=>s.code!==e);ee(s),s.length>0?ef.mutate(s.map(e=>e.code)):(en(0),er(0))},disabled:eP.isPending,checkoutSessionRefId:"session"===D?A:void 0,modalOpen:es,setModalOpen:et})})]}),(0,a.jsx)("div",{className:"h-max",children:(0,a.jsxs)("div",{className:"p-4 bg-white border rounded-xl border-neutral-200",children:[(0,a.jsx)("div",{className:"mb-2 text-lg font-semibold",children:"Order Summary"}),(0,a.jsx)("div",{className:"flex flex-col gap-3",children:eb.map(e=>{var s,t,n,i,r,l;let d=(null===(t=e.variation)||void 0===t?void 0:null===(s=t.image)||void 0===s?void 0:s.key)||(null===(i=e.product)||void 0===i?void 0:null===(n=i.image)||void 0===n?void 0:n.key)||"",o=ey(e),c=o*e.quantity,u=(null===(l=e.variation)||void 0===l?void 0:null===(r=l.attributes)||void 0===r?void 0:r.map(e=>{var s;return null===(s=e.attributeValue)||void 0===s?void 0:s.value}).filter(Boolean))||[];return(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex-shrink-0 overflow-hidden bg-white border rounded-md w-14 h-14",children:d?(0,a.jsx)(Z(),{src:(0,I.I)(d),alt:e.product.name,width:56,height:56,className:"object-contain w-full h-full"}):null}),(0,a.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,a.jsx)("div",{className:"font-medium line-clamp-2",children:e.product.name}),u.length>0&&(0,a.jsx)("div",{className:"text-xs text-neutral-500",children:u.join(" / ")}),(0,a.jsxs)("div",{className:"text-xs text-neutral-500",children:["RM ",o.toFixed(2)," \xd7 ",e.quantity]})]}),(0,a.jsxs)("div",{className:"font-medium",children:["RM ",c.toFixed(2)]})]},e.refId)})}),(0,a.jsxs)("div",{className:"pt-3 mt-3 border-t border-neutral-200",children:[(0,a.jsxs)("div",{className:"flex justify-between mb-1 text-sm",children:[(0,a.jsx)("span",{children:"Subtotal"}),(0,a.jsxs)("span",{children:["RM ",eg.toFixed(2)]})]}),0===$.length&&ex>0&&(0,a.jsxs)("button",{type:"button",onClick:()=>et(!0),className:"flex items-center justify-between w-full gap-2 p-0 mb-1 text-sm bg-transparent border-none cursor-pointer text-primary",children:[(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,a.jsx)(N.Z,{size:14}),ex," voucher",ex>
11?"s":""," available"]}),(0,a.jsx)(w.Z,{size:16})]}),ea>0&&(0,a.jsxs)("div",{className:"flex justify-between mb-1 text-sm text-green-600",children:[(0,a.jsx)("span",{children:"Discount"}),(0,a.jsxs)("span",{children:["-RM ",ea.toFixed(2)]})]}),(0,a.jsxs)("div",{className:"flex justify-between mb-1 text-sm",children:[(0,a.jsx)("span",{children:"Shipping"}),(0,a.jsx)("span",{children:"PICKUP"===V?(0,a.jsx)("span",{className:"font-medium text-green-600",children:"FREE"}):ej.isPending?(0,a.jsx)("span",{className:"text-neutral-400",children:"Calculating..."}):eu?(0,a.jsx)("span",{className:"text-xs text-red-500",children:eu}):"RM ".concat(el.toFixed(2))})]}),ei>0&&"DELIVERY"===V&&(0,a.jsxs)("div",{className:"flex justify-between mb-1 text-sm text-green-600",children:[(0,a.jsxs)("span",{children:["Free Shipping Voucher",ei>=el?" (FREE)":""]}),(0,a.jsxs)("span",{children:["-RM ",ei.toFixed(2)]})]}),eo&&"DELIVERY"===V&&(0,a.jsxs)("div",{className:"mt-1 ml-4 text-xs text-neutral-500",children:[(0,a.jsxs)("div",{children:["Weight: ",eo.chargeableWeight.toFixed(2)," kg"]}),eo.discount>0&&(0,a.jsxs)("div",{className:"text-green-600",children:["Discount: -RM ",eo.discount.toFixed(2)]})]}),(0,a.jsxs)("div",{className:"flex justify-between mt-2 text-lg font-semibold",children:[(0,a.jsx)("span",{children:"Total"}),(0,a.jsxs)("span",{children:["RM ",eN.toFixed(2)]})]})]}),(0,a.jsx)(c.ZP,{type:"primary",size:"large",block:!0,onClick:()=>eP.mutate(),loading:eP.isPending||ew.isPending||ej.isPending,disabled:"DELIVERY"===V&&(null!==(R=null===(n=ev.data)||void 0===n?void 0:n.length)&&void 0!==R?R:0)===0||!!eu||ej.isPending||ew.isPending,className:"mt-4",children:ej.isPending?"Calculating...":"Proceed to Payment"})]})})]}),(0,a.jsx)(u.Z,{title:"Select Address",open:O,onCancel:()=>K(!1),footer:null,width:600,children:(0,a.jsxs)("div",{className:"space-y-2",children:[null===(P=ev.data)||void 0===P?void 0:P.map(e=>(0,a.jsxs)("div",{onClick:()=>{W(e.refId),K(!1)},className:"p-3 border rounded-lg cursor-pointer hover:border-neutral-400 ".concat(H===e.refId?"border-neutral-800 bg-neutral-50":"border-neutral-200"),children:[(0,a.jsxs)("div",{className:"font-medium",children:[e.firstName," ",e.lastName," (",e.phone,")"]}),(0,a.jsxs)("div",{className:"text-sm",children:[e.addressLine1,e.addressLine2?", ".concat(e.addressLine2):""]}),(0,a.jsxs)("div",{className:"text-sm",children:[e.postcode," ",e.city,", ",e.state]}),(0,a.jsx)("div",{className:"text-sm",children:e.country||"Malaysia"})]},e.refId)),(0,a.jsx)(c.ZP,{type:"dashed",block:!0,onClick:()=>{K(!1),G(!0)},children:"Add New Address"})]})}),(0,a.jsx)(u.Z,{title:"Add New Address",open:Y,onCancel:()=>{G(!1),eI.resetFields()},footer:null,width:600,children:(0,a.jsxs)(l.Z,{form:eI,layout:"vertical",children:[(0,a.jsx)(j.Z,{form:eI}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,a.jsx)(c.ZP,{onClick:()=>{G(!1),eI.resetFields()},children:"Cancel"}),(0,a.jsx)(c.ZP,{type:"primary",htmlType:"submit",loading:eZ.isPending,onClick:()=>{eZ.mutate(eI.getFieldsValue())},children:"Add Address"})]})]})})]}):(L.replace("/cart"),null)}},33028:function(e,s,t){"use strict";t.d(s,{G:function(){return i},M:function(){return n}});var a=t(5409);async function n(e){return a.Z.post("/checkout-session",e)}async function i(e){return a.Z.get("/checkout-session/".concat(e))}},75218:function(e,s,t){"use strict";t.d(s,{Io:function(){return r},TJ:function(){return d},US:function(){return n},_N:function(){return u},_z:function(){return l},lF:function(){return i},p6:function(){return o},y3:function(){return c}});var a=t(5409);let n=()=>a.Z.get("/public/user"),i=e=>a.Z.put("/public/user",e),r=e=>a.Z.put("/public/user/credential",e),l=()=>a.Z.get("/public/user/address"),d=e=>a.Z.get("/public/user/address/".concat(e)),o=e=>a.Z.post("/public/user/address",e),c=e=>a.Z.put("/public/user/address/".concat(e.id),e),u=e=>a.Z.delete("/public/user/address/".concat(e))},56115:function(e,s,t){"use strict";t.d(s,{OU:function(){return r},co:function(){return n},m9:function(){return l},sl:function(){return i}});var a=t(5409);async function n(e){return await a.Z.get("/orders/".concat(e))}async function i(e){return await a.Z.post("/orders/".concat(e,"/cancel"))}async function r(e){return await a.Z.post("/orders/init-with-delivery",e)}async function l(e,s){return await a.Z.post("/orders/init-from-session?sessionId=".concat(e),s)}},6443:function(e,s,t){"use strict";t.d(s,{j:function(){return i},y:function(){return n}});var a=t(5409);async function n(e){return await a.Z.post("/payment/init/".concat(e))}async function i(e){let s=new URLSearchParams;return e.orderid&&s.set("orderid",e.orderid),await a.Z.get("/payment/return?".concat(s.toString()))}}},function(e){e.O(0,[5989,4237,7610,8174,9834,8051,9513,4540,4298,4190,6631,6220,9575,7444,9406,1887,8060,9
1059,9830,8672,7645,7005,388,4079,6980,2888,9774,179],function(){return e(e.s=1690)}),_N_E=e.O()}]);

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.