1import{j as e,r as o,h as t,o as n,U as a,H as s,k as c,m as r,A as l,u as i,K as d,w as u,v as p,l as f,P as m,t as v,n as I,x as h,q as _,s as y,E as g,G as b}from"./vendor-BFWRUIHt.js";import{_ as k}from"./loading-CTo5vyGD.js";import{t as x,i as S,D as T,E as A,F as w,G as P,T as j,C,e as D}from"./flexible-BAsQ4LzO.js";import{_ as O}from"./general.vue_vue_type_script_setup_true_lang-DLhtg8zK.js";/* empty css */const N=e=>(g("data-v-c687241a"),e=e(),b(),e),U={class:"checkout_page m-main"},$={class:"sub_info"},q=N((()=>r("p",{class:"sub_info_title"},"Perfect365 PLUS Membership Subscription",-1))),B={class:"sub_info_tips"},F={class:"sub_line_box"},L={class:"line_item"},J={class:"title"},M={class:"content price_color"},W={key:0,class:"line_item"},X={class:"title"},E={class:"content price_color"},G={class:"total_line line_item"},K=N((()=>r("span",{class:"title"},"Total",-1))),R={class:"content price_color"},z={class:"pay_card"},H={class:"mask"},Q={class:"icon",src:k,alt:""},Z={id:"payment-form"},V=N((()=>r("div",{id:"link-authentication-element"},null,-1))),Y=N((()=>r("div",{id:"payment-element"},null,-1))),ee=N((()=>r("div",{id:"error-message",class:"message_tips"},null,-1))),oe=D(e({__name:"checkout",props:["commonData"],setup(e){const g=x(),b=e,k=v("eventgahandler"),D=S(),N=I(),oe=h();let te=null,ne=null,ae=null;const se=o(""),ce=t({productType:null,loading:!1,disabled:!0,checkoutInfo:{},isTrailSub:null});n((()=>{ce.isTrailSub=oe.query.it,se.value=g.selectedInfo.couponId,ce.disabled=!0,re()}));const re=async()=>{var e,o,t;te=await a("pk_live_51IztUDAy5hC0S2nCvkrIKp13Xr0Za4jBMrO90B4Qdab77OkRlk958dv9Pjn7kOfCWXWPnlg8CguId4W51U5M0iLk00fh50ar6r"),T({priceId:g.selectedInfo.priceId,coupon:se.value,state:D.subscriptionInfo.state,pty:null==(e=g.selectedInfo.productInfo)?void 0:e.pty,ptl:null==(o=g.selectedInfo.productInfo)?void 0:o.hasTrial,pit:ce.isTrailSub,proName:"Perfect365 "+(null==(t=g.selectedInfo.productInfo)?void 0:t.title)}).then((e=>{var o,t,n,a,c,r,l,i,d;0==e.code&&(ce.checkoutInfo=e.data,ae=e.data.state,(null==(o=ce.checkoutInfo)?void 0:o.coupon)&&(null==(n=null==(t=ce.checkoutInfo)?void 0:t.coupon)?void 0:n.name)&&(se.value=null==(c=null==(a=ce.checkoutInfo)?void 0:a.coupon)?void 0:c.name,(null==(r=ce.checkoutInfo)?void 0:r.coupon.percent_off)&&(se.value=`${null==(i=null==(l=ce.checkoutInfo)?void 0:l.coupon)?void 0:i.name} (${null==(d=ce.checkoutInfo)?void 0:d.coupon.percent_off}% discount)`)),ue(e.data.clientSecret),s((()=>{ce.disabled=!1})))}))},le=async()=>{if(ce.loading)return;ce.loading=!0,await new Promise((async e=>{const{error:o}=await ne.submit();o&&("card_error"===o.type||"validation_error"===o.type?pe(o.message):pe("An unexpected error occurred."),e(!1)),e(!0)}))?(k({event:"subscribe",group:"subscription",label:"payfor"}),A({...ce.checkoutInfo}).then((async e=>{0==e.code?ie():(pe("An unexpected error occurred."),ce.loading=!1)})).catch((()=>{pe("An unexpected error occurred."),ce.loading=!1}))):ce.loading=!1},ie=async()=>{let e={elements:ne,redirect:"if_required"};const o=ce.checkoutInfo.subType?await te.confirmSetup(e):await te.confirmPayment(e);
1if(o.error)"card_error"===o.error.type||"validation_error"===o.error.type?pe(o.error.message):pe("An unexpected error occurred."),await w({state:ce.checkoutInfo.state,delmsg:`error1-${JSON.stringify(o.error)}`}),ce.loading=!1;else{let e=ce.checkoutInfo.subType?o.setupIntent:o.paymentIntent;de(e)}},de=async e=>{"succeeded"==e.status?P({payment_intent:e,state:ae}).then((async e=>{0==e.code?(N.push("/purchase/guide"),D.updateUserInfo()):(pe("An unexpected error occurred."),await w({state:ce.checkoutInfo.state,delmsg:`error2-${JSON.stringify(e)}`})),ce.loading=!1})).catch((()=>ce.loading=!1)):(pe("An unexpected error occurred."),ce.loading=!1,await w({state:ce.checkoutInfo.state,delmsg:`error3-${JSON.stringify(e)}`}))},ue=e=>{const o={clientSecret:e,appearance:{theme:"stripe",variables:{colorPrimary:"#0570de",colorBackground:"#ffffff",colorText:"#30313d",colorDanger:"#df1b41",borderRadius:"0PX"}}};ne=te.elements(o);ne.create("payment").mount("#payment-element")},pe=e=>{const o=document.querySelector("#error-message");o.classList.remove("hidden"),o.textContent=e,setTimeout((function(){o.classList.add("hidden"),o.textContent=""}),4e3)};return(e,o)=>{var t,n,a,s,v,I,h,g,k,x;return _(),c("div",U,[r("div",$,[q,r("p",B,l(b.commonData.productInfo.tips),1),r("div",F,[r("div",L,[r("span",J,l(null==(t=ce.checkoutInfo)?void 0:t.productName),1),r("span",M,l(i(j)(i(C)[null==(n=ce.checkoutInfo)?void 0:n.currency])+i(j)(null==(a=ce.checkoutInfo)?void 0:a.subtotal)),1)]),se.value&&(null==(s=ce.checkoutInfo)?void 0:s.totalDiscountAmounts)>0?(_(),c("div",W,[r("span",X,l(se.value),1),r("span",E," -"+l(i(j)(i(C)[null==(v=ce.checkoutInfo)?void 0:v.currency])+i(j)(null==(h=null==(I=ce.checkoutInfo)?void 0:I.totalDiscountAmounts)?void 0:h.toFixed(2))),1)])):d("",!0)]),r("div",G,[K,r("span",R,l(i(j)(i(C)[null==(g=ce.checkoutInfo)?void 0:g.currency])+i(j)(null==(x=null==(k=ce.checkoutInfo)?void 0:k.total)?void 0:x.toFixed(2))),1)])]),r("div",z,[u(r("div",H,[u(r("img",Q,null,512),[[p,!ce.disabled]])],512),[[p,ce.disabled]]),u(r("form",Z,[V,Y,f(O,{style:{"margin-top":"20px"},disabled:ce.disabled,loading:ce.loading,onTrial:le},{default:m((()=>[y("Subscribe")])),_:1},8,["disabled","loading"]),ee],512),[[p,!ce.disabled]])])])}}}),[["__scopeId","data-v-c687241a"]]);export{oe as default};
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.