import{l as V,a as C,b as S}from"./logger-D3RVzcfQ-v2acROFG.chunk.mjs";import{c as N}from"./index-DaEUtA7I.chunk.mjs";import{g as F}from"./index-BgmsSgl5.chunk.mjs";import{r as L,e as M,_ as $,b as q,a as n,N as z}from"./createElementId-DhjFt1I9-Cdw8hg_s.chunk.mjs";import{d as H}from"./index-DqIuD5e7.chunk.mjs";import{N as I}from"./TrashCanOutline-DGTAXxb4.chunk.mjs";import{b as O,q as c,s as v,v as U,x as j,r as m,c as A,o as D,y as E,w as f,m as G,e as J,u as o,z as K,p as h}from"./runtime-dom.esm-bundler-CnPoR0UW.chunk.mjs";L(M);const Q=O({__name:"NcPasswordField",props:c({class:{},inputClass:{default:""},id:{},label:{},labelOutside:{type:Boolean},placeholder:{},showTrailingButton:{type:Boolean,default:!0},success:{type:Boolean},error:{type:Boolean},helperText:{},disabled:{type:Boolean},pill:{type:Boolean},checkPasswordStrength:{type:Boolean},minlength:{default:void 0},asText:{type:Boolean}},{modelValue:{default:""},modelModifiers:{},visible:{type:Boolean,default:!1},visibleModifiers:{}}),emits:c(["valid","invalid"],["update:modelValue","update:visible"]),setup(l,{expose:y,emit:w}){const s=v(l,"modelValue"),a=v(l,"visible"),t=l,d=w;U(s,H(B,500)),y({focus:_,select:P});const{password_policy:g}=F(),u=j("inputField"),r=m(""),i=m(),x=h(()=>{const e={...t};return delete e.checkPasswordStrength,delete e.minlength,delete e.asText,delete e.error,delete e.helperText,delete e.inputClass,delete e.success,e}),b=h(()=>t.minlength??(t.checkPasswordStrength?g?.minLength:void 0)??void 0);async function B(){if(t.checkPasswordStrength)try{const{data:e}=await N.post(q("apps/password_policy/api/v1/validate"),{password:s.value});if(i.value=e.ocs.data.passed,e.ocs.data.passed){r.value=n("Password is secure"),d("valid");return}r.value=e.ocs.data.reason,d("invalid")}catch(e){V.error("Password policy returned an error",{error:e})}}function T(){a.value=!a.value}function _(e){u.value.focus(e)}function P(){u.value.select()}return(e,p)=>(D(),A(I,K(x.value,{ref:"inputField",modelValue:s.value,"onUpdate:modelValue":p[0]||(p[0]=k=>s.value=k),error:e.error||i.value===!1,helperText:e.helperText||r.value,inputClass:[e.inputClass,{"password-field__input--secure-text":!a.value&&e.asText}],minlength:b.value,success:e.success||i.value===!0,trailingButtonLabel:a.value?o(n)("Hide password"):o(n)("Show password"),type:a.value||e.asText?"text":"password",onTrailingButtonClick:T}),E({"trailing-button-icon":f(()=>[J(z,{path:a.value?o(C):o(S)},null,8,["path"])]),_:2},[e.$slots.icon?{name:"icon",fn:f(()=>[G(e.$slots,"icon",{},void 0,!0)]),key:"0"}:void 0]),1040,["modelValue","error","helperText","inputClass","minlength","success","trailingButtonLabel","type"]))}}),se=$(Q,[["__scopeId","data-v-00e75248"]]);export{se as N};
//# sourceMappingURL=NcPasswordField-BOLzDHBJ-GBwBvLv5.chunk.mjs.map
