import{html as e,css as o}from"../../../lit/index.js";import{HAXStore as t}from"./hax-store.js";import{HaxUploadField as l}from"./hax-upload-field.js";import{autorun as a,toJS as i}from"../../../mobx/dist/mobx.esm.js";class HaxTrayUpload extends l{static get tag(){return"hax-tray-upload"}constructor(){super(),this.hideInput=!0,this.__winEvents=this.__winEvents||{},this.__winEvents={...this.__winEvents,"place-holder-file-drop":"_placeHolderFileDrop","hax-file-upload":"_uploadFile"},a((()=>{this._editModeChanged(i(t.editMode))}))}updated(e){super.updated&&super.updated(e),e.forEach(((e,o)=>{"t"===o&&(this.label=this.t.uploadMedia)}))}_editModeChanged(e){!e&&this.shadowRoot&&this.shadowRoot.querySelector("#fileupload")&&(this.shadowRoot.querySelector("#fileupload").files=[])}_fileUploadResponse(e){super._fileUploadResponse(e),this.newAssetConfigure()}_canUpload(){return!this.__allowUpload}newAssetConfigure(){let e={source:this.shadowRoot.querySelector("#url").value,title:this.shadowRoot.querySelector("#url").value};t.insertLogicFromValues(e,this)}_placeHolderFileDrop(e){t.activePlaceHolder=e.detail.placeHolderElement,this.shadowRoot.querySelector("#fileupload")._onDrop(e.detail)}_uploadFile(e){t.activePlaceHolder=e.detail.placeHolderElement,t.activePlaceHolderOperationType=e.detail.operationType,this.shadowRoot.querySelector("#fileupload")._addFile(e.detail.file)}}customElements.define(HaxTrayUpload.tag,HaxTrayUpload);export{HaxTrayUpload};