tribe.tickets.commerce.gateway.free=tribe.tickets.commerce.gateway.free||{},tribe.tickets.commerce.gateway.free.checkout={},((e,t,c)=>{"use strict";t.checkout=tecTicketsCommerceGatewayFreeCheckout,t.selectors={submitButton:"#tec-tc-gateway-free-checkout-button",hiddenElement:".tribe-common-a11y-hidden"},t.checkoutContainer=null,t.onBeforeRetry=async e=>(console.log(e),c.stop),t.onBeforeError=async e=>(console.log(e),c.stop),t.getRequestArgs=(e,c)=>{void 0===c&&(c={"X-WP-Nonce":t.checkout.nonce});const o={headers:c,hooks:{beforeRetry:[t.onBeforeRetry],beforeError:[t.onBeforeError]},timeout:3e4,throwHttpErrors:!1};return e&&(o.json=e),o},t.hideNotice=t=>{t.length||(t=e(tribe.tickets.commerce.selectors.checkoutContainer));const c=tribe.tickets.commerce.notice,o=t.find(c.selectors.item);c.hide(o)},t.showNotice=(t,c,o)=>{t&&t.length||(t=e(tribe.tickets.commerce.selectors.checkoutContainer));const r=tribe.tickets.commerce.notice,i=t.find(r.selectors.item);r.populate(i,c,o),r.show(i)},t.submitButton=c=>{e(t.selectors.submitButton).prop("disabled",!c)},t.handlePayment=async c=>{c.preventDefault(),t.checkoutContainer=e(c.target).closest(tribe.tickets.commerce.selectors.checkoutContainer),t.hideNotice(t.checkoutContainer),tribe.tickets.loader.show(t.checkoutContainer);const o=await t.handleCreateOrder();t.submitButton(!1),o.success?window.location.replace(o.redirect_url):(tribe.tickets.loader.hide(t.checkoutContainer),t.showNotice({},o.message,"")),t.submitButton(!0)},t.handleCreateOrder=async()=>{const e=t.getRequestArgs({purchaser:t.getPurchaserData()});let c;try{c=await tribe.ky.post(t.checkout.orderEndpoint,e).json()}catch(e){c=e}return tribe.tickets.debug.log("free","createOrder",c),c},t.getPurchaserData=()=>tribe.tickets.commerce.getPurchaserData(e(tribe.tickets.commerce.selectors.purchaserFormContainer)),t.bindEvents=()=>{e(t.selectors.submitButton).on("click",t.handlePayment)},t.ready=()=>{t.bindEvents()},e(t.ready)})(jQuery,tribe.tickets.commerce.gateway.free,tribe.ky),window.tec=window.tec||{},window.tec.tickets=window.tec.tickets||{},window.tec.tickets.commerce=window.tec.tickets.commerce||{},window.tec.tickets.commerce.gateway=window.tec.tickets.commerce.gateway||{},window.tec.tickets.commerce.gateway.free=window.tec.tickets.commerce.gateway.free||{},window.tec.tickets.commerce.gateway.free.checkout={};