// formSubmitValidation will be deprecated. use "validateControls" instead.
// TODO: Improve the way we mark components with error. We must not use error classes.
const o = {
  "ch-checkbox": "checkbox-error",
  "ch-combo-box-render": "combo-box-error",
  "ch-edit": "input-error"
};

const toggleErrorClass = (c, e) => {
  const s = e.tagName.toLowerCase();
  const n = o[s];
  if (c) {
    e.classList.add(n);
  } else {
    e.classList.remove(n);
  }
};

const validateControls = (o, c) => {
  const e = new Map(c);
  o.fieldErrors.forEach((o => {
    const c = o.key;
    const s = o.hasError;
    const n = e.get(c);
    if (n === null || n === void 0 ? void 0 : n.reference) {
      // toggle class to add or remove error style
      toggleErrorClass(s, n.reference);
      e.set(c, Object.assign(Object.assign({}, n), {
        hasError: s,
        message: o.message
      }));
    }
  }));
  // return validatableControls updated.
    return e;
};

const clearControlError = (o, c) => {
  const e = o.get(c);
  if (e === null || e === void 0 ? void 0 : e.reference) {
    toggleErrorClass(false, e.reference);
    e.hasError = false;
    e.message = "";
    o.set(c, e);
  }
};

export { clearControlError as c, validateControls as v };
//# sourceMappingURL=p-b32b6b1f.js.map