import './async-D55cHugf.js';
import { a as attr, f as attr_class, g as attr_style, d as bind_props } from './index-u8mz_F03.js';
import { o as onDestroy, t as tick } from './index-server-CQz6EZl_.js';
import { b as bs } from './2-EyCg4N-O.js';
import { e as escape_html } from './escaping-CBnpiEl5.js';

/* empty css                                    */function Q(P,m){P.component(e=>{let {upload_id:r,root:y,files:b,stream_handler:v,ondone:w}=m,h=false,n=d[0],d=b.map(u=>({...u,progress:0}));function x(u){return u.progress*100/(u.size||0)||0}onDestroy(()=>{}),e.push(`<div${attr_class("wrap svelte-ua961l",void 0,{progress:h})}><span class="uploading svelte-ua961l">Uploading ${escape_html(d.length)}
		${escape_html(d.length>1?"files":"file")}...</span> `),n?(e.push("<!--[-->"),e.push(`<div class="file svelte-ua961l"><span><div class="progress-bar svelte-ua961l"><progress style="visibility:hidden;height:0;width:0;"${attr("value",x(n))} max="100" class="svelte-ua961l">${escape_html(x(n))}</progress></div></span> <span class="file-name svelte-ua961l">${escape_html(n.orig_name)}</span></div>`)):e.push("<!--[!-->"),e.push("<!--]--></div>");});}function ee(P,m){P.component(e=>{let{filetype:r=null,dragging:y=false,boundedheight:b=true,center:v=true,flex:w=true,file_count:o="single",disable_click:h=false,root:_,hidden:n=false,format:d="file",uploading:c=false,show_progress:x=true,max_file_size:u=null,upload:p,stream_handler:g,icon_upload:W=false,height:f=void 0,aria_label:z=void 0,upload_promise:U=void 0,onload:C,onerror:E,children:k}=m;function S(){}let A="",F,I=null,L=(()=>{if(typeof navigator<"u"){const t=navigator.userAgent.toLowerCase();return t.indexOf("iphone")>-1||t.indexOf("ipad")>-1}return  false})();const D=["image","video","audio","text","file"],J=t=>L&&t.startsWith(".")?(I=true,t):L&&t.includes("file/*")?"*":t.startsWith(".")||t.endsWith("/*")?t:D.includes(t)?t+"/*":"."+t;function N(){navigator.clipboard.read().then(async t=>{for(let i=0;i<t.length;i++){const l=t[i].types.find(s=>s.startsWith("image/"));if(l){t[i].getType(l).then(async s=>{const T=new File([s],`clipboard.${l.replace("image/","")}`);await O([T]);});break}}});}function R(){}async function j(t,i){return i?A=i:A=Math.random().toString(36).substring(2,15),await tick(),c=true,U=new Promise(async l=>{try{const s=await p(t,_,A,u??1/0);C?.(o==="single"?s?.[0]:s),l(s||[]),c=!1;}catch(s){E?.(s.message),c=false,l([]);}}),U}async function O(t,i){if(!t.length)return;let l=t.map(s=>new File([s],s instanceof File?s.name:"file",{type:s.type}));return L&&I&&(l=l.filter(s=>M(s)?true:(E?.(`Invalid file type: ${s.name}. Only ${r} allowed.`),false)),l.length===0)?[]:(F=await bs(l),await j(F,i))}function M(t){return r?(Array.isArray(r)?r:[r]).some(l=>{const s=J(l);if(s.startsWith("."))return t.name.toLowerCase().endsWith(s.toLowerCase());if(s==="*")return  true;if(s.endsWith("/*")){const[T]=s.split("/");return t.type.startsWith(T+"/")}return t.type===s}):true}async function q(t){if(y=false,!t.dataTransfer?.files)return;const i=Array.from(t.dataTransfer.files).filter(M);if(d!="blob")await O(i);else {if(o==="single"){C?.(i[0]);return}C?.(i);}}r==="clipboard"?(e.push("<!--[-->"),e.push(`<button${attr("tabindex",n?-1:0)}${attr("aria-label",z||"Paste from clipboard")}${attr_class("svelte-8prmba",void 0,{hidden:n,center:v,boundedheight:b,flex:w,"icon-mode":W})}${attr_style("",{height:W?"":f?typeof f=="number"?f+"px":f:"100%"})}>`),k?(e.push("<!--[-->"),k(e),e.push("<!---->")):e.push("<!--[!-->"),e.push("<!--]--></button>")):(e.push("<!--[!-->"),c&&x?(e.push("<!--[-->"),n?e.push("<!--[!-->"):(e.push("<!--[-->"),Q(e,{root:_,upload_id:A,files:F,stream_handler:g})),e.push("<!--]-->")):(e.push("<!--[!-->"),e.push(`<button${attr("tabindex",n?-1:0)}${attr("aria-label",z||"Click to upload or drop files")} aria-dropeffect="copy"${attr_class("svelte-8prmba",void 0,{hidden:n,center:v,boundedheight:b,flex:w,disable_click:h,"icon-mode":W})}${attr_style("",{height:W?"":f?typeof f=="number"?f+"px":f:"100%"})}>`),k?(e.push("<!--[-->"),k(e),e.push("<!---->")):e.push("<!--[!-->"),e.push("<!--]--></button>")),e.push("<!--]-->")),e.push("<!--]-->"),bind_props(m,{dragging:y,uploading:c,upload_promise:U,open_upload:S,paste_clipboard:N,open_file_upload:R,load_files:O,load_files_from_drop:q});});}

export { Q, ee as e };
//# sourceMappingURL=Upload2-CnUKERBu.js.map
