"use strict";(globalThis.webpackChunkbooktics=globalThis.webpackChunkbooktics||[]).push([[2655],{82655:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var s=r(47143),n=r(86087),o=r(22926),a=r(11534),i=r(60532);const c=()=>{const{bookingResponse:e,frontendStepsOrder:t}=(0,s.useSelect)(e=>e(i.H).getFrontendState(),[]),r=(0,o.useStripe)(),c=(0,o.useElements)(),[l,d]=(0,n.useState)(null),[u,m]=(0,n.useState)(!1),{setFrontendState:f}=(0,s.useDispatch)(i.H),h=e?.id;return{handleSubmit:async s=>{try{if(s.preventDefault(),m(!0),null==c)return;const{error:n}=await c.submit();if(n)return void d(n.message);const o=await r.confirmPayment({elements:c,clientSecret:e?.client_secret,confirmParams:{return_url:window.location.href},redirect:"if_required"}),{error:i}=o||{};if(i)d(i?.message);else{const r=e?.order_key;if(h&&r){try{sessionStorage.setItem(`booktics_order_key_${h}`,r)}catch(e){}try{await a.A.orders.makePayment(h,{order_id:parseInt(h,10),payment_method:"stripe"},{order_key:r})}catch(e){console.error("Payment status update failed:",e)}}f({currentStep:t.length-1,invoiceId:h})}}catch(e){console.log(e)}finally{m(!1)}},errorMessage:l,disabled:!r||!c,loading:u}}}}]);