/*!
 * KoliBri - The accessible HTML-Standard
 */
import{h as n}from"./index-Brmny3Vg.js";import{a as t}from"./tslib.es6-QNbPBOk5.js";import{I as o}from"./component-DHo2YdSx.js";import{b as s}from"./component-names-Dy77vq43.js";import{b as e}from"./common-DEEjER7G.js";import{g as i,i as r,I as a}from"./FormFieldStateWrapper-DCXQnRBu.js";import{c}from"./clsx-COFh-Vc8.js";import{i as l}from"./component-CQaxTS4u.js";import{i as d}from"./_Uint8Array-kJHDjtoP.js";import{v as m}from"./icons-DOGnS2Iv.js";const u=o=>{const{label:e,icons:i,hideLabel:r,disabled:a,onClick:c}=o,l=t(o,["label","icons","hideLabel","disabled","onClick"]);return n(s,Object.assign({_label:e,_disabled:a,_icons:i,_hideLabel:r,_on:{onClick:c}},l))};const b=s=>{const{componentName:e="button",label:i,icon:r,onClick:a}=s,c=t(s,["componentName","label","icon","onClick"]);const l=e==="button"?u:o;return n(l,Object.assign({label:i||"",hideLabel:true,icons:`${r}`,onClick:a},c))};const p=(o,s)=>{var{position:e="start",class:i}=o,r=t(o,["position","class"]);const a=`kol-input-container__adornment`;const l=`${a}--${e}`;return n("div",Object.assign({class:c(a,l,i)},r),s)};function f(n){if(!n){return false}return Array.isArray(n)?n.length>0:Boolean(n)}const h=(o,s)=>{var{class:e}=o,i=t(o,["class"]);return n("div",Object.assign({class:c("kol-input-container__container",e)},i),s)};const j=(o,s)=>{const{class:e,startAdornment:a,endAdornment:l,disabled:d,msg:m,touched:u,containerProps:b,startAdornmentProps:j,endAdornmentProps:_}=o,v=t(o,["class","startAdornment","endAdornment","disabled","msg","touched","containerProps","startAdornmentProps","endAdornmentProps"]);const k={["kol-input-container--disabled"]:d,[`kol-input-container--${i(m)}`]:r(m,u)};const A=Object.assign({class:c("kol-input-container",k,e)},v);if(!f(a)&&!f(l)){return n("div",Object.assign({},A),n(h,Object.assign({},b),s))}return n("div",Object.assign({},A),n(p,Object.assign({},j,{position:"start"}),a),n(h,Object.assign({},b),s),n(p,Object.assign({},_,{position:"end"}),l))};function _(n){let t=undefined;let o;if("_icons"in n){t=n._icons}if("_smartButton"in n){o=n._smartButton}return{icons:t,smartButton:o,disabled:n._disabled,msg:n._msg,touched:n._touched}}const v=({state:t,startAdornment:s,endAdornment:e},i)=>{var r,a;const{icons:c,smartButton:m,disabled:u,msg:p,touched:f}=_(t);let h=c===null||c===void 0?void 0:c.left;if(l(h)){h={icon:h}}let v=c===null||c===void 0?void 0:c.right;if(l(v)){v={icon:v}}const k=[];const A=[];if(s){if(Array.isArray(s)){k.push(...s)}else{k.push(s)}}if(h){if(d(h)){k.push(n(o,{class:"kol-input-container__icon",icons:h.icon,label:(r=h.label)!==null&&r!==void 0?r:"",style:h.style}))}else{k.push(n(o,{class:"kol-input-container__icon",icons:h,label:""}))}}if(d(m)){A.push(n(b,Object.assign({componentName:"button",class:"kol-input-container__smart-button"},m,{hideLabel:true,disabled:u})))}if(v){if(d(v)){A.push(n(o,{class:"kol-input-container__icon",icons:v.icon,label:(a=v.label)!==null&&a!==void 0?a:"",style:v.style}))}else{A.push(n(o,{class:"kol-input-container__icon",icons:v,label:""}))}}if(e){if(Array.isArray(e)){A.push(...e)}else{A.push(e)}}return n(j,{disabled:u,msg:p,touched:f,startAdornment:k,endAdornment:A},i)};class k extends a{constructor(n,t,o){super(n,t,o);this.numberStringRegex=/^\d+(\.\d+)?$/;this.parseToNumber=n=>{if(typeof n==="number"){return isNaN(n)?null:n}if(this.isNumberString(n)){return parseFloat(n)}return null};this.validateNumber=(n,t)=>e(this.component,n,(n=>n===undefined||n===null||typeof n==="number"||typeof n==="string"&&this.numberStringRegex.test(n)),new Set(["number","NumberString"]),t,{hooks:{beforePatch:(t,o)=>{if(o===null||o===void 0?void 0:o.has(n)){o===null||o===void 0?void 0:o.set(n,this.parseToNumber(t))}}}});this.component=n}validateIcons(n){m(this.component,n)}isNumberString(n){return typeof n==="string"&&this.numberStringRegex.test(n)}componentWillLoad(){super.componentWillLoad();this.validateIcons(this.component._icons)}}export{k as I,b as K,v as a};
//# sourceMappingURL=controller-icon-ClFIXmW5.js.map