(()=>{var t,e;tribe.events=tribe.events||{},tribe.events.zoomSettingsAdmin=tribe.events.zoomSettingsAdmin||{},t=jQuery,(e=tribe.events.zoomSettingsAdmin).selectors={authorizedClass:"tribe-zoom-authorized",clientIdInput:"#zoom-application__client-id",clientSecretInput:"#zoom-application__client-secret",refreshAccount:".tribe-settings-zoom-account-details__account-refresh",accountStatus:".tribe-events-virtual-meetings-zoom-settings-switch__input.account-status",deleteAccount:".tribe-settings-zoom-account-details__delete-account",accountDetailsContainer:".tribe-settings-zoom-account-details",accountMessageContainer:".tec-zoom-accounts-messages",virtualContainer:"#tribe-settings-zoom-application",zoomToken:"#tribe-field-zoom_token"},e.handleConnectButton=function(){const n={action:"events_virtual_meetings_zoom_autosave_client_keys",clientId:t(e.selectors.clientIdInput).val(),clientSecret:t(e.selectors.clientSecretInput).val(),security:t(e.selectors.virtualContainer).attr("data-nonce")};t.ajax({type:"post",url:ajaxurl,dataType:"text/html",data:n}).always(e.swapConnectButton)},e.swapConnectButton=function(n){if(void 0===n.responseText)return;const o=n.responseText;t(e.selectors.zoomToken).find(".tribe-field-wrap").html(o)},e.bindEvents=function(){t(e.selectors.virtualContainer).hasClass(e.selectors.authorizedClass)||t(e.selectors.virtualContainer).on("click",e.selectors.refreshAccount,e.handleRefreshAccount).on("click",e.selectors.accountStatus,e.handleAccountStatus).on("click",e.selectors.deleteAccount,e.handleDeleteAccount).on("blur",e.selectors.clientIdInput,e.handleConnectButton).on("blur",e.selectors.clientSecretInput,e.handleConnectButton)},e.handleRefreshAccount=function(e){if(e.preventDefault(),!confirm(tribe_events_virtual_settings_strings.refreshConfirm))return;const n=t(this).data("zoomRefresh");window.location=n},e.handleAccountStatus=function(){const n=t(this),o=n.data("ajaxStatusUrl");n.prop("disabled",!0),t.ajax(o,{contentType:"application/json",context:n,success:e.onAccountStatusSuccess})},e.onAccountStatusSuccess=function(n){t(e.selectors.accountMessageContainer).html(n),t(this).prop("disabled",!1);const o=t(this).closest(e.selectors.accountDetailsContainer);o.find(e.selectors.refreshAccount).prop("disabled",(function(t,e){return!e})),o.find(e.selectors.deleteAccount).prop("disabled",(function(t,e){return!e}))},e.handleDeleteAccount=function(n){if(n.preventDefault(),!confirm(tribe_events_virtual_settings_strings.deleteConfirm))return;const o=t(this).data("ajaxDeleteUrl");t.ajax(o,{contentType:"application/json",context:t(this).closest(e.selectors.accountDetailsContainer),success:e.onAccountDeleteSuccess})},e.onAccountDeleteSuccess=function(n){t(e.selectors.accountMessageContainer).html(n),t(".error",t(e.selectors.accountMessageContainer)).length>0||t(this).remove()},e.ready=function(){console.info("Scripts deprecated and replaced with tribe.events.apiSettingsAdmin."),e.bindEvents()},t(e.ready),window.tec=window.tec||{},window.tec.eventsPro=window.tec.eventsPro||{},window.tec.eventsPro.eventsVirtualZoomSettings={}})();