var j=Object.defineProperty,F=Object.defineProperties;var U=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var A=(t,a,r)=>a in t?j(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r,O=(t,a)=>{for(var r in a||(a={}))V.call(a,r)&&A(t,r,a[r]);if(w)for(var r of w(a))$.call(a,r)&&A(t,r,a[r]);return t},R=(t,a)=>F(t,U(a));var x=(t,a,r)=>new Promise((d,g)=>{var s=i=>{try{v(r.next(i))}catch(_){g(_)}},h=i=>{try{v(r.throw(i))}catch(_){g(_)}},v=i=>i.done?d(i.value):Promise.resolve(i.value).then(s,h);v((r=r.apply(t,a)).next())});import{b6 as m,aw as H,c0 as C}from"./bootstrap-Bqxdt4iG.js";import{u as z}from"./data-refresh-BZ1_-6mk.js";import{u as q}from"./tms-order-details-BRpXrzlt.js";import{_ as G}from"./order-detail-form.vue_vue_type_script_setup_true_lang-BvaeXkpr.js";import{T as E,t as I}from"./tms-order-details-D5ZqC9Ar.js";import{T as J}from"./index-D_Q8NZVJ.js";import{T as L}from"./index-axp3BSAN.js";import{a1 as K,L as S,ai as P,aj as c,a9 as l,ak as y,ap as u,p as b,az as p,ax as k,ay as f,F as Q,aq as W,aR as X}from"../jse/index-index-BUJ_4tQs.js";import{u as Y}from"./use-drawer-CLDmRz16.js";const Z={key:0,class:"flex h-full flex-col items-center justify-center py-12"},ee={class:"mb-8 text-gray-400"},ae={class:"flex justify-center gap-6"},re=["onClick"],se={key:0},te={key:1},le={key:2},oe={key:3},ne={key:4},ce={class:"text-base font-semibold"},ie={class:"mt-8"},ue={key:1},de={class:"mb-4 flex items-center gap-2"},me={class:"text-gray-500"},ke=K({__name:"order-detail-create-drawer",setup(t){const a=q(),r=z(),d=S(""),g=S(""),s=S(null),h=S(!1),v=o=>{switch(o){case"AIR":return"purple";case"CUSTOMS":return"orange";case"LAND":return"green";case"OTHERS":return"default";case"SEA":return"blue";default:return"default"}},i=new Set([E.CUSTOMS,E.OTHERS]),_=o=>{if(i.has(o)){C.info("This feature is coming soon.");return}s.value=o},N=o=>x(null,null,function*(){if(!(!d.value||!s.value)){h.value=!0;try{yield s.value==="LAND"?a.createLandDetail(d.value,o):a.createFreightDetail(d.value,R(O({},o),{freightType:s.value})),r.invalidateTmsOrderDetails(),C.success(m("page.tms.orders.message.detailCreated")),T.close()}catch(n){console.error("Failed to create detail:",n);const e=(n==null?void 0:n.message)||m("page.tms.orders.message.detailCreateError");C.error(e)}finally{h.value=!1}}}),B=()=>{s.value?s.value=null:T.close()},[M,T]=Y({title:m("page.tms.orderDetails.drawer.createTitle"),footer:!1,onOpenChange:o=>x(null,null,function*(){var n;if(o){const e=T.getData();e!=null&&e.orderId&&(d.value=e.orderId,g.value=(n=e.customerId)!=null?n:"",s.value=null)}}),onClosed:()=>{d.value="",g.value="",s.value=null}});return(o,n)=>(c(),P(l(M),{class:"w-[1100px]"},{default:y(()=>[s.value?(c(),u("div",ue,[p("div",de,[b(l(L),{color:v(s.value)},{default:y(()=>{var e;return[k(f((e=l(I).find(D=>D.value===s.value))==null?void 0:e.label),1)]}),_:1},8,["color"]),p("span",me,f(l(m)("page.tms.orders.detail.newDetail")),1)]),b(G,{"transport-type":s.value,"customer-id":g.value,mode:"create",onSubmit:N,onCancel:B},null,8,["transport-type","customer-id"])])):(c(),u("div",Z,[b(l(J).Title,{level:4,class:"mb-2"},{default:y(()=>[k(f(l(m)("page.tms.orders.detail.selectType")),1)]),_:1}),p("p",ee,f(l(m)("page.tms.orders.detail.selectTypeDesc")),1),p("div",ae,[(c(!0),u(Q,null,W(l(I),e=>(c(),u("div",{key:e.value,class:"group flex w-[160px] cursor-pointer flex-col items-center gap-3 rounded-xl border border-gray-200 p-6 transition-all hover:border-blue-400 hover:shadow-md dark:border-gray-700 dark:hover:border-blue-500",onClick:D=>_(e.value)},[p("div",{class:X(["flex h-12 w-12 items-center justify-center rounded-full text-2xl",{"bg-green-50 dark:bg-green-900/20":e.value==="LAND","bg-blue-50 dark:bg-blue-900/20":e.value==="SEA","bg-purple-50 dark:bg-purple-900/20":e.value==="AIR","bg-orange-50 dark:bg-orange-900/20":e.value==="CUSTOMS","bg-gray-50 dark:bg-gray-900/20":e.value==="OTHERS"}])},[e.value==="LAND"?(c(),u("span",se,"🚛")):e.value==="SEA"?(c(),u("span",te,"🚢")):e.value==="AIR"?(c(),u("span",le,"✈️")):e.value==="CUSTOMS"?(c(),u("span",oe,"📋")):(c(),u("span",ne,"📦"))],2),p("span",ce,f(e.label),1),b(l(L),{color:v(e.value),class:"m-0"},{default:y(()=>[k(f(e.value),1)]),_:2},1032,["color"])],8,re))),128))]),p("div",ie,[b(l(H),{onClick:n[0]||(n[0]=e=>l(T).close())},{default:y(()=>[k(f(l(m)("page.table.button.cancel")),1)]),_:1})])]))]),_:1}))}});export{ke as _};
