import{__decorate as t}from"tslib";import{s}from"./nile-file-upload.css.esm.js";import{N as i}from"../internal/nile-element.esm.js";import{D as e}from"./utils/drag-drop.util.esm.js";import{d as h,F as r,e as a,b as o}from"./types/file-upload.enums.esm.js";import{html as l}from"lit";import{property as n,state as p,query as d,customElement as u}from"lit/decorators.js";import{s as m,a as c,b as y,u as f}from"./utils/file-validation.util.esm.js";import{g as v,a as g,b as j,c as b,d as S,e as w,f as U,h as B}from"./nile-file-upload.template.esm.js";import"../internal/accessibility/a11y.state.enum.esm.js";import"../internal/accessibility/a11y.property.enum.esm.js";import"../internal/accessibility/role.enum.esm.js";import"../lit-html-39a6718c.esm.js";import"../directive-ee0c609c.esm.js";let F=class extends i{constructor(){super(...arguments),this.size="10MB",this.error=!1,this.errorMessage="",this.allowMultiple=!1,this.allowDuplicates=!1,this.allowedTypes=[],this.uploadedFiles=[],this.title=h.TITLE,this.subtitle=h.SUBTITLE,this.state=r.DEFAULT,this.variant=a.HORIZONTAL,this.fileUploadUrl="",this.autoUpload=!0,this.doNotUpload=[],this.uploadRequests=new Map,this.fileSizeExceededFilesNumber=0,this.isStringTruncated=!1,this.setState=t=>{this.state=t}}static get styles(){return[s]}connectedCallback(){super.connectedCallback(),this.emit(o.NILE_INIT)}firstUpdated(t){super.firstUpdated(t),this.dragHandler=new e,m(this,this.dragHandler),c(this,this.dragHandler,this.uploadRequests),y(this.dragHandler)}updated(t){super.updated(t),t.has("uploadedFiles")?(this.fileUploadUrl&&this.autoUpload&&f(this),this.emit(o.NILE_CHANGE,{files:this.uploadedFiles})):t.has("state")&&this.dragHandler.setValuesInDragHandler(this.state),t.has("autoUpload")&&this.autoUpload&&(this.fileUploadUrl&&this.autoUpload&&f(this),this.emit(o.NILE_CHANGE,{files:this.uploadedFiles}))}browseFiles(){this.emit(o.NILE_BROWSE),this.errorMessage="",this.input.click()}render(){return l`
      ${this.getState()}
    `}clearAllUploadedFiles(){this.uploadedFiles=[],this.state=r.DEFAULT,this.errorMessage=""}getState(){return this.variant===a.HORIZONTAL?this.getHorizontalState():this.getVerticalState()}getHorizontalState(){switch(this.state){case r.DEFAULT:return v(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.state,this.errorMessage,this.allowedTypes,this);case r.DISABLED:return b(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.state,this.errorMessage,this.allowedTypes,this);case r.DRAG:return j();case r.ERROR:return g(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.state,this.errorMessage,this.allowedTypes,this);default:return v(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.state,this.errorMessage,this.allowedTypes,this)}}getVerticalState(){switch(this.state){case r.DEFAULT:return S(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.errorMessage,this.allowedTypes,this);case r.DISABLED:return B(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.errorMessage,this.allowedTypes,this);case r.DRAG:return U();case r.ERROR:return w(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.errorMessage,this.allowedTypes,this);default:return S(this.browseFiles,this.title,this.subtitle,this.dragHandler,this.errorMessage,this.allowedTypes,this)}}disconnectedCallback(){this.emit(o.NILE_DESTROY)}};t([n({type:String})],F.prototype,"size",void 0),t([n({type:Boolean})],F.prototype,"error",void 0),t([n({type:String})],F.prototype,"errorMessage",void 0),t([n({type:Boolean})],F.prototype,"allowMultiple",void 0),t([n({type:Boolean})],F.prototype,"allowDuplicates",void 0),t([n({type:Array})],F.prototype,"allowedTypes",void 0),t([n({type:Array})],F.prototype,"uploadedFiles",void 0),t([n({type:String})],F.prototype,"title",void 0),t([n({type:String})],F.prototype,"subtitle",void 0),t([n({type:String})],F.prototype,"state",void 0),t([n({type:String})],F.prototype,"variant",void 0),t([n({type:String})],F.prototype,"fileUploadUrl",void 0),t([n({type:Boolean})],F.prototype,"autoUpload",void 0),t([p()],F.prototype,"doNotUpload",void 0),t([d("input")],F.prototype,"input",void 0),t([d(".horizontal-div")],F.prototype,"horizontalDiv",void 0),F=t([u("nile-file-upload")],F);export{F as N};
