1import{a as Ke,i as Xe,M as X,D as Ze,c as m,d as h,b as l,t as r,j as u,m as f,w as B,z as o,k as ea,n as aa,p as W,x as Re,u as ta,aB as Ve,o as p,I as oe,P as We,be as Me,s as la,f as Oe,dc as oa,l as se,aA as sa,S as ie}from"../app-vue3.js";import{A as Ue}from"./index2.js";import{P as ia}from"./PaymentBreakdown.js";import{P as na}from"./PaymentDiscountSummaryCard.js";import{n as ra}from"./no_results_found.js";import{D as ua}from"./index31.js";import"./index3.js";import"./index4.js";import"./index.js";import"./index5.js";import"./index6.js";import"./courierValidation.js";import"./AddressBook.vue_vue_type_style_index_1_lang.js";import"./index.vue_vue_type_style_index_0_scoped_beb65ed1_lang.js";import"./smartAddressPrompt.js";import"./index7.js";import"./index8.js";import"./vue-tel-input.js";import"./index9.js";import"./index10.js";import"./index35.js";import"./popper.esm.js";import"./index21.js";import"./index33.js";import"./index32.js";const ca={key:0,class:"d-flex flex-column justify-content-center align-items-center py-5"},da={class:"heading-sm text-center"},pa={key:1,class:"d-flex flex-column justify-content-center align-items-center py-5"},va={class:"heading-sm text-center"},ma={class:"checkout-mobile-title checkout-responsive-title mb-2"},_a={class:"d-flex flex-column flex-md-row gap-2 checkout-container"},ha={key:0,class:"d-flex flex-column address-column"},ya={class:"d-flex align-items-center gap-2"},fa={class:"fw-bold mb-0"},ga={key:0,class:"text-secondary small mb-0"},ba={class:"heading-sm address-desktop-title"},ka={class:"address-form-collapsible"},Ca={class:"d-flex align-items-center gap-2"},Sa={class:"fw-bold mb-0"},wa={key:0,class:"text-secondary small mb-0"},xa={class:"heading-sm address-desktop-title"},Ea={class:"address-form-collapsible"},Pa={key:1,class:"d-flex flex-column checkout-column"},Aa={class:"d-flex flex-column gap-1"},Ba={class:"d-flex justify-content-between align-items-center"},Da={class:"heading-sm mb-0"},Ia={class:"d-flex gap-1"},Fa=["src"],Na={class:"d-flex flex-column ml-1 product-info"},Ta={class:"body-md text-truncate"},La={class:"label-md text-secondary"},Ra={class:"label-md text-secondary"},Va={class:"d-flex flex-column gap-1"},Wa={class:"body-md fw-bold mt-1"},Ma={key:0,class:"border rounded p-75 d-flex align-items-center"},Oa={class:"body-md mb-0"},Ua={class:"body-md mb-0"},ja={key:0},qa={key:0,class:"mb-1"},Ja={key:0,class:"d-flex flex-column gap-1"},Ha={key:0,class:"pi pi-spin pi-spinner me-2"},$a=["innerHTML"],Ya={key:1},za={key:0,class:"pi pi-spin pi-spinner me-2"},Ga=["innerHTML"],Qa={key:1,class:"d-flex flex-column gap-1"},Ka={key:2,class:"d-flex flex-row gap-1 align-items-center mt-1"},Xa={class:"body-md text-danger mb-0"},Za={__name:"EasyparcelShopCheckout",setup(et){const M=ea(),{t:s,n:je}=Xe(),j=ta(),D=o(""),N=o(!1),O=o(!1),I=o(!1),Z=o(null),ee=o(null),d=o({}),_=o({}),ne=o(null),re=o(null),q=o(!0),J=o(!0),ue=a=>[a==null?void 0:a.postcode,a==null?void 0:a.city,a==null?void 0:a.country_name].filter(i=>i).join(", "),ce=W(()=>ue(d.value)),de=W(()=>ue(_.value)),y=o(null),g=o(null),H=o(null),$=o(1),Y=o(!1),v=o(!1),U=o([]),z=o([]),pe=o(!1),F=o(null),ae=o(!1),qe=W(()=>{var a,e;return((e=(a=y.value)==null?void 0:a.payment_support)==null?void 0:e.includes("free_credit"))??!0}),te=o(!1),w=W(()=>M.getters["user/getCurrentWallet"]),T=W(()=>M.getters["user/getActiveAccount"]),L=o(null),ve=o({MY:{first_name:"fake_name",last_name:"fake_last_name",company:"fake_company",address_1:"Suntech @ Penang Cybercity, Lintang Mayang Pasir 3",address_2:"Bandar Bayan Baru",city:"Bayan Lepas",postcode:"11950",phone:"88888888",province_code:"MY-07",country_code:"MY"},SG:{first_name:"fake_name",last_name:"fake_last_name",company:"fake_company",address_1:"fake_address_1",address_2:"fake_address_2",city:"Singapore",postcode:"608586",phone:"88888888",province_code:"SG-01",country_code:"SG"}}),G=o(0),Q=o(0),R=o(null),le=o(null),V=o(!1),me=a=>{var e;return je(Number(a),"currency",sa(((e=w.value)==null?void 0:e.currency)||"MYR"))},Je=W(()=>{const a={};if(R.value!=null&&v.value==!1){let e=R.value;a.productCharges=[],a.productCharges.push({name:y.value.name,quantity:e.shop_order_item[0].quantity,price:e.shop_order_item[0].total_price}),e.shop_order_item[0].total_tax>0&&(a.productTax={percentage:e.shop_order_item[0].product_tax_rate??Number((e.shop_order_item[0].total_tax/e.shop_order_item[0].total_price).toFixed(2)),amount:e.shop_order_item[0].total_tax}),a.shipmentDeliveryPrice=e.delivery_price,a.redeemCoupon=e.coupon_applied,a.redeemFreeCredit=e.free_credit_applied,a.deliveryTax={percentage:e.delivery_tax_rate??Number((e.delivery_tax/(e.delivery_price-(e.coupon_applied||0))).toFixed(2)),amount:e.delivery_tax}}else if(le.value!=null&&v.value==!0){let e=le.value;a.productCharges=[],a.productCharges.push({name:y.value.name,quantity:e.shop_order_item[0].quantity,price:e.shop_order_item[0].total_point}),a.shipmentDeliveryPrice=e.delivery_point}return a}),He=()=>{let a={name:"RewardShopDetails",query:{id:y.value.id,variation:g.value.id}};H.value!=null&&(a.query.category=H.value),j.push(a)},$e=async()=>{var a;try{let e=await M.dispatch("reward/fetchRewardBalance",{accountId:T.value.business_information.account_id,campaignCode:"EASYREWARD",currency:(a=w.value)==null?void 0:a.currency});for(let i of e)L.value=i}catch(e){console.error(e)}},Ye=async()=>
1{if(N.value=!0,await $e(),JSON.parse(localStorage.getItem("shopCheckoutItem"))){let a=JSON.parse(localStorage.getItem("shopCheckoutItem"));y.value=a.selectedProduct,g.value=a.selectedVariant,H.value=a.selectedCategoryId,$.value=a.quantity,g.value.custom_regular_price==null?v.value=!0:v.value=!1;try{await E()}catch(e){console.error(e)}te.value=!0}N.value=!1},ze=a=>{var i;const e=((i=F.value)==null?void 0:i.is_free_credit_apply)??!1;F.value=a,te.value&&a.is_free_credit_apply!==e&&E()},Ge=async()=>{var a,e,i,t,n,k,C;if(!(!((a=w.value)!=null&&a.id)||v.value)){pe.value=!0;try{let c=T.value.business_information.account_id,b={wallet_id:w.value.id};R.value&&(b.order_price=R.value.price,b.delivery_price=R.value.delivery_price),((e=y.value)==null?void 0:e.id)!=null&&(b.product_ids=[y.value.id]);let P=((i=d.value)==null?void 0:i.country_code)||((t=T.value)==null?void 0:t.base_country);P&&(b.country_code=P);let A=(n=d.value)==null?void 0:n.province_code;A&&(b.province_code=A);let S=await Re.post(`/portal/v2/user/account/${c}/shop/coupon/eligible`,b);z.value=((C=(k=S==null?void 0:S.data)==null?void 0:k.data)==null?void 0:C.applicable_coupon_codes)||[]}catch(c){console.error(c),z.value=[]}pe.value=!1}},E=async()=>{var a,e;O.value=!0;try{let i=await K(!0,w.value.id,null);for(let t of((a=i==null?void 0:i.data)==null?void 0:a.data)||[])R.value=t,G.value=Number(t.credit_applied.toFixed(2));if(L.value!=null){let t=await K(!0,w.value.id,L.value.id);for(let n of((e=t==null?void 0:t.data)==null?void 0:e.data)||[])le.value=n,Q.value=Number((n.point+n.delivery_point).toFixed(2)),V.value=!(L.value.balance>=Q.value)}else{const t=g.value,n=(t==null?void 0:t.easyreward_sale_points)??(t==null?void 0:t.easyreward_points)??0;Q.value=Number(n)*Number($.value),V.value=!0}D.value="",ae.value=!1}catch(i){console.error(i);let t=JSON.parse(i.response.data.data).errors[0].message;t!=null&&t.toLowerCase().includes("free credit")?(ae.value=!0,F.value=null):D.value=t}await Ge(),O.value=!1},K=async(a=!0,e=null,i=null)=>{var c,b,P,A,S,he,ye,fe,ge,be,ke,Ce,Se,we,xe,Ee,Pe,Ae,Be,De,Ie,Fe,Ne,Te,Le;let t=null,n=null;(c=_.value)!=null&&c.postcode?t={first_name:((b=_.value)==null?void 0:b.name)||null,company:((P=_.value)==null?void 0:P.company_name)||null,email:((A=_.value)==null?void 0:A.email)||null,address_1:((S=_.value)==null?void 0:S.address1)||null,address_2:((he=_.value)==null?void 0:he.address2)||null,city:((ye=_.value)==null?void 0:ye.city)||null,postcode:((fe=_.value)==null?void 0:fe.postcode)||null,phone:((ge=_.value)==null?void 0:ge.phone_dial_code)+((be=_.value)==null?void 0:be.phone_number)||null,province_code:((ke=_.value)==null?void 0:ke.province_code)||null,country_code:((Ce=_.value)==null?void 0:Ce.country_code)||null}:t=ve.value[T.value.base_country],(Se=d.value)!=null&&Se.postcode?n={first_name:((we=d.value)==null?void 0:we.name)||null,company:((xe=d.value)==null?void 0:xe.company_name)||null,email:((Ee=d.value)==null?void 0:Ee.email)||null,address_1:((Pe=d.value)==null?void 0:Pe.address1)||null,address_2:((Ae=d.value)==null?void 0:Ae.address2)||null,city:((Be=d.value)==null?void 0:Be.city)||null,postcode:((De=d.value)==null?void 0:De.postcode)||null,phone:((Ie=d.value)==null?void 0:Ie.phone_dial_code)+((Fe=d.value)==null?void 0:Fe.phone_number)||null,province_code:((Ne=d.value)==null?void 0:Ne.province_code)||null,country_code:((Te=d.value)==null?void 0:Te.country_code)||null}:n=ve.value[T.value.base_country],Object.keys(t).forEach(x=>{t[x]===null&&delete t[x]}),Object.keys(n).forEach(x=>{n[x]===null&&delete n[x]});let k=T.value.business_information.account_id,C={wallet_id:e,for_calculation:a,shipping:n,billing:t,line_items:[{product_id:y.value.id,variation_id:g.value.id,quantity:$.value,is_self_claim:H.value!=null}]};return i!=null&&(C.reward_wallet_id=i),(Le=F.value)!=null&&Le.is_free_credit_apply&&v.value==!1&&(C.free_credit_wallet_id=F.value.id,C.free_credit_redeemed=F.value.redeem_free_credit),U.value.length>0&&v.value==!1&&(C.account_coupons=U.value.flatMap(x=>x.account_coupons||[]).map(x=>({coupon_code:x.coupon_code}))),Re.post(`/portal/v2/user/account/${k}/shop/order`,C)};X([()=>d.value.postcode,()=>Y.value],async(a,e)=>{var i,t;if(a[0]!==e[0]&&a[0]&&d.value.postcode&&!Y.value){let n=await((i=Z.value)==null?void 0:i.validateForm());await((t=ee.value)==null?void 0:t.validateForm()),n?ie.fire({type:"info",title:s("EasyparcelShopCheckout.PostcodeChanged"),message:s("EasyparcelShopCheckout.PostcodeChangedMessage"),primaryButtonLabel:s("EasyparcelShopCheckout.Proceed"),showCloseButton:!1,showPrimaryButton:!0,primaryAction:()=>{E()}}):E()}else a[0]!==e[0]&&a[0]&&E()}),X(()=>d.value.province_code,(a,e)=>{te.value&&a!==e&&a&&E()}),X(()=>U.value,()=>{v.value||E()},{deep:!0}),X(()=>v.value,(a,e)=>{a!=e&&(a==!0&&(U.value=[],z.value=[],F.value=null),E())}),Ze(async()=>{sessionStorage.getItem("isShopCheckoutDeliveryAddress")&&(ne.value=JSON.parse(sessionStorage.getItem("isShopCheckoutDeliveryAddress")),sessionStorage.removeItem("isShopCheckoutDeliveryAddress")),sessionStorage.getItem("isShopCheckoutBillingAddress")&&(re.value=JSON.parse(sessionStorage.getItem("isShopCheckoutBillingAddress")),sessionStorage.removeItem("isShopCheckoutBillingAddress")),sessionStorage.getItem("isShopCheckout")&&sessionStorage.removeItem("isShopCheckout"),await M.dispatch("wallet/fetchWalletFreeCredits"),await Ye()});const Qe=async()=>{sessionStorage.setItem("isShopCheckout","true"),sessionStorage.setItem("isShopCheckoutDeliveryAddress",JSON.stringify(d.value)),sessionStorage.setItem("isShopCheckoutBillingAddress",JSON.stringify(_.value)),j.push({name:"TopupBenefit"})},_e=async()=>{var a,e,i;if(!I.value){I.value=!0;try{let t=await((a=Z.value)==null?void 0:a.validateForm()),n=await((e=ee.value)==null?void 0:e.validateForm());if(!(t&&n))return;let k=null;v.value==!1?k=await K(!1,w.value.id,null):k=await K(!1,w.value.id,((i=L.value)==null?void 0:i.id)??null),await M.dispatch("user/refreshActiveAccountFreeCredit").catch(()=>{}),ie.fire({type:"success",title:s("EasyparcelShopCheckout.PaymentSuccessful"),message:s("EasyparcelShopCheckout.PaymentSuccessfulMessage"),primaryButtonLabel:s("EasyparcelShopCheckout.ViewOrder"),closeButtonLabel:s("EasyparcelShopCheckout.ExploreShop"),showCloseButton:!0,showPrimaryButton:!0,primaryAction:()=>{j.push({name:"RewardOrder"})},close:()=>{j.push({name:"RewardRedemption"})}})}catch(t){let n=JSON.parse(t.response.data.data).errors[0].message;ie.fire({type:"error",title:s("EasyparcelShopCheckout.PaymentFailed"),message:n,
1closeButtonLabel:s("EasyparcelShopCheckout.Continue"),showCloseButton:!0,showPrimaryButton:!1,close:()=>{}})}finally{I.value=!1}}};return(a,e)=>{const i=Ve("EppyLoading"),t=aa,n=la,k=oa,C=Ve("SkeletonTemplate");return p(),m("div",null,[N.value?(p(),m("div",ca,[h(i,{class:"loadingAnimation",size:200}),l("p",da,r(u(s)("EasyparcelShopProductDetail.Loading")),1)])):f("",!0),!y.value&&!g.value&&!N.value?(p(),m("div",pa,[h(u(ua),{class:"noResultAnimation",autoplay:"",loop:"",data:JSON.stringify(u(ra))},null,8,["data"]),l("p",va,r(u(s)("EasyparcelShopProductDetail.ProductNotFound")),1)])):f("",!0),l("h1",ma,r(u(s)("EasyparcelShopCheckout.CheckoutTitle")),1),l("div",_a,[y.value&&g.value&&!N.value?(p(),m("div",ha,[h(t,{class:"mr-1 mb-1"},{content:B(()=>[l("div",{class:"d-flex justify-content-between align-items-center address-collapsible-header cursor-pointer mb-1",onClick:e[0]||(e[0]=c=>q.value=!q.value)},[l("div",ya,[e[9]||(e[9]=l("i",{class:"pi pi-check-circle text-success"},null,-1)),l("div",null,[l("p",fa,r(u(s)("EasyparcelShopCheckout.DeliveryAddressTitle")),1),ce.value?(p(),m("p",ga,r(ce.value),1)):f("",!0)])]),l("i",{class:oe([q.value?"pi pi-chevron-up":"pi pi-chevron-down","text-secondary"])},null,2)]),l("p",ba,r(u(s)("EasyparcelShopCheckout.DeliveryAddressTitle")),1),We(l("div",ka,[h(Ue,{ref_key:"deliveryAddressForm",ref:Z,addressType:"delivery",header:{show:!1},"onUpdate:address":e[1]||(e[1]=c=>d.value=c),prefilledData:ne.value,onHandlePostcodeFocused:e[2]||(e[2]=c=>Y.value=c),onHandlePostcodeBlurred:e[3]||(e[3]=c=>Y.value=c)},null,8,["prefilledData"])],512),[[Me,q.value]])]),_:1}),h(t,{class:"mr-1 mb-1"},{content:B(()=>[l("div",{class:"d-flex justify-content-between align-items-center address-collapsible-header cursor-pointer mb-1",onClick:e[4]||(e[4]=c=>J.value=!J.value)},[l("div",Ca,[e[10]||(e[10]=l("i",{class:"pi pi-check-circle text-success"},null,-1)),l("div",null,[l("p",Sa,r(u(s)("EasyparcelShopCheckout.BillingAddressTitle")),1),de.value?(p(),m("p",wa,r(de.value),1)):f("",!0)])]),l("i",{class:oe([J.value?"pi pi-chevron-up":"pi pi-chevron-down","text-secondary"])},null,2)]),l("p",xa,r(u(s)("EasyparcelShopCheckout.BillingAddressTitle")),1),We(l("div",Ea,[h(Ue,{ref_key:"billingAddressForm",ref:ee,addressType:"billing",header:{show:!1},"onUpdate:address":e[5]||(e[5]=c=>{_.value=c}),prefilledData:re.value},null,8,["prefilledData"])],512),[[Me,J.value]])]),_:1})])):f("",!0),y.value&&g.value&&!N.value?(p(),m("div",Pa,[h(t,{class:"mb-1 product-card"},{content:B(()=>{var c,b,P,A;return[l("div",Aa,[l("div",Ba,[l("h2",Da,r(u(s)("EasyparcelShopCheckout.ProductSummary")),1),h(n,{class:"p-button-text p-button-pink",onClick:He},{default:B(()=>[e[11]||(e[11]=l("i",{class:"pi pi-pen-to-square me-2"},null,-1)),Oe(" "+r(u(s)("EasyparcelShopCheckout.Edit")),1)]),_:1})]),l("div",Ia,[l("img",{src:(b=(c=y.value.images)==null?void 0:c[0])==null?void 0:b.src,class:"product-image",alt:"Product Image"},null,8,Fa),l("div",Na,[l("span",Ta,r(y.value.name),1),l("span",La,r(u(s)("EasyparcelShopCheckout.Variants"))+": "+r(((A=(P=g.value.attributes)==null?void 0:P[0])==null?void 0:A.option_name)||`${u(s)("EasyparcelShopCheckout.Variant")} ${g.value.id}`),1),l("span",Ra,r(u(s)("EasyparcelShopCheckout.Qty"))+": "+r($.value),1)])]),l("div",Va,[l("h3",Wa,r(u(s)("EasyparcelShopCheckout.SelectRedeemOption")),1),h(C,{loading:O.value,rows:"2",class:"m-1",parentClass:"gap-1",height:"20px",width:"80%",animation:"wave"},{default:B(()=>[g.value.custom_regular_price!==null?(p(),m("div",Ma,[h(k,{modelValue:v.value,"onUpdate:modelValue":e[6]||(e[6]=S=>v.value=S),value:!1,class:"me-2"},null,8,["modelValue"]),l("label",Oa,r(u(s)("EasyparcelShopCheckout.PayWith"))+" "+r(me(G.value)),1)])):f("",!0),g.value.easyreward_points!==null?(p(),m("div",{key:1,class:oe([V.value?"disabled-redeem-with-point":"","border rounded p-75 d-flex align-items-center"])},[h(k,{modelValue:v.value,"onUpdate:modelValue":e[7]||(e[7]=S=>v.value=S),value:!0,class:"me-2",disabled:V.value},null,8,["modelValue","disabled"]),l("label",Ua,[Oe(r(u(s)("EasyparcelShopCheckout.RedeemWith"))+" "+r(Q.value)+" "+r(u(s)("EasyparcelShopCheckout.Points"))+" ",1),L.value==null||V.value?(p(),m("span",ja,"("+r(u(s)("EasyparcelShopCheckout.Insufficient"))+")",1)):f("",!0)])],2)):f("",!0)]),_:1},8,["loading"])])])]}),_:1}),v.value?f("",!0):(p(),m("div",qa,[h(na,{loading:O.value,applicableAccountCoupons:z.value,disabledFreeCreditToggledButton:!qe.value||ae.value,"onUpdate:selectedCoupons":e[8]||(e[8]=c=>U.value=c),"onUpdate:freeCreditWallet":ze},null,8,["loading","applicableAccountCoupons","disabledFreeCreditToggledButton"])])),h(t,{class:"price-breakdown-card"},{content:B(()=>[h(ia,{showHeader:!0,summary:Je.value,showSubtotal:!1,asPanel:!0,isLoading:O.value,isUsingPoint:v.value,emphasizeHeader:!0},null,8,["summary","isLoading","isUsingPoint"]),v.value?(p(),m("div",Ja,[V.value?(p(),se(n,{key:1,severity:"secondary",class:"w-100 mb-1",label:u(s)("EasyparcelShopCheckout.Insufficient"),disabled:!0},null,8,["label"])):(p(),se(n,{key:0,class:"w-100 mb-1",onClick:_e,loading:I.value,disabled:D.value!=""},{default:B(()=>[I.value?(p(),m("i",Ha)):f("",!0),l("span",{innerHTML:u(s)("EasyparcelShopCheckout.PayWithPoint")},null,8,$a)]),_:1},8,["loading","disabled"]))])):(p(),m("div",Ya,[Number(w.value.balance)-Number(G.value)>=0?(p(),se(n,{key:0,class:"w-100 mb-1",onClick:_e,loading:I.value,disabled:D.value!=""},{default:B(()=>[I.value?(p(),m("i",za)):f("",!0),l("span",{innerHTML:u(s)("EasyparcelShopCheckout.PayWithCredit")},null,8,Ga)]),_:1},8,["loading","disabled"])):(p(),m("div",Qa,[h(n,{severity:"primary",class:"w-100",label:u(s)("EasyparcelShopCheckout.TopupAndPay")+" "+me(G.value),onClick:Qe,disabled:D.value!=""},null,8,["label","disabled"])]))])),D.value!=""?(p(),m("div",Ka,[e[12]||(e[12]=l("i",{class:"pi pi-exclamation-triangle text-danger"},null,-1)),l("p",Xa,r(D.value),1)])):f("",!0)]),_:1})])):f("",!0)])])}}},Et=Ke(Za,[["__scopeId","data-v-7b68f07c"]]);export{Et as default};
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.