1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B4zRp9L1.js","assets/index-DvP66-mD.css"])))=>i.map(i=>d[i]); 2import{a0 as u,a1 as p}from"./index-B4zRp9L1.js";const h=60,s=async t=>{const e=await t.json().catch(()=>null);if(!t.ok||!e){const n=e&&typeof e=="object"&&"error"in e?e.error:void 0;throw new Error(n||"Falha ao comunicar com o checkout.")}return e},m=t=>{const e=t?new Date(t):new Date,n=new Date(e);return n.setMinutes(n.getMinutes()+h),n},l=t=>{const e=t.expires_at?new Date(t.expires_at):m(t.created_at),n=t.status==="pending"&&!t.payment_id&&e.getTime()<=Date.now();return{status:n?"cancelled":t.status,paymentStatus:n?"expired":t.payment_status,expiresAt:e.toISOString(),isExpired:n}},w=async(t,e)=>{const n={"Content-Type":"application/json"},{getAttribution:a}=await p(async()=>{const{getAttribution:c}=await import("./index-B4zRp9L1.js").then(o=>o.b4);return{getAttribution:c}},__vite__mapDeps([0,1]));let i={...t,attribution:a()??void 0};if(e!=null&&e.isTest){const{getAuthSession:c}=await p(async()=>{const{getAuthSession:_}=await import("./index-B4zRp9L1.js").then(d=>d.b3);return{getAuthSession:_}},__vite__mapDeps([0,1])),o=await c();if(!(o!=null&&o.access_token))throw new Error("Sessão admin expirada. Faça login novamente.");n.Authorization=`Bearer ${o.access_token}`,i={...i,isTest:!0}}else{const{getCustomerSession:c}=await p(async()=>{const{getCustomerSession:_}=await import("./index-B4zRp9L1.js").then(d=>d.b2);return{getCustomerSession:_}},__vite__mapDeps([0,1])),o=await c();o!=null&&o.access_token&&(n.Authorization=`Bearer ${o.access_token}`)}const r=await fetch("/api/mercado-pago/initialize-checkout",{method:"POST",headers:n,body:JSON.stringify(i)});return s(r)},f=async t=>{const e=await fetch("/api/mercado-pago/create-payment",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return s(e)},y=t=>(t==null?void 0:t.trim().toUpperCase())??"",S=async(t,e,n)=>{const a=await fetch("/api/checkout/validate-coupon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:t,couponCode:y(e),customerState:(n==null?void 0:n.trim())||null})});return s(a)},b=async(t,e)=>{const n=await fetch("/api/checkout/calculate-shipping",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:t,shippingAddress:e})});return s(n)},O=async t=>{const e=await fetch("/api/integrations/mailchimp/sync-cart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return s(e)},T=async(t,e)=>{const n=new URLSearchParams({orderId:t});e&&n.set("paymentId",e);const a=await fetch(`/api/mercado-pago/payment-status?${n.toString()}`);return s(a)},A=async()=>{const{data:t,error:e}=await u.from("checkout_orders").select("id, order_number, status, payment_status, total_amount, subtotal_amount, discount_amount, shipping_amount, shipping_service, coupon_code, customer_name, customer_email, customer_phone, customer_document, customer_notes, items, shipping_address, currency, preference_id, payment_id, merchant_order_id, payment_reference, paid_at, created_at, expires_at, bling_order_id, bling_sync_status, bling_sync_error, bling_invoice_id, bling_invoice_type, bling_invoice_status, melhor_envio_cart_id, melhor_envio_sync_status, melhor_envio_sync_error, mailchimp_sync_status, mailchimp_synced_at, mailchimp_sync_error, tracking_code, tracking_email_sent_at, confirmation_email_sent_at, is_test, subscription_id, attribution").order("created_at",{ascending:!1});if(e)throw e;return t??[]},E=async t=>{const e=await fetch("/api/integrations/melhor-envio/resend",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:t})});return s(e)},C=async t=>{const e=await fetch("/api/integrations/bling/resync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orderId:t})});return s(e)},P=async t=>{const{getAuthSession:e}=await p(async()=>{const{getAuthSession:i}=await import("./index-B4zRp9L1.js").then(r=>r.b3);return{getAuthSession:i}},__vite__mapDeps([0,1])),n=await e();if(!(n!=null&&n.access_token))throw new Error("Sessão expirada. Faça login novamente.");const a=await fetch("/api/integrations/mailchimp/resync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.access_token}`},body:JSON.stringify({orderId:t})});return s(a)},k=async t=>{const{getAuthSession:e}=await p(async()=>{const{getAuthSession:i}=await import("./index-B4zRp9L1.js").then(r=>r.b3);return{getAuthSession:i}},__vite__mapDeps([0,1])),n=await e();if(!(n!=null&&n.access_token))throw new Error("Sessão expirada. Faça login novamente.");const a=await fetch("/api/admin/resend-confirmation",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.access_token}`},body:JSON.stringify({orderId:t})});return s(a)},v=async(t,e)=>{const{getAuthSession:n}=await p(async()=>{const{getAuthSession:r}=await import("./index-B4zRp9L1.js").then(c=>c.b3);return{getAuthSession:r}},__vite__mapDeps([0,1])),a=await n();if(!(a!=null&&a.access_token))throw new Error("Sessão expirada. Faça login novamente.");const i=await fetch("/api/admin/refund-payment",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.access_token}`},body:JSON.stringify({orderId:t,paymentId:e??void 0})});return s(i)};export{h as PENDING_ORDER_EXPIRATION_MINUTES,b as calculateCheckoutShipping,m as calculatePendingOrderExpiration,f as createTransparentCheckoutPayment,T as fetchCheckoutStatus,A as getAdminOrders,l as getEffectiveOrderState,w as initializeTransparentCheckout,y as normalizeCouponCode,v as refundOrderPayment,E as resendMelhorEnvio,k as resendOrderConfirmation,C as resyncBling,P as resyncMailchimp,O as syncMailchimpCart,S as validateCheckoutCoupon};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.