module.exports=[14747,(a,b,c)=>{b.exports=a.x("path",()=>require("path"))},59406,a=>{"use strict";var b=a.i(29562),c=a.i(32596),d=a.i(77894),e=a.i(75750);let f=new class{async fetchExportData(a){if(!a||0===a.length)return[];let c=Array.from(a),{data:d,error:e}=await b.supabase.from("orders").select(`
        *,
        users!orders_user_id_fkey (name, phone, email),
        addresses (
          full_address, pincode, label
        ),
        order_items (
          quantity, subtotal, price, product_name
        )
      `).in("id",c).order("created_at",{ascending:!1});if(e)throw console.error("Error fetching export data:",e),Error("Failed to fetch complete order details for export.");return d}formatAddress(a){if(!a)return"N/A";let b=a.label?`[${a.label.toUpperCase()}]
`:"";return`${b}${a.full_address}
Pincode: ${a.pincode}`}exportAsText(a){let b="";a.forEach(a=>{b+=`====================================
ORDER #${a.order_number}
====================================

Customer:
${a.users?.name||"Guest"}

Phone:
${a.users?.phone||"N/A"}

`,a.users?.email&&(b+=`Email:
${a.users.email}

`),b+=`Address:
${this.formatAddress(a.addresses)}

Payment:
${a.payment_method} (${a.payment_status})

Products:

`,a.order_items&&a.order_items.length>0?a.order_items.forEach((a,c)=>{let d=a.products?.name||a.product_name;b+=`${c+1}. ${d}
Qty: ${a.quantity}
Price: ₹${a.price}

`}):b+=`No products found.

`,b+=`------------------------------------
TOTAL: ₹${parseFloat(a.total).toFixed(2)}
------------------------------------


`});let c=new Blob([b],{type:"text/plain;charset=utf-8"}),d=URL.createObjectURL(c),e=document.createElement("a");e.href=d,e.download=`orders_export_${new Date().getTime()}.txt`,e.click(),URL.revokeObjectURL(d)}exportAsExcel(a){let b=[];a.forEach(a=>{let c={"Order Number":a.order_number,"Customer Name":a.users?.name||"Guest",Phone:a.users?.phone||"N/A",Address:this.formatAddress(a.addresses).replace(/\n/g,", "),"Payment Method":`${a.payment_method} (${a.payment_status})`,Status:a.status,"Order Total":a.total};a.order_items&&a.order_items.length>0?a.order_items.forEach(a=>{b.push({...c,"Product Name":a.products?.name||a.product_name,Quantity:a.quantity,Price:a.price})}):b.push(c)});let c=e.utils.json_to_sheet(b),d=e.utils.book_new();e.utils.book_append_sheet(d,c,"Orders"),e.writeFile(d,`orders_export_${new Date().getTime()}.xlsx`)}exportAsPDF(a){let b=new c.default;a.forEach((a,c)=>{c>0&&b.addPage(),b.setFontSize(20),b.text("Delivery Sheet",14,22),b.setFontSize(12),b.text(`Order: #${a.order_number}`,14,32),b.text(`Date: ${new Date(a.created_at).toLocaleDateString()}`,14,38),b.text(`Status: ${a.status.toUpperCase()}`,14,44),b.setFontSize(14),b.text("Customer Details",14,56),b.setFontSize(10),b.text(`Name: ${a.users?.name||"Guest"}`,14,62),b.text(`Phone: ${a.users?.phone||"N/A"}`,14,68);let e=this.formatAddress(a.addresses).split("\n");b.text("Delivery Address:",100,56),e.forEach((a,c)=>{b.text(a,100,62+6*c)}),b.setFontSize(14),b.text("Payment Details",14,85),b.setFontSize(10),b.text(`Method: ${a.payment_method}`,14,91),b.text(`Status: ${a.payment_status}`,14,97);let f=110;if(a.order_items&&a.order_items.length>0){let c=a.order_items.map((a,b)=>[b+1,a.products?.name||a.product_name,a.quantity,`Rs. ${a.price}`]);(0,d.default)(b,{startY:f,head:[["#","Product Name","Quantity","Unit Price"]],body:c}),f=b.lastAutoTable.finalY+10}b.setFontSize(12),b.text(`Total Amount: Rs. ${parseFloat(a.total).toFixed(2)}`,14,f),a.notes&&(b.setFontSize(10),b.text(`Vendor Notes: ${a.notes}`,14,f+10))}),b.save(`orders_export_${new Date().getTime()}.pdf`)}};a.s(["exportService",0,f])}];

//# sourceMappingURL=%5Broot-of-the-server%5D__1p-31h5._.js.map