text: !function(a,b){function c(b){return a("#"+b+" .as3cf-main-settings form").find("input:not(.no-compare)").serialize()}function d(a){var b=o.find("#"+a),c=b.find("input[type=checkbox]");b.toggleClass("on").find("span").toggleClass("checked");var d=b.find("span.on").hasClass("checked");c.prop("checked",d).trigger("change")}function e(b){var c=b.next(".as3cf-validation-error"),d=a("#"+o.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9\.\-]/;e.test(b.val())?(c.show(),d.prop("disabled",!0)):(c.hide(),d.prop("disabled",!1))}function f(b){var c=b.next(".as3cf-validation-error"),d=a("#"+o.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9]/;e.test(b.val())?(c.show(),d.prop("disabled",!0)):(c.hide(),d.prop("disabled",!1))}function g(b){var c=b.next(".as3cf-validation-error"),d=a("#"+o.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9\.\-\\:\/ _]/;e.test(b.val())?(c.show(),d.prop("disabled",!0)):(c.hide(),d.prop("disabled",!1))}function h(b){var c=b.next(".as3cf-validation-error"),d=a("#"+o.attr("id")+' form button[type="submit"]'),e=/[^a-zA-Z0-9\-\/ ]/;e.test(b.val())?(c.show(),d.prop("disabled",!0)):(c.hide(),d.prop("disabled",!1))}function i(){var c=a("#"+b.prefix+"-bucket").val(),d=o.find('input[name="object-prefix"]'),e=d.val();""!==e&&(e=as3cf.provider_console_url_prefix_param+encodeURIComponent(e));var f=as3cf.provider_console_url+c+e;a("#"+b.prefix+"-view-bucket").attr("href",f)}function j(){a("#as3cf-remove-local-file").is(":checked")&&a("#as3cf-serve-from-s3").is(":not(:checked)")?a("#as3cf-lost-files-notice").show():a("#as3cf-lost-files-notice").hide()}function k(){a("#as3cf-remove-local-file").is(":checked")?a("#as3cf-remove-local-notice").show():a("#as3cf-remove-local-notice").hide()}function l(b){!0!==b?a("#as3cf-seo-friendly-url-notice").show():a("#as3cf-seo-friendly-url-notice").hide()}function m(){a(".as3cf-url-preview").html("Generating...");var b={_nonce:as3cf.nonces.get_url_preview};a.each(a("#tab-"+as3cf.tabs.defaultTab+" .as3cf-main-settings form").serializeArray(),function(a,c){var d=c.name,e=c.value;d=d.replace("[]",""),b[d]=void 0===b[d]?e:Array.isArray(b[d])?b[d].concat(e):[b[d],e]}),b.action="as3cf-get-url-preview",a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:b,error:function(a,b,c){alert(as3cf.strings.get_url_preview_error+c)},success:function(b,c,d){"undefined"!=typeof b.success?(a(".as3cf-url-preview").html(b.url),l(b.seo_friendly)):alert(as3cf.strings.get_url_preview_error+b.error)}})}function n(){return"#"+as3cf.tabs.defaultTab===location.hash?void(location.hash=""):(as3cf.tabs.toggle(location.hash.replace("#",""),!0),void a(document).trigger("as3cf.tabRendered",[location.hash.replace("#","")]))}var o,p={},q=/[^a-z0-9.-]/,r=a("body"),s=a(".as3cf-tab");a(".as3cf-settings");as3cf.tabs={defaultTab:"media",toggle:function(c,d){c=as3cf.tabs.sanitizeHash(c),s.hide(),o=a("#tab-"+c),o.show(),a(".nav-tab").removeClass("nav-tab-active"),a('a.nav-tab[data-tab="'+c+'"]').addClass("nav-tab-active"),a(".as3cf-main").data("tab",c),o.data("prefix")&&(b.prefix=o.data("prefix")),d||a(".as3cf-updated").removeClass("show"),"support"===c&&as3cf.tabs.getDiagnosticInfo()},getDiagnosticInfo:function(){var b=a(".debug-log-textarea");b.html(as3cf.strings.get_diagnostic_info);var c={action:"as3cf-get-diagnostic-info",_nonce:as3cf.nonces.get_diagnostic_info};a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:c,error:function(a,c,d){b.html(d)},success:function(a,c,d){"undefined"!=typeof a.success?b.html(a.diagnostic_info):(b.html(as3cf.strings.get_diagnostic_info_error),b.append(a.error))}})},sanitizeHash:function(b){var c=a("#tab-"+b);return 0===c.length&&(b=as3cf.tabs.defaultTab),b}},as3cf.buckets={validLength:3,bucketSelectLock:!1,loadList:function(c){"undefined"==typeof c&&(c=!1);var d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select"),e=d.find(".bucket-select-region"),f=d.find(".as3cf-bucket-list"),g=a("#"+b.prefix+"-bucket").val();if(!1===c&&f.find("li").length>1)return a(".as3cf-bucket-list a").removeClass("selected"),a('.as3cf-bucket-list a[data-bucket="'+g+'"]').addClass("selected"),void this.scrollToSelected();f.html('<li class="loading">'+f.data("working")+"</li>"),this.disabledButtons();var h={action:b.prefix+"-get-buckets",_nonce:window[b.prefix.replace(/-/g,"_")].nonces.get_buckets};e.val()&&(h.region=e.val());var i=this;a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",data:h,error:function(a,b,c){f.html(""),i.showError(as3cf.strings.get_buckets_error,c,"as3cf-bucket-select")},success:function(b,c,d){f.html(""),"undefined"!=typeof b.success?(a(".as3cf-bucket-error").hide(),0===b.buckets.length?f.html('<li class="loading">'+f.data("nothing-found")+"</li>"):(a(b.buckets).each(function(a,b){var c=b.Name===g?"selected":"";f.append('<li><a class="'+c+'" href="#" data-bucket="'+b.Name+'"><span class="bucket"><span class="dashicons dashicons-portfolio"></span> '+b.Name+'</span><span class="spinner"></span></span></a></li>')}),i.scrollToSelected(),i.disabledButtons())):i.showError(as3cf.strings.get_buckets_error,b.error,"as3cf-bucket-select")}})},scrollToSelected:function(){if(a(".as3cf-bucket-list a.selected").length){var b=a("ul.as3cf-bucket-list li").first().position().top+150;a(".as3cf-bucket-list").animate({scrollTop:a("ul.as3cf-bucket-list li a.selected").position().top-b})}},setSelected:function(c){a(".as3cf-bucket-list a").removeClass("selected"),c.addClass("selected"),a("#"+b.prefix+"-bucket-select-name").val(c.data("bucket"))},disabledButtons:function(){var c=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-create"),d=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-manual"),e=a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select");0===c.length&&0===d.length&&0===e.length||(0<c.length&&this.isValidName(c.find(".as3cf-bucket-name").val())?c.find("button[type=submit]").prop("disabled",!1):c.find("button[type=submit]").prop("disabled",!0),0<d.length&&this.isValidName(d.find(".as3cf-bucket-name").val())?d.find("button[type=submit]").prop("disabled",!1):d.find("button[type=submit]").prop("disabled",!0),0<e.length&&1===e.find(".as3cf-bucket-list a.selected").length?e.find("button[type=submit]").prop("disabled",!1):e.find("button[type=submit]").prop("disabled",!0))},showError:function(b,c,d){var e=a(".as3cf-bucket-container").children(":visible"),f=e.find(".as3cf-bucket-error");d="undefined"==typeof d?null:d,d&&!e.hasClass(d)||(f.find("span.title").html(b+" &mdash;"),f.find("span.message").html(c),f.show(),this.bucketSelectLock=!1)},isValidName:function(a){return!(a.length<3||a.length>63)&&!0!==q.test(a)},updateNameNotice:function(b){var c=null;!0===q.test(b)?c=as3cf.strings.create_bucket_invalid_chars:b.length<3?c=as3cf.strings.create_bucket_name_short:b.length>63&&(c=as3cf.strings.create_bucket_name_long),c&&b.length>0?a(".as3cf-invalid-bucket-name").html(c):a(".as3cf-invalid-bucket-name").html("")}},as3cf.reloadUpdated=function(){var a=location.pathname+location.search;location.search.match(/[?&]updated=/)||(a+="&updated=1"),a+=location.hash,location.assign(a)},as3cf.showSettingsSavedNotice=function(){if(!(0<a("#setting-error-settings_updated:visible").length||0<a("#as3cf-settings_updated:visible").length)){var b='<div id="as3cf-settings_updated" class="updated settings-error notice is-dismissible"><p><strong>'+as3cf.strings.settings_saved+"</strong></p></div>";a("h2.nav-tab-wrapper").after(b),a(document).trigger("wp-updates-notice-added")}},as3cf.Settings=as3cf.Settings?as3cf.Settings:{},as3cf.Settings.Media={lock:function(b){a("#as3cf-media-settings-locked-"+b).show(),a(".as3cf-media-settings").addClass("locked locked-"+b),a(".as3cf-media-settings.locked-"+b).each(function(){a(this).find("input,button").prop("disabled",!0),a(this).find(".as3cf-settings-container").addClass("as3cf-locked-setting"),a(this).find("a.as3cf-change-settings").hide()})},unlock:function(b){a(".as3cf-media-settings.locked-"+b).each(function(){a(this).find("input,button").filter(":not(.disabled)").prop("disabled",!1),a(this).find(".as3cf-settings-container").removeClass("as3cf-locked-setting"),a(this).find("a.as3cf-change-settings").show(),a(this).removeClass("locked locked-"+b)}),a("#as3cf-media-settings-locked-"+b).hide()},locked:function(){return a(".as3cf-media-settings").hasClass("locked")}},a(document).ready(function(){n(),window.onhashchange=function(a){"function"==typeof history.replaceState&&"#"===location.href.slice(-1)&&history.replaceState({},"",location.href.slice(0,-1)),n()};var l=a(".as3cf-main .nav-tab-wrapper");a(".as3cf-compatibility-notice, div.updated, div.error, div.notice").not(".below-h2, .inline").insertAfter(l),s.length&&s.each(function(a,b){p[b.id]=c(b.id)}),a(window).on("beforeunload.as3cf-settings",function(){if(!a.isEmptyObject(p)&&!as3cf.Settings.Media.locked()){var b=o.attr("id");return c(b)!==p[b]?as3cf.strings.save_alert:void 0}}),a(document).on("submit",".as3cf-main-settings form",function(b){a(window).off("beforeunload.as3cf-settings")}),a(".as3cf-switch").on("click",function(b){a(this).hasClass("disabled")||a(this).parents().hasClass("locked")||d(a(this).attr("id"))}),s.on("change",".sub-toggle",function(b){var c=a(this).attr("id");a(".as3cf-setting."+c).toggleClass("hide")}),a(".url-preview").on("change","input",function(a){m()}),j(),a("#as3cf-serve-from-s3,#as3cf-remove-local-file").on("change",function(a){j()}),k(),a("#as3cf-remove-local-file").on("change",function(a){k()}),a('.as3cf-setting input[type="text"]').on("keypress",function(a){if(13===a.which)return a.preventDefault(),!1}),a(".as3cf-enable-delivery-domain-container").on("change",'input[type="checkbox"]',function(b){var c=a(this).is(":checked"),d=a(this).parents(".as3cf-enable-delivery-domain-container").find(".as3cf-setting.as3cf-delivery-domain");d.toggleClass("hide",!c);var e=a(this).parents(".as3cf-enable-delivery-domain-container").siblings(".as3cf-enable-signed-urls-container");e.toggleClass("hide",!c)}),a('input[name="enable-delivery-domain"]').on("change",function(b){var c=a(this),d=a("#"+o.attr("id")+' form button[type="submit"]');"1"!==c.val()?d.prop("disabled",!1):e(c.next(".as3cf-setting").find('input[name="delivery-domain"]'))}),a('input[name="delivery-domain"]').on("keyup",function(b){e(a(this))}),a(".as3cf-enable-signed-urls-container").on("change",'input[type="checkbox"]',function(b){var c=a(this).is(":checked"),d=a(this).parents(".as3cf-enable-signed-urls-container").find(".as3cf-setting.as3cf-signed-urls");d.toggleClass("hide",!c)}),a('input[name="signed-urls-key-id"]').on("keyup",function(b){f(a(this))}),a('input[name="enable-signed-urls-key-id"]').on("change",function(b){var c=a(this),d=a("#"+o.attr("id")+' form button[type="submit"]');"1"!==c.val()?d.prop("disabled",!1):f(c.next(".as3cf-setting").find('input[name="signed-urls-key-id"]'))}),a('input[name="signed-urls-key-file-path"]').on("keyup",function(b){g(a(this))}),a('input[name="enable-signed-urls-key-file-path"]').on("change",function(b){var c=a(this),d=a("#"+o.attr("id")+' form button[type="submit"]');"1"!==c.val()?d.prop("disabled",!1):g(c.next(".as3cf-setting").find('input[name="signed-urls-key-file-path"]'))}),a('input[name="signed-urls-object-prefix"]').on("keyup",function(b){h(a(this))}),a('input[name="enable-signed-urls-object-prefix"]').on("change",function(b){var c=a(this),d=a("#"+o.attr("id")+' form button[type="submit"]');"1"!==c.val()?d.prop("disabled",!1):h(c.next(".as3cf-setting").find('input[name="signed-urls-object-prefix"]'))}),a('input[name="object-prefix"]').on("change",function(a){i()}),a("#tab-media > .as3cf-bucket-error").detach().insertAfter(".as3cf-bucket-container h3"),as3cf.buckets.disabledButtons(),r.on("click",".bucket-action-refresh",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),r.on("change",".bucket-select-region",function(a){a.preventDefault(),as3cf.buckets.loadList(!0)}),0<a(".as3cf-bucket-container."+b.prefix+" .as3cf-bucket-select").length&&as3cf.buckets.loadList(!0),r.on("click",".as3cf-bucket-list a",function(b){b.preventDefault(),as3cf.buckets.setSelected(a(this)),as3cf.buckets.disabledButtons()}),a(".as3cf-bucket-container").on("click","a.js-link",function(b){return b.preventDefault(),window.open(a(this).attr("href")),!1}),r.on("input keyup",".as3cf-bucket-create .as3cf-bucket-name",function(b){var c=a(this).val();as3cf.buckets.updateNameNotice(c),as3cf.buckets.disabledButtons()}),r.on("input keyup",".as3cf-bucket-manual .as3cf-bucket-name",function(b){var c=a(this).val();as3cf.buckets.updateNameNotice(c),as3cf.buckets.disabledButtons()}),a('.as3cf-bucket-container input[type="text"]').on("keypress",function(a){if(13===a.which)return a.preventDefault(),!1}),a(".as3cf-change-bucket-access-prompt").on("change","#origin-access-identity-confirmation",function(b){a("#block-public-access-confirmed").prop("disabled",!a(this).prop("checked"))}),a(".as3cf-media-settings.locked.locked-upgrade").each(function(){as3cf.Settings.Media.lock("upgrade")})})}(jQuery,as3cfModal);