import{h as r,w as O,e as v}from"./index-DCi8lcS0.js";import{_ as u}from"./tslib.es6-CxX45GIN-BGVaTf34.js";import{K as y}from"./Icon-Dl4_Q-3S-BFTozRMP.js";import{c as g}from"./clsx-eK3rPvPS-B-dksMZM.js";import{c as P,I as B}from"./FormFieldStateWrapper-dDuHhzJa-2UFDj4Vr.js";import{i as _}from"./InternalUnderlinedBadgeText-BD4Dy3Jk-xRioRAvg.js";import{i as b}from"./isObject-DvSELytj-CqVuuo6Q.js";import{v as K}from"./icons-vgwIIwAr-C7YSjDtT.js";const C=(n,o)=>{var{position:i="start",class:e}=n,t=u(n,["position","class"]);const c="kol-input-container__adornment",s=`${c}--${i}`;return r("div",Object.assign({class:g(c,s,e)},t),o)};function I(n){return n?Array.isArray(n)?n.length>0:!!n:!1}const N=(n,o)=>{var{class:i}=n,e=u(n,["class"]);return r("div",Object.assign({class:g("kol-input-container__container",i)},e),o)},L=(n,o)=>{const{class:i,startAdornment:e,endAdornment:t,disabled:c,msg:s,touched:a,containerProps:l,startAdornmentProps:d,endAdornmentProps:p}=n,m=u(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),j=P(s,a),k=typeof s=="string"?"error":s?._type,A={"kol-input-container--disabled":c,[`kol-input-container--${k||"error"}`]:j},f=Object.assign({class:g("kol-input-container",A,i)},m);return!I(e)&&!I(t)?r("div",Object.assign({},f),r(N,Object.assign({},l),o)):r("div",Object.assign({},f),r(C,Object.assign({},d,{position:"start"}),e),r(N,Object.assign({},l),o),r(C,Object.assign({},p,{position:"end"}),t))},F=n=>{const{label:o,icons:i,hideLabel:e,disabled:t,onClick:c}=n,s=u(n,["label","icons","hideLabel","disabled","onClick"]);return r(v,Object.assign({_label:o,_disabled:t,_icons:i,_hideLabel:e,_on:{onClick:c}},s))},h=n=>{const{componentName:o="button",label:i,icon:e,onClick:t}=n,c=u(n,["componentName","label","icon","onClick"]);return r(o==="button"?F:y,Object.assign({label:i||"",hideLabel:!0,icons:`${e}`,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:n._msg,touched:n._touched}}const V=({state:n,endAdornment:o},i)=>{const{icons:e,smartButton:t,disabled:c,msg:s,touched:a}=$(n);let l=e?.left;_(l)&&(l={icon:l});let d=e?.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:s,touched:a,startAdornment:p,endAdornment:m},i)};class q extends B{constructor(o,i,e){super(o,i,e),this.numberStringRegex=/^\d+(\.\d+)?$/,this.parseToNumber=t=>typeof t=="number"?isNaN(t)?null:t:this.isNumberString(t)?parseFloat(t):null,this.validateNumber=(t,c)=>O(this.component,t,s=>s==null||typeof s=="number"||typeof s=="string"&&this.numberStringRegex.test(s),new Set(["number","NumberString"]),c,{hooks:{beforePatch:(s,a)=>{a?.has(t)&&a?.set(t,this.parseToNumber(s))}}}),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-BQiMXXEq-Dl2q5WxY.js.map
