1import{a as Ce,i as Be,D as Ue,az as Ie,aT as Re,M as Se,c as p,b as o,t as u,d as U,j as _,G as se,H as re,m as x,l as J,w as Te,k as Ee,z as m,u as Me,p as v,s as Ne,h as Pe,o as d,a0 as oe,P as De,T as $e,aH as ie}from"../app-vue3.js";import{C as Ae}from"./CartListing.js";import{i as Ve}from"./euCustoms.js";import"./index21.js";import"./index14.js";import"./index15.js";import"./index16.js";import"./index17.js";import"./index23.js";import"./index20.js";import"./index4.js";import"./PrivacyMasking.js";import"./TrackingNotifications.js";import"./popper.esm.js";import"./index30.js";import"./index31.js";import"./EmailPreview.js";import"./AddressBook.vue_vue_type_style_index_1_lang.js";import"./courierValidation.js";import"./compileCourierService.js";import"./index3.js";import"./index.vue_vue_type_style_index_0_scoped_beb65ed1_lang.js";import"./vue-tel-input.js";import"./CourierService.js";import"./index.js";import"./index19.js";import"./index29.js";import"./index32.js";import"./index33.js";import"./index10.js";import"./PaymentBreakdown.js";import"./index34.js";import"./index35.js";import"./CompareRatesModal.js";import"./no_results_found.js";import"./useBulkEditCart.js";import"./InsuranceComponent.js";import"./AWBBranding2.js";import"./AWBPreview.js";import"./index.esm-bundler.js";import"./EasyTrackDetails.js";import"./index36.js";import"./VueTurnstile.js";import"./index28.js";import"./easyTrackCopyResult.js";import"./index13.js";import"./ChargeableWeightTooltip.js";import"./index37.js";const Le={class:"pending-checkout pb-md-2 pb-5 mb-2"},je={key:0,class:"d-flex flex-column align-items-center justify-content-center py-5"},ze={class:"text-muted small mb-0"},Fe={key:0,class:"w-100 mt-3",style:{"max-width":"400px"}},qe={class:"d-flex justify-content-between mb-1"},Oe={class:"small text-muted"},Ye={class:"small text-muted"},Ke={key:1,class:"w-100 mt-3",style:{"max-width":"400px"}},He={key:1,class:"d-flex flex-column align-items-center justify-content-center py-5"},Je={class:"mt-3 mb-1"},We={class:"text-muted small"},Ge={key:0,class:"mt-3",style:{"max-width":"640px",width:"100%"}},Qe={class:"small text-muted",style:{"max-height":"240px","overflow-y":"auto"}},Xe={class:"d-flex gap-2 mt-2"},Ze={key:2,class:"row"},et={key:0,class:"col-md-12 mb-3"},tt={class:"alert alert-warning d-flex flex-column",role:"alert"},lt={class:"d-flex align-items-start gap-2"},at={class:"flex-grow-1"},st={class:"small text-muted"},rt={class:"small text-muted mt-2 mb-0",style:{"max-height":"180px","overflow-y":"auto"}},ot={key:1,class:"col-md-12 mb-3"},it={class:"alert alert-info d-flex flex-column",role:"alert"},nt={class:"d-flex align-items-start gap-2"},ut={class:"flex-grow-1"},ct={class:"small text-muted mt-1"},dt={class:"small text-muted mt-2 mb-0"},mt={key:0,class:"d-flex align-items-center gap-2 mt-2"},pt={class:"small"},_t={class:"col-md-12"},ft={class:"d-flex justify-content-between align-items-center flex-wrap gap-3"},vt={class:"d-flex flex-column"},ht={class:"mb-0 heading-sm"},gt={class:"d-flex flex-rows gap-2 text-secondary body-md"},yt={key:0},bt={class:"d-flex align-items-center gap-2"},kt=3,xt={__name:"BulkUploadItems",setup(wt){const b=Ee(),{t:f}=Be(),ne=Pe(),I=Me(),h=v(()=>ne.params.uploadNumber||""),R=m(""),g=m([]),W=m([]),M=m([]),N=m(!0),P=m(!1),q=m(!1),O=m(!1),G=v(()=>{if(!g.value||g.value.length<=1)return 0;let e=new Map;for(let l of g.value){let r=(l.receiver_name||"").trim().toLowerCase(),s=(l.receiver_phone_number||"").replace(/[\s\-()]/g,""),a=(l.receiver_postcode||"").trim(),n=(l.receiver_address1||"").trim().toLowerCase().replace(/\s+/g," "),i=`${r}|${s}|${a}|${n}`;(r||s)&&e.set(i,(e.get(i)||0)+1)}let t=0;for(let l of e.values())l>1&&(t+=l-1);return t}),D=m(""),$=m(!1),A=m(!1),w=m([]),ue=e=>{var l,r;if(!e)return"";let t=e.toString().trim().toUpperCase();return((r=(l=ie.data)==null?void 0:l[t])==null?void 0:r.name)||e},ce=(e,t)=>{var s,a,n,i;if(!e||!t)return"";let l=e.toString().trim().toUpperCase(),r=t.toString().trim().toUpperCase();return((i=(n=(a=(s=ie.data)==null?void 0:s[l])==null?void 0:a.sub)==null?void 0:n[r])==null?void 0:i.name)||t},Q=e=>{if(!e||typeof e!="string")return e||"";if(/[()]/.test(e)||/\s[a-z]/i.test(e))return e;let t=e.split("/").map(c=>c.trim());if(t.length<2)return e;
1let l=t[0],r=t[1]||"",s=t[2]||"",a=ue(l),i=[ce(l,r),s].filter(Boolean).join(" ");return a&&i?`${a} (${i})`:a||i||e},X=e=>{if(!e)return"";if(e.display)return e.display;let t=[];e.receiver_name&&t.push(`Shipment to ${e.receiver_name}`);let l=e.from_country||Q(e.from),r=e.to_country||Q(e.to),s=[l,r].filter(Boolean).join(" â ");return s&&t.push(s),e.service_name?t.push(e.service_name):e.service_id&&t.push(`Service #${e.service_id}`),e.weight&&t.push(`${e.weight}kg`),t.join(" · ")||e.cart_number||e.uuid||"Unknown shipment"},de=v(()=>$.value&&A.value?"eKYC & Card Binding Required":$.value?"eKYC Verification Required":A.value?"Bind Card Required":"Processing Failed"),me=()=>{try{I.push({name:"AccountVerification"})}catch{F()}},pe=()=>{try{I.push({name:"BankCards"})}catch{F()}},S=m(0),B=m(0),V=m(null);let T=null,L=null;const j=m(0),E=m(0);let y=null;const _e=v(()=>j.value),Z=v(()=>E.value),k=v(()=>b.getters["user/getActiveAccount"]),Y=v(()=>(g.value||[]).filter(e=>Ve(e.receiver_country_code,e.receiver_postcode))),fe=v(()=>Y.value.length>0),ve=v(()=>Y.value.length),he=v(()=>{var e,t,l;return Number((e=k.value)==null?void 0:e.type)!==2||!!Number((l=(t=k.value)==null?void 0:t.business_information)==null?void 0:l.eori_verified)}),ee=v(()=>{var t;let e=0;for(let l of Y.value){if((l.consignee_type||"").toString().toUpperCase()==="B2B")continue;let s=new Set;for(let a of l.cart_item||[]){let n=(t=a.hs_code)!=null&&t.label?a.hs_code.label.split(" - ")[0]:a.hs_code||"",i=a.country_of_origin||"";s.add(`${String(n).trim()}|${String(i).trim().toUpperCase()}`)}e+=s.size}return{b2cLines:e}}),ge=v(()=>`EUR ${(ee.value.b2cLines*kt).toFixed(2)}`),ye=()=>{try{I.push({name:"Profile",query:{section:"business-information"}})}catch{}},K=async()=>{var e,t;if(!h.value||!((t=(e=k.value)==null?void 0:e.business_information)!=null&&t.account_id))return-1;try{const l=await b.dispatch("bulkUploadV2/fetchBulkUploads",{account_id:k.value.business_information.account_id,search:{bulk_upload_number:h.value}});if(l!=null&&l.data&&Array.isArray(l.data)){const r=l.data.find(s=>{var a;return s.bulk_upload_number===h.value||((a=s.bulk_upload_number)==null?void 0:a.toString())===h.value.toString()});if(r){V.value=r,r.original_file_name&&(R.value=r.original_file_name),S.value=r.processed_rows||0,B.value=r.total_rows||0;let s=(r.uploaded_status_text||"").toLowerCase();if(s==="processing"||s==="pending")return 0;if(s==="completed"){let a=r.system_fail_log||{};return a.partial_success&&Array.isArray(a.unavailable_rows)&&a.unavailable_rows.length>0&&(D.value=typeof a.reason=="string"?a.reason:"",w.value=a.unavailable_rows),1}if(s==="failed"){let a=r.system_fail_log||{},n=a.reason;return Array.isArray(n)&&(n=n.map(i=>i&&typeof i=="object"?i.message||i.code:i).filter(Boolean).join(", ")),D.value=n||"",$.value=!!a.requires_ekyc,A.value=!!a.requires_bind_card,w.value=Array.isArray(a.unavailable_rows)?a.unavailable_rows:[],2}return-1}}return-1}catch(l){return console.error("Failed to fetch bulk upload info:",l),-1}};Ue(async()=>{let e=await b.dispatch("cart/getAllCouriers");W.value=e||[];let t=await K();t===0?(P.value=!0,be()):t===2?q.value=!0:ae()}),Ie(()=>{H()});function be(){T||(j.value=Math.max(1,S.value||0),te(),T=setInterval(async()=>{let e=await K();e===1?(S.value=B.value,le(100),setTimeout(()=>{P.value=!1,H(),ae()},800)):e===2?(P.value=!1,q.value=!0,H()):te()},3e3),L=setInterval(()=>{ke()},200))}function te(){let e=B.value||0,t=S.value||0;if(e<=0)return;let l=Math.round(t/e*100),r=Math.min(99,l+Math.min(50,Math.round(e*.05)));le(r)}function le(e){y&&(clearInterval(y),y=null);let t=E.value;if(t>=e){E.value=e;return}let l=e-t,r=Math.min(1200,Math.max(400,l*15)),s=30,a=r/s,n=0;y=setInterval(()=>{if(n++,n>=s)E.value=e,clearInterval(y),y=null;else{let i=n/s,c=1-Math.pow(1-i,3);E.value=Math.round(t+l*c)}},a)}function ke(){let e=B.value||0,t=S.value||0;if(e<=0)return;let l=t/e*100,r=Math.min(99,l+Math.min(50,e*.05)),s=Math.min(e,Math.round(r/100*e)),a=j.value;if(s<=a)return;let n=e-a,i=s-a,c=n<=15||n/e<=.15,C;c?C=1:a<=1?C=4:i>50?C=Math.max(5,Math.ceil(i/20)*5):C=5,j.value=Math.min(s,a+C)}function ae(){var a,n;let e=V.value;if(!e){z();return}let t=e.error_summary,l=0;Array.isArray(t)?l=t.reduce((i,c)=>i+(Number(c==null?void 0:c.count)||0),0):t&&typeof t=="object"&&(l=(Number(t.error_invalid_details_count)||0)+(Number(t.error_out_of_coverage_count)||0));let r=!!e.error_file_path||l>0,s=Number(e.cart_count)||0;r&&s===0&&e.id&&e.review_data_path?I.replace({name:"BulkUploadReview",params:{bulkUploadId:e.id},query:{account_id:(n=(a=k.value)==null?void 0:a.business_information)==null?void 0:n.account_id}}):z()}function H(){T&&(clearInterval(T),T=null),L&&(clearInterval(L),L=null),y&&(clearInterval(y),y=null)}const xe=async e=>{var l,r;let t=[];
1if(e.cart_item){let s={courier_id:e.courier_id,courier_service_id:e.service_id,receiver_country_code:e.receiver_country_code,sender_country_code:e.sender_country_code,price:e.price,wallet_country_code:b.getters["user/getCurrentWallet"].country_code,currency:b.getters["user/getCurrentWallet"].currency,collection_date:e.collection_date,parcel_weight:e.weight,parcel_item:[]};for(let a of e.cart_item){let n=(l=a.hs_code)!=null&&l.label?(r=a.hs_code)==null?void 0:r.label.split(" - ")[0]:a.hs_code,i=a.value,c=a.content,C=a.quantity;s.parcel_item.push({commodity_id:n,parcel_content:c,parcel_value:i,parcel_unit:C})}try{const a=await b.dispatch("cart/calculateDdpCharges",s);a.data.success.length>0&&(t=a.data.success)}catch(a){console.error("Error calculating DDP:",a)}}return t},z=()=>{N.value=!0,M.value=[],b.dispatch("cart/getCartItems",{account_bulk_upload_number:h.value}).then(async e=>{g.value=JSON.parse(JSON.stringify(e))||[];let t=g.value.filter(l=>{if(l.ddp_ddu_charges!=null)return l});if(t.length>0){for(let r of t){let s=await xe(r);if(s.length>0){let a=0,n=0,i=s[0].handling_fee_price;s.map(c=>{a+=c.tax_charges?c.tax_charges:(c==null?void 0:c.total_duty_n_tax_charges)||0,n+=(c==null?void 0:c.duty_charges)||0}),r.cart_ddp_charges={tax_type:r.ddp_ddu_charges.tax_type,handling_charges:i,tax_charges:a,duty_charges:n}}}let l=Re.groupBy(t,"id");g.value=g.value.map(r=>(l[r.id]&&(r.latest_cart_ddp_charges=l[r.id][0].cart_ddp_charges),r))}M.value=g.value.slice(),N.value=!1}).catch(()=>{N.value=!1})},F=()=>{I.push({name:"BulkUpload"})},we=async()=>{var e,t,l;if(!(!((e=V.value)!=null&&e.id)||!((l=(t=k.value)==null?void 0:t.business_information)!=null&&l.account_id))){O.value=!0;try{let s=(await b.dispatch("bulkUploadV2/mergeDuplicateCarts",{account_id:k.value.business_information.account_id,bulk_upload_id:V.value.id})).data||{};s.merged_groups>0?(alert(`Merged ${s.merged_groups} group(s), removed ${s.deleted_carts} duplicate shipment(s).`),z()):alert("No duplicates found to merge.")}catch(r){console.error("Merge failed:",r),alert("Failed to merge duplicates: "+(r.message||"Unknown error"))}finally{O.value=!1}}};return Se([k,h],async([e,t])=>{var l;(l=e==null?void 0:e.business_information)!=null&&l.account_id&&t&&!R.value&&await K()},{immediate:!1}),(e,t)=>{const l=Ne,r=$e;return d(),p("div",Le,[P.value?(d(),p("div",je,[t[1]||(t[1]=o("i",{class:"pi pi-spin pi-cog",style:{"font-size":"2.5rem",color:"var(--p-primary-color)"}},null,-1)),t[2]||(t[2]=o("h5",{class:"mt-3 mb-1"},"Processing your shipments...",-1)),o("p",ze,u(R.value||h.value),1),B.value>0?(d(),p("div",Fe,[o("div",qe,[o("span",Oe,u(_e.value)+" / "+u(B.value)+" rows",1),o("span",Ye,u(Z.value)+"%",1)]),U(_(oe),{value:Z.value,showValue:!1,class:"smooth-progress-bar",style:{height:"8px"}},null,8,["value"])])):(d(),p("div",Ke,[U(_(oe),{mode:"indeterminate",style:{height:"8px"}})]))])):q.value?(d(),p("div",He,[t[4]||(t[4]=o("i",{class:"pi pi-exclamation-triangle",style:{"font-size":"2.5rem",color:"#f59e0b"}},null,-1)),o("h5",Je,u(de.value),1),o("p",We,u(D.value||"An error occurred during processing."),1),w.value.length>0?(d(),p("div",Ge,[t[3]||(t[3]=o("p",{class:"small mb-1"},"Shipments with no courier coverage:",-1)),o("ul",Qe,[(d(!0),p(se,null,re(w.value,(s,a)=>(d(),p("li",{key:a},u(X(s)),1))),128))])])):x("",!0),o("div",Xe,[$.value?(d(),J(l,{key:0,label:"Complete eKYC",icon:"pi pi-check-circle",severity:"primary",size:"small",onClick:me})):x("",!0),A.value?(d(),J(l,{key:1,label:"Bind Card",icon:"pi pi-credit-card",severity:"primary",size:"small",onClick:pe})):x("",!0),U(l,{label:"Back to Bulk Upload",icon:"pi pi-arrow-left",severity:"secondary",size:"small",onClick:F})])])):(d(),p("div",Ze,[w.value.length>0?(d(),p("div",et,[o("div",tt,[o("div",lt,[t[5]||(t[5]=o("i",{class:"pi pi-exclamation-triangle mt-1",style:{"font-size":"1.1rem"}},null,-1)),o("div",at,[o("strong",null,u(w.value.length)+" shipment(s) skipped â courier service doesn't cover this route",1),o("div",st,u(D.value||"The selected courier service doesn't cover these routes. Edit the affected shipments to pick a different c
1ourier, or remove them from this upload."),1),o("ul",rt,[(d(!0),p(se,null,re(w.value,(s,a)=>(d(),p("li",{key:a},u(X(s)),1))),128))])])])])])):x("",!0),fe.value?(d(),p("div",ot,[o("div",it,[o("div",nt,[t[7]||(t[7]=o("i",{class:"pi pi-info-circle mt-1 eu-customs-banner-icon"},null,-1)),o("div",ut,[o("strong",null,u(_(f)("BulkUploadItem.EuCustoms.BannerTitle",{count:ve.value})),1),o("div",ct,u(_(f)("BulkUploadItem.EuCustoms.BannerBody")),1),o("ul",dt,[o("li",null,u(_(f)("BulkUploadItem.EuCustoms.LineB2c",{lines:ee.value.b2cLines,duty:ge.value})),1),o("li",null,u(_(f)("BulkUploadItem.EuCustoms.LineB2b")),1),o("li",null,u(_(f)("BulkUploadItem.EuCustoms.LineIoss")),1)]),he.value?x("",!0):(d(),p("div",mt,[t[6]||(t[6]=o("i",{class:"pi pi-exclamation-triangle eu-customs-warning-icon"},null,-1)),o("span",pt,u(_(f)("CreateOrder.EuCustoms.MerchantEoriNotVerified")),1),U(l,{label:_(f)("CreateOrder.EuCustoms.VerifyEoriNow"),size:"small",severity:"warning",class:"p-button-sm",onClick:ye},null,8,["label"])]))])])])])):x("",!0),o("div",_t,[U(Ae,{modelValue:M.value,"onUpdate:modelValue":t[0]||(t[0]=s=>M.value=s),carts:g.value,couriers:W.value,loading:N.value,"enable-expanded-details":!0,"default-sort-key":"oldest_to_latest","default-rows-per-page":1e3,title:_(f)("BulkUploadItem.BulkUploadItems"),"show-header-actions":!1,"show-selection":!0,"show-actions":!0,"action-buttons":{checkout:!0,edit:!0,duplicate:!1,delete:!1,addons:!0},"show-bulk-actions":!0,"bulk-action-buttons":{checkout:!0,edit:!1,duplicate:!1,delete:!1,changeCourier:!0,nextAvailableDate:!0,chooseDate:!0,addons:!0},"account-bulk-upload-number":h.value,"return-route":{name:"BulkUploadItems",params:{uploadNumber:h.value}},onReload:z},{header:Te(({title:s})=>[o("div",ft,[o("div",vt,[o("h4",ht,u(s),1),o("div",gt,[o("p",null,u(_(f)("BulkUploadItem.UploadID"))+" : "+u(h.value),1),R.value?(d(),p("p",yt,u(_(f)("BulkUploadItem.FileName"))+" : "+u(R.value),1)):x("",!0)])]),o("div",bt,[G.value>0?De((d(),J(l,{key:0,icon:"pi pi-objects-column",label:`Combine Same Receivers (${G.value})`,severity:"info",size:"small",loading:O.value,onClick:we},null,8,["label","loading"])),[[r,_(f)("BulkUploadItem.CombineSameReceiversTooltip"),void 0,{bottom:!0}]]):x("",!0),U(l,{icon:"pi pi-arrow-left",label:_(f)("BulkUploadItem.BackToBulkUpload"),onClick:F,severity:"secondary",class:"p-button-text text-muted body-sm"},null,8,["label"])])])]),_:1},8,["modelValue","carts","couriers","loading","title","account-bulk-upload-number","return-route"])])]))])}}},gl=Ce(xt,[["__scopeId","data-v-7d450561"]]);export{gl 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.