document.addEventListener("DOMContentLoaded",function(){const i=document.getElementById("editPaymentGatewayForm"),{paymentGateway:s,translations:r}=window;i&&i.addEventListener("submit",function(e){e.preventDefault(),c()});function c(){const e=new FormData;e.append("name",document.getElementById("edit_name").value),e.append("description",document.getElementById("edit_description").value),e.append("fee_percentage",document.getElementById("edit_fee_percentage").value),e.append("fee_fixed",document.getElementById("edit_fee_fixed").value),e.append("logo",document.getElementById("edit_logo").value),e.append("sort_order",document.getElementById("edit_sort_order").value),e.append("is_active",document.getElementById("edit_is_active").checked?"1":"0"),e.append("test_mode",document.getElementById("edit_test_mode").checked?"1":"0"),e.append("_method","PUT");const t=i.querySelector('button[type="submit"]')||document.querySelector(`button[type="submit"][form="${i.id}"]`),o=t.innerHTML;t.disabled=!0,t.innerHTML='<i class="fas fa-spinner fa-spin"></i> Kaydediliyor...',m(),fetch(s.updateUrl,{method:"POST",body:e,headers:{Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")}}).then(n=>n.json()).then(n=>{var d,a;n.success?(console.log(((d=r.messages)==null?void 0:d.updated)||"Ödeme geçidi başarıyla güncellendi."),setTimeout(()=>{window.location.href="/admin/payment-gateways"},1e3)):n.errors?l(n.errors):console.error(n.message||((a=r.messages)==null?void 0:a.error)||"An error occurred.")}).catch(n=>{var d;console.error(((d=r.messages)==null?void 0:d.error)||"An error occurred.")}).finally(()=>{t.disabled=!1,t.innerHTML=o})}function l(e){Object.keys(e).forEach(t=>{const o=document.getElementById(`edit_${t}`);if(o){o.classList.add("is-invalid");const n=o.nextElementSibling;n&&n.classList.contains("invalid-feedback")&&(n.textContent=e[t][0])}})}function m(){i.querySelectorAll(".form-control, .form-check-input").forEach(t=>{t.classList.remove("is-invalid");const o=t.nextElementSibling;o&&o.classList.contains("invalid-feedback")&&(o.textContent="")})}});
