import{s as Te,u as Ae,j as t,g as r,k as Ee,A as q,h as Me,r as Be,C as ze,F as ue,B as $e,N as Le,I as K,t as We,G as R,v as Re,w as qe,x as je,y as se,z as Ve,V as Ue,W as le}from"./index-OkLaRrT4.js";import{r as h,ai as Ge,aj as _e,ak as Fe,aB as Qe,aC as Ye,al as He,am as Ke,ay as Je,an as Xe,ao as Ze}from"./mui-icons-DSJWgROT.js";import{c as et,r as tt,d as at,u as rt,a as nt,b as ot}from"./finishedGoodsInventoryApi-DPCZ-Wed.js";import{u as it}from"./useDebounce-CTawQPqa.js";import{d as de,D as st}from"./mui-x-pickers-DVr_eQ3-.js";import{u as ge,T as s,f as P}from"./mui-x-charts-BC4WZfuI.js";import{l as o,k as lt,I as j,m as dt,c as ce,n as pe,o as he,S as me,P as ct,p as y,M as pt}from"./mui-x-datagrid-Uj6xW2G5.js";const ht=({open:T,onClose:D,packing:l,onApprove:A,onReject:B,entity:w})=>{const g=ge();if(!l)return null;const k=(l.items||[]).reduce((i,v)=>{const m=v.masterBarcode;return i[m]||(i[m]=[]),i[m].push(v),i},{}),z=()=>{const i=window.open("","_blank");if(i){const v=`
        <html>
          <head>
            <title>Order Booking - ${l.packingNumber}</title>
            <style>
              body { font-family: 'Segoe UI', Arial, sans-serif; margin: 0; padding: 24px; background: #fff; color: #222; }
              .header { text-align: center; margin-bottom: 32px; border-bottom: 2px solid #1976d2; padding-bottom: 16px; }
              .header h1 { margin: 0; font-size: 2.2rem; color: #1976d2; }
              .header h2 { margin: 0; font-size: 1.2rem; color: #555; font-weight: 400; }
              .info-section { margin-bottom: 28px; }
              .info-grid { display: flex; gap: 32px; justify-content: center; margin-bottom: 12px; }
              .info-item { background: #f5faff; border: 1px solid #e3eafc; padding: 14px 18px; border-radius: 8px; min-width: 180px; }
              .info-label { font-weight: 600; color: #1976d2; font-size: 13px; }
              .info-value { font-size: 15px; margin-top: 4px; color: #222; }
              .section-title { font-size: 1.1rem; color: #1976d2; font-weight: 600; margin-bottom: 10px; margin-top: 30px; }
              .table-section { margin-bottom: 24px; border-radius: 10px; box-shadow: 0 2px 8px #e3eafc; background: #fafdff; padding: 10px 10px 4px 10px; }
              .table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
              .table-title { font-weight: 600; color: #1976d2; font-size: 1rem; }
              .table-subtitle { color: #888; font-size: 12px; }
              table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
              th, td { border: 1px solid #e3eafc; padding: 4px 7px; font-size: 12px; }
              th { background: #e3eafc; color: #1976d2; font-weight: 600; }
              td { background: #fff; }
              .table-summary { background: #f5faff; padding: 6px; border-radius: 0 0 8px 8px; font-size: 12px; color: #1976d2; border: 1px solid #e3eafc; border-top: none; }
              .sub-table-title { font-size: 0.95rem; color: #388e3c; font-weight: 600; margin: 7px 0 2px 0; }
              .overall-summary { background: #e3f2fd; padding: 10px; border-radius: 8px; border: 1px solid #1976d2; margin-top: 18px; }
              .overall-title { font-weight: 700; color: #1976d2; margin-bottom: 7px; font-size: 1.05rem; }
              .overall-stats { display: flex; gap: 24px; font-size: 0.98rem; }
              .highlight { color: #388e3c; font-weight: 600; }
              @media print {
                body { margin: 0; padding: 0; background: #fff; }
                .no-print { display: none; }
                .header { margin-bottom: 12px; padding-bottom: 6px; }
                .info-section { margin-bottom: 10px; }
                .info-grid { gap: 10px; margin-bottom: 4px; }
                .info-item { padding: 6px 8px; min-width: 120px; font-size: 11px; background: #fff !important; border-color: #e3eafc !important; }
                .info-label { font-size: 11px; }
                .info-value { font-size: 12px; }
                .table-section, .overall-summary { box-shadow: none !important; background: #fff !important; margin-bottom: 10px; padding: 4px 2px 2px 2px; page-break-inside: avoid; }
                .sub-table-title { margin: 3px 0 1px 0; font-size: 11px; }
                table { margin-bottom: 2px; }
                th, td { padding: 2px 4px; font-size: 10px; }
                .table-summary { padding: 3px; font-size: 10px; }
                .overall-summary { padding: 5px; margin-top: 8px; }
                .overall-title { font-size: 11px; margin-bottom: 3px; }
                .overall-stats { gap: 10px; font-size: 10px; }
              }
            </style>
          </head>
          <body>
            <div class="header">
              <h1>Order Booking</h1>
              <h2>Order No: ${l.packingNumber} | Date: ${new Date(l.createdAt||"").toLocaleDateString()}</h2>
            </div>
            <div class="info-section">
              <div class="info-grid">
                <div class="info-item">
                  <div class="info-label">Client Name</div>
                  <div class="info-value">${l.clientName}</div>
                </div>
                <div class="info-item">
                  <div class="info-label">Phone Number</div>
                  <div class="info-value">${l.phoneNumber}</div>
                </div>
                <div class="info-item">
                  <div class="info-label">Experience Center</div>
                  <div class="info-value">${l.experienceCenterName||"Main Unit"}</div>
                </div>
              </div>
            </div>
            ${Object.entries(k).map(([m,N])=>{const c=N[0],I=N.reduce((d,u)=>d+(parseFloat(u.sqft)||0),0),C=N.filter(d=>d.packingItemDetailDTOList&&d.packingItemDetailDTOList.length>0).flatMap(d=>d.packingItemDetailDTOList).filter((d,u,$)=>u===$.findIndex(S=>S.subBarcode===d.subBarcode)),M=C.length>0?C.length:N.length;return`
                  <div class="table-section">
                    <div class="table-header">
                      <div class="table-title">${c.name} (${c.country})</div>
                      <div class="table-subtitle">Master Barcode: <span class="highlight">${m}</span></div>
                    </div>
                    <table>
                      <thead>
                        <tr>
                          <th>S.No</th>
                          <th>Master Barcode</th>
                          <th>Country</th>
                          <th>Type</th>
                          <th>Name</th>
                          <th>Unit</th>
                          <th>Sqft</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr>
                          <td>1</td>
                          <td>${m}</td>
                          <td>${c.country}</td>
                          <td>${c.type}</td>
                          <td>${c.name}</td>
                          <td>${c.unit}</td>
                          <td>${I}</td>
                        </tr>
                      </tbody>
                    </table>
                    <div class="table-summary">
                      Items: ${M} | Total Sqft: <span class="highlight">${I}</span>
                    </div>
                    ${C.length>0?`<div class="sub-table-title">Sub Items for ${c.name} (${m}):</div>
                                <table>
                                  <thead>
                                    <tr>
                                      <th>S.No</th>
                                      <th>Sub Barcode</th>
                                      <th>Width</th>
                                      <th>Length</th>
                                      <th>UOM</th>
                                      <th>Quantity</th>
                                      <th>Storage Type</th>
                                    </tr>
                                  </thead>
                                  <tbody>
                                    ${C.map((d,u)=>`<tr>
                                            <td>${u+1}</td>
                                            <td>${d.subBarcode}</td>
                                            <td>${d.width}</td>
                                            <td>${d.length}</td>
                                            <td>${d.uom}</td>
                                            <td>${d.quantity}</td>
                                            <td>${d.storageType||"-"}</td>
                                          </tr>`).join("")}
                                  </tbody>
                                </table>`:""}
                  </div>
                `}).join("")}
            <div class="overall-summary">
              <div class="overall-title">Overall Summary</div>
              <div class="overall-stats">
                <span>Total Items: <span class="highlight">${l.items.length}</span></span>
                <span>Total Sqft: <span class="highlight">${l.totalSqft}</span></span>
              </div>
            </div>
          </body>
        </html>
      `;i.document.write(v),i.document.close(),i.focus(),i.print(),i.close()}};return t(pt,{open:T,onClose:D,children:r(o,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"95%",maxWidth:1200,maxHeight:"95vh",bgcolor:"background.paper",borderRadius:3,boxShadow:24,p:0,overflow:"hidden"},children:[t(o,{sx:{p:3,borderBottom:`1px solid ${g.palette.divider}`,backgroundColor:P(g.palette.primary.main,.07)},children:r(o,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r(o,{children:[r(s,{variant:"h5",fontWeight:700,color:"primary",children:["Order Booking - ",l.packingNumber]}),r(s,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:["Created on ",new Date(l.createdAt).toLocaleDateString()]})]}),r(o,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.status==="PENDING_APPROVAL"&&w.write&&r(ue,{children:[t(q,{btnType:"approve",onClick:()=>A==null?void 0:A("APPROVED"),children:"Approve"}),t(q,{btnType:"close",onClick:()=>B==null?void 0:B("REJECTED"),children:"Rejected"})]}),t(q,{btnType:"print",onClick:z,children:"Print"}),t(j,{onClick:D,size:"large",children:t(Ze,{})})]})]})}),r(o,{sx:{p:{xs:1,md:3},maxHeight:"calc(95vh - 120px)",overflow:"auto"},children:[r(We,{sx:{p:3,mb:3,backgroundColor:i=>i.palette.mode==="dark"?"rgba(3, 169, 244, 0.1)":P(i.palette.info.main,.07),borderRadius:2,boxShadow:0},children:[t(s,{variant:"h6",sx:{mb:2,color:g.palette.info.main,fontWeight:600},children:"Client Information"}),r(R,{container:!0,spacing:3,children:[t(R,{item:!0,xs:12,md:4,children:r(o,{children:[t(s,{variant:"body2",color:"text.secondary",gutterBottom:!0,fontWeight:600,children:"Client Name"}),t(s,{variant:"body1",fontWeight:700,color:"primary.main",children:l.clientName})]})}),t(R,{item:!0,xs:12,md:4,children:r(o,{children:[t(s,{variant:"body2",color:"text.secondary",gutterBottom:!0,fontWeight:600,children:"Phone Number"}),t(s,{variant:"body1",fontWeight:700,color:"primary.main",children:l.phoneNumber})]})}),t(R,{item:!0,xs:12,md:4,children:r(o,{children:[t(s,{variant:"body2",color:"text.secondary",gutterBottom:!0,fontWeight:600,children:"Experience Center"}),t(s,{variant:"body1",fontWeight:700,color:"primary.main",children:l.experienceCenterName||"Main Unit"})]})})]})]}),Object.entries(k).map(([i,v])=>{const m=v[0],N=v.reduce((c,I)=>c+(parseFloat(I.sqft)||0),0);return r(o,{sx:{mb:4,borderRadius:2,boxShadow:1,p:2,border:`1px solid ${P(g.palette.primary.main,.08)}`},children:[r(o,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,p:1.5,backgroundColor:c=>c.palette.mode==="dark"?"rgba(25, 118, 210, 0.1)":P(c.palette.primary.main,.04),borderRadius:1,border:c=>`1px solid ${c.palette.mode==="dark"?"rgba(25, 118, 210, 0.2)":P(c.palette.primary.main,.08)}`},children:[r(o,{children:[r(s,{variant:"h6",sx:{color:g.palette.primary.main,fontWeight:700},children:[m.name," (",m.country,")"]}),m.type&&r(s,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:["Colour: ",t("span",{style:{color:g.palette.info.main,fontWeight:600},children:m.type})]})]}),r(s,{variant:"h6",sx:{color:g.palette.primary.main,fontWeight:700},children:["Price: ₹",m.sellingPricePerUom]}),r(s,{variant:"body2",color:"text.secondary",children:["Master Barcode: ",t("span",{style:{color:g.palette.success.main,fontWeight:600},children:i})]})]}),(()=>{const I=v.filter(p=>p.packingItemDetailDTOList&&p.packingItemDetailDTOList.length>0).flatMap(p=>p.packingItemDetailDTOList).filter((p,C,M)=>C===M.findIndex(d=>d.subBarcode===p.subBarcode));return I.length>0?t(o,{sx:{mt:2,mb:2,ml:2,borderRadius:1,p:2,border:`1px solid ${P(g.palette.info.main,.08)}`},children:t(Re,{component:ct,sx:{boxShadow:0},children:r(qe,{size:"small",children:[t(je,{children:r(se,{children:[t(y,{sx:{fontWeight:700},children:"S.No"}),t(y,{sx:{fontWeight:700},children:"Sub Barcode"}),t(y,{sx:{fontWeight:700},children:"Width"}),t(y,{sx:{fontWeight:700},children:"Length"}),t(y,{sx:{fontWeight:700},children:"UOM"}),t(y,{sx:{fontWeight:700},children:"Quantity"}),t(y,{sx:{fontWeight:700},children:"Storage Type"})]})}),t(Ve,{children:I.map((p,C)=>r(se,{children:[t(y,{children:C+1}),t(y,{children:p.subBarcode}),t(y,{children:p.width}),t(y,{children:p.length}),t(y,{children:p.uom}),t(y,{children:p.quantity}),t(y,{children:p.storageType||"-"})]},p.id||`${p.subBarcode}-${C}`))})]})})}):null})(),r(o,{sx:{p:1.5,borderRadius:1,mt:1,fontWeight:600,color:g.palette.primary.main},children:["Items: ",v.length," | Total Sqft: ",t("span",{style:{color:g.palette.success.main},children:N})]})]},i)}),r(o,{sx:{mt:3,p:2,backgroundColor:i=>i.palette.mode==="dark"?"rgba(25, 118, 210, 0.1)":P(i.palette.primary.main,.07),borderRadius:2,border:i=>`1px solid ${i.palette.mode==="dark"?"rgba(25, 118, 210, 0.2)":P(i.palette.primary.main,.08)}`,display:"flex",justifyContent:"space-between",alignItems:"center",boxShadow:0},children:[t(s,{variant:"h6",color:"primary",fontWeight:700,children:"Overall Summary"}),r(o,{sx:{display:"flex",gap:3},children:[r(s,{variant:"body1",color:"text.secondary",children:["Total Items: ",t("span",{style:{fontWeight:700,color:g.palette.primary.main},children:l.items.length})]}),r(s,{variant:"body1",color:"text.secondary",children:["Total Sqft: ",t("span",{style:{fontWeight:700,color:g.palette.success.main},children:l.totalSqft})]})]})]})]})]})})},mt=({onCreateNew:T,onEditPacking:D})=>{const l=ge(),[A,B]=h.useState("list"),[w,g]=h.useState({packingNumber:"",clientName:"",experienceCenter:"",phoneNumber:""}),[k,z]=h.useState(null),[i,v]=h.useState(!1),[m,N]=h.useState(null),[c,I]=h.useState(null),[p,C]=h.useState(null),[M,d]=h.useState(!1),[u,$]=h.useState(null),[S,fe]=h.useState({}),V=Te(e=>e.userRole.roleDetails),be=[w.packingNumber,w.clientName,w.experienceCenter,w.phoneNumber].filter(Boolean).join(" ");h.useEffect(()=>{if(V){const e=V.find(a=>a.applicationEntityName.toLowerCase().replace(/\s+/g,"")==="orderbookings");fe(e)}},[V]);const U=it(be,500),{data:G,isLoading:ut,refetch:J}=et(m!==null?{id:m}:tt.skipToken,{refetchOnMountOrArgChange:!0});h.useEffect(()=>{},[G,m]);const[O,X]=h.useState({page:0,pageSize:10}),{openSnackbar:f}=Ae(),[L,_]=h.useState([]),[xe,F]=h.useState(0),[Z,{data:gt={},isLoading:ye}]=at(),[ft]=rt(),[ve]=nt(),[ke]=ot(),[Ce,Q]=h.useState(null),W=h.useCallback(async(e,a)=>{Q(null);try{const n=await Z({page:e,size:a,searchByName:{searchValue:U}});if(n&&n.data){const x=n.data,E=(x.data||[]).map((b,ie)=>({packingNumber:b.packingNumber||`temp-${b.id||ie}`,clientName:b.clientName||"",phoneNumber:b.phoneNumber||"",totalSqft:b.totalSqft||0,totalAmount:b.totalAmount||0,items:b.packingItemsDTOList||[],id:b.id!==void 0&&b.id!==null?b.id:ie,createdAt:b.createdDate||"",experience:b.experience||"Main Unit",status:b.status||""}));_(E),F(x.totalCount||0)}else{Q(n.error);const x=n.error;_([]),F(0)}}catch(n){Q(n),_([]),F(0)}},[Z,U]);h.useEffect(()=>{W(O.page,O.pageSize)},[W,O,U]),new Set(L.map(e=>e.clientName)).size,L.reduce((e,a)=>e+(a.totalSqft||0),0),L.reduce((e,a)=>e+(a.totalAmount||0),0);const ee=e=>{if(e.id===void 0||e.id===null||e.id===""){f("Cannot view: Missing packing ID","error");return}const a=typeof e.id=="string"?parseInt(e.id):e.id;if(isNaN(a)){f("Invalid packing ID","error");return}N(a),z(e),v(!0),typeof J=="function"&&J()},te=e=>{if(e.id===void 0||e.id===null||e.id===""){f("Cannot edit: Missing packing ID","error");return}if(D)try{D(e)}catch{f("Error opening edit mode","error")}},Y=()=>{v(!1),z(null),N(null)},H=()=>{I(null),C(null)},Se=()=>{p&&f("Order Booking approved!","success"),H()},Ne=()=>{p&&f("Order Booking rejected!","error"),H()},ae=e=>{$(e),d(!0)},re=()=>{d(!1),$(null)},Ie=async()=>{var e;if(u&&u.id){const a=parseInt(u.id.toString());if(isNaN(a)){f("Invalid packing ID","error");return}const n=await ve({orderId:a,orderNumber:u.packingNumber||""});if("data"in n)f("Order Booking sent for approval!","success"),W(O.page,O.pageSize),Y();else{const x=n.error,E=((e=x==null?void 0:x.data)==null?void 0:e.message)??"An error occurred";f(E,"error")}}re()},ne=async e=>{var a;if(k&&k.id!==void 0&&k.id!==null&&k.id!==""){const n=typeof k.id=="string"?parseInt(k.id):k.id;if(isNaN(n)){f("Invalid packing ID","error");return}const x=await ke({id:n,status:e});if("data"in x)f(`Order Booking ${e.toLowerCase()}!`,"success"),W(O.page,O.pageSize),Y();else{const E=x.error,b=((a=E==null?void 0:E.data)==null?void 0:a.message)??"An error occurred";f(b,"error")}}},De=e=>{e&&(navigator&&navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(()=>{f("Pack No copied to clipboard.","success")}).catch(()=>{f("Failed to copy Pack No.","error")}):f("Clipboard not supported in this browser.","error"))},oe=(e,a)=>{g(n=>({...n,[e]:a})),X(n=>({...n,page:0}))},we=[{field:"clientName",headerName:"Client",flex:1},{field:"phoneNumber",headerName:"Phone",flex:1},{field:"experience",headerName:"Experience",flex:1},{field:"packingNumber",headerName:"Pack No",flex:1.2,renderCell:e=>{const a=e.value||e.row.packingNumber||"";return r(me,{direction:"row",alignItems:"center",spacing:1,children:[t(s,{variant:"body2",sx:{fontFamily:"monospace"},children:a}),a&&t(j,{size:"small",onClick:n=>{n.stopPropagation(),De(a)},children:t(Xe,{fontSize:"small"})})]})}},{field:"createdAt",headerName:"Created",flex:1,renderCell:e=>de(e.value).format("M/D/YYYY h:mm A")},{field:"status",headerName:"Status",flex:1,renderCell:e=>Be(e.value)},{field:"action",headerName:"Action",flex:1.5,sortable:!1,renderCell:e=>{const a=(e.row.status||"").toUpperCase(),n=a!=="CANCELLED"&&a!=="COMPLETED"&&a!=="PENDING"&&a!=="APPROVED"&&a!=="CANCELLED_INVOICE",x=a==="INITIATED";return r(me,{direction:"row",spacing:1,children:[S.read&&t(K,{type:"View",onClick:()=>ee(e.row)}),D&&n&&S.create&&t(K,{type:"Edit",onClick:()=>te(e.row)}),x&&S.create&&t(K,{type:"Send",onClick:()=>ae(e.row)})]})}}];function Oe(e){return{packingNumber:e.packingNumber,clientName:e.clientName,phoneNumber:e.phoneNumber,experienceCenterName:e.experience||"Main Unit",totalSqft:Array.isArray(e.packingItemsDTOList)?e.packingItemsDTOList.reduce((a,n)=>a+(n.totalQuantity||0),0):0,totalAmount:0,items:Array.isArray(e.packingItemsDTOList)?e.packingItemsDTOList.flatMap(a=>(a.packingItemDetailDTOList||[]).map(n=>({id:n.id,itemId:a.id,country:a.country,type:a.colour||"",name:a.productName,masterBarcode:a.masterBarcode,barcode:n.subBarcode,unit:n.uom,sqft:n.quantity,rate:a.sellingPricePerUom||0,total:(n.quantity*(a.sellingPricePerUom||0)).toFixed(2),width:n.width,length:n.length,storageType:n.storageType||"",sellingPricePerUom:a.sellingPricePerUom||0,packingItemDetailDTOList:a.packingItemDetailDTOList||[]}))):[],createdAt:e.createdDate||e.date||"",status:e.status||"",id:e.id}}const Pe=h.useCallback(()=>t("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:l.palette.text.secondary,fontSize:"16px"},children:"No Data Available"}),[l.palette.text.secondary]);return t(Le,{error:Ce,children:r(o,{p:2,sx:{width:"100%"},children:[r(Ee,{children:[r(o,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:[t(o,{sx:{display:"flex",gap:2,alignItems:"center",flexWrap:"wrap"},children:t(lt,{placeholder:"Search packing number...",variant:"outlined",size:"small",value:w.packingNumber,sx:{width:240,"& .MuiOutlinedInput-root":{backgroundColor:e=>e.palette.mode==="dark"?"rgba(255,255,255,0.05)":"white","&:hover":{"& .MuiOutlinedInput-notchedOutline":{borderColor:"primary.main"}}}},onChange:e=>oe("packingNumber",e.target.value),InputProps:{startAdornment:t(j,{edge:"start",size:"small",sx:{color:"text.secondary"},children:t(_e,{})}),endAdornment:w.packingNumber&&t(j,{edge:"end",onClick:()=>oe("packingNumber",""),size:"small",sx:{color:"text.secondary"},children:t(Ge,{})})}})}),t(o,{children:T&&S.create&&t(q,{btnType:"create",onClick:T,children:"Create Order"})})]}),A==="list"?t(Me,{columns:we,rows:L,checkboxSelection:!1,enableManageColumns:!0,defaultHiddenColumns:["id"],autoHeight:!0,getRowId:e=>e.id||e.packingNumber||`row-${Math.random()}`,rowCount:xe,paginationMode:"server",paginationModel:O,onPaginationModelChange:X,pageSizeOptions:[10,25,50,100],components:{NoRowsOverlay:Pe},loading:ye,mobileCardRenderer:e=>{const a=(e.status||"").toUpperCase(),n=!["CANCELLED","COMPLETED","PENDING","APPROVED","CANCELLED_INVOICE"].includes(a),x=a==="INITIATED";return t(ze,{title:e.packingNumber||`Order #${e.id}`,fields:[{label:"Client",value:e.clientName},{label:"Phone",value:e.phoneNumber},{label:"Status",value:e.status},{label:"Created",value:e.createdAt?de(e.createdAt).format("M/D/YYYY"):"-"}],actions:[...S.read?[{icon:t(Fe,{fontSize:"small"}),label:"View",onClick:()=>ee(e)}]:[],...D&&n&&S.create?[{icon:t(Qe,{fontSize:"small"}),label:"Edit",onClick:()=>te(e),color:"primary"}]:[],...x&&S.create?[{icon:t(Ye,{fontSize:"small"}),label:"Send",onClick:()=>ae(e)}]:[]]})}}):t(ue,{})]}),t(ht,{open:i,onClose:Y,packing:G?Oe(G):k,onApprove:ne,onReject:ne,entity:S}),r(dt,{anchorEl:c,open:!!c,onClose:H,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{mt:1,minWidth:180,boxShadow:e=>e.palette.mode==="dark"?"0 8px 32px rgba(0,0,0,0.3)":"0 8px 32px rgba(0,0,0,0.12)",borderRadius:3,border:"1px solid",borderColor:e=>e.palette.divider,overflow:"hidden"}},children:[r(ce,{onClick:Se,sx:{py:2,px:2,"&:hover":{backgroundColor:e=>e.palette.mode==="dark"?"success.dark":"success.50"},borderBottom:"1px solid",borderColor:e=>e.palette.divider},children:[t(pe,{children:t(o,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:"50%",backgroundColor:"success.100",mr:1.5},children:t(He,{fontSize:"small",sx:{color:"success.main"}})})}),t(he,{primary:"Approve",primaryTypographyProps:{fontSize:"0.95rem",fontWeight:600,color:"success.main"},secondary:"Mark as approved",secondaryTypographyProps:{fontSize:"0.75rem",color:"text.secondary"}})]}),r(ce,{onClick:Ne,sx:{py:2,px:2,"&:hover":{backgroundColor:e=>e.palette.mode==="dark"?"error.dark":"error.50"}},children:[t(pe,{children:t(o,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:"50%",backgroundColor:"error.100",mr:1.5},children:t(Ke,{fontSize:"small",sx:{color:"error.main"}})})}),t(he,{primary:"Reject",primaryTypographyProps:{fontSize:"0.95rem",fontWeight:600,color:"error.main"},secondary:"Mark as rejected",secondaryTypographyProps:{fontSize:"0.75rem",color:"text.secondary"}})]})]}),t($e,{open:M,onClose:re,maxWidth:"xs",onConfirm:()=>Ie(),confirmText:"Move to Packing List",children:t(st,{sx:{pt:2,pb:2,px:2},children:r(o,{sx:{display:"flex",alignItems:"flex-start",gap:1.5},children:[t(o,{sx:{width:40,height:40,borderRadius:"50%",backgroundColor:e=>e.palette.mode==="dark"?"rgba(3, 169, 244, 0.2)":"info.100",display:"flex",alignItems:"center",justifyContent:"center",mt:.5,flexShrink:0},children:t(Je,{sx:{color:"info.main",fontSize:22}})}),r(o,{flex:1,children:[t(s,{variant:"subtitle1",fontWeight:600,color:"info.main",gutterBottom:!0,children:"Packing List Approve"}),r(s,{variant:"body2",color:"text.secondary",mb:2,children:["Are you sure you want to approve and send this to the Packing List?"," "]}),r(o,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",columnGap:2,flexWrap:"wrap"},children:[r(o,{sx:{minWidth:"45%"},children:[t(s,{variant:"caption",color:"text.secondary",children:"Packing NO"}),t(s,{variant:"body2",fontWeight:500,children:(u==null?void 0:u.packingNumber)||"—"})]}),r(o,{sx:{minWidth:"45%"},children:[t(s,{variant:"caption",color:"text.secondary",children:"Client Name"}),t(s,{variant:"body2",fontWeight:500,children:(u==null?void 0:u.clientName)||"—"})]})]})]})]})})})]})})},It=()=>{const T=Ue();return t(mt,{onCreateNew:()=>{T(le.ORDER_BOOKING_CREATE)},onEditPacking:A=>{T(le.ORDER_BOOKING_CREATE,{state:{editData:A,mode:"edit"}})}})};export{It as default};
