class MPCustomCheckoutHandler{static FORM_SELECTORS={CLASSIC:"form[name=checkout]",BLOCKS:".wc-block-components-form.wc-block-checkout__form",ORDER_REVIEW:"form#order_review"};static FORM_IDS={CLASSIC_CHECKOUT:"checkout",BLOCKS_CHECKOUT:"blocks_checkout_form",PAY_FOR_ORDER:"order_review"};constructor(e,t,o){this.cardForm=e,this.threeDSHandler=t,this.eventHandler=o,this.init()}async init(){await this.setupFormConfiguration(),this.eventHandler.triggeredPaymentMethodSelectedEvent||jQuery("body").trigger("payment_method_selected"),this.eventHandler.bindEvents()}async setupFormConfiguration(){try{const e=await this.getFormConfig();e.element&&(e.element.id=e.formId),this.syncFormIds(e.formId)}catch(e){console.error("Failed to configure checkout form:",e)}}getFormConfig(){return new Promise(((e,t)=>{let o=0;const r=()=>{o++;const n=document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.CLASSIC),c=document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.BLOCKS),m=document.querySelector(MPCustomCheckoutHandler.FORM_SELECTORS.ORDER_REVIEW);n?e({element:n,formId:MPCustomCheckoutHandler.FORM_IDS.CLASSIC_CHECKOUT}):c?e({element:c,formId:MPCustomCheckoutHandler.FORM_IDS.BLOCKS_CHECKOUT}):m?e({element:m,formId:MPCustomCheckoutHandler.FORM_IDS.PAY_FOR_ORDER}):o>=10?t(new Error("No checkout form found after 10 attempts")):setTimeout(r,500)};r()}))}syncFormIds(e){this.eventHandler.mpFormId=e,this.cardForm.mpFormId=e}}document.addEventListener("DOMContentLoaded",(function(){const e=new MPCardForm,t=new MPThreeDSHandler,o=new MPEventHandler(e,t),r=new MPCustomCheckoutHandler(e,t,o);window.mpCustomCheckoutHandler=r,window.mpEventHandler=o}));