1import{j as e}from"./vendor-maps-C15praqj.js";import{r,u as t}from"./vendor-router-DA6yNf3X.js";import{l as a,E as o,u as d,a as s,C as n}from"./vendor-stripe-Dn1b00Ho.js";import{A as i,V as l}from"./index-CjCZp4kG.js";const c=({address_id:a,order_number:o,order_id:c,vendor_id:u,total_amount:m,onClose:p})=>{const y=d(),_=s(),[b,x]=r.useState(!1),[f,v]=r.useState(""),h=t();return e.jsxs("form",{onSubmit:async e=>{var r,t,d,s,b,f,j;if(e.preventDefault(),!y||!_)return;x(!0);const g=_.getElement(n),{error:P,paymentMethod:N}=await y.createPaymentMethod({type:"card",card:g});if(P)v(P.message),x(!1);else{try{const e=JSON.parse(localStorage.getItem("authToken")),n=(N.card.brand,N.card.last4,N.card.exp_month,N.card.exp_year,await fetch(i.paymentInit,{method:"POST",headers:{"Content-Type":"application/json",Authorization:e,code:"afdb79",currency:"147",language:1,"App-Version":"3.6.0"},body:JSON.stringify({order_number:o,payment_option_id:4,payment_method_id:N.id,action:"cart",amount:m,card:N.card})})),y=await n.json();if(!y.id)return h("/order-success",{state:{orderId:(null==(r=y.data)?void 0:r.id)||c,orderNumber:(null==(t=y.data)?void 0:t.order_number)||o,vendor_id:(null==(b=null==(s=null==(d=y.data)?void 0:d.vendors)?void 0:s[0])?void 0:b.vendor_id)||u}}),v("Payment successful! â
"),l.success("Order placed successfully!"),p(),void x(!1);const _=await fetch(i.confirmPaymentIntent,{method:"POST",headers:{"Content-Type":"application/json",Authorization:e,code:"afdb79",currency:"147",language:1,"App-Version":"3.6.0"},body:JSON.stringify({address_id:a,order_number:o,payment_option_id:"4",payment_intent_id:y.id,action:"cart",amount:m,card:N.card})}),g=await _.json(),P=g.data;g.error?v(g.error):(h("/order-success",{state:{orderId:(null==P?void 0:P.id)||c,orderNumber:(null==P?void 0:P.order_number)||o,vendor_id:(null==(j=null==(f=null==P?void 0:P.vendors)?void 0:f[0])?void 0:j.vendor_id)||u}}),v("Payment successful! â
"),l.success("Payment successful! â
"),p())}catch(S){v("Payment failed â"),l.error("Payment failed â")}x(!1)}},children:[e.jsx(n,{options:{style:{base:{fontSize:"16px"}},hidePostalCode:!0}}),e.jsx("button",{type:"submit",disabled:!y||b,className:"cursor-pointer mt-8 bg-[var(--primary-color)] px-3 py-1 rounded-lg",children:b?"Processingâ¦":"Pay"}),f&&e.jsx("p",{style:{marginTop:"10px"},children:f})]})},u=({address_id:t,order_number:d,order_id:s,vendor_id:n,total_amount:i,isOpen:l,onClose:u})=>{const m=localStorage.getItem("stripe_publishable_key"),p=r.useMemo(()=>m?a(m):null,[m]);return l&&p?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center backdrop-blur-sm bg-black/50 p-4",children:e.jsxs("div",{className:"w-full max-w-md bg-white rounded-xl shadow-lg animate-fade-in",children:[e.jsxs("div",{className:"flex justify-between items-center mb-5 px-4 py-4",children:[e.jsx("h2",{className:"text-2xl font-semibold text-center text-gray-800",children:"Complete Your Payment"}),e.jsx("button",{className:"text-gray-500 hover:text-red-500 cursor-pointer text-xl font-bold",onClick:u,"aria-label":"Close",children:"Ã"})]}),e.jsx("div",{className:"p-6",children:e.jsx(o,{stripe:p,children:e.jsx(c,{address_id:t,order_number:d,order_id:s,vendor_id:n,onClose:u,total_amount:i})})})]})}):null};export{u as S};
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.