/*!
 * KoliBri - The accessible HTML-Standard
 */
import{o as objectObjectHandler,p as parseJson,w as watchValidator}from"./prop.validators-9feb1d92.js";import{b as isObject}from"./common-54bf85ba.js";import{_ as __rest}from"./tslib.es6-1173d062.js";import{c as clsx}from"./clsx-09a06a12.js";import{h}from"./index-2ae1c631.js";import{K as KolAlertFc}from"./Alert-15d42d1c.js";function transformObjectProperties(r){return Object.entries(r).reduce(((r,[s,e])=>{const t=s.startsWith("_")?s.slice(1):s;return Object.assign(Object.assign({},r),{[t]:e})}),{})}const validateMsg=(r,s)=>{objectObjectHandler(s,(()=>{try{s=parseJson(s)}catch(r){}watchValidator(r,"_msg",(r=>isObject(r)&&"string"==typeof(null==r?void 0:r._description)),new Set(["MsgPropType"]),s,{defaultValue:{_description:"",_type:"error"}})}))};function isMsgEmpty(r){return!r||"error"===r._type&&!r._description}function convertMsgToInternMsg(r){if(r&&!isMsgEmpty(r))return transformObjectProperties(r)}function checkHasError(r,s){return Boolean((null==r?void 0:r.description)&&(null==r?void 0:r.description.length)>0)&&(!0===s||"error"!==(null==r?void 0:r.type))}const FormFieldMsgFc=r=>{var{alert:s,msg:e,hideMsg:t,id:o,class:i}=r,a=__rest(r,["alert","msg","hideMsg","id","class"]);return h(KolAlertFc,Object.assign({id:`${o}-msg`,alert:s,type:"error",class:clsx("kol-form-field__msg",{"visually-hidden":!0===t},i)},e,a,{"aria-hidden":"true"}),(null==e?void 0:e.description)||void 0)},KolFormFieldMsgFc=FormFieldMsgFc;export{KolFormFieldMsgFc as K,convertMsgToInternMsg as a,checkHasError as c,validateMsg as v};