/*!
 * KoliBri - The accessible HTML-Standard
 */
import{_ as __rest}from"./tslib.es6.js";import{h,Fragment}from"@stencil/core/internal/client";import{c as clsx}from"./clsx.js";import"./common.js";import{b as buildBadgeTextString,s as showExpertSlot}from"./reuse.js";import{c as checkHasMsg,a as FormFieldTooltipFc,K as KolFormFieldLabelFc,b as KolFormFieldHintFc}from"./controller2.js";const InputContainer=(l,e)=>{var{class:o}=l,r=__rest(l,["class"]);return h("div",Object.assign({class:clsx("kol-field-control__input",o)},r),e)},KolFieldControlFc=(l,e)=>{const{class:o,id:r,disabled:t,label:i,hideLabel:s,labelAlign:n,renderNoTooltip:a,hint:d,renderNoHint:c,tooltipAlign:b,accessKey:p,shortKey:g,msg:_,touched:F,required:f,readonly:u,fieldControlInputProps:m,fieldControlLabelProps:y,fieldControlTooltipProps:K,fieldControlHintProps:C}=l,k=__rest(l,["class","id","disabled","label","hideLabel","labelAlign","renderNoTooltip","hint","renderNoHint","tooltipAlign","accessKey","shortKey","msg","touched","required","readonly","fieldControlInputProps","fieldControlLabelProps","fieldControlTooltipProps","fieldControlHintProps"]),j=!c,x=!a,B=checkHasMsg(_,F),P=showExpertSlot(i),O=x&&!P&&s,T=buildBadgeTextString(p,g),v="string"==typeof _?"error":null==_?void 0:_._type,H=[h(Fragment,null,h(InputContainer,Object.assign({},m),e),O&&h(FormFieldTooltipFc,Object.assign({},K||{},{id:r,label:i,align:b,badgeText:T}))),h(KolFormFieldLabelFc,Object.assign({},y||{},{id:r,baseClassName:"kol-field-control",class:clsx(null==y?void 0:y.class,{"kol-field-control__label--visually-hidden":Boolean(s)}),hasExpertSlot:P,label:i,accessKey:p,shortKey:g}))];"left"===n&&H.reverse();const L={"kol-field-control--disabled":Boolean(t),"kol-field-control--required":Boolean(f),"kol-field-control--touched":Boolean(F),"kol-field-control--hide-label":Boolean(s),"kol-field-control--read-only":Boolean(u),[`kol-field-control--${v||"error"}`]:Boolean(B),[`kol-field-control--label-align-${n}`]:Boolean(n)};return h("div",Object.assign({class:clsx("kol-field-control",L,o)},k),H,j&&h(KolFormFieldHintFc,Object.assign({},C||{},{baseClassName:"kol-field-control",id:r,hint:d})))};function getFieldControlProps(l){const e={id:l._id,disabled:l._disabled,msg:l._msg,hint:l._hint,label:l._label,hideLabel:l._hideLabel,touched:l._touched};return"_required"in l&&(e.required=l._required),"_readOnly"in l&&(e.readonly=l._readOnly),"_labelAlign"in l&&(e.labelAlign=l._labelAlign),"_accessKey"in l&&(e.accessKey=l._accessKey),"_shortKey"in l&&(e.shortKey=l._shortKey),e}const FieldControlStateWrapper=(l,e)=>{var{state:o}=l,r=__rest(l,["state"]);return h(KolFieldControlFc,Object.assign({},getFieldControlProps(o),r),e)};export{FieldControlStateWrapper as F};