import{h as r,w as A,e as O}from"./index-yJ8X--q8.js";import{c as v,a as P,I as y}from"./getRenderStates-B4Xg8PG8-CdOczHfm.js";import{_ as u}from"./Heading-D_vnx163-UWSZHCcZ.js";import{c as g}from"./clsx-eK3rPvPS-BT_IL7Fz.js";import{K as B}from"./Icon-XldYcxyr-CesIFDsR.js";import{i as _}from"./InternalUnderlinedBadgeText-Cy3ElU32-BKlO6_-s.js";import{i as b}from"./isObject-DvSELytj-B0RigBxT.js";import{v as K}from"./icons-BVOoMgA0-jvdEfCKr.js";/*!
 * KoliBri - The accessible HTML-Standard
 */const I=(n,o)=>{var{position:i="start",class:s}=n,t=u(n,["position","class"]);const c="kol-input-container__adornment",e=`${c}--${i}`;return r("div",Object.assign({class:g(c,e,s)},t),o)};function C(n){return n?Array.isArray(n)?n.length>0:!!n:!1}const N=(n,o)=>{var{class:i}=n,s=u(n,["class"]);return r("div",Object.assign({class:g("kol-input-container__container",i)},s),o)},L=(n,o)=>{const{class:i,startAdornment:s,endAdornment:t,disabled:c,msg:e,touched:a,containerProps:l,startAdornmentProps:d,endAdornmentProps:p}=n,m=u(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),j=P(e,a),k={"kol-input-container--disabled":c,[`kol-input-container--${(e==null?void 0:e.type)||"error"}`]:j},f=Object.assign({class:g("kol-input-container",k,i)},m);return!C(s)&&!C(t)?r("div",Object.assign({},f),r(N,Object.assign({},l),o)):r("div",Object.assign({},f),r(I,Object.assign({},d,{position:"start"}),s),r(N,Object.assign({},l),o),r(I,Object.assign({},p,{position:"end"}),t))},F=n=>{const{label:o,icons:i,hideLabel:s,disabled:t,onClick:c}=n,e=u(n,["label","icons","hideLabel","disabled","onClick"]);return r(O,Object.assign({_label:o,_disabled:t,_icons:i,_hideLabel:s,_on:{onClick:c}},e))},h=n=>{const{componentName:o="button",label:i,icon:s,onClick:t}=n,c=u(n,["componentName","label","icon","onClick"]);return r(o==="button"?F:B,Object.assign({label:i||"",hideLabel:!0,icons:`codicon codicon-${s}`,onClick:t},c))};function $(n){let o,i;return"_icons"in n&&(o=n._icons),"_smartButton"in n&&(i=n._smartButton),{icons:o,smartButton:i,disabled:n._disabled,msg:v(n._msg),touched:n._touched}}const V=({state:n,endAdornment:o},i)=>{const{icons:s,smartButton:t,disabled:c,msg:e,touched:a}=$(n);let l=s==null?void 0:s.left;_(l)&&(l={icon:l});let d=s==null?void 0:s.right;_(d)&&(d={icon:d});const p=[],m=[];return o&&(Array.isArray(o)?m.push(...o):m.push(o)),l&&p.push(r(h,Object.assign({componentName:"icon",class:"kol-input-container__icon"},b(l)?l:{}))),b(t)&&m.push(r(h,Object.assign({componentName:"button",class:"kol-input-container__smart-button"},t,{hideLabel:!0,disabled:c}))),d&&m.push(r(h,Object.assign({componentName:"icon",class:"kol-input-container__icon"},b(d)?d:{}))),r(L,{disabled:c,msg:e,touched:a,startAdornment:p,endAdornment:m},i)};class q extends y{constructor(o,i,s){super(o,i,s),this.numberStringRegex=/^\d+(\.\d+)?$/,this.parseToNumber=t=>typeof t=="number"?isNaN(t)?null:t:this.isNumberString(t)?parseFloat(t):null,this.validateNumber=(t,c)=>A(this.component,t,e=>e==null||typeof e=="number"||typeof e=="string"&&this.numberStringRegex.test(e),new Set(["number","NumberString"]),c,{hooks:{beforePatch:(e,a)=>{a!=null&&a.has(t)&&(a==null||a.set(t,this.parseToNumber(e)))}}}),this.component=o}validateIcons(o){K(this.component,o)}isNumberString(o){return typeof o=="string"&&this.numberStringRegex.test(o)}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}export{V as I,h as K,q as a};
//# sourceMappingURL=controller-icon-C2QQZ_hH-B4xNdxj9.js.map
