System.register(["./aiMemoryToggle.scss-legacy.Bff-dczE.js"],(function(e,t){"use strict";return{setters:[null],execute:function(){e("r",(function(){const e=jQuery;e(document).on("change",".saai-ai-memory-toggle",(function(){const t=e(this),s=t.closest(".saai-ai-memory-control"),a=t.data("post-id"),i=t.is(":checked")?"yes":"no";t.prop("disabled",!0),e.ajax({url:saaiObj.ajaxUrl,type:"POST",headers:{"X-WP-Nonce":saaiObj.nonce},data:{post_id:a,enabled:i},success:function(a){if(a.success){const t=s.find(".saai-status-indicator");if(a.status_icon)if(t.length>0)t.html(a.status_icon),t.attr("data-saai-tooltip",a.hover_text);else{const t=e('<span class="saai-status-indicator" data-saai-tooltip="'+a.hover_text+'">'+a.status_icon+"</span>");s.append(t)}else t.remove()}else{var o;const s=e('<div class="notice notice-error is-dismissible saai-ajax-notice" style="margin: 5px 0;"><p>'+((null===(o=a.data)||void 0===o?void 0:o.message)||(null==a?void 0:a.message)||"Unknown error occurred")+"</p></div>");e(".wrap h1").after(s),setTimeout((function(){s.fadeOut((function(){e(this).remove()}))}),5e3),t.prop("checked",!i)}},error:function(){const s=e('<div class="notice notice-error is-dismissible saai-ajax-notice" style="margin: 5px 0;"><p>Network error occurred. Please try again.</p></div>');e(".wrap h1").after(s),setTimeout((function(){s.fadeOut((function(){this.remove()}))}),5e3),t.prop("checked",!i)},complete:function(){t.prop("disabled",!1)}})}))}))}}}));
