// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../chunks/tslib.es6 ../../core/Accessor ../../core/asyncUtils ../../core/Error ../../core/events ../../core/promiseUtils ../../core/accessorSupport/decorators/property ../../core/has ../../core/Logger ../../core/RandomLCG ../../core/accessorSupport/decorators/subclass ../../geometry/Point ../../layers/graphics/sources/support/uploadProgressWeights ../../layers/support/infoFor3D ../../support/progressUtils".split(" "),function(b,f,p,q,r,t,k,h,A,B,C,u,v,w,x,n){async function y(c){const {resolve:e, promise:d}=k.createResolver(),a=document.createElement("input");a.type="file";a.multiple=!1;a.accept=[...x.getSupportedExtensions(c.infoFor3D),".zip"].join();a.style.display="none";document.body.appendChild(a);const g=t.on(a,"change",()=>e(a.files?Array.from(a.files):[]));l?l(a):a.click();return d.finally(()=>{g.remove();a.remove()})}b.Upload=class extends p{constructor(){super({});this.files=[];this.progress=0;this._layer=this._uploadTask=null}destroy(){this.cancel();this.files=[];this._uploadTask= this._layer=null}get state(){const c=this._uploadTask;return c&&0!==this.files.length?c.finished?c.error?"error":"success":"pending":"default"}get result(){return this._uploadTask?.value??null}get error(){return this._uploadTask?.error??null}uploadTo(c){this.cancel();this.files=[];this._layer=c;this._uploadTask=q.createTask(async e=>{var d=await y(c);k.throwIfAborted(e);this.progress=0;this.files=d;var a=n.makeProgressManager(w.uploadProgressWeights.upload,m=>{this.progress=m},"Upload.uploadTo"); if(0===d.length)return null;k.throwIfAborted(e);const g=await c.extractAndFilterFiles(d);k.throwIfAborted(e);0m+z.size,0);a=a.simulate("loadMesh",n.estimatedTransferTime(e));try{await d.load()}finally{a.remove()}return d})}retry(){this._layer&& this.uploadTo(this._layer)}cancel(){this._uploadTask?.abort()}};f.__decorate([h.property()],b.Upload.prototype,"files",void 0);f.__decorate([h.property()],b.Upload.prototype,"progress",void 0);f.__decorate([h.property()],b.Upload.prototype,"state",null);f.__decorate([h.property()],b.Upload.prototype,"result",null);f.__decorate([h.property()],b.Upload.prototype,"error",null);f.__decorate([h.property()],b.Upload.prototype,"_uploadTask",void 0);f.__decorate([h.property()],b.Upload.prototype,"_layer", void 0);b.Upload=f.__decorate([u.subclass("esri.widgets.Editor.Upload")],b.Upload);let l=null;b.clearPromptForFilesStub=function(){l=null};b.stubFilePickerToSelect=function(c){l=e=>{Promise.resolve().then(()=>c).then(d=>{if(l){var a=new DataTransfer;d.forEach(g=>a.items.add(g));e.files=a.files;e.dispatchEvent(new Event("change"))}})}};Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});