import{c as Z,o as x,H as A,G as J,b as c,a_ as Q,bP as ee,T as te,U as F,aW as t,aU as q,d7 as ae,a$ as oe,F as N,a as r,bV as j,w as u,d as h,bd as C,bm as _,bW as z,bY as E,bX as M,ap as U,c1 as L,c2 as O,f as le,V as se,c3 as re,e as ne,b_ as ie}from"./index-CxvxTWuH.js";import{p as G}from"./payApi-ChlY9pCu.js";import{_ as de}from"./ReCaptcha-g5PzMc6U.js";import{_ as B}from"./_plugin-vue_export-helper-DlAUqK2U.js";const ue={name:"Overlay",props:{show:Boolean}},ce={key:0,class:"overlays"};function me(S,v,I,d,s,p){return x(),Z(te,{to:"body"},[I.show?(x(),A("div",ce,[c("div",{class:"modal",onClick:v[0]||(v[0]=ee(y=>S.$emit("close"),["self"]))},[Q(S.$slots,"default",{},void 0,!0)])])):J("",!0)])}const pe=B(ue,[["render",me],["__scopeId","data-v-333a22a5"]]),fe={class:"d-flex align-center"},ve={id:"card-errors",class:"sr-field-error",role:"alert"},ye={class:"mt-6 d-flex align-center",style:{color:"#106ebe","justify-content":"center"}},ge=F({__name:"AddPaymentCardDialog",props:{title:String},emits:["reflash"],setup(S,{expose:v,emit:I}){let d=t(!1);const s=t(!1);t([]),t([]),t([]);let p=t([]),y=t("");const b=t("");t(""),t(""),t(""),t(""),t(""),t("");const n=t(""),o=q({color:"",msg:"",isShow:!1});let P=t(!1);t([e=>!!e||"Country is required"]),t([e=>!!e||"State is required"]),t([e=>!!e||"Address is required",e=>e&&e.length<40||"Max length 40"]),t([e=>!!e||"City is required",e=>e&&e.length<40||"Max length 40"]),t([e=>!!e||"ZIP code is required"]),ae();let f=t(""),w=t(""),k=t(""),i=t(""),l=t("");const m=I,K=S,V=G();function W(){V.publicKey().then(e=>{V.createPaymentIntent({orderIds:p.value,couponCode:l.value,contentType:"application/json;charset=UTF-8"}).then(a=>{i.value=a.data.clientSecret,y.value=a.data.stripePaymentIntentId,w.value=Stripe(e.data);let T=w.value.elements({locale:"en"});var g={base:{fontSize:"16px",color:"#32325d",fontFamily:"-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif",fontSmoothing:"antialiased","::placeholder":{color:"rgba(0,0,0,0.4)"}}};f.value=T.create("card",{style:g,hidePostalCode:!0}),f.value.mount("#card-element"),f.value.on("focus",function(){var $=document.getElementById("card-element");$.classList.add("focused")}),f.value.on("blur",function(){var $=document.getElementById("card-element");$.classList.remove("focused")})})})}function H(){if(!n.value){o.color="error",o.msg="Please verify reCaptcha",o.isShow=!0;return}s.value=!0,V.recaptchaValid({recaptchaToken:n.value}).then(e=>{w.value.confirmCardPayment(i.value,{payment_method:{card:f.value,type:"card"}}).then(a=>{console.log(a),a.error?(s.value=!1,o.color="error",o.msg=a.error.message,o.isShow=!0):R()})}).catch(e=>{o.color="error",o.msg=e.msg,o.isShow=!0,s.value=!1})}function R(){setTimeout(async()=>{V.createPaymentIntentStatus({stripePaymentIntentId:y.value}).then(e=>{e.data.status===1?R():e.data.status===3?(o.color="error",o.msg=e.data.failReason,o.isShow=!0,s.value=!1,D()):e.data.status===2&&(o.color="success",o.msg="paySuccess",o.isShow=!0,s.value=!1,m("reflash"),D())})},500)}function X(e){return console.log("val....",e),n.value=e,e}function Y(e){p.value=e.orderId,l.value=e.couponCode,console.log("orderId1...",e),console.log("orderId...",p.value),d.value=!0,setTimeout(()=>{P.value=!0},1e3),W()}function D(){s.value=!1,d.value=!1}return v({openDialog:Y,closeDialog:D}),(e,a)=>{const T=oe("lockIcon");return x(),A(N,null,[r(j,{modelValue:o.isShow,"onUpdate:modelValue":a[0]||(a[0]=g=>o.isShow=g),color:o.color,timeout:3e3,variant:"flat",rounded:"md",location:"top"},{default:u(()=>[h(C(o.msg),1)]),_:1},8,["modelValue","color"]),r(pe,{show:_(d)},{default:u(()=>[r(z,{style:{"max-width":"570px"}},{default:u(()=>[r(E,{style:{"padding-top":"24px"}},{default:u(()=>[c("h3",fe,[h(C(K.title)+" ",1),r(M,{src:_(L),width:32,height:32,class:"close",onClick:a[1]||(a[1]=g=>U(d)?d.value=!1:d=!1)},null,8,["src"])]),r(O,{class:"mt-4"}),a[5]||(a[5]=c("p",{class:"mt-6"},"1.Add a credit card information",-1)),a[6]||(a[6]=c("div",{id:"card-element"},null,-1)),c("div",ve,C(_(k)),1),r(le,{class:"mt-4"},{default:u(()=>[r(se,{lg:"12",cols:"12"},{default:u(()=>[r(re,{label:"Cardholder name",color:"primary",variant:"outlined",modelValue:b.value,"onUpdate:modelValue":a[2]||(a[2]=g=>b.value=g)},null,8,["modelValue"])]),_:1})]),_:1}),r(de,{onGetChildren:X}),r(ne,{class:"mt-6",color:"primary",block:"",loading:s.value,disabled:!n.value,onClick:H},{default:u(()=>a[3]||(a[3]=[h("Submit")])),_:1},8,["loading","disabled"]),c("div",ye,[r(T),a[4]||(a[4]=h("lock Secure card form "))]),a[7]||(a[7]=c("div",{class:"mt-4 text-medium-emphasis text-center pb-4",style:{"font-size":"12px"}}," Credit cards handled securely with SSL encryption ",-1))]),_:1})]),_:1})]),_:1},8,["show"])],64)}}}),Ve=B(ge,[["__scopeId","data-v-91a541e5"]]),he={class:"d-flex align-center"},Se=F({__name:"AddPayPalDialog",props:{title:String},emits:["reflash"],setup(S,{expose:v,emit:I}){let d=t(""),s=t(!1);const p=G(),y="https://dashboard.jetprintapp.com",b=t(""),n=q({color:"",msg:"",isShow:!1});function o(){paypal.Button.render({env:"production",commit:!0,style:{size:"large",color:"blue",shape:"rect"},locale:"en_US",payment:function(){return P()},onAuthorize:function(i,l){console.log(i,l);var m={paymentId:i.paymentID,payerId:i.payerID};return f(m)}},"paypal-button-container2")}async function P(){try{return(await p.createPaypal({contentType:"application/json;charset=UTF-8",couponCode:b.value,cancelUrl:y+"/order/order?id="+d.value,orderIds:d.value,returnUrl:y+"/order/order?id="+d.value})).data.payId}catch(i){throw i}}function f(i){p.executePaypal(i).then(l=>{data.status===1?(n.color="success",n.msg="Pay success",n.isShow=!0):(n.color="error",n.msg=l.failReason,n.isShow=!0)})}function w(i,l){d.value=i,b.value=l,s.value=!0,setTimeout(()=>{o()},100)}function k(){isSubmit.value=!1,s.value=!1}return v({openDialog:w,closeDialog:k}),(i,l)=>(x(),A(N,null,[r(j,{modelValue:n.isShow,"onUpdate:modelValue":l[0]||(l[0]=m=>n.isShow=m),color:n.color,timeout:3e3,variant:"flat",rounded:"md",location:"top"},{default:u(()=>[h(C(n.msg),1)]),_:1},8,["modelValue","color"]),r(ie,{modelValue:_(s),"onUpdate:modelValue":l[2]||(l[2]=m=>U(s)?s.value=m:s=m),"max-width":575},{default:u(()=>[r(z,null,{default:u(()=>[r(E,{style:{"padding-top":"24px"}},{default:u(()=>[c("h3",he,[l[3]||(l[3]=h("Pay Paypal ")),r(M,{src:_(L),width:32,height:32,class:"close",onClick:l[1]||(l[1]=m=>U(s)?s.value=!1:s=!1)},null,8,["src"])]),r(O,{class:"mt-4 mb-6"}),l[4]||(l[4]=c("div",{class:"text-center"},[c("div",{id:"paypal-button-container2"})],-1))]),_:1})]),_:1})]),_:1},8,["modelValue"])],64))}}),Ce=B(Se,[["__scopeId","data-v-fcb1e508"]]);export{Ve as A,Ce as a};