import{r as t,c as i,h as e,H as s,a as r}from"./p-DBTJNfo7.js";import{c as o,i as a}from"./p-CWuGCKo1.js";import{b as n}from"./p-CaObZtau.js";import{b as h}from"./p-BgPHaiMH.js";import{b as l}from"./p-DMyO3At_.js";import{i as c}from"./p-B8VKuhvH.js";import{c as p}from"./p-JbKhhoXs.js";import"./p-DlJXKdhK.js";import"./p-CgNJbSP4.js";import"./p-DTNvx8HZ.js";import"./p-DtS35Df5.js";import"./p-BJQylLSL.js";import"./p-efBXH4mj.js";import"./p-oiMYqRQ0.js";import"./p-BOEi1C7r.js";import"./p-CK4jS9_E.js";function f(t,i,e,s){for(var r=-1,o=null==t?0:t.length;++r<o;){var a=t[r];i(s,a,e(a),t)}return s}var d,m=(d=n,function(t,i){if(null==t)return t;if(!h(t))return d(t,i);for(var e=t.length,s=-1,r=Object(t);++s<e&&!1!==i(r[s],s,r););return t});function b(t,i,e,s){return m(t,(function(t,r,o){i(s,t,e(t),o)})),s}var u,j,v=(u=function(t,i,e){t[e?0:1].push(i)},j=function(){return[[],[]]},function(t,i){var e=c(t)?f:b,s=j?[[],[]]:{};return e(t,u,l(i),s)});const y=class{constructor(s){t(this,s),this.filesSelected=i(this,"filesSelected"),this.filesRejected=i(this,"filesRejected"),this.accept="*",this.disabled=!1,this.helperText="",this.hasFileToDrop=!1,this.renderOnDragLayout=()=>{if(!this.disabled&&this.hasFileToDrop)return e("div",{class:"has-file-to-drop"},e("limel-icon",{class:"icon",name:"upload_2"}),e("div",{class:"text-helpertext"},this.renderText(),this.renderHelperText()))},this.renderText=()=>{if(this.text)return e("span",{class:"text"},this.text)},this.renderHelperText=()=>{if(this.helperText)return e("span",{class:"helper-text"},this.helperText)},this.handleDrop=t=>{if(t.stopPropagation(),t.preventDefault(),this.hasFileToDrop=!1,this.disabled)return;const i=[...t.dataTransfer.files].map(o),[e,s]=v(i,(t=>a(t,this.accept)));e.length>0&&this.filesSelected.emit(e),s.length>0&&this.filesRejected.emit(s)},this.handleDragOver=t=>{this.hasFileToDrop=!0,t.preventDefault()},this.handleDragLeave=t=>{this.hasFileToDrop=!1,t.preventDefault()}}render(){return e(s,{key:"a66ef9c3d9a005567749b61967a63caa4496135a",onDrop:this.handleDrop,onDragOver:this.handleDragOver,onDragLeave:this.handleDragLeave},e("slot",{key:"7a770aa9f98365da4b83038662f04c0e9e5c20c6"}),this.renderOnDragLayout())}};y.style=":host(limel-file-dropzone){display:block;position:relative}.has-file-to-drop{animation:display-drop-zone 0.6s ease forwards;box-sizing:border-box;isolation:isolate;z-index:1;position:absolute;inset:0.25rem;overflow:hidden;display:flex;justify-content:center;align-items:center;gap:0.5rem;color:rgb(var(--contrast-700));border:0.125rem dashed rgb(var(--color-cyan-light));border-radius:0.75rem}.text-helpertext{display:flex;flex-direction:column;justify-content:center;align-items:flex-start}.icon{width:clamp(2rem, 5vh, 7rem)}.text{font-size:clamp(1rem, 2vh, 1.75rem)}.helper-text{font-size:clamp(0.75rem, 1.5vh, 1rem)}@keyframes display-drop-zone{0%{background-color:rgb(var(--contrast-1100), 0);backdrop-filter:blur(0);-webkit-backdrop-filter:blur(0);scale:0.9;opacity:0}50%{scale:1;opacity:1}100%{background-color:rgb(var(--contrast-1100), 0.8);backdrop-filter:blur(0.25rem);-webkit-backdrop-filter:blur(0.25rem)}}";const g=class{constructor(e){t(this,e),this.filesSelected=i(this,"filesSelected"),this.accept="*",this.disabled=!1,this.multiple=!1,this.fileInputId=p(),this.handleClick=t=>{if(this.disabled)return t.stopPropagation(),void t.preventDefault();this.triggerFileDialog(),t.stopPropagation()},this.handleKeyUp=t=>{t.stopPropagation(),t.preventDefault(),"Enter"===t.code&&this.triggerFileDialog()},this.handleFileChange=t=>{const i=[...this.fileInput.files];i.length>0&&(t.stopPropagation(),this.filesSelected.emit(i.map(o)),this.fileInput.value="")}}componentDidLoad(){this.fileInput=this.element.shadowRoot.getElementById(this.fileInputId)}render(){return e(s,{key:"62d72f49b1a71bef9c5b91c36f34f763a04d78e2",onClick:this.handleClick,onKeyUp:this.handleKeyUp,onKeyDown:this.handleKeyDown},e("input",{key:"72272f710f8ffb09eec2ace7409ab516ec4f80bd",hidden:!0,id:this.fileInputId,onChange:this.handleFileChange,type:"file",accept:this.accept,disabled:this.disabled,multiple:this.multiple}),e("slot",{key:"7ecff23ba41d76a23a2b8a542f56044615cb8b24"}))}handleKeyDown(t){"Tab"!==t.code&&"Backspace"!==t.code&&"Enter"!==t.code&&(t.preventDefault(),t.stopPropagation())}triggerFileDialog(){this.fileInput.click()}get element(){return r(this)}};export{y as limel_file_dropzone,g as limel_file_input}