import{p as l,d as J,i as j,a as m,r as K}from"./i18n-eTakDDhg.js";import{R as I,S as k,a as g,t as z,T as P,X as G,W as x,au as L,M as N,aj as O,a6 as Q,w as U,a5 as W,v as V,y as Y,a7 as Z,a0 as $,a8 as ee}from"./index-BkylzejB.js";import{G as te}from"./utils.svelte-DZ62NrTu.js";import{s as ae}from"./snippet-CC9u6I34.js";import{B as ie}from"./Button-CIsBas6L.js";import"./clone-IGppQJ7B.js";import"./Image-BfEz-0y2.js";import"./misc-Q1bfX-rj.js";/* empty css                                            */import"./ScrollFade.svelte_svelte_type_style_lang-De9nUaYy.js";/* empty css                                                   */var re=x('<img class="button-icon svelte-94gmgt"/>'),le=x("<!> <!>",1),ne=x('<input class="hide svelte-94gmgt" type="file"/> <!>',1);function se(p,e){I(e,!0);let b=l(e,"elem_id",3,""),t=l(e,"elem_classes",19,()=>[]),d=l(e,"visible",3,!0),c=l(e,"file_types",19,()=>[]),y=l(e,"size",3,"lg"),a=l(e,"icon",3,null),v=l(e,"scale",3,null),h=l(e,"min_width",3,void 0),A=l(e,"variant",3,"secondary"),M=l(e,"disabled",3,!1),R=l(e,"max_file_size",3,null),w,S=W(()=>c()==null?null:c().map(i=>i.startsWith(".")?i:i+"/*").join(", "));function T(){e.onclick?.(),w.click()}async function X(r){let i=Array.from(r);if(!r.length)return;e.file_count==="single"&&(i=[r[0]]);let s=await L(i);await N();try{s=(await e.upload(s,e.root,void 0,R()??1/0))?.filter(f=>f!==null)}catch(f){e.onerror?.(f.message);return}const _=e.file_count==="single"?s?.[0]:s;e.onchange?.(_),e.onupload?.(_)}async function q(r){const i=r.target;i.files&&await X(i.files)}function C(r){const i=r.target;i.value&&(i.value="")}var B=ne(),n=k(B);n.__change=q,n.__click=C,J(n,r=>w=r,()=>w);var D=G(n,2);ie(D,{get size(){return y()},get variant(){return A()},get elem_id(){return b()},get elem_classes(){return t()},get visible(){return d()},onclick:T,get scale(){return v()},get min_width(){return h()},get disabled(){return M()},children:(r,i)=>{var s=le(),_=k(s);{var f=o=>{var u=re();z(()=>{m(u,"src",a().url),m(u,"alt",`${e.value} icon`)}),g(o,u)};j(_,o=>{a()&&o(f)})}var E=G(_,2);{var F=o=>{var u=Q(),H=k(u);ae(H,()=>e.children),g(o,u)};j(E,o=>{e.children&&o(F)})}g(r,s)},$$slots:{default:!0}}),z(()=>{m(n,"accept",U(S)),n.multiple=e.file_count==="multiple"||void 0,n.webkitdirectory=e.file_count==="directory"||void 0,m(n,"mozdirectory",e.file_count==="directory"||void 0),m(n,"data-testid",`${e.label??""}-upload-button`)}),g(p,B),P()}O(["change","click"]);function be(p,e){I(e,!0);const b=K(e,["$$slots","$$events","$$legacy"]),t=new te(b);let d=V(t.props.value);Y(()=>{d!==t.props.value&&(t.props.value=d)});async function c(a,v){t.props.value=a,t.dispatch(v)}const y=W(()=>!t.shared.interactive);se(p,{get elem_id(){return t.shared.elem_id},get elem_classes(){return t.shared.elem_classes},get visible(){return t.shared.visible},get file_count(){return t.props.file_count},get file_types(){return t.props.file_types},get size(){return t.props.size},get scale(){return t.shared.scale},get icon(){return t.props.icon},get min_width(){return t.shared.min_width},get root(){return t.shared.root},get value(){return d},get disabled(){return U(y)},get variant(){return t.props.variant},get label(){return t.shared.label},get max_file_size(){return t.shared.max_file_size},onclick:()=>t.dispatch("click"),onchange:a=>c(a,"change"),onupload:a=>c(a,"upload"),onerror:a=>{t.dispatch("error",a)},upload:(...a)=>t.shared.client.upload(...a),children:(a,v)=>{ee();var h=Z();z(()=>$(h,t.shared.label??"")),g(a,h)},$$slots:{default:!0}}),P()}export{se as BaseUploadButton,be as default};
