window.wp=window.wp||{},function(e,a){var d;"undefined"!=typeof _wpPluploadSettings&&(d=function(e){var t,i,o=this,r={container:"container",browser:"browse_button",dropzone:"drop_element"};if(this.supports={upload:d.browser.supported},this.supported=this.supports.upload,this.supported){for(t in this.plupload=a.extend(!0,{multipart_params:{}},d.defaults),this.container=document.body,a.extend(!0,this,e),this)a.isFunction(this[t])&&(this[t]=a.proxy(this[t],this));for(t in r)this[t]&&(this[t]=a(this[t]).first(),this[t].length?(this[t].prop("id")||this[t].prop("id","__wp-uploader-id-"+d.uuid++),this.plupload[r[t]]=this[t].prop("id")):delete this[t]);(this.browser&&this.browser.length||this.dropzone&&this.dropzone.length)&&(this.uploader=new plupload.Uploader(this.plupload),delete this.plupload,this.param(this.params||{}),delete this.params,i=function(e,t,r){r.attachment&&r.attachment.destroy(),d.errors.unshift({message:e||pluploadL10n.default_error,data:t,file:r}),o.error(e,t,r)},this.uploader.init(),this.supports.dragdrop=this.uploader.features.dragdrop&&!d.browser.mobile,function(e,t){var r,o;if(e){if(e.toggleClass("supports-drag-drop",!!t),!t)return e.unbind(".wp-uploader");e.bind("dragover.wp-uploader",function(){r&&clearTimeout(r),o||(e.trigger("dropzone:enter").addClass("drag-over"),o=!0)}),e.bind("dragleave.wp-uploader, drop.wp-uploader",function(){r=setTimeout(function(){o=!1,e.trigger("dropzone:leave").removeClass("drag-over")},0)})}}(this.dropzone,this.supports.dragdrop),this.browser?this.browser.on("mouseenter",this.refresh):(this.uploader.disableBrowse(!0),a("#"+this.uploader.id+"_html5_container").hide()),this.uploader.bind("FilesAdded",function(e,t){_.each(t,function(e){var t,r;plupload.FAILED!==e.status&&(t=_.extend({file:e,uploading:!0,date:new Date,filename:e.name,menuOrder:0,uploadedTo:wp.media.model.settings.post.id},_.pick(e,"loaded","size","percent")),(r=/(?:jpe?g|png|gif)$/i.exec(e.name))&&(t.type="image",t.subtype="jpg"===r[0]?"jpeg":r[0]),e.attachment=wp.media.model.Attachment.create(t),d.queue.add(e.attachment),o.added(e.attachment))}),e.refresh(),e.start()}),this.uploader.bind("UploadProgress",function(e,t){t.attachment.set(_.pick(t,"loaded","percent")),o.progress(t.attachment)}),this.uploader.bind("FileUploaded",function(e,t,r){try{r=JSON.parse(r.response)}catch(e){return i(pluploadL10n.default_error,e,t)}return!_.isObject(r)||_.isUndefined(r.success)?i(pluploadL10n.default_error,null,t):r.success?(_.each(["file","loaded","size","percent"],function(e){t.attachment.unset(e)}),t.attachment.set(_.extend(r.data,{uploading:!1})),wp.media.model.Attachment.get(r.data.id,t.attachment),d.queue.all(function(e){return!e.get("uploading")})&&d.queue.reset(),void o.success(t.attachment)):i(r.data&&r.data.message,r.data,t)}),this.uploader.bind("Error",function(e,t){var r,o=pluploadL10n.default_error;for(r in d.errorMap)if(t.code===plupload[r]){o=d.errorMap[r],_.isFunction(o)&&(o=o(t.file,t));break}i(o,t,t.file),e.refresh()}),this.init())}},a.extend(d,_wpPluploadSettings),d.uuid=0,d.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,HTTP_ERROR:pluploadL10n.http_error,SECURITY_ERROR:pluploadL10n.security_error,FILE_SIZE_ERROR:function(e){return pluploadL10n.file_exceeds_size_limit.replace("%s",e.name)}},a.extend(d.prototype,{param:function(e,t){if(1===arguments.length&&"string"==typeof e)return this.uploader.settings.multipart_params[e];1').css({position:"fixed",top:"-1000px",left:"-1000px",height:0,width:0}).attr("id","wp-uploader-browser-"+this.uploader.id).appendTo("body"):r).append(this.browser))}this.uploader.refresh()}}),d.queue=new wp.media.model.Attachments([],{query:!1}),d.errors=new Backbone.Collection,e.Uploader=d)}(wp,jQuery);