import{_ as c}from"./FlashMessages-DW2Y2mP0.js";import{c as i,o as n,f as d,b as s,t as r,e as m,n as u}from"./app-BhD6J0Va.js";const f={props:{modelValue:File,label:String,accept:String,errors:{type:Array,default:()=>[]}},emits:["update:modelValue"],watch:{modelValue(e){e||(this.$refs.file.value="")}},methods:{filesize(e){var t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)*1+" "+["B","kB","MB","GB","TB"][t]},browse(){this.$refs.file.click()},change(e){this.$emit("update:modelValue",e.target.files[0])},remove(){this.$emit("update:modelValue",null)}}},h={key:0,class:"form-label"},g=["accept"],b={key:0,class:"p-1"},y={key:1,class:"flex items-center justify-between p-2"},x={class:"flex-1 pr-1 truncate"},_={class:"text-gray-500 text-xs"},v={key:1,class:"form-error"};function p(e,t,l,V,k,a){return n(),i("div",null,[l.label?(n(),i("label",h,r(l.label),1)):d("",!0),s("div",{class:u(["form-input p-0",{error:l.errors.length}])},[s("input",{ref:"file",type:"file",accept:l.accept,class:"hidden",onChange:t[0]||(t[0]=(...o)=>a.change&&a.change(...o))},null,40,g),l.modelValue?(n(),i("div",y,[s("div",x,[m(r(l.modelValue.name)+" ",1),s("span",_,"("+r(a.filesize(l.modelValue.size))+")",1)]),s("button",{type:"button",class:"px-4 py-1 text-white text-xs font-medium bg-gray-500 hover:bg-gray-700 rounded-sm",onClick:t[2]||(t[2]=(...o)=>a.remove&&a.remove(...o))},r(e.$t("Remove")),1)])):(n(),i("div",b,[s("button",{type:"button",class:"px-4 py-1 text-white text-xs font-medium bg-gray-500 hover:bg-gray-700 rounded-sm",onClick:t[1]||(t[1]=(...o)=>a.browse&&a.browse(...o))},r(e.$t("Browse")),1)]))],2),l.errors.length?(n(),i("div",v,r(l.errors[0]),1)):d("",!0)])}const C=c(f,[["render",p]]);export{C as F};
