(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,19053,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(18566),i=e.i(62870),s=e.i(10708),a=e.i(67881),d=e.i(94179),l=e.i(57559),o=e.i(6799),c=e.i(64898);let u=Object.keys(c.ORDER_STATUS_LABELS);e.s(["OrderStatusControl",0,function({orderId:e,currentStatus:f,isSuperAdmin:m,refundAvailable:E,hasPaidPayment:x}){let S=(0,n.useRouter)(),{toast:h}=(0,o.useToast)(),[p,g]=(0,r.useState)(!1),[D,N]=(0,r.useState)(!1),[R,T]=(0,r.useState)(!1);async function b(t){g(!0);let r=await fetch(`/api/admin/orders/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})}),n=await r.json().catch(()=>null);(g(!1),r.ok)?(h({variant:"success",title:"Status updated"}),S.refresh()):h({variant:"error",title:n?.error??"Could not update status"})}async function C(){T(!0);let t=await fetch(`/api/admin/orders/${e}/refund`,{method:"POST"}),r=await t.json().catch(()=>null);(T(!1),N(!1),t.ok)?(h({variant:"success",title:"Order refunded"}),S.refresh()):h({variant:"error",title:r?.error??"Refund failed"})}return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,t.jsxs)("div",{className:"w-56",children:[(0,t.jsx)(s.Label,{htmlFor:"order-status",children:"Status"}),(0,t.jsx)(i.Select,{id:"order-status",value:f,disabled:p,onChange:e=>b(e.target.value),children:u.map(e=>(0,t.jsx)("option",{value:e,disabled:!(e=>{if(e===f)return!0;if("CANCELLED"===e)return m&&("PENDING_PAYMENT"===f||"PAID"===f);if("REFUNDED"===e)return!1;let t=c.ORDER_STATUS_FLOW.indexOf(f),r=c.ORDER_STATUS_FLOW.indexOf(e);return -1!==t&&r>t})(e),className:"disabled:hidden",children:c.ORDER_STATUS_LABELS[e]},e))})]}),(0,t.jsx)(d.Badge,{variant:"COMPLETED"===f?"success":"CANCELLED"===f||"REFUNDED"===f?"danger":"PENDING_PAYMENT"===f?"warning":"info",children:c.ORDER_STATUS_LABELS[f]})]}),(0,t.jsx)("p",{className:"text-xs text-muted",children:m?"Super admin can cancel pending or paid orders; refunds process via Stripe.":"Super admin only: cancel or refund orders."}),E&&x&&"PAID"===f&&m&&(0,t.jsx)(a.Button,{variant:"danger",loading:R,onClick:()=>N(!0),children:"Refund order"}),(0,t.jsx)(l.ConfirmDialog,{open:D,onClose:()=>N(!1),onConfirm:C,loading:R,title:"Refund this order?",message:"The payment will be refunded via Stripe and stock will be restored. This cannot be undone.",confirmLabel:"Refund order"})]})}])},94179,e=>{"use strict";var t=e.i(43476);let r={neutral:"bg-primary/10 text-foreground",success:"bg-green-100 text-green-800",warning:"bg-amber-100 text-amber-800",danger:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800"};e.s(["Badge",0,function({variant:e="neutral",className:n="",...i}){return(0,t.jsx)("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${r[e]} ${n}`,...i})}])},57559,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(2957),i=e.i(67881);e.s(["ConfirmDialog",0,function({open:e,title:s,message:a,confirmLabel:d="Delete",cancelLabel:l="Cancel",loading:o=!1,error:c,onConfirm:u,onClose:f}){let[m]=(0,r.useState)(!1);return(0,t.jsxs)(n.Modal,{open:e,onClose:f,title:s,children:[(0,t.jsx)("p",{className:"mb-6 text-sm text-muted",children:a}),c&&(0,t.jsx)("p",{className:"-mt-4 mb-4 text-sm text-red-600",role:"alert",children:c}),(0,t.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,t.jsx)(i.Button,{variant:"ghost",onClick:f,disabled:o,children:l}),(0,t.jsx)(i.Button,{variant:"danger",onClick:u,loading:o,children:d})]})]})}])},62870,e=>{"use strict";var t=e.i(43476);let r=(0,e.i(71645).forwardRef)(function({invalid:e=!1,className:r="",children:n,...i},s){return(0,t.jsx)("select",{ref:s,"aria-invalid":e||void 0,className:`h-10 w-full rounded-md border border-border bg-white px-3 text-sm focus:outline-2 focus:outline-offset-1 focus:outline-accent ${e?"border-red-500":""} ${r}`,...i,children:n})});e.s(["Select",0,r])},64898,e=>{"use strict";e.s(["ORDER_STATUS_FLOW",0,["PENDING_PAYMENT","PAID","PROCESSING","READY","SHIPPED","COMPLETED"],"ORDER_STATUS_LABELS",0,{PENDING_PAYMENT:"Pending payment",PAID:"Paid",PROCESSING:"Processing",READY:"Ready",SHIPPED:"Shipped",COMPLETED:"Completed",CANCELLED:"Cancelled",REFUNDED:"Refunded"}])}]);