System.register(["./state-legacy.BfeTROjz.js","./ui-helpers-legacy.DZ1NznsM.js"],(function(e,t){"use strict";var a,n,i,d,l;return{setters:[e=>{a=e.g,n=e.b},e=>{i=e.b,d=e.a,l=e.u}],execute:function(){e({c:function(){n.modal&&n.modal.length>0&&(n.modal.hide(),n.modal&&0!==n.modal.length&&(n.loading&&n.loading.hide(),n.results&&n.results.hide(),n.error&&n.error.hide(),n.generateButton&&n.generateButton.show(),n.saveButton&&n.saveButton.hide(),n.modal&&0!==n.modal.length&&n.modal.find(".saai-alt-text, .saai-caption, .saai-title, .saai-description").text(""),n.modal.find('input[name="generate_alt"]').prop("checked",n.defaultFields.includes("alt")),n.modal.find('input[name="generate_caption"]').prop("checked",n.defaultFields.includes("caption")),n.modal.find('input[name="generate_title"]').prop("checked",n.defaultFields.includes("title")),n.modal.find('input[name="generate_description"]').prop("checked",n.defaultFields.includes("description")),d()))},o:function(){const e=jQuery;a()&&function(){const e=jQuery;return new Promise(((t,i)=>{e.ajax({url:`${n.restUrl}form?attachment_id=${a()}`,method:"GET",headers:{"X-WP-Nonce":n.nonce}}).done((e=>{!function(e){if(!n.modal||0===n.modal.length)return;const t=n.modal.find(".saai-image-preview img");t.length&&e.image_url&&(t.attr("src",e.image_url),t.attr("alt",e.current_alt||"")),n.modal.find(".saai-current-field-alt .saai-current-value").text(e.current_alt||"None"),n.modal.find(".saai-current-field-caption .saai-current-value").text(e.caption||"None"),n.modal.find(".saai-current-field-title .saai-current-value").text(e.title||"None"),n.modal.find(".saai-current-field-description .saai-current-value").text(e.description||"None"),n.modal.find('input[name="generate_alt"]').prop("checked",n.defaultFields.includes("alt")),n.modal.find('input[name="generate_caption"]').prop("checked",n.defaultFields.includes("caption")),n.modal.find('input[name="generate_title"]').prop("checked",n.defaultFields.includes("title")),n.modal.find('input[name="generate_description"]').prop("checked",n.defaultFields.includes("description")),d(),l()}(e),t()})).fail((e=>{i(new Error(`HTTP error! status: ${e.status}`))}))}))}().then((()=>{n.modal=e("#saai-image-alt-tags-modal"),n.modal&&n.modal.length>0&&(n.modal.show(),d(),l())})).catch((e=>{console.error("Failed to load form data:",e),i("Failed to load image data. Please try again.")}))}})}}}));
