text: /**
   * skylark-widgets-wordpad - The skylark richeditor widget
   * @author Hudaokeji, Inc.
   * @version v0.9.0
   * @link https://github.com/skylark-widgets/skylark-widgets-wordpad/
   * @license MIT
   */
  define(["skylark-langx/langx","skylark-domx-query","skylark-net-http/xhr"],function(e,t,i){var n,o=e.Evented.inherit({init:function(i){var n;this.options=e.mixin({},this.options,i),this.files=[],this.queue=[],this.id=++o.count,this.on("uploadcomplete",(n=this,function(t,i){return n.files.splice(e.inArray(i,n.files),1),n.queue.length>0&&n.files.length<n.options.connectionCount?n.upload(n.queue.shift()):n.uploading=!1})),t(window).on("beforeunload.uploader-"+this.id,function(e){return function(t){if(e.uploading)return t.originalEvent.returnValue=e._t("leaveConfirm"),e._t("leaveConfirm")}}(this))}});return o.count=0,o.prototype.options={url:"",params:null,fileKey:"upload_file",connectionCount:3,headers:null},o.prototype.generateId=(n=0,function(){return n+=1}),o.prototype.upload=function(i,n){var o,r,l,a;if(null==n&&(n={}),null!=i){if(e.isArray(i)||i instanceof FileList)for(r=0,a=i.length;r<a;r++)o=i[r],this.upload(o,n);else t(i).is("input:file")?((l=t(i).attr("name"))&&(n.fileKey=l),this.upload(e.makeArray(t(i)[0].files),n)):i.id&&i.obj||(i=this.getFile(i));if(i&&i.obj)if(e.extend(i,n),this.files.length>=this.options.connectionCount)this.queue.push(i);else if(!1!==this.trigger("beforeupload",i))return this.files.push(i),this._xhrUpload(i),this.uploading=!0}},o.prototype.getFile=function(e){var t,i,n;return e instanceof window.File||e instanceof window.Blob?(t=null!=(i=e.fileName)?i:e.name,{id:this.generateId(),url:this.options.url,params:this.options.params,fileKey:this.options.fileKey,name:t,headers:this.options.headers,size:null!=(n=e.fileSize)?n:e.size,ext:t?t.split(".").pop().toLowerCase():"",obj:e}):null},o.prototype._xhrUpload=function(e){var t,n,o,r;if((t=new FormData).append(e.fileKey,e.obj),t.append("original_filename",e.name),e.params)for(n in o=e.params)r=o[n],t.append(n,r);var l=e.xhr=new i({url:this.options.url}),a={"X-File-Name":encodeURIComponent(e.name)};if(e.headers)for(n in o=e.headers)r=o[n],a[n]=r;var s=this;return l.post({data:t,processData:!1,contentType:!1,headers:a}).progress(function(t){if(t.lengthComputable)return s.trigger("uploadprogress",e,t.loaded,t.total)}).then(function(t){s.trigger("uploadsuccess",e,t),s.trigger("uploadcomplete")}).catch(function(t,i){s.trigger("uploaderror",e,l),s.trigger("uploadcomplete")}),l},o.prototype.cancel=function(e){var t,i,n,o;if(!e.id)for(i=0,n=(o=this.files).length;i<n;i++)if((t=o[i]).id===1*e){e=t;break}return this.trigger("uploadcancel",[e]),e.xhr&&e.xhr.abort(),e.xhr=null},o.prototype.destroy=function(){var e,i,n,o;for(this.queue.length=0,i=0,n=(o=this.files).length;i<n;i++)e=o[i],this.cancel(e);return t(window).off(".uploader-"+this.id),t(document).off(".uploader-"+this.id)},o.i18n={"zh-CN":{leaveConfirm:"正在上传文件，如果离开上传会自动取消"}},o.locale="zh-CN",function(e){return new o(e)}});
  //# sourceMappingURL=sourcemaps/uploader.js.map
  