import{h as r,w as j,e as O}from"./index-DpEJCboz.js";import{_ as p}from"./tslib.es6-CxX45GIN-BGVaTf34.js";import{K as k}from"./Icon-DfgbH-hb-O2Vh_zhx.js";import{a as y,i as P,I as v}from"./FormFieldStateWrapper--onY0vtr-Cqv50fJ0.js";import{c as f}from"./clsx-COFh-Vc8-D7cYsJM5.js";import{i as I}from"./InternalUnderlinedBadgeText-BJBDCfSS-CEaSIctE.js";import{i as h}from"./isObject-DvSELytj-DhzEQer1.js";import{v as B}from"./icons-CmA8Oww0-CjE5_G_U.js";const C=(n,s)=>{var{position:t="start",class:e}=n,o=p(n,["position","class"]);const c="kol-input-container__adornment",i=`${c}--${t}`;return r("div",Object.assign({class:f(c,i,e)},o),s)};function A(n){return n?Array.isArray(n)?n.length>0:!!n:!1}const N=(n,s)=>{var{class:t}=n,e=p(n,["class"]);return r("div",Object.assign({class:f("kol-input-container__container",t)},e),s)},K=(n,s)=>{const{class:t,startAdornment:e,endAdornment:o,disabled:c,msg:i,touched:a,containerProps:b,startAdornmentProps:l,endAdornmentProps:d}=n,m=p(n,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]),u={"kol-input-container--disabled":c,[`kol-input-container--${y(i)}`]:P(i,a)},_=Object.assign({class:f("kol-input-container",u,t)},m);return!A(e)&&!A(o)?r("div",Object.assign({},_),r(N,Object.assign({},b),s)):r("div",Object.assign({},_),r(C,Object.assign({},l,{position:"start"}),e),r(N,Object.assign({},b),s),r(C,Object.assign({},d,{position:"end"}),o))},L=n=>{const{label:s,icons:t,hideLabel:e,disabled:o,onClick:c}=n,i=p(n,["label","icons","hideLabel","disabled","onClick"]);return r(O,Object.assign({_label:s,_disabled:o,_icons:t,_hideLabel:e,_on:{onClick:c}},i))},g=n=>{const{componentName:s="button",label:t,icon:e,onClick:o}=n,c=p(n,["componentName","label","icon","onClick"]);return r(s==="button"?L:k,Object.assign({label:t||"",hideLabel:!0,icons:`${e}`,onClick:o},c))};function F(n){let s,t;return"_icons"in n&&(s=n._icons),"_smartButton"in n&&(t=n._smartButton),{icons:s,smartButton:t,disabled:n._disabled,msg:n._msg,touched:n._touched}}const S=({state:n,startAdornment:s,endAdornment:t},e)=>{const{icons:o,smartButton:c,disabled:i,msg:a,touched:b}=F(n);let l=o?.left;I(l)&&(l={icon:l});let d=o?.right;I(d)&&(d={icon:d});const m=[],u=[];return s&&(Array.isArray(s)?m.push(...s):m.push(s)),l&&m.push(r(g,Object.assign({componentName:"icon",class:"kol-input-container__icon"},h(l)?l:{}))),h(c)&&u.push(r(g,Object.assign({componentName:"button",class:"kol-input-container__smart-button"},c,{hideLabel:!0,disabled:i}))),d&&u.push(r(g,Object.assign({componentName:"icon",class:"kol-input-container__icon"},h(d)?d:{}))),t&&(Array.isArray(t)?u.push(...t):u.push(t)),r(K,{disabled:i,msg:a,touched:b,startAdornment:m,endAdornment:u},e)};class V extends v{constructor(s,t,e){super(s,t,e),this.numberStringRegex=/^\d+(\.\d+)?$/,this.parseToNumber=o=>typeof o=="number"?isNaN(o)?null:o:this.isNumberString(o)?parseFloat(o):null,this.validateNumber=(o,c)=>j(this.component,o,i=>i==null||typeof i=="number"||typeof i=="string"&&this.numberStringRegex.test(i),new Set(["number","NumberString"]),c,{hooks:{beforePatch:(i,a)=>{a?.has(o)&&a?.set(o,this.parseToNumber(i))}}}),this.component=s}validateIcons(s){B(this.component,s)}isNumberString(s){return typeof s=="string"&&this.numberStringRegex.test(s)}componentWillLoad(){super.componentWillLoad(),this.validateIcons(this.component._icons)}}export{S as I,g as K,V as a};
//# sourceMappingURL=controller-icon-kGj-dj9j-DvlQTtGV.js.map
