import{ac as Z,aV as H,by as Q,cx as X,af as ee,ap as le,aW as te,aY as ne,J as s,cD as $,l as V,G as ae,ag as oe,a_ as ue,a$ as x,cy as ie,q as o,cA as se,K as C,F as g,cE as re,bZ as ce,ba as de,cF as fe}from"./index-2e57ee69.js";import{V as ve}from"./VChip-73a1db56.js";const pe=Z({chips:Boolean,counter:Boolean,counterSizeString:{type:String,default:"$vuetify.fileInput.counterSize"},counterString:{type:String,default:"$vuetify.fileInput.counter"},multiple:Boolean,showSize:{type:[Boolean,Number],default:!1,validator:e=>typeof e=="boolean"||[1e3,1024].includes(e)},...H({prependIcon:"$file"}),modelValue:{type:Array,default:()=>[],validator:e=>Q(e).every(f=>f!=null&&typeof f=="object")},...X({clearable:!0})},"VFileInput"),Ce=ee()({name:"VFileInput",inheritAttrs:!1,props:pe(),emits:{"click:control":e=>!0,"mousedown:control":e=>!0,"update:focused":e=>!0,"update:modelValue":e=>!0},setup(e,f){let{attrs:D,emit:h,slots:n}=f;const{t:k}=le(),a=te(e,"modelValue"),{isFocused:v,focus:M,blur:N}=ne(e),F=s(()=>typeof e.showSize!="boolean"?e.showSize:void 0),I=s(()=>(a.value??[]).reduce((l,t)=>{let{size:r=0}=t;return l+r},0)),b=s(()=>$(I.value,F.value)),m=s(()=>(a.value??[]).map(l=>{const{name:t="",size:r=0}=l;return e.showSize?`${t} (${$(r,F.value)})`:t})),E=s(()=>{var t;const l=((t=a.value)==null?void 0:t.length)??0;return e.showSize?k(e.counterSizeString,l,b.value):k(e.counterString,l)}),S=V(),P=V(),i=V(),j=s(()=>v.value||e.active),z=s(()=>["plain","underlined"].includes(e.variant));function y(){var l;i.value!==document.activeElement&&((l=i.value)==null||l.focus()),v.value||M()}function U(l){w(l)}function _(l){h("mousedown:control",l)}function w(l){var t;(t=i.value)==null||t.click(),h("click:control",l)}function q(l){l.stopPropagation(),y(),de(()=>{a.value=[],fe(e["onClick:clear"],l)})}return ae(a,l=>{(!Array.isArray(l)||!l.length)&&i.value&&(i.value.value="")}),oe(()=>{const l=!!(n.counter||e.counter),t=!!(l||n.details),[r,G]=ue(D),[{modelValue:me,...J}]=x.filterProps(e),[K]=ie(e);return o(x,C({ref:S,modelValue:a.value,"onUpdate:modelValue":c=>a.value=c,class:["v-file-input",{"v-text-field--plain-underlined":z.value},e.class],style:e.style,"onClick:prepend":U},r,J,{centerAffix:!z.value,focused:v.value}),{...n,default:c=>{let{id:p,isDisabled:d,isDirty:A,isReadonly:R,isValid:L}=c;return o(se,C({ref:P,"prepend-icon":e.prependIcon,onMousedown:_,onClick:w,"onClick:clear":q,"onClick:prependInner":e["onClick:prependInner"],"onClick:appendInner":e["onClick:appendInner"]},K,{id:p.value,active:j.value||A.value,dirty:A.value,disabled:d.value,focused:v.value,error:L.value===!1}),{...n,default:O=>{var B;let{props:{class:T,...W}}=O;return o(g,null,[o("input",C({ref:i,type:"file",readonly:R.value,disabled:d.value,multiple:e.multiple,name:e.name,onClick:u=>{u.stopPropagation(),R.value&&u.preventDefault(),y()},onChange:u=>{if(!u.target)return;const Y=u.target;a.value=[...Y.files??[]]},onFocus:y,onBlur:N},W,G),null),o("div",{class:T},[!!((B=a.value)!=null&&B.length)&&(n.selection?n.selection({fileNames:m.value,totalBytes:I.value,totalBytesReadable:b.value}):e.chips?m.value.map(u=>o(ve,{key:u,size:"small",color:e.color},{default:()=>[u]})):m.value.join(", "))])])}})},details:t?c=>{var p,d;return o(g,null,[(p=n.details)==null?void 0:p.call(n,c),l&&o(g,null,[o("span",null,null),o(re,{active:!!((d=a.value)!=null&&d.length),value:E.value},n.counter)])])}:void 0})}),ce({},S,P,i)}});export{Ce as V};
