(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,10160,e=>{"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}e.s(["default",()=>t])},83535,e=>{"use strict";var t=e.i(65464),r=e.i(55749),s=e.i(45700),o=e.i(70016);let a=new class{async fetchExportData(e){if(!e||0===e.length)return[];let r=Array.from(e),{data:s,error:o}=await t.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",r).order("created_at",{ascending:!1});if(o)throw console.error("Error fetching export data:",o),Error("Failed to fetch complete order details for export.");return s}formatAddress(e){if(!e)return"N/A";let t=e.label?`[${e.label.toUpperCase()}]
`:"";return`${t}${e.full_address}
Pincode: ${e.pincode}`}exportAsText(e){let t="";e.forEach(e=>{t+=`====================================
ORDER #${e.order_number}
====================================

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

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

`,e.users?.email&&(t+=`Email:
${e.users.email}

`),t+=`Address:
${this.formatAddress(e.addresses)}

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

Products:

`,e.order_items&&e.order_items.length>0?e.order_items.forEach((e,r)=>{let s=e.products?.name||e.product_name;t+=`${r+1}. ${s}
Qty: ${e.quantity}
Price: ₹${e.price}

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

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


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