import"./datatables-Bo82YvhT.js";import"./bootstrap.esm-Bb7dPm-H.js";document.addEventListener("DOMContentLoaded",function(){const a=window.translations||{},i=document.getElementById("createCustomFieldForm"),o=document.getElementById("type"),l=document.getElementById("valuesContainer"),s=document.getElementById("valuesList"),r=document.getElementById("addValue");o&&o.value==="select"&&(l.style.display="block",s&&s.querySelectorAll(".input-group").length===0&&u()),o&&o.addEventListener("change",function(){this.value==="select"?(l.style.display="block",s.querySelectorAll(".input-group").length===0&&u()):l.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(o.value==="select"&&s.querySelectorAll('input[name="values[]"]').length===0)return e.preventDefault(),window.toastr?window.toastr.error(((n=a.messages)==null?void 0:n.required_values)||"You must add at least one value for select fields."):window.bootstrap&&window.bootstrap.Toast?new bootstrap.Toast(document.getElementById("errorToast")).show():window.showWarning(((t=a.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=a.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)}});
