import{bi as ne,ba as j,ac as ot,b1 as Ot,bh as _t,b2 as zt,aW as xe,aX as re,bj as kt,aV as st,aS as Mt,bk as we,bl as ae,aY as Vt,bm as M,q as k,l as Bt,s as ee,x as te,S as Be,k as Ft,al as Nt,G as ce,C as pe,d as it,aj as Rt,b as Dt,e as m,u as Fe,J as _,z as Lt,K as Ut,D as Kt,E as Ht,o as b,f as T,V as h,F as fe,n as w,a as o,r as J,M as z,c as C,w as R,X as Q,m as de,Q as Wt,$ as Gt,az as Yt,O as Z,g as qt,I as Ne,h as Xt}from"./index-b8bd6c45.js";import{c as Jt,m as Qt,U as ge,d as Zt,i as ea,u as ta,e as Re}from"./index-ec296065.js";import{D as lt,i as De,U as aa,a5 as na,O as ra,a0 as oa,V as sa,ae as ia,af as la,E as D,W as ua,_ as ca}from"./el-button-46177dcd.js";const pa=()=>lt&&/firefox/i.test(window.navigator.userAgent);var fa=ne(j,"WeakMap");const ye=fa;var Le=Object.create,da=function(){function e(){}return function(r){if(!ot(r))return{};if(Le)return Le(r);e.prototype=r;var t=new e;return e.prototype=void 0,t}}();const va=da;function ur(e,r){var t=-1,a=e.length;for(r||(r=Array(a));++t-1&&e%1==0&&e<=ga}function ct(e){return e!=null&&ut(e.length)&&!zt(e)}var ya=Object.prototype;function Se(e){var r=e&&e.constructor,t=typeof r=="function"&&r.prototype||ya;return e===t}function ba(e,r){for(var t=-1,a=Array(e);++t/([\uAC00-\uD7AF\u3130-\u318F])+/gi.test(e);function Wn(e){const r=k();function t(){if(e.value==null)return;const{selectionStart:s,selectionEnd:i,value:u}=e.value;if(s==null||i==null)return;const v=u.slice(0,Math.max(0,s)),p=u.slice(Math.max(0,i));r.value={selectionStart:s,selectionEnd:i,value:u,beforeTxt:v,afterTxt:p}}function a(){if(e.value==null||r.value==null)return;const{value:s}=e.value,{beforeTxt:i,afterTxt:u,selectionStart:v}=r.value;if(i==null||u==null||v==null)return;let p=s.length;if(s.endsWith(u))p=s.length-u.length;else if(s.startsWith(i))p=i.length;else{const d=i[v-1],y=s.indexOf(d,v-1);y!==-1&&(p=y+1)}e.value.setSelectionRange(p,p)}return[t,a]}function Gn(e,{afterFocus:r,afterBlur:t}={}){const a=Bt(),{emit:s}=a,i=ee(),u=k(!1),v=y=>{u.value||(u.value=!0,s("focus",y),r==null||r())},p=y=>{var g;y.relatedTarget&&((g=i.value)!=null&&g.contains(y.relatedTarget))||(u.value=!1,s("blur",y),t==null||t())},d=()=>{var y;(y=e.value)==null||y.focus()};return te(i,y=>{y&&y.setAttribute("tabindex","-1")}),Jt(i,"click",d),{wrapperRef:i,isFocused:u,handleFocus:v,handleBlur:p}}let S;const Yn=` height:0 !important; visibility:hidden !important; ${pa()?"":"overflow:hidden !important;"} position:absolute !important; z-index:-1000 !important; top:0 !important; right:0 !important; `,qn=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing"];function Xn(e){const r=window.getComputedStyle(e),t=r.getPropertyValue("box-sizing"),a=Number.parseFloat(r.getPropertyValue("padding-bottom"))+Number.parseFloat(r.getPropertyValue("padding-top")),s=Number.parseFloat(r.getPropertyValue("border-bottom-width"))+Number.parseFloat(r.getPropertyValue("border-top-width"));return{contextStyle:qn.map(u=>`${u}:${r.getPropertyValue(u)}`).join(";"),paddingSize:a,borderSize:s,boxSizing:t}}function rt(e,r=1,t){var a;S||(S=document.createElement("textarea"),document.body.appendChild(S));const{paddingSize:s,borderSize:i,boxSizing:u,contextStyle:v}=Xn(e);S.setAttribute("style",`${v};${Yn}`),S.value=e.value||e.placeholder||"";let p=S.scrollHeight;const d={};u==="border-box"?p=p+i:u==="content-box"&&(p=p-s),S.value="";const y=S.scrollHeight-s;if(Be(r)){let g=y*r;u==="border-box"&&(g=g+s+i),p=Math.max(g,p),d.minHeight=`${g}px`}if(Be(t)){let g=y*t;u==="border-box"&&(g=g+s+i),p=Math.min(g,p)}return d.height=`${p}px`,(a=S.parentNode)==null||a.removeChild(S),S=void 0,d}const Jn=Ft({id:{type:String,default:void 0},size:Nt,disabled:Boolean,modelValue:{type:ce([String,Number,Object]),default:""},type:{type:String,default:"text"},resize:{type:String,values:["none","both","horizontal","vertical"]},autosize:{type:ce([Boolean,Object]),default:!1},autocomplete:{type:String,default:"off"},formatter:{type:Function},parser:{type:Function},placeholder:{type:String},form:{type:String},readonly:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},showPassword:{type:Boolean,default:!1},showWordLimit:{type:Boolean,default:!1},suffixIcon:{type:De},prefixIcon:{type:De},containerRole:{type:String,default:void 0},label:{type:String,default:void 0},tabindex:{type:[String,Number],default:0},validateEvent:{type:Boolean,default:!0},inputStyle:{type:ce([Object,Array,String]),default:()=>Qt({})},autofocus:{type:Boolean,default:!1}}),Qn={[ge]:e=>pe(e),input:e=>pe(e),change:e=>pe(e),focus:e=>e instanceof FocusEvent,blur:e=>e instanceof FocusEvent,clear:()=>!0,mouseleave:e=>e instanceof MouseEvent,mouseenter:e=>e instanceof MouseEvent,keydown:e=>e instanceof Event,compositionstart:e=>e instanceof CompositionEvent,compositionupdate:e=>e instanceof CompositionEvent,compositionend:e=>e instanceof CompositionEvent},Zn=["role"],er=["id","type","disabled","formatter","parser","readonly","autocomplete","tabindex","aria-label","placeholder","form","autofocus"],tr=["id","tabindex","disabled","readonly","autocomplete","aria-label","placeholder","form","autofocus"],ar=it({name:"ElInput",inheritAttrs:!1}),nr=it({...ar,props:Jn,emits:Qn,setup(e,{expose:r,emit:t}){const a=e,s=Rt(),i=Dt(),u=m(()=>{const n={};return a.containerRole==="combobox"&&(n["aria-haspopup"]=s["aria-haspopup"],n["aria-owns"]=s["aria-owns"],n["aria-expanded"]=s["aria-expanded"]),n}),v=m(()=>[a.type==="textarea"?Ie.b():c.b(),c.m(bt.value),c.is("disabled",E.value),c.is("exceed",wt.value),{[c.b("group")]:i.prepend||i.append,[c.bm("group","append")]:i.append,[c.bm("group","prepend")]:i.prepend,[c.m("prefix")]:i.prefix||a.prefixIcon,[c.m("suffix")]:i.suffix||a.suffixIcon||a.clearable||a.showPassword,[c.bm("suffix","password-clear")]:q.value&&ie.value},s.class]),p=m(()=>[c.e("wrapper"),c.is("focus",se.value)]),d=Zt({excludeKeys:m(()=>Object.keys(u.value))}),{form:y,formItem:g}=aa(),{inputId:Te}=na(a,{formItemContext:g}),bt=ra(),E=oa(),c=Fe("input"),Ie=Fe("textarea"),K=ee(),I=ee(),oe=k(!1),V=k(!1),H=k(!1),Ce=k(),W=ee(a.inputStyle),P=m(()=>K.value||I.value),{wrapperRef:mt,isFocused:se,handleFocus:G,handleBlur:Y}=Gn(P,{afterBlur(){var n;a.validateEvent&&((n=g==null?void 0:g.validate)==null||n.call(g,"blur").catch(l=>Re()))}}),$e=m(()=>{var n;return(n=y==null?void 0:y.statusIcon)!=null?n:!1}),B=m(()=>(g==null?void 0:g.validateState)||""),Ae=m(()=>B.value&&sa[B.value]),ht=m(()=>H.value?ia:la),xt=m(()=>[s.style,a.inputStyle]),je=m(()=>[a.inputStyle,W.value,{resize:a.resize}]),$=m(()=>ea(a.modelValue)?"":String(a.modelValue)),q=m(()=>a.clearable&&!E.value&&!a.readonly&&!!$.value&&(se.value||oe.value)),ie=m(()=>a.showPassword&&!E.value&&!a.readonly&&!!$.value&&(!!$.value||se.value)),O=m(()=>a.showWordLimit&&!!d.value.maxlength&&(a.type==="text"||a.type==="textarea")&&!E.value&&!a.readonly&&!a.showPassword),le=m(()=>$.value.length),wt=m(()=>!!O.value&&le.value>Number(d.value.maxlength)),St=m(()=>!!i.suffix||!!a.suffixIcon||q.value||a.showPassword||O.value||!!B.value&&$e.value),[Tt,It]=Wn(K);ta(I,n=>{if(Ct(),!O.value||a.resize!=="both")return;const l=n[0],{width:x}=l.contentRect;Ce.value={right:`calc(100% - ${x+15+6}px)`}});const F=()=>{const{type:n,autosize:l}=a;if(!(!lt||n!=="textarea"||!I.value))if(l){const x=Ne(l)?l.minRows:void 0,X=Ne(l)?l.maxRows:void 0,Ve=rt(I.value,x,X);W.value={overflowY:"hidden",...Ve},_(()=>{I.value.offsetHeight,W.value=Ve})}else W.value={minHeight:rt(I.value).minHeight}},Ct=(n=>{let l=!1;return()=>{var x;if(l||!a.autosize)return;((x=I.value)==null?void 0:x.offsetParent)===null||(n(),l=!0)}})(F),N=()=>{const n=P.value,l=a.formatter?a.formatter($.value):$.value;!n||n.value===l||(n.value=l)},ue=async n=>{Tt();let{value:l}=n.target;if(a.formatter&&(l=a.parser?a.parser(l):l),!V.value){if(l===$.value){N();return}t(ge,l),t("input",l),await _(),N(),It()}},Ee=n=>{t("change",n.target.value)},Pe=n=>{t("compositionstart",n),V.value=!0},Oe=n=>{var l;t("compositionupdate",n);const x=(l=n.target)==null?void 0:l.value,X=x[x.length-1]||"";V.value=!Hn(X)},_e=n=>{t("compositionend",n),V.value&&(V.value=!1,ue(n))},$t=()=>{H.value=!H.value,ze()},ze=async()=>{var n;await _(),(n=P.value)==null||n.focus()},At=()=>{var n;return(n=P.value)==null?void 0:n.blur()},jt=n=>{oe.value=!1,t("mouseleave",n)},Et=n=>{oe.value=!0,t("mouseenter",n)},ke=n=>{t("keydown",n)},Pt=()=>{var n;(n=P.value)==null||n.select()},Me=()=>{t(ge,""),t("change",""),t("clear"),t("input","")};return te(()=>a.modelValue,()=>{var n;_(()=>F()),a.validateEvent&&((n=g==null?void 0:g.validate)==null||n.call(g,"change").catch(l=>Re()))}),te($,()=>N()),te(()=>a.type,async()=>{await _(),N(),F()}),Lt(()=>{!a.formatter&&a.parser,N(),_(F)}),r({input:K,textarea:I,ref:P,textareaStyle:je,autosize:Ut(a,"autosize"),focus:ze,blur:At,select:Pt,clear:Me,resizeTextarea:F}),(n,l)=>Kt((b(),T("div",de(o(u),{class:o(v),style:o(xt),role:n.containerRole,onMouseenter:Et,onMouseleave:jt}),[h(" input "),n.type!=="textarea"?(b(),T(fe,{key:0},[h(" prepend slot "),n.$slots.prepend?(b(),T("div",{key:0,class:w(o(c).be("group","prepend"))},[J(n.$slots,"prepend")],2)):h("v-if",!0),z("div",{ref_key:"wrapperRef",ref:mt,class:w(o(p))},[h(" prefix slot "),n.$slots.prefix||n.prefixIcon?(b(),T("span",{key:0,class:w(o(c).e("prefix"))},[z("span",{class:w(o(c).e("prefix-inner"))},[J(n.$slots,"prefix"),n.prefixIcon?(b(),C(o(D),{key:0,class:w(o(c).e("icon"))},{default:R(()=>[(b(),C(Q(n.prefixIcon)))]),_:1},8,["class"])):h("v-if",!0)],2)],2)):h("v-if",!0),z("input",de({id:o(Te),ref_key:"input",ref:K,class:o(c).e("inner")},o(d),{type:n.showPassword?H.value?"text":"password":n.type,disabled:o(E),formatter:n.formatter,parser:n.parser,readonly:n.readonly,autocomplete:n.autocomplete,tabindex:n.tabindex,"aria-label":n.label,placeholder:n.placeholder,style:n.inputStyle,form:a.form,autofocus:a.autofocus,onCompositionstart:Pe,onCompositionupdate:Oe,onCompositionend:_e,onInput:ue,onFocus:l[0]||(l[0]=(...x)=>o(G)&&o(G)(...x)),onBlur:l[1]||(l[1]=(...x)=>o(Y)&&o(Y)(...x)),onChange:Ee,onKeydown:ke}),null,16,er),h(" suffix slot "),o(St)?(b(),T("span",{key:1,class:w(o(c).e("suffix"))},[z("span",{class:w(o(c).e("suffix-inner"))},[!o(q)||!o(ie)||!o(O)?(b(),T(fe,{key:0},[J(n.$slots,"suffix"),n.suffixIcon?(b(),C(o(D),{key:0,class:w(o(c).e("icon"))},{default:R(()=>[(b(),C(Q(n.suffixIcon)))]),_:1},8,["class"])):h("v-if",!0)],64)):h("v-if",!0),o(q)?(b(),C(o(D),{key:1,class:w([o(c).e("icon"),o(c).e("clear")]),onMousedown:Gt(o(Yt),["prevent"]),onClick:Me},{default:R(()=>[Wt(o(ua))]),_:1},8,["class","onMousedown"])):h("v-if",!0),o(ie)?(b(),C(o(D),{key:2,class:w([o(c).e("icon"),o(c).e("password")]),onClick:$t},{default:R(()=>[(b(),C(Q(o(ht))))]),_:1},8,["class"])):h("v-if",!0),o(O)?(b(),T("span",{key:3,class:w(o(c).e("count"))},[z("span",{class:w(o(c).e("count-inner"))},Z(o(le))+" / "+Z(o(d).maxlength),3)],2)):h("v-if",!0),o(B)&&o(Ae)&&o($e)?(b(),C(o(D),{key:4,class:w([o(c).e("icon"),o(c).e("validateIcon"),o(c).is("loading",o(B)==="validating")])},{default:R(()=>[(b(),C(Q(o(Ae))))]),_:1},8,["class"])):h("v-if",!0)],2)],2)):h("v-if",!0)],2),h(" append slot "),n.$slots.append?(b(),T("div",{key:1,class:w(o(c).be("group","append"))},[J(n.$slots,"append")],2)):h("v-if",!0)],64)):(b(),T(fe,{key:1},[h(" textarea "),z("textarea",de({id:o(Te),ref_key:"textarea",ref:I,class:o(Ie).e("inner")},o(d),{tabindex:n.tabindex,disabled:o(E),readonly:n.readonly,autocomplete:n.autocomplete,style:o(je),"aria-label":n.label,placeholder:n.placeholder,form:a.form,autofocus:a.autofocus,onCompositionstart:Pe,onCompositionupdate:Oe,onCompositionend:_e,onInput:ue,onFocus:l[2]||(l[2]=(...x)=>o(G)&&o(G)(...x)),onBlur:l[3]||(l[3]=(...x)=>o(Y)&&o(Y)(...x)),onChange:Ee,onKeydown:ke}),null,16,tr),o(O)?(b(),T("span",{key:0,style:qt(Ce.value),class:w(o(c).e("count"))},Z(o(le))+" / "+Z(o(d).maxlength),7)):h("v-if",!0)],64))],16,Zn)),[[Ht,n.type!=="hidden"]])}});var rr=ca(nr,[["__file","/home/runner/work/element-plus/element-plus/packages/components/input/src/input.vue"]]);const br=Xt(rr);export{br as E,U as S,nt as U,ct as a,Sa as b,bn as c,dr as d,vr as e,Aa as f,hn as g,nn as h,Hn as i,ut as j,fn as k,cr as l,pr as m,ur as n,fr as o,gr as p,yr as q,_n as r,jn as s,zn as t,Kn as u,We as v,Za as w};