"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[2439,2655],{2439:(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var n=r(51609),a=r(22926),s=r(82655),o=r(27723);const{PrimaryOutlinedButton:i,Text:l,Space:c,Spin:d}=window?.booktics?.components||{},u=()=>{const{handleSubmit:e,errorMessage:t,disabled:r,loading:u}=(0,s.default)();return(0,n.createElement)("form",{onSubmit:e},(0,n.createElement)(d,{spinning:r},(0,n.createElement)(c,{size:10,direction:"vertical",className:"bkt-w-100"},(0,n.createElement)(a.PaymentElement,null),(0,n.createElement)(i,{htmlType:"submit",text:(0,o.__)("Pay","booktics"),disabled:r,loading:u,size:"middle"}),(0,n.createElement)(l,{type:"danger",text:t}))))}},82655:(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var n=r(47143),a=r(86087),s=r(22926),o=r(11534),i=r(60532);const l=()=>{const{bookingResponse:e,frontendStepsOrder:t}=(0,n.useSelect)(e=>e(i.H).getFrontendState(),[]),r=(0,s.useStripe)(),l=(0,s.useElements)(),[c,d]=(0,a.useState)(null),[u,m]=(0,a.useState)(!1),{setFrontendState:b}=(0,n.useDispatch)(i.H),p=e?.id;return{handleSubmit:async n=>{try{if(n.preventDefault(),m(!0),null==l)return;const{error:a}=await l.submit();if(a)return void d(a.message);const s=await r.confirmPayment({elements:l,clientSecret:e?.client_secret,confirmParams:{return_url:window.location.href},redirect:"if_required"}),{error:i}=s||{};if(i)d(i?.message);else{const r=e?.order_key;if(p&&r){try{sessionStorage.setItem(`booktics_order_key_${p}`,r)}catch(e){}try{await o.A.orders.makePayment(p,{order_id:parseInt(p,10),payment_method:"stripe"},{order_key:r})}catch(e){console.error("Payment status update failed:",e)}}b({currentStep:t.length-1,invoiceId:p})}}catch(e){console.log(e)}finally{m(!1)}},errorMessage:c,disabled:!r||!l,loading:u}}}}]);