const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ButtonElement-VEOfE7ak.js","assets/index-m7Z9H1b_.js","assets/KPopper-CuBnpfRA.js"])))=>i.map(i=>d[i]); import{_,d as S,ao as p,ap as T,r as V,o as a,f as i,q as o,W as w,h as b,t as v,i as h,w as I,j as r,l as g,F as c,p as f,m as B,a as E}from"./index-m7Z9H1b_.js";const A={name:"InputField",components:{ButtonElement:S(()=>E(()=>import("./ButtonElement-VEOfE7ak.js"),__vite__mapDeps([0,1]))),KPopper:S(()=>E(()=>import("./KPopper-CuBnpfRA.js"),__vite__mapDeps([2,1])))},props:{type:{type:String,default:"text"},modelValue:{type:[String,Number],default:""},id:{type:[String,Number],default:null},label:{type:String,default:null},helpText:{type:String,default:null},long:{type:Boolean,default:!1},rows:{type:String,default:"7"},placeholder:{type:String,default:null},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1},slugifyValue:{type:Boolean,default:!1},subSeparator:{type:String,default:"-"},prependText:{type:String,default:null},prependIcon:{type:[String,Array],default:null},prependIconSpin:{type:Boolean,default:!1},highlighted:{type:Boolean,default:!1},stacked:{type:Boolean,default:!1},stackedBottom:{type:Boolean,default:!1},prependVariant:{type:String,default:""},appendText:{type:String,default:null},appendIcon:{type:[String,Array],default:null},appendIconSpin:{type:Boolean,default:!1},iconSize:{type:String,default:"sm"},appendVariant:{type:String,default:""},min:{type:[Number,String],default:function(d){return d.type==="number"?0:null}},max:{type:[Number,String],default:function(d){return d.type==="number"?99999999999999:null}},step:{type:Number,default:function(d){return d.type==="number"?1:null}},valueRequired:{type:Boolean,default:!1},v:{type:Object,default:null},rowMargin:{type:String,default:"mb-3"},aliasableClass:{type:Object,default:null},aliasableField:{type:String,default:null},noLabel:{type:Boolean,default:!1},aliasesEditable:{type:Boolean,default:!0}},emits:["update:modelValue","blur"],data(){return{passwordVisible:!1}},computed:{hasAppendSlot:({$slots:d})=>!!d.append,isAliasable:({aliasableClass:d,aliasableField:l})=>d!==null&&l!==null,textareaClasses:({stacked:d,stackedBottom:l,highlighted:e})=>{let u="form-control textarea-lg";return d?`${u} stacked`:l?`${u} stacked--bottom`:e?`${u} highlighted`:u},hasErrors:({v:d})=>d!==null&&d.$error,errors:({v:d,$t:l})=>{let e={};return d!==null&&d.$errors.forEach(u=>{let s=u.$params;switch(u.$validator){case"required":case"requiredUnless":e[u.$validator]=l("validationErrors.required-field");break;case"email":e[u.$validator]=l("validationErrors.email");break;case"minLength":e[u.$validator]=l("validationErrors.min-length",{min:s.min});break;case"maxLength":e[u.$validator]=l("validationErrors.max-length",{max:s.max});break;case"minValue":e[u.$validator]=l("validationErrors.min-value",{min:s.min});break;case"maxValue":e[u.$validator]=l("validationErrors.max-value",{max:s.max});break;case"sameAsPassword":e[u.$validator]=l("validationErrors.same-as-password");break;case"sameAsEmail":e[u.$validator]=l("validationErrors.same-as-email");break;case"between":e[u.$validator]=l("validationErrors.between",{min:s.min,max:s.max});break;case"validPassword":e[u.$validator]=l("validationErrors.valid-password");break;case"linkSource":e[u.$validator]=l("validationErrors.link-source",{source:s.value});break;case"url":e[u.$validator]=l("validationErrors.invalid-url");break;case"validVariables":const t=typeof s.value.availableVariables[0]=="object"?s.value.availableVariables.map(y=>y.key):s.value.availableVariables,m=s.value.usedVariables.filter(y=>!t.includes(y)),x=p(m.map(y=>`"${y}"`),", ",` ${l("general.and")} `);e[u.$validator]=l("validationErrors.unavailable-variables",{varNames:x},m.length);break;default:console.log("InputField - need to handle this error message"),console.log(u),console.log(s)}}),e},hasLabelSlot:({$slots:d})=>!!d.label,hasPrepend:({prependText:d,prependIcon:l})=>d!==null||l!==null,hasAppend:({appendText:d,appendIcon:l})=>d!==null||l!==null,shouldDisplayAsInputGroup:({hasPrepend:d,hasAppend:l,hasAppendSlot:e,isAliasable:u,type:s})=>d||l||e||u||s==="password",inputElement:({$refs:d})=>d.input},methods:{updateValue:function(d){let l=d.target.value;if(this.type==="text"&&this.max!==null&&l.length>this.max&&(l=l.substring(0,this.max),this.$refs.input.value=l),this.slugifyValue){const e=T(l,this.subSeparator);this.$refs.input.value=e,this.$emit("update:modelValue",e)}else this.$emit("update:modelValue",l)},emit:function(d,l){this.v!==null&&this.v.$touch(),this.$emit(d,l.target.value)},togglePasswordView:function(){this.passwordVisible=!this.passwordVisible},showAliases:function(){this.$modal.show("Aliases",{aliasableClass:this.aliasableClass,field:this.aliasableField,editable:this.aliasesEditable})}}},q=["for"],C={class:"text-truncate"},z={key:0,name:"help"},P={class:"popper__tooltip"},L={key:0,class:"input-group"},N=["id","type","name","value","disabled","readonly","min","max","step","autofocus","placeholder","required"],F=["id","name","value","disabled","readonly","rows","placeholder"],M=["id","type","name","value","disabled","readonly","min","max","step","autofocus","placeholder","required"],R=["id","name","value","disabled","readonly","rows","placeholder"],j={key:2,class:"input-field-error-message"},D=["innerHTML"],H={key:0,class:"input-group"},O=["id","type","name","value","disabled","readonly","min","max","step","autofocus","placeholder","required"],G=["id","name","value","disabled","readonly","rows","placeholder"],K=["id","type","name","value","disabled","readonly","min","max","step","autofocus","placeholder","required"],U=["id","name","value","disabled","readonly","rows","placeholder"],W={class:"input-field-error-message"},J=["innerHTML"];function Q(d,l,e,u,s,t){const m=V("icon"),x=V("KPopper"),y=V("ButtonElement");return a(),i("div",{class:o({row:!e.vertical,[e.rowMargin]:e.rowMargin!==""})},[e.label||t.hasLabelSlot?(a(),i("label",{key:0,for:e.id,class:o(["form-label",{"col-xl-3":!e.vertical,"form-label-lg":!e.vertical,"justify-content-xl-end":!e.vertical}])},[w(d.$slots,"label",{},()=>[b("span",C,v(e.label),1)]),e.helpText!==null?(a(),i("div",z,[h(x,{hover:"",placement:"top",arrow:"","offset-distance":"15,0"},{content:I(()=>[b("div",P,v(e.helpText),1)]),default:I(()=>[h(m,{icon:["fal","info-circle"]})]),_:1})])):r("",!0)],10,q)):r("",!0),e.vertical?(a(),i(c,{key:2},[t.shouldDisplayAsInputGroup?(a(),i("div",H,[t.hasPrepend?(a(),i("span",{key:0,class:o({"input-group-text":!0,success:e.prependVariant==="success",error:e.prependVariant==="error"})},[e.prependIcon!==null?(a(),g(m,{key:0,icon:e.prependIcon,"fixed-width":"",size:e.iconSize,spin:e.prependIconSpin},null,8,["icon","size","spin"])):r("",!0),e.prependIcon!==null&&e.prependText!==null?(a(),i(c,{key:1},[f(" ")],64)):r("",!0),e.prependText!==null?(a(),i(c,{key:2},[f(v(e.prependText),1)],64)):r("",!0)],2)):r("",!0),e.long?(a(),i("textarea",{key:2,id:e.id,ref:"input",name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,class:o(t.textareaClasses),rows:e.rows,placeholder:e.placeholder,onInput:l[11]||(l[11]=n=>t.updateValue(n)),onBlur:l[12]||(l[12]=n=>t.emit("blur",n))},null,42,G)):(a(),i("input",{key:1,id:e.id,ref:"input",type:e.type==="password"&&s.passwordVisible?"text":e.type,name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,min:e.min,max:e.max,step:e.step,autofocus:e.autofocus,class:"form-control form-control-lg",placeholder:e.placeholder,required:e.valueRequired,onInput:l[9]||(l[9]=n=>t.updateValue(n)),onBlur:l[10]||(l[10]=n=>t.emit("blur",n))},null,40,O)),e.type==="password"?(a(),i("div",{key:3,class:o(["password-toggle",e.appendIcon===null?null:"has-append-icon"]),onClick:l[13]||(l[13]=(...n)=>t.togglePasswordView&&t.togglePasswordView(...n))},[h(m,{icon:s.passwordVisible?["fal","eye-slash"]:["fal","eye"],"fixed-width":""},null,8,["icon"])],2)):r("",!0),e.aliasableClass!==null&&e.aliasableField!==null?(a(),g(y,{key:4,variant:"tertiary",action:t.showAliases,icon:["fal","language"],size:"lg"},null,8,["action"])):t.hasAppend?(a(),i("span",{key:5,class:o({"input-group-text":!0,success:e.appendVariant==="success",error:e.appendVariant==="error",icon:e.appendIcon!==null})},[e.appendIcon!==null?(a(),g(m,{key:0,icon:e.appendIcon,"fixed-width":"",size:e.iconSize,spin:e.appendIconSpin},null,8,["icon","size","spin"])):r("",!0),e.appendIcon!==null&&e.appendText!==null?(a(),i(c,{key:1},[f(" ")],64)):r("",!0),e.appendText!==null?(a(),i(c,{key:2},[f(v(e.appendText),1)],64)):r("",!0)],2)):t.hasAppendSlot?w(d.$slots,"append",{key:6}):r("",!0)])):(a(),i(c,{key:1},[e.long?(a(),i("textarea",{key:1,id:e.id,ref:"input",name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,class:o(t.textareaClasses),rows:e.rows,placeholder:e.placeholder,onInput:l[16]||(l[16]=n=>t.updateValue(n)),onBlur:l[17]||(l[17]=n=>t.emit("blur",n))},null,42,U)):(a(),i("input",{key:0,id:e.id,ref:"input",type:e.type,name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,min:e.min,max:e.max,step:e.step,autofocus:e.autofocus,class:"form-control form-control-lg",placeholder:e.placeholder,required:e.valueRequired,onInput:l[14]||(l[14]=n=>t.updateValue(n)),onBlur:l[15]||(l[15]=n=>t.emit("blur",n))},null,40,K))],64)),t.hasErrors?(a(),i("div",{key:2,class:o({"col-md-9":!e.vertical,"offset-md-3":!e.vertical})},[b("div",W,[b("ul",null,[(a(!0),i(c,null,B(t.errors,(n,k)=>(a(),i("li",{key:k},[b("span",{innerHTML:n},null,8,J)]))),128))])])],2)):r("",!0)],64)):(a(),i("div",{key:1,class:o({"col-xl-9":!e.vertical,"offset-xl-3":!(e.label||t.hasLabelSlot)})},[t.shouldDisplayAsInputGroup?(a(),i("div",L,[t.hasPrepend?(a(),i("span",{key:0,class:o({"input-group-text":!0,success:e.prependVariant==="success",error:e.prependVariant==="error"})},[e.prependIcon!==null?(a(),g(m,{key:0,icon:e.prependIcon,"fixed-width":"",size:e.iconSize,spin:e.prependIconSpin},null,8,["icon","size","spin"])):r("",!0),e.prependIcon!==null&&e.prependText!==null?(a(),i(c,{key:1},[f(" ")],64)):r("",!0),e.prependText!==null?(a(),i(c,{key:2},[f(v(e.prependText),1)],64)):r("",!0)],2)):r("",!0),e.long?(a(),i("textarea",{key:2,id:e.id,ref:"input",name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,class:o(t.textareaClasses),rows:e.rows,placeholder:e.placeholder,onInput:l[2]||(l[2]=n=>t.updateValue(n)),onBlur:l[3]||(l[3]=n=>t.emit("blur",n))},null,42,F)):(a(),i("input",{key:1,id:e.id,ref:"input",type:e.type==="password"&&s.passwordVisible?"text":e.type,name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,min:e.min,max:e.max,step:e.step,autofocus:e.autofocus,class:"form-control form-control-lg",placeholder:e.placeholder,required:e.valueRequired,onInput:l[0]||(l[0]=n=>t.updateValue(n)),onBlur:l[1]||(l[1]=n=>t.emit("blur",n))},null,40,N)),e.type==="password"?(a(),i("div",{key:3,class:o(["password-toggle",e.appendIcon===null?null:"has-append-icon"]),onClick:l[4]||(l[4]=(...n)=>t.togglePasswordView&&t.togglePasswordView(...n))},[h(m,{icon:s.passwordVisible?["fal","eye-slash"]:["fal","eye"],"fixed-width":""},null,8,["icon"])],2)):r("",!0),e.aliasableClass!==null&&e.aliasableField!==null?(a(),g(y,{key:4,variant:"tertiary",action:t.showAliases,icon:["fal","language"],size:"lg"},null,8,["action"])):t.hasAppend?(a(),i("span",{key:5,class:o({"input-group-text":!0,success:e.appendVariant==="success",error:e.appendVariant==="error",icon:e.appendIcon!==null})},[e.appendIcon!==null?(a(),g(m,{key:0,icon:e.appendIcon,"fixed-width":"",size:e.iconSize,spin:e.appendIconSpin},null,8,["icon","size","spin"])):r("",!0),e.appendIcon!==null&&e.appendText!==null?(a(),i(c,{key:1},[f(" ")],64)):r("",!0),e.appendText!==null?(a(),i(c,{key:2},[f(v(e.appendText),1)],64)):r("",!0)],2)):t.hasAppendSlot?w(d.$slots,"append",{key:6}):r("",!0)])):(a(),i(c,{key:1},[e.long?(a(),i("textarea",{key:1,id:e.id,ref:"input",name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,class:o(t.textareaClasses),rows:e.rows,placeholder:e.placeholder,onInput:l[7]||(l[7]=n=>t.updateValue(n)),onBlur:l[8]||(l[8]=n=>t.emit("blur",n))},null,42,R)):(a(),i("input",{key:0,id:e.id,ref:"input",type:e.type,name:e.id,value:e.modelValue,disabled:e.disabled,readonly:e.readonly,min:e.min,max:e.max,step:e.step,autofocus:e.autofocus,class:"form-control form-control-lg",placeholder:e.placeholder,required:e.valueRequired,onInput:l[5]||(l[5]=n=>t.updateValue(n)),onBlur:l[6]||(l[6]=n=>t.emit("blur",n))},null,40,M))],64)),t.hasErrors?(a(),i("div",j,[b("ul",null,[(a(!0),i(c,null,B(t.errors,(n,k)=>(a(),i("li",{key:k,innerHTML:n},null,8,D))),128))])])):r("",!0)],2))],2)}const Y=_(A,[["render",Q]]);export{Y as default};