/*!
 * KoliBri - The accessible HTML-Standard
 */
"use strict";const prop_validators=require("./prop.validators-96dfedce.js"),common=require("./common-1ab929ac.js"),tslib_es6=require("./tslib.es6-5e301284.js"),clsx=require("./clsx-dd4d6dd1.js"),index=require("./index-87a7393a.js"),Alert=require("./Alert-ea442259.js");function transformObjectProperties(e){return Object.entries(e).reduce(((e,[r,s])=>{const t=r.startsWith("_")?r.slice(1):r;return Object.assign(Object.assign({},e),{[t]:s})}),{})}const validateMsg=(e,r)=>{prop_validators.objectObjectHandler(r,(()=>{try{r=prop_validators.parseJson(r)}catch(e){}prop_validators.watchValidator(e,"_msg",(e=>common.isObject(e)&&"string"==typeof(null==e?void 0:e._description)),new Set(["MsgPropType"]),r,{defaultValue:{_description:"",_type:"error"}})}))};function isMsgEmpty(e){return!e||"error"===e._type&&!e._description}function convertMsgToInternMsg(e){if(e&&!isMsgEmpty(e))return transformObjectProperties(e)}function checkHasError(e,r){return Boolean((null==e?void 0:e.description)&&(null==e?void 0:e.description.length)>0)&&(!0===r||"error"!==(null==e?void 0:e.type))}const FormFieldMsgFc=e=>{var{alert:r,msg:s,hideMsg:t,id:o,class:i}=e,n=tslib_es6.__rest(e,["alert","msg","hideMsg","id","class"]);return index.h(Alert.KolAlertFc,Object.assign({id:`${o}-msg`,alert:r,type:"error",class:clsx.clsx("kol-form-field__msg",{"visually-hidden":!0===t},i)},s,n,{"aria-hidden":"true"}),(null==s?void 0:s.description)||void 0)},KolFormFieldMsgFc=FormFieldMsgFc;exports.KolFormFieldMsgFc=KolFormFieldMsgFc,exports.checkHasError=checkHasError,exports.convertMsgToInternMsg=convertMsgToInternMsg,exports.validateMsg=validateMsg;