import"./datatables-Bo82YvhT.js";import"./bootstrap.esm-Bb7dPm-H.js";document.addEventListener("DOMContentLoaded",function(){const o=window.translations||{},i=document.getElementById("editCustomFieldForm"),l=document.getElementById("type"),a=document.getElementById("valuesContainer"),s=document.getElementById("valuesList"),r=document.getElementById("addValue");l&&l.value==="select"&&(a.style.display="block",s&&s.querySelectorAll(".input-group").length===0&&u()),l&&l.addEventListener("change",function(){this.value==="select"?(a.style.display="block",s.querySelectorAll(".input-group").length===0&&u()):a.style.display="none"}),r&&r.addEventListener("click",u),document.addEventListener("click",function(e){if(e.target.classList.contains("remove-value")||e.target.closest(".remove-value")){const t=(e.target.classList.contains("remove-value")?e.target:e.target.closest(".remove-value")).closest(".input-group");t&&t.remove()}}),i&&i.addEventListener("submit",function(e){var n,t;if(l.value==="select"&&s.querySelectorAll('input[name="values[]"]').length===0)return e.preventDefault(),window.showAlert?showAlert("error",((n=o.messages)==null?void 0:n.required_values)||"You must add at least one value for select fields."):window.showError(((t=o.messages)==null?void 0:t.required_values)||"You must add at least one value for select fields."),!1});function u(){var t;const e=((t=o.fields)==null?void 0:t.value)||"Value",n=document.createElement("div");n.className="input-group mb-2",n.innerHTML=`
            <input type="text" class="form-control" name="values[]" placeholder="${e}">
            <button type="button" class="btn btn-danger remove-value">
                <i class="fas fa-trash"></i>
            </button>
        `,s.appendChild(n)}});
