(()=>{"use strict";var e={n:a=>{var t=a&&a.__esModule?()=>a.default:()=>a;return e.d(t,{a:t}),t},d:(a,t)=>{for(var s in t)e.o(t,s)&&!e.o(a,s)&&Object.defineProperty(a,s,{enumerable:!0,get:t[s]})},o:(e,a)=>Object.prototype.hasOwnProperty.call(e,a)};const a=window.jQuery;var t=e.n(a);const s=function(e,a){const s=a.sugar_calendar_bookings_admin?.antispam||{},i={$cards:t()(".scb-antispam-method-card"),$cardPanels:t()(".scb-antispam-card-content"),$description:t()(".scb-antispam-method-description"),$shared:t()("#scb-antispam-shared"),$previewBox:t()("#sugar-calendar-bookings-setting-row-antispam-preview"),$previewTarget:t()("#scb-antispam-preview"),$previewDesc:t()("#scb-antispam-preview-description"),$methodInput:t()('input[name="sugar-calendar-bookings[antispam][method]"]'),$recaptchaRadio:t()('input[name="sugar-calendar-bookings[antispam][recaptcha][method]"]'),$themeRowReca:t()("#sugar-calendar-bookings-setting-row-antispam-recaptcha-theme"),$thresholdRow:t()("#sugar-calendar-bookings-setting-row-antispam_recaptcha_threshold"),$v2KeyRows:t()("#sugar-calendar-bookings-setting-row-antispam_recaptcha_v2_site_key, #sugar-calendar-bookings-setting-row-antispam_recaptcha_v2_secret_key"),$v3KeyRows:t()("#sugar-calendar-bookings-setting-row-antispam_recaptcha_v3_site_key, #sugar-calendar-bookings-setting-row-antispam_recaptcha_v3_secret_key")};let n=!1;const r={init(){t()(r.ready)},ready(){i.$cards.on("click",r.onCardClick),i.$recaptchaRadio.on("change",r.onRecaptchaMethodChange),t()("form.sugar-calendar-bookings-admin-content__settings-form input").on("change",r.onFormInputChange)},onFormInputChange(){n||(n=!0,r.updatePreview())},updatePreview(){i.$previewTarget.addClass("scb-antispam-hide"),i.$previewDesc.text(s.preview_save_instruction||"")},onCardClick(){r.updatePreview();const e=t()(this).data("method");i.$cards.removeClass("selected"),t()(this).addClass("selected"),i.$methodInput.val(r.resolveFlatMethod(e)),i.$cardPanels.addClass("scb-antispam-hide"),t()("#scb-antispam-panel-"+e).removeClass("scb-antispam-hide"),s.method_descriptions&&s.method_descriptions[e]&&i.$description.html(s.method_descriptions[e]),"none"===e?i.$shared.addClass("scb-antispam-hide"):i.$shared.removeClass("scb-antispam-hide"),"turnstile"!==e&&"recaptcha"!==e||i.$previewBox.removeClass("scb-antispam-hide")},onRecaptchaMethodChange(){const e=t()(this).val(),a="recaptcha_v3"===e;"recaptcha"===i.$cards.filter(".selected").data("method")&&i.$methodInput.val(e),i.$themeRowReca.toggleClass("scb-antispam-hide",a),i.$thresholdRow.toggleClass("scb-antispam-hide",!a),i.$v2KeyRows.toggleClass("scb-antispam-hide",a),i.$v3KeyRows.toggleClass("scb-antispam-hide",!a)},resolveFlatMethod:e=>"recaptcha"===e?i.$recaptchaRadio.filter(":checked").val()||"checkbox_recaptcha_v2":e,initSpamProtection(){void 0!==a.grecaptcha&&r.initGrecaptchaPreview(),void 0!==a.turnstile&&r.initTurnstilePreview()},initGrecaptchaPreview(){const e=s.recaptcha||{};if(!e.site_key)return;const t={sitekey:e.site_key,theme:e.theme||"auto"};"checkbox_recaptcha_v2"===e.method?t.size="normal":(t.size="invisible",t.badge="inline"),a.grecaptcha.render(i.$previewTarget[0],t)},initTurnstilePreview(){const e=s.turnstile||{};a.turnstile.render(i.$previewTarget[0],{sitekey:e.site_key,theme:e.theme||"auto",size:"normal",appearance:"always",execution:"render"})}};return r}(document,window);s.init(),window.scbAntispamOnCaptchaLoad=function(){s.initSpamProtection()}})();