(()=>{var e,t,s;tribe.tickets=tribe.tickets||{},tribe.tickets.commerce=tribe.tickets.commerce||{},tribe.tickets.commerce.gateway=tribe.tickets.commerce.gateway||{},tribe.tickets.commerce.gateway.stripe=tribe.tickets.commerce.gateway.stripe||{},tribe.tickets.commerce.gateway.stripe.webhooks={},e=jQuery,t=tribe.tickets.commerce.gateway.stripe.webhooks,s=window.ajaxurl,t.selectors={button:".tribe-field-tickets-commerce-stripe-webhooks-copy",signingKey:'[name="tickets-commerce-stripe-webhooks-signing-key"]',statusLabel:".tribe-field-tickets-commerce-stripe-webhooks-signing-key-status",tooltip:".tooltip",genericDashicon:".dashicons",saveButton:"input#tribeSaveSettings"},t.clipboardButton=null,t.setupCopyUrl=()=>{t.clipboardButton=new ClipboardJS(t.selectors.button),e(t.selectors.button).on("click",(e=>e.preventDefault()))},t.setupSigningValidation=()=>{e(t.selectors.signingKey).on("change",t.onSigningFieldChange)},t.initiateValidation=async(e,t,i)=>{const a=new URLSearchParams;a.set("signing_key",e.val()),a.set("action",e.data("ajaxAction")),a.set("tc_nonce",e.data("ajaxNonce"));const o={timeout:3e4,body:a,hooks:{beforeRequest:[()=>{i.text(e.data("loadingText")),t.removeClass(["dashicons-no","dashicons-yes"]).addClass("dashicons-update")}]}};return await tribe.ky.post(s,o).json()},t.checkValidationSuccess=async(e,t,i)=>{const a=new URLSearchParams;a.set("signing_key",e.val()),a.set("action",e.data("ajaxActionVerify")),a.set("tc_nonce",e.data("ajaxNonce"));const o={timeout:3e4,body:a,hooks:{beforeRequest:[()=>{i.text(e.data("loadingText")),t.removeClass(["dashicons-no","dashicons-yes"]).addClass("dashicons-update")}]}};return await tribe.ky.post(s,o).json()},t.onSigningFieldChange=async s=>{const i=e(s.target),a=i.siblings(t.selectors.tooltip),o=a.find(t.selectors.genericDashicon),n=a.find(t.selectors.statusLabel),c=e(t.selectors.saveButton);if(""===i.val().trim())return;i.prop("disabled",!0),c.prop("disabled",!0);let d=await t.initiateValidation(i,o,n);return d.data.is_valid_webhook?o.removeClass(["dashicons-update"]).addClass("dashicons-yes"):(d=await t.checkValidationSuccess(i,o,n),d.data.is_valid_webhook?o.removeClass(["dashicons-update"]).addClass("dashicons-yes"):o.removeClass(["dashicons-update"]).addClass("dashicons-no")),n.text(d.data.status),i.prop("disabled",!1),c.prop("disabled",!1),d},t.ready=()=>{t.setupCopyUrl(),t.setupSigningValidation()},e(document).ready(t.ready),window.tec=window.tec||{},window.tec.tickets=window.tec.tickets||{},window.tec.tickets.admin=window.tec.tickets.admin||{},window.tec.tickets.admin.gateway=window.tec.tickets.admin.gateway||{},window.tec.tickets.admin.gateway.stripe=window.tec.tickets.admin.gateway.stripe||{},window.tec.tickets.admin.gateway.stripe.webhooks={}})();