(()=>{var __webpack_modules__=({7145
(module){var Selection=wp.media.model.Selection,Library=wp.media.controller.Library,CollectionAdd;CollectionAdd=Library.extend({defaults:_.defaults({multiple:'add',filterable:'uploaded',priority:100,syncSelection:false},Library.prototype.defaults),initialize:function(){var collectionType=this.get('collectionType');if('video'===this.get('type')){collectionType='video-'+collectionType;}
this.set('id',collectionType+'-library');this.set('toolbar',collectionType+'-add');this.set('menu',collectionType);if(!this.get('library')){this.set('library',wp.media.query({type:this.get('type')}));}
Library.prototype.initialize.apply(this,arguments);},activate:function(){var library=this.get('library'),editLibrary=this.get('editLibrary'),edit=this.frame.state(this.get('collectionType')+'-edit').get('library');if(editLibrary&&editLibrary!==edit){library.unobserve(editLibrary);}
library.validator=function(attachment){return!!this.mirroring.get(attachment.cid)&&!edit.get(attachment.cid)&&Selection.prototype.validator.apply(this,arguments);};library.reset(library.mirroring.models,{silent:true});library.observe(edit);this.set('editLibrary',edit);Library.prototype.activate.apply(this,arguments);}});module.exports=CollectionAdd;},8612
(module){var Library=wp.media.controller.Library,l10n=wp.media.view.l10n,$=jQuery,CollectionEdit;CollectionEdit=Library.extend({defaults:{multiple:false,sortable:true,date:false,searchable:false,content:'browse',describe:true,dragInfo:true,idealColumnWidth:170,editing:false,priority:60,SettingsView:false,syncSelection:false},initialize:function(){var collectionType=this.get('collectionType');if('video'===this.get('type')){collectionType='video-'+collectionType;}
this.set('id',collectionType+'-edit');this.set('toolbar',collectionType+'-edit');if(!this.get('library')){this.set('library',new wp.media.model.Selection());}
if(!this.get('AttachmentView')){this.set('AttachmentView',wp.media.view.Attachment.EditLibrary);}
Library.prototype.initialize.apply(this,arguments);},activate:function(){var library=this.get('library');library.props.set('type',this.get('type'));this.get('library').observe(wp.Uploader.queue);this.frame.on('content:render:browse',this.renderSettings,this);Library.prototype.activate.apply(this,arguments);},deactivate:function(){this.get('library').unobserve(wp.Uploader.queue);this.frame.off('content:render:browse',this.renderSettings,this);Library.prototype.deactivate.apply(this,arguments);},renderSettings:function(attachmentsBrowserView){var library=this.get('library'),collectionType=this.get('collectionType'),dragInfoText=this.get('dragInfoText'),SettingsView=this.get('SettingsView'),obj={};if(!library||!attachmentsBrowserView){return;}
library[collectionType]=library[collectionType]||new Backbone.Model();obj[collectionType]=new SettingsView({controller:this,model:library[collectionType],priority:40});attachmentsBrowserView.sidebar.set(obj);if(dragInfoText){attachmentsBrowserView.toolbar.set('dragInfo',new wp.media.View({el:$('<div class="instructions">'+dragInfoText+'</div>')[0],priority:-40}));}
attachmentsBrowserView.toolbar.set('reverse',{text:l10n.reverseOrder,priority:80,click:function(){library.reset(library.toArray().reverse());}});}});module.exports=CollectionEdit;},5422
(module){var l10n=wp.media.view.l10n,Cropper;Cropper=wp.media.controller.State.extend({defaults:{id:'cropper',title:l10n.cropImage,toolbar:'crop',content:'crop',router:false,canSkipCrop:false,doCropArgs:{}},activate:function(){this.frame.on('content:create:crop',this.createCropContent,this);this.frame.on('close',this.removeCropper,this);this.set('selection',new Backbone.Collection(this.frame._selection.single));},deactivate:function(){this.frame.toolbar.mode('browse');},createCropContent:function(){this.cropperView=new wp.media.view.Cropper({controller:this,attachment:this.get('selection').first()});this.cropperView.on('image-loaded',this.createCropToolbar,this);this.frame.content.set(this.cropperView);},removeCropper:function(){this.imgSelect.cancelSelection();this.imgSelect.setOptions({remove:true});this.imgSelect.update();this.cropperView.remove();},createCropToolbar:function(){var canSkipCrop,hasRequiredAspectRatio,suggestedCropSize,toolbarOptions;suggestedCropSize=this.get('suggestedCropSize');hasRequiredAspectRatio=this.get('hasRequiredAspectRatio');canSkipCrop=this.get('canSkipCrop')||false;toolbarOptions={controller:this.frame,items:{insert:{style:'primary',text:l10n.cropImage,priority:80,requires:{library:false,selection:false},click:function(){var controller=this.controller,selection;selection=controller.state().get('selection').first();selection.set({cropDetails:controller.state().imgSelect.getSelection()});this.$el.text(l10n.cropping);this.$el.prop('disabled',true);controller.state().doCrop(selection).done(function(croppedImage){controller.trigger('cropped',croppedImage);controller.close();}).fail(function(){controller.trigger('content:error:crop');});}}}};if(canSkipCrop||hasRequiredAspectRatio){_.extend(toolbarOptions.items,{skip:{style:'secondary',text:l10n.skipCropping,priority:70,requires:{library:false,selection:false},click:function(){var controller=this.controller,selection=controller.state().get('selection').first();controller.state().cropperView.remove();if(hasRequiredAspectRatio&&!canSkipCrop){selection.set({cropDetails:suggestedCropSize});controller.state().doCrop(selection).done(function(croppedImage){controller.trigger('cropped',croppedImage);controller.close();}).fail(function(){controller.trigger('content:error:crop');});return;}
controller.trigger('skippedcrop',selection);controller.close();}}});}
this.frame.toolbar.set(new wp.media.view.Toolbar(toolbarOptions));},doCrop:function(attachment){return wp.ajax.post('custom-header-crop',_.extend({},this.defaults.doCropArgs,{nonce:attachment.get('nonces').edit,id:attachment.get('id'),cropDetails:attachment.get('cropDetails')}));}});module.exports=Cropper;},9660
(module){var Controller=wp.media.controller,CustomizeImageCropper;CustomizeImageCropper=Controller.Cropper.extend({doCrop:function(attachment){var cropDetails=attachment.get('cropDetails'),control=this.get('control'),ratio=cropDetails.width / cropDetails.height;if(control.params.flex_width&&control.params.flex_height){cropDetails.dst_width=cropDetails.width;cropDetails.dst_height=cropDetails.height;}else{cropDetails.dst_width=control.params.flex_width?control.params.height*ratio:control.params.width;cropDetails.dst_height=control.params.flex_height?control.params.width / ratio:control.params.height;}
return wp.ajax.post('crop-image',{wp_customize:'on',nonce:attachment.get('nonces').edit,id:attachment.get('id'),context:control.id,cropDetails:cropDetails});}});module.exports=CustomizeImageCropper;},5663
(module){var l10n=wp.media.view.l10n,EditImage;EditImage=wp.media.controller.State.extend({defaults:{id:'edit-image',title:l10n.editImage,menu:false,toolbar:'edit-image',content:'edit-image',url:''},activate:function(){this.frame.on('toolbar:render:edit-image',_.bind(this.toolbar,this));},deactivate:function(){this.frame.off('toolbar:render:edit-image');},toolbar:function(){var frame=this.frame,lastState=frame.lastState(),previous=lastState&&lastState.id;frame.toolbar.set(new wp.media.view.Toolbar({controller:frame,items:{back:{style:'primary',text:l10n.back,priority:20,click:function(){if(previous){frame.setState(previous);}else{frame.close();}}}}}));}});module.exports=EditImage;},4910
(module){var l10n=wp.media.view.l10n,$=Backbone.$,Embed;Embed=wp.media.controller.State.extend({defaults:{id:'embed',title:l10n.insertFromUrlTitle,content:'embed',menu:'default',toolbar:'main-embed',priority:120,type:'link',url:'',metadata:{}},sensitivity:400,initialize:function(options){this.metadata=options.metadata;this.debouncedScan=_.debounce(_.bind(this.scan,this),this.sensitivity);this.props=new Backbone.Model(this.metadata||{url:''});this.props.on('change:url',this.debouncedScan,this);this.props.on('change:url',this.refresh,this);this.on('scan',this.scanImage,this);},scan:function(){var scanners,embed=this,attributes={type:'link',scanners:[]};if(this.props.get('url')){this.trigger('scan',attributes);}
if(attributes.scanners.length){scanners=attributes.scanners=$.when.apply($,attributes.scanners);scanners.always(function(){if(embed.get('scanners')===scanners){embed.set('loading',false);}});}else{attributes.scanners=null;}
attributes.loading=!!attributes.scanners;this.set(attributes);},scanImage:function(attributes){var frame=this.frame,state=this,url=this.props.get('url'),image=new Image(),deferred=$.Deferred();attributes.scanners.push(deferred.promise());image.onload=function(){deferred.resolve();if(state!==frame.state()||url!==state.props.get('url')){return;}
state.set({type:'image'});state.props.set({width:image.width,height:image.height});};image.onerror=deferred.reject;image.src=url;},refresh:function(){this.frame.toolbar.get().refresh();},reset:function(){this.props.clear().set({url:''});if(this.active){this.refresh();}}});module.exports=Embed;},1169
(module){var Attachment=wp.media.model.Attachment,Library=wp.media.controller.Library,l10n=wp.media.view.l10n,FeaturedImage;FeaturedImage=Library.extend({defaults:_.defaults({id:'featured-image',title:l10n.setFeaturedImageTitle,multiple:false,filterable:'uploaded',toolbar:'featured-image',priority:60,syncSelection:true},Library.prototype.defaults),initialize:function(){var library,comparator;if(!this.get('library')){this.set('library',wp.media.query({type:'image'}));}
Library.prototype.initialize.apply(this,arguments);library=this.get('library');comparator=library.comparator;library.comparator=function(a,b){var aInQuery=!!this.mirroring.get(a.cid),bInQuery=!!this.mirroring.get(b.cid);if(!aInQuery&&bInQuery){return-1;}else if(aInQuery&&!bInQuery){return 1;}else{return comparator.apply(this,arguments);}};library.observe(this.get('selection'));},activate:function(){this.frame.on('open',this.updateSelection,this);Library.prototype.activate.apply(this,arguments);},deactivate:function(){this.frame.off('open',this.updateSelection,this);Library.prototype.deactivate.apply(this,arguments);},updateSelection:function(){var selection=this.get('selection'),id=wp.media.view.settings.post.featuredImageId,attachment;if(''!==id&&-1!==id){attachment=Attachment.get(id);attachment.fetch();}
selection.reset(attachment?[attachment]:[]);}});module.exports=FeaturedImage;},7127
(module){var Selection=wp.media.model.Selection,Library=wp.media.controller.Library,l10n=wp.media.view.l10n,GalleryAdd;GalleryAdd=Library.extend({defaults:_.defaults({id:'gallery-library',title:l10n.addToGalleryTitle,multiple:'add',filterable:'uploaded',menu:'gallery',toolbar:'gallery-add',priority:100,syncSelection:false},Library.prototype.defaults),initialize:function(){if(!this.get('library')){this.set('library',wp.media.query({type:'image'}));}
Library.prototype.initialize.apply(this,arguments);},activate:function(){var library=this.get('library'),edit=this.frame.state('gallery-edit').get('library');if(this.editLibrary&&this.editLibrary!==edit){library.unobserve(this.editLibrary);}
library.validator=function(attachment){return!!this.mirroring.get(attachment.cid)&&!edit.get(attachment.cid)&&Selection.prototype.validator.apply(this,arguments);};library.reset(library.mirroring.models,{silent:true});library.observe(edit);this.editLibrary=edit;Library.prototype.activate.apply(this,arguments);}});module.exports=GalleryAdd;},2038
(module){var Library=wp.media.controller.Library,l10n=wp.media.view.l10n,GalleryEdit;GalleryEdit=Library.extend({defaults:{id:'gallery-edit',title:l10n.editGalleryTitle,multiple:false,searchable:false,sortable:true,date:false,display:false,content:'browse',toolbar:'gallery-edit',describe:true,displaySettings:true,dragInfo:true,idealColumnWidth:170,editing:false,priority:60,syncSelection:false},initialize:function(){if(!this.get('library')){this.set('library',new wp.media.model.Selection());}
if(!this.get('AttachmentView')){this.set('AttachmentView',wp.media.view.Attachment.EditLibrary);}
Library.prototype.initialize.apply(this,arguments);},activate:function(){var library=this.get('library');library.props.set('type','image');this.get('library').observe(wp.Uploader.queue);this.frame.on('content:render:browse',this.gallerySettings,this);Library.prototype.activate.apply(this,arguments);},deactivate:function(){this.get('library').unobserve(wp.Uploader.queue);this.frame.off('content:render:browse',this.gallerySettings,this);Library.prototype.deactivate.apply(this,arguments);},gallerySettings:function(browser){if(!this.get('displaySettings')){return;}
var library=this.get('library');if(!library||!browser){return;}
library.gallery=library.gallery||new Backbone.Model();browser.sidebar.set({gallery:new wp.media.view.Settings.Gallery({controller:this,model:library.gallery,priority:40})});browser.toolbar.set('reverse',{text:l10n.reverseOrder,priority:80,click:function(){library.reset(library.toArray().reverse());}});}});module.exports=GalleryEdit;},705
(module){var State=wp.media.controller.State,Library=wp.media.controller.Library,l10n=wp.media.view.l10n,ImageDetails;ImageDetails=State.extend({defaults:_.defaults({id:'image-details',title:l10n.imageDetailsTitle,content:'image-details',menu:false,router:false,toolbar:'image-details',editing:false,priority:60},Library.prototype.defaults),initialize:function(options){this.image=options.image;State.prototype.initialize.apply(this,arguments);},activate:function(){this.frame.modal.$el.addClass('image-details');}});module.exports=ImageDetails;},472
(module){var l10n=wp.media.view.l10n,getUserSetting=window.getUserSetting,setUserSetting=window.setUserSetting,Library;Library=wp.media.controller.State.extend({defaults:{id:'library',title:l10n.mediaLibraryTitle,multiple:false,content:'upload',menu:'default',router:'browse',toolbar:'select',searchable:true,filterable:false,sortable:true,autoSelect:true,describe:false,contentUserSetting:true,syncSelection:true},initialize:function(){var selection=this.get('selection'),props;if(!this.get('library')){this.set('library',wp.media.query());}
if(!(selection instanceof wp.media.model.Selection)){props=selection;if(!props){props=this.get('library').props.toJSON();props=_.omit(props,'orderby','query');}
this.set('selection',new wp.media.model.Selection(null,{multiple:this.get('multiple'),props:props}));}
this.resetDisplays();},activate:function(){this.syncSelection();wp.Uploader.queue.on('add',this.uploading,this);this.get('selection').on('add remove reset',this.refreshContent,this);if(this.get('router')&&this.get('contentUserSetting')){this.frame.on('content:activate',this.saveContentMode,this);this.set('content',getUserSetting('libraryContent',this.get('content')));}},deactivate:function(){this.recordSelection();this.frame.off('content:activate',this.saveContentMode,this);this.get('selection').off(null,null,this);wp.Uploader.queue.off(null,null,this);},reset:function(){this.get('selection').reset();this.resetDisplays();this.refreshContent();},resetDisplays:function(){var defaultProps=wp.media.view.settings.defaultProps;this._displays=[];this._defaultDisplaySettings={align:getUserSetting('align',defaultProps.align)||'none',size:getUserSetting('imgsize',defaultProps.size)||'medium',link:getUserSetting('urlbutton',defaultProps.link)||'none'};},display:function(attachment){var displays=this._displays;if(!displays[attachment.cid]){displays[attachment.cid]=new Backbone.Model(this.defaultDisplaySettings(attachment));}
return displays[attachment.cid];},defaultDisplaySettings:function(attachment){var settings=_.clone(this._defaultDisplaySettings);settings.canEmbed=this.canEmbed(attachment);if(settings.canEmbed){settings.link='embed';}else if(!this.isImageAttachment(attachment)&&settings.link==='none'){settings.link='file';}
return settings;},isImageAttachment:function(attachment){if(attachment.get('uploading')){return/\.(jpe?g|png|gif|webp|avif|heic|heif)$/i.test(attachment.get('filename'));}
return attachment.get('type')==='image';},canEmbed:function(attachment){if(!attachment.get('uploading')){var type=attachment.get('type');if(type!=='audio'&&type!=='video'){return false;}}
return _.contains(wp.media.view.settings.embedExts,attachment.get('filename').split('.').pop());},refreshContent:function(){var selection=this.get('selection'),frame=this.frame,router=frame.router.get(),mode=frame.content.mode();if(this.active&&!selection.length&&router&&!router.get(mode)){this.frame.content.render(this.get('content'));}},uploading:function(attachment){var content=this.frame.content;if('upload'===content.mode()){this.frame.content.mode('browse');}
if(this.get('autoSelect')){this.get('selection').add(attachment);this.frame.trigger('library:selection:add');}},saveContentMode:function(){if('browse'!==this.get('router')){return;}
var mode=this.frame.content.mode(),view=this.frame.router.get();if(view&&view.get(mode)){setUserSetting('libraryContent',mode);}}});_.extend(Library.prototype,wp.media.selectionSync);module.exports=Library;},8065
(module){var Library=wp.media.controller.Library,MediaLibrary;MediaLibrary=Library.extend({defaults:_.defaults({filterable:'uploaded',displaySettings:false,priority:80,syncSelection:false},Library.prototype.defaults),initialize:function(options){this.media=options.media;this.type=options.type;this.set('library',wp.media.query({type:this.type}));Library.prototype.initialize.apply(this,arguments);},activate:function(){if(wp.media.frame.lastMime){this.set('library',wp.media.query({type:wp.media.frame.lastMime}));delete wp.media.frame.lastMime;}
Library.prototype.activate.apply(this,arguments);}});module.exports=MediaLibrary;},9875
(module){var Region=function(options){_.extend(this,_.pick(options||{},'id','view','selector'));};Region.extend=Backbone.Model.extend;_.extend(Region.prototype,{mode:function(mode){if(!mode){return this._mode;}
if(mode===this._mode){return this;}
this.trigger('deactivate');this._mode=mode;this.render(mode);this.trigger('activate');return this;},render:function(mode){if(mode&&mode!==this._mode){return this.mode(mode);}
var set={view:null},view;this.trigger('create',set);view=set.view;this.trigger('render',view);if(view){this.set(view);}
return this;},get:function(){return this.view.views.first(this.selector);},set:function(views,options){if(options){options.add=false;}
return this.view.views.set(this.selector,views,options);},trigger:function(event){var base,args;if(!this._mode){return;}
args=_.toArray(arguments);base=this.id+':'+event;args[0]=base+':'+this._mode;this.view.trigger.apply(this.view,args);args[0]=base;this.view.trigger.apply(this.view,args);return this;}});module.exports=Region;},2275
(module){var Library=wp.media.controller.Library,l10n=wp.media.view.l10n,ReplaceImage;ReplaceImage=Library.extend({defaults:_.defaults({id:'replace-image',title:l10n.replaceImageTitle,multiple:false,filterable:'uploaded',toolbar:'replace',menu:false,priority:60,syncSelection:true},Library.prototype.defaults),initialize:function(options){var library,comparator;this.image=options.image;if(!this.get('library')){this.set('library',wp.media.query({type:'image'}));}
Library.prototype.initialize.apply(this,arguments);library=this.get('library');comparator=library.comparator;library.comparator=function(a,b){var aInQuery=!!this.mirroring.get(a.cid),bInQuery=!!this.mirroring.get(b.cid);if(!aInQuery&&bInQuery){return-1;}else if(aInQuery&&!bInQuery){return 1;}else{return comparator.apply(this,arguments);}};library.observe(this.get('selection'));},activate:function(){this.frame.on('content:render:browse',this.updateSelection,this);Library.prototype.activate.apply(this,arguments);},deactivate:function(){this.frame.off('content:render:browse',this.updateSelection,this);Library.prototype.deactivate.apply(this,arguments);},updateSelection:function(){var selection=this.get('selection'),attachment=this.image.attachment;selection.reset(attachment?[attachment]:[]);}});module.exports=ReplaceImage;},6172
(module){var Controller=wp.media.controller,SiteIconCropper;SiteIconCropper=Controller.Cropper.extend({activate:function(){this.frame.on('content:create:crop',this.createCropContent,this);this.frame.on('close',this.removeCropper,this);this.set('selection',new Backbone.Collection(this.frame._selection.single));},createCropContent:function(){this.cropperView=new wp.media.view.SiteIconCropper({controller:this,attachment:this.get('selection').first()});this.cropperView.on('image-loaded',this.createCropToolbar,this);this.frame.content.set(this.cropperView);},doCrop:function(attachment){var cropDetails=attachment.get('cropDetails'),control=this.get('control');cropDetails.dst_width=control.params.width;cropDetails.dst_height=control.params.height;return wp.ajax.post('crop-image',{nonce:attachment.get('nonces').edit,id:attachment.get('id'),context:'site-icon',cropDetails:cropDetails});}});module.exports=SiteIconCropper;},6150
(module){var StateMachine=function(){return{extend:Backbone.Model.extend};};_.extend(StateMachine.prototype,Backbone.Events,{state:function(id){this.states=this.states||new Backbone.Collection();id=id||this._state;if(id&&!this.states.get(id)){this.states.add({id:id});}
return this.states.get(id);},setState:function(id){var previous=this.state();if((previous&&id===previous.id)||!this.states||!this.states.get(id)){return this;}
if(previous){previous.trigger('deactivate');this._lastState=previous.id;}
this._state=id;this.state().trigger('activate');return this;},lastState:function(){if(this._lastState){return this.state(this._lastState);}}});_.each(['on','off','trigger'],function(method){StateMachine.prototype[method]=function(){this.states=this.states||new Backbone.Collection();this.states[method].apply(this.states,arguments);return this;};});module.exports=StateMachine;},5694
(module){var State=Backbone.Model.extend({constructor:function(){this.on('activate',this._preActivate,this);this.on('activate',this.activate,this);this.on('activate',this._postActivate,this);this.on('deactivate',this._deactivate,this);this.on('deactivate',this.deactivate,this);this.on('reset',this.reset,this);this.on('ready',this._ready,this);this.on('ready',this.ready,this);Backbone.Model.apply(this,arguments);this.on('change:menu',this._updateMenu,this);},ready:function(){},activate:function(){},deactivate:function(){},reset:function(){},_ready:function(){this._updateMenu();},_preActivate:function(){this.active=true;},_postActivate:function(){this.on('change:menu',this._menu,this);this.on('change:titleMode',this._title,this);this.on('change:content',this._content,this);this.on('change:toolbar',this._toolbar,this);this.frame.on('title:render:default',this._renderTitle,this);this._title();this._menu();this._toolbar();this._content();this._router();},_deactivate:function(){this.active=false;this.frame.off('title:render:default',this._renderTitle,this);this.off('change:menu',this._menu,this);this.off('change:titleMode',this._title,this);this.off('change:content',this._content,this);this.off('change:toolbar',this._toolbar,this);},_title:function(){this.frame.title.render(this.get('titleMode')||'default');},_renderTitle:function(view){view.$el.text(this.get('title')||'');},_router:function(){var router=this.frame.router,mode=this.get('router'),view;this.frame.$el.toggleClass('hide-router',!mode);if(!mode){return;}
this.frame.router.render(mode);view=router.get();if(view&&view.select){view.select(this.frame.content.mode());}},_menu:function(){var menu=this.frame.menu,mode=this.get('menu'),actionMenuItems,actionMenuLength,view;if(this.frame.menu){actionMenuItems=this.frame.menu.get('views'),actionMenuLength=actionMenuItems?actionMenuItems.views.get().length:0,this.frame.$el.toggleClass('hide-menu',!mode||actionMenuLength<2);}
if(!mode){return;}
menu.mode(mode);view=menu.get();if(view&&view.select){view.select(this.id);}},_updateMenu:function(){var previous=this.previous('menu'),menu=this.get('menu');if(previous){this.frame.off('menu:render:'+previous,this._renderMenu,this);}
if(menu){this.frame.on('menu:render:'+menu,this._renderMenu,this);}},_renderMenu:function(view){var menuItem=this.get('menuItem'),title=this.get('title'),priority=this.get('priority');if(!menuItem&&title){menuItem={text:title};if(priority){menuItem.priority=priority;}}
if(!menuItem){return;}
view.set(this.id,menuItem);}});_.each(['toolbar','content'],function(region){State.prototype['_'+region]=function(){var mode=this.get(region);if(mode){this.frame[region].render(mode);}};});module.exports=State;},4181
(module){var selectionSync={syncSelection:function(){var selection=this.get('selection'),manager=this.frame._selection;if(!this.get('syncSelection')||!manager||!selection){return;}
if(selection.multiple){selection.reset([],{silent:true});selection.validateAll(manager.attachments);manager.difference=_.difference(manager.attachments.models,selection.models);}
selection.single(manager.single);},recordSelection:function(){var selection=this.get('selection'),manager=this.frame._selection;if(!this.get('syncSelection')||!manager||!selection){return;}
if(selection.multiple){manager.attachments.reset(selection.toArray().concat(manager.difference));manager.difference=[];}else{manager.attachments.add(selection.toArray());}
manager.single=selection._single;}};module.exports=selectionSync;},2982
(module){var View=wp.media.View,AttachmentCompat;AttachmentCompat=View.extend({tagName:'form',className:'compat-item',events:{'submit':'preventDefault','change input':'save','change select':'save','change textarea':'save'},initialize:function(){this.listenTo(this.model,'add',this.render);},dispose:function(){if(this.$(':focus').length){this.save();}
return View.prototype.dispose.apply(this,arguments);},render:function(){var compat=this.model.get('compat');if(!compat||!compat.item){return;}
this.views.detach();this.$el.html(compat.item);this.views.render();return this;},preventDefault:function(event){event.preventDefault();},save:function(event){var data={};if(event){event.preventDefault();}
_.each(this.$el.serializeArray(),function(pair){data[pair.name]=pair.value;});this.controller.trigger('attachment:compat:waiting',['waiting']);this.model.saveCompat(data).always(_.bind(this.postSave,this));},postSave:function(){this.controller.trigger('attachment:compat:ready',['ready']);}});module.exports=AttachmentCompat;},7709
(module){var $=jQuery,AttachmentFilters;AttachmentFilters=wp.media.View.extend({tagName:'select',className:'attachment-filters',id:'media-attachment-filters',events:{change:'change'},keys:[],initialize:function(){this.createFilters();_.extend(this.filters,this.options.filters);this.$el.html(_.chain(this.filters).map(function(filter,value){return{el:$('<option></option>').val(value).html(filter.text)[0],priority:filter.priority||50};},this).sortBy('priority').pluck('el').value());this.listenTo(this.model,'change',this.select);this.select();},createFilters:function(){this.filters={};},change:function(){var filter=this.filters[this.el.value];if(filter){this.model.set(filter.props);}},select:function(){var model=this.model,value='all',props=model.toJSON();_.find(this.filters,function(filter,id){var equal=_.all(filter.props,function(prop,key){return prop===(_.isUndefined(props[key])?null:props[key]);});if(equal){return value=id;}});this.$el.val(value);}});module.exports=AttachmentFilters;},7349
(module){var l10n=wp.media.view.l10n,All;All=wp.media.view.AttachmentFilters.extend({createFilters:function(){var filters={},uid=window.userSettings?parseInt(window.userSettings.uid,10):0;_.each(wp.media.view.settings.mimeTypes||{},function(text,key){filters[key]={text:text,props:{status:null,type:key,uploadedTo:null,orderby:'date',order:'DESC',author:null}};});filters.all={text:l10n.allMediaItems,props:{status:null,type:null,uploadedTo:null,orderby:'date',order:'DESC',author:null},priority:10};if(wp.media.view.settings.post.id){filters.uploaded={text:l10n.uploadedToThisPost,props:{status:null,type:null,uploadedTo:wp.media.view.settings.post.id,orderby:'menuOrder',order:'ASC',author:null},priority:20};}
filters.unattached={text:l10n.unattached,props:{status:null,uploadedTo:0,type:null,orderby:'menuOrder',order:'ASC',author:null},priority:50};if(uid){filters.mine={text:l10n.mine,props:{status:null,type:null,uploadedTo:null,orderby:'date',order:'DESC',author:uid},priority:50};}
if(wp.media.view.settings.mediaTrash&&this.controller.isModeActive('grid')){filters.trash={text:l10n.trash,props:{uploadedTo:null,status:'trash',type:null,orderby:'date',order:'DESC',author:null},priority:50};}
this.filters=filters;}});module.exports=All;},6472
(module){var l10n=wp.media.view.l10n,DateFilter;DateFilter=wp.media.view.AttachmentFilters.extend({id:'media-attachment-date-filters',createFilters:function(){var filters={};_.each(wp.media.view.settings.months||{},function(value,index){filters[index]={text:value.text,props:{year:value.year,monthnum:value.month}};});filters.all={text:l10n.allDates,props:{monthnum:false,year:false},priority:10};this.filters=filters;}});module.exports=DateFilter;},1368
(module){var l10n=wp.media.view.l10n,Uploaded;Uploaded=wp.media.view.AttachmentFilters.extend({createFilters:function(){var type=this.model.get('type'),types=wp.media.view.settings.mimeTypes,uid=window.userSettings?parseInt(window.userSettings.uid,10):0,text;if(types&&type){text=types[type];}
this.filters={all:{text:text||l10n.allMediaItems,props:{uploadedTo:null,orderby:'date',order:'DESC',author:null},priority:10},uploaded:{text:l10n.uploadedToThisPost,props:{uploadedTo:wp.media.view.settings.post.id,orderby:'menuOrder',order:'ASC',author:null},priority:20},unattached:{text:l10n.unattached,props:{uploadedTo:0,orderby:'menuOrder',order:'ASC',author:null},priority:50}};if(uid){this.filters.mine={text:l10n.mine,props:{orderby:'date',order:'DESC',author:uid},priority:50};}}});module.exports=Uploaded;},4075
(module){var View=wp.media.View,$=jQuery,Attachment;Attachment=View.extend({tagName:'li',className:'attachment',template:wp.template('attachment'),attributes:function(){var ariaLabel=this.model.get('title');if(!ariaLabel){if(this.model.get('uploading')){ariaLabel=wp.i18n.__('uploading…');}else{ariaLabel=wp.i18n.__('(no title)');}}
return{'tabIndex':0,'role':'checkbox','aria-label':ariaLabel,'aria-checked':false,'data-id':this.model.get('id')};},events:{'click':'toggleSelectionHandler','change [data-setting]':'updateSetting','change [data-setting] input':'updateSetting','change [data-setting] select':'updateSetting','change [data-setting] textarea':'updateSetting','click .attachment-close':'removeFromLibrary','click .check':'checkClickHandler','keydown':'toggleSelectionHandler'},buttons:{},initialize:function(){var selection=this.options.selection,options=_.defaults(this.options,{rerenderOnModelChange:true});if(options.rerenderOnModelChange){this.listenTo(this.model,'change',this.render);}else{this.listenTo(this.model,'change:percent',this.progress);}
this.listenTo(this.model,'change:title',this._syncTitle);this.listenTo(this.model,'change:caption',this._syncCaption);this.listenTo(this.model,'change:artist',this._syncArtist);this.listenTo(this.model,'change:album',this._syncAlbum);this.listenTo(this.model,'add',this.select);this.listenTo(this.model,'remove',this.deselect);if(selection){selection.on('reset',this.updateSelect,this);this.listenTo(this.model,'selection:single selection:unsingle',this.details);this.details(this.model,this.controller.state().get('selection'));}
this.listenTo(this.controller.states,'attachment:compat:waiting attachment:compat:ready',this.updateSave);},dispose:function(){var selection=this.options.selection;this.updateAll();if(selection){selection.off(null,null,this);}
View.prototype.dispose.apply(this,arguments);return this;},render:function(){var options=_.defaults(this.model.toJSON(),{orientation:'landscape',uploading:false,type:'',subtype:'',icon:'',filename:'',caption:'',title:'',dateFormatted:'',width:'',height:'',compat:false,alt:'',description:''},this.options);options.buttons=this.buttons;options.describe=this.controller.state().get('describe');if('image'===options.type){options.size=this.imageSize();}
options.can={};if(options.nonces){options.can.remove=!!options.nonces['delete'];options.can.save=!!options.nonces.update;}
if(this.controller.state().get('allowLocalEdits')&&!options.uploading){options.allowLocalEdits=true;}
if(options.uploading&&!options.percent){options.percent=0;}
this.views.detach();this.$el.html(this.template(options));this.$el.toggleClass('uploading',options.uploading);if(options.uploading){this.$bar=this.$('.media-progress-bar div');}else{delete this.$bar;}
this.updateSelect();this.updateSave();this.views.render();return this;},progress:function(){if(this.$bar&&this.$bar.length){this.$bar.width(this.model.get('percent')+'%');}},toggleSelectionHandler:function(event){var method;if('INPUT'===event.target.nodeName||'BUTTON'===event.target.nodeName){return;}
if(37===event.keyCode||38===event.keyCode||39===event.keyCode||40===event.keyCode){this.controller.trigger('attachment:keydown:arrow',event);return;}
if('keydown'===event.type&&13!==event.keyCode&&32!==event.keyCode){return;}
event.preventDefault();if(this.controller.isModeActive('grid')){if(this.controller.isModeActive('edit')){this.controller.trigger('edit:attachment',this.model,event.currentTarget);return;}
if(this.controller.isModeActive('select')){method='toggle';}}
if(event.shiftKey){method='between';}else if(event.ctrlKey||event.metaKey){method='toggle';}
if((event.metaKey||event.ctrlKey)&&(13===event.keyCode||10===event.keyCode)){return;}
this.toggleSelection({method:method});this.controller.trigger('selection:toggle');},toggleSelection:function(options){var collection=this.collection,selection=this.options.selection,model=this.model,method=options&&options.method,single,models,singleIndex,modelIndex;if(!selection){return;}
single=selection.single();method=_.isUndefined(method)?selection.multiple:method;if('between'===method&&single&&selection.multiple){if(single===model){return;}
singleIndex=collection.indexOf(single);modelIndex=collection.indexOf(this.model);if(singleIndex<modelIndex){models=collection.models.slice(singleIndex,modelIndex+1);}else{models=collection.models.slice(modelIndex,singleIndex+1);}
selection.add(models);selection.single(model);return;}else if('toggle'===method){selection[this.selected()?'remove':'add'](model);selection.single(model);return;}else if('add'===method){selection.add(model);selection.single(model);return;}
if(!method){method='add';}
if(method!=='add'){method='reset';}
if(this.selected()){selection[single===model?'remove':'single'](model);}else{selection[method](model);selection.single(model);}},updateSelect:function(){this[this.selected()?'select':'deselect']();},selected:function(){var selection=this.options.selection;if(selection){return!!selection.get(this.model.cid);}},select:function(model,collection){var selection=this.options.selection,controller=this.controller;if(!selection||(collection&&collection!==selection)){return;}
if(this.$el.hasClass('selected')){return;}
this.$el.addClass('selected').attr('aria-checked',true);if(!(controller.isModeActive('grid')&&controller.isModeActive('select'))){this.$('.check').attr('tabindex','0');}},deselect:function(model,collection){var selection=this.options.selection;if(!selection||(collection&&collection!==selection)){return;}
this.$el.removeClass('selected').attr('aria-checked',false).find('.check').attr('tabindex','-1');},details:function(model,collection){var selection=this.options.selection,details;if(selection!==collection){return;}
details=selection.single();this.$el.toggleClass('details',details===this.model);},imageSize:function(size){var sizes=this.model.get('sizes'),matched=false;size=size||'medium';if(sizes){if(sizes[size]){matched=sizes[size];}else if(sizes.large){matched=sizes.large;}else if(sizes.thumbnail){matched=sizes.thumbnail;}else if(sizes.full){matched=sizes.full;}
if(matched){return _.clone(matched);}}
return{url:this.model.get('url'),width:this.model.get('width'),height:this.model.get('height'),orientation:this.model.get('orientation')};},updateSetting:function(event){var $setting=$(event.target).closest('[data-setting]'),setting,value;if(!$setting.length){return;}
setting=$setting.data('setting');value=event.target.value;if(this.model.get(setting)!==value){this.save(setting,value);}},save:function(){var view=this,save=this._save=this._save||{status:'ready'},request=this.model.save.apply(this.model,arguments),requests=save.requests?$.when(request,save.requests):request;if(save.savedTimer){clearTimeout(save.savedTimer);}
this.updateSave('waiting');save.requests=requests;requests.always(function(){if(save.requests!==requests){return;}
view.updateSave(requests.state()==='resolved'?'complete':'error');save.savedTimer=setTimeout(function(){view.updateSave('ready');delete save.savedTimer;},2000);});},updateSave:function(status){var save=this._save=this._save||{status:'ready'};if(status&&status!==save.status){this.$el.removeClass('save-'+save.status);save.status=status;}
this.$el.addClass('save-'+save.status);return this;},updateAll:function(){var $settings=this.$('[data-setting]'),model=this.model,changed;changed=_.chain($settings).map(function(el){var $input=$('input, textarea, select, [value]',el),setting,value;if(!$input.length){return;}
setting=$(el).data('setting');value=$input.val();if(model.get(setting)!==value){return[setting,value];}}).compact().object().value();if(!_.isEmpty(changed)){model.save(changed);}},removeFromLibrary:function(event){if('keydown'===event.type&&13!==event.keyCode&&32!==event.keyCode){return;}
event.stopPropagation();this.collection.remove(this.model);},checkClickHandler:function(event){var selection=this.options.selection;if(!selection){return;}
event.stopPropagation();if(selection.where({id:this.model.get('id')}).length){selection.remove(this.model);this.$el.focus();}else{selection.add(this.model);}
this.controller.trigger('selection:toggle');}});_.each({caption:'_syncCaption',title:'_syncTitle',artist:'_syncArtist',album:'_syncAlbum'},function(method,setting){Attachment.prototype[method]=function(model,value){var $setting=this.$('[data-setting="'+setting+'"]');if(!$setting.length){return this;}
if(value===$setting.find('input, textarea, select, [value]').val()){return this;}
return this.render();};});module.exports=Attachment;},6090
(module){var Attachment=wp.media.view.Attachment,l10n=wp.media.view.l10n,$=jQuery,Details,__=wp.i18n.__;Details=Attachment.extend({tagName:'div',className:'attachment-details',template:wp.template('attachment-details'),attributes:{},events:{'change [data-setting]':'updateSetting','change [data-setting] input':'updateSetting','change [data-setting] select':'updateSetting','change [data-setting] textarea':'updateSetting','click .delete-attachment':'deleteAttachment','click .trash-attachment':'trashAttachment','click .untrash-attachment':'untrashAttachment','click .edit-attachment':'editAttachment','keydown':'toggleSelectionHandler'},copyAttachmentDetailsURLClipboard:function(){var clipboard=new ClipboardJS('.copy-attachment-url'),successTimeout;clipboard.on('success',function(event){var triggerElement=$(event.trigger),successElement=$('.success',triggerElement.closest('.copy-to-clipboard-container'));event.clearSelection();clearTimeout(successTimeout);successElement.removeClass('hidden');successTimeout=setTimeout(function(){successElement.addClass('hidden');},3000);wp.a11y.speak(__('The file URL has been copied to your clipboard'));});},initialize:function(){this.options=_.defaults(this.options,{rerenderOnModelChange:false});Attachment.prototype.initialize.apply(this,arguments);this.copyAttachmentDetailsURLClipboard();},getFocusableElements:function(){var editedAttachment=$('li[data-id="'+this.model.id+'"]');this.previousAttachment=editedAttachment.prev();this.nextAttachment=editedAttachment.next();},moveFocus:function(){if(this.previousAttachment.length){this.previousAttachment.trigger('focus');return;}
if(this.nextAttachment.length){this.nextAttachment.trigger('focus');return;}
if(this.controller.uploader&&this.controller.uploader.$browser){this.controller.uploader.$browser.trigger('focus');return;}
this.moveFocusToLastFallback();},moveFocusToLastFallback:function(){$('.media-frame').attr('tabindex','-1').trigger('focus');},deleteAttachment:function(event){event.preventDefault();this.getFocusableElements();if(window.confirm(l10n.warnDelete)){this.model.destroy({wait:true,error:function(){window.alert(l10n.errorDeleting);}});this.moveFocus();}},trashAttachment:function(event){var library=this.controller.library,self=this;event.preventDefault();this.getFocusableElements();if(wp.media.view.settings.mediaTrash&&'edit-metadata'===this.controller.content.mode()){this.model.set('status','trash');this.model.save().done(function(){library._requery(true);self.moveFocusToLastFallback();});}else{this.model.destroy();this.moveFocus();}},untrashAttachment:function(event){var library=this.controller.library;event.preventDefault();this.model.set('status','inherit');this.model.save().done(function(){library._requery(true);});},editAttachment:function(event){var editState=this.controller.states.get('edit-image');if(window.imageEdit&&editState){event.preventDefault();editState.set('image',this.model);this.controller.setState('edit-image');}else{this.$el.addClass('needs-refresh');}},toggleSelectionHandler:function(event){if('keydown'===event.type&&9===event.keyCode&&event.shiftKey&&event.target===this.$(':tabbable').get(0)){this.controller.trigger('attachment:details:shift-tab',event);return false;}},render:function(){Attachment.prototype.render.apply(this,arguments);wp.media.mixin.removeAllPlayers();this.$('audio, video').each(function(i,elem){var el=wp.media.view.MediaDetails.prepareSrc(elem);new window.MediaElementPlayer(el,wp.media.mixin.mejsSettings);});}});module.exports=Details;},5232
(module){var EditLibrary=wp.media.view.Attachment.extend({buttons:{close:true}});module.exports=EditLibrary;},4593
(module){var EditSelection=wp.media.view.Attachment.Selection.extend({buttons:{close:true}});module.exports=EditSelection;},3443
(module){var Library=wp.media.view.Attachment.extend({buttons:{check:true}});module.exports=Library;},3962
(module){var Selection=wp.media.view.Attachment.extend({className:'attachment selection',toggleSelection:function(){this.options.selection.single(this.model);}});module.exports=Selection;},8142
(module){var View=wp.media.View,$=jQuery,Attachments,infiniteScrolling=wp.media.view.settings.infiniteScrolling;Attachments=View.extend({tagName:'ul',className:'attachments',attributes:{tabIndex:-1},initialize:function(){this.el.id=_.uniqueId('__attachments-view-');_.defaults(this.options,{infiniteScrolling:infiniteScrolling||false,refreshSensitivity:wp.media.isTouchDevice?300:200,refreshThreshold:3,AttachmentView:wp.media.view.Attachment,sortable:false,resize:true,idealColumnWidth:$(window).width()<640?135:150});this._viewsByCid={};this.$window=$(window);this.resizeEvent='resize.media-modal-columns';this.collection.on('add',function(attachment){this.views.add(this.createAttachmentView(attachment),{at:this.collection.indexOf(attachment)});},this);this.collection.on('remove',function(attachment){var view=this._viewsByCid[attachment.cid];delete this._viewsByCid[attachment.cid];if(view){view.remove();}},this);this.collection.on('reset',this.render,this);this.controller.on('library:selection:add',this.attachmentFocus,this);if(this.options.infiniteScrolling){this.scroll=_.chain(this.scroll).bind(this).throttle(this.options.refreshSensitivity).value();this.options.scrollElement=this.options.scrollElement||this.el;$(this.options.scrollElement).on('scroll',this.scroll);}
this.initSortable();_.bindAll(this,'setColumns');if(this.options.resize){this.on('ready',this.bindEvents);this.controller.on('open',this.setColumns);_.defer(this.setColumns,this);}},bindEvents:function(){this.$window.off(this.resizeEvent).on(this.resizeEvent,_.debounce(this.setColumns,50));},attachmentFocus:function(){if(this.columns){this.$el.focus();}},restoreFocus:function(){this.$('li.selected:first').focus();},arrowEvent:function(event){var attachments=this.$el.children('li'),perRow=this.columns,index=attachments.filter(':focus').index(),row=(index+1)<=perRow?1:Math.ceil((index+1)/ perRow);if(index===-1){return;}
if(37===event.keyCode){if(0===index){return;}
attachments.eq(index-1).focus();}
if(38===event.keyCode){if(1===row){return;}
attachments.eq(index-perRow).focus();}
if(39===event.keyCode){if(attachments.length===index){return;}
attachments.eq(index+1).focus();}
if(40===event.keyCode){if(Math.ceil(attachments.length / perRow)===row){return;}
attachments.eq(index+perRow).focus();}},dispose:function(){this.collection.props.off(null,null,this);if(this.options.resize){this.$window.off(this.resizeEvent);}
View.prototype.dispose.apply(this,arguments);},setColumns:function(){var prev=this.columns,width=this.$el.width();if(width){this.columns=Math.min(Math.round(width / this.options.idealColumnWidth),12)||1;if(!prev||prev!==this.columns){this.$el.closest('.media-frame-content').attr('data-columns',this.columns);}}},initSortable:function(){var collection=this.collection;if(!this.options.sortable||!$.fn.sortable){return;}
this.$el.sortable(_.extend({disabled:!!collection.comparator,tolerance:'pointer',start:function(event,ui){ui.item.data('sortableIndexStart',ui.item.index());},update:function(event,ui){var model=collection.at(ui.item.data('sortableIndexStart')),comparator=collection.comparator;delete collection.comparator;collection.remove(model,{silent:true});collection.add(model,{silent:true,at:ui.item.index()});collection.comparator=comparator;collection.trigger('reset',collection);collection.saveMenuOrder();}},this.options.sortable));collection.props.on('change:orderby',function(){this.$el.sortable('option','disabled',!!collection.comparator);},this);this.collection.props.on('change:orderby',this.refreshSortable,this);this.refreshSortable();},refreshSortable:function(){if(!this.options.sortable||!$.fn.sortable){return;}
var collection=this.collection,orderby=collection.props.get('orderby'),enabled='menuOrder'===orderby||!collection.comparator;this.$el.sortable('option','disabled',!enabled);},createAttachmentView:function(attachment){var view=new this.options.AttachmentView({controller:this.controller,model:attachment,collection:this.collection,selection:this.options.selection});return this._viewsByCid[attachment.cid]=view;},prepare:function(){if(this.collection.length){this.views.set(this.collection.map(this.createAttachmentView,this));}else{this.views.unset();if(this.options.infiniteScrolling){this.collection.more().done(this.scroll);}}},ready:function(){if(this.options.infiniteScrolling){this.scroll();}},scroll:function(){var view=this,el=this.options.scrollElement,scrollTop=el.scrollTop,toolbar;if(el===document){el=document.body;scrollTop=$(document).scrollTop();}
if(!$(el).is(':visible')||!this.collection.hasMore()){return;}
toolbar=this.views.parent.toolbar;if(el.scrollHeight-(scrollTop+el.clientHeight)<el.clientHeight / 3){toolbar.get('spinner').show();}
if(el.scrollHeight<scrollTop+(el.clientHeight*this.options.refreshThreshold)){this.collection.more().done(function(){view.scroll();toolbar.get('spinner').hide();});}}});module.exports=Attachments;},6829
(module){var View=wp.media.View,mediaTrash=wp.media.view.settings.mediaTrash,l10n=wp.media.view.l10n,$=jQuery,AttachmentsBrowser,infiniteScrolling=wp.media.view.settings.infiniteScrolling,__=wp.i18n.__,sprintf=wp.i18n.sprintf;AttachmentsBrowser=View.extend({tagName:'div',className:'attachments-browser',initialize:function(){_.defaults(this.options,{filters:false,search:true,date:true,display:false,sidebar:true,AttachmentView:wp.media.view.Attachment.Library});this.controller.on('toggle:upload:attachment',this.toggleUploader,this);this.controller.on('edit:selection',this.editSelection);if(this.options.sidebar&&'errors'===this.options.sidebar){this.createSidebar();}
if(this.controller.isModeActive('grid')){this.createUploader();this.createToolbar();}else{this.createToolbar();this.createUploader();}
this.createAttachmentsHeading();this.createAttachmentsWrapperView();if(!infiniteScrolling){this.$el.addClass('has-load-more');this.createLoadMoreView();}
if(this.options.sidebar&&'errors'!==this.options.sidebar){this.createSidebar();}
this.updateContent();if(!infiniteScrolling){this.updateLoadMoreView();}
if(!this.options.sidebar||'errors'===this.options.sidebar){this.$el.addClass('hide-sidebar');if('errors'===this.options.sidebar){this.$el.addClass('sidebar-for-errors');}}
this.collection.on('add remove reset',this.updateContent,this);if(!infiniteScrolling){this.collection.on('add remove reset',this.updateLoadMoreView,this);}
this.collection.on('attachments:received',this.announceSearchResults,this);},announceSearchResults:_.debounce(function(){var count,mediaFoundHasMoreResultsMessage=__('Number of media items displayed: %d. Click load more for more results.');if(infiniteScrolling){mediaFoundHasMoreResultsMessage=__('Number of media items displayed: %d. Scroll the page for more results.');}
if(this.collection.mirroring&&this.collection.mirroring.args.s){count=this.collection.length;if(0===count){wp.a11y.speak(l10n.noMediaTryNewSearch);return;}
if(this.collection.hasMore()){wp.a11y.speak(mediaFoundHasMoreResultsMessage.replace('%d',count));return;}
wp.a11y.speak(l10n.mediaFound.replace('%d',count));}},200),editSelection:function(modal){modal.$('.media-button-backToLibrary').focus();},dispose:function(){this.options.selection.off(null,null,this);View.prototype.dispose.apply(this,arguments);return this;},createToolbar:function(){var LibraryViewSwitcher,Filters,toolbarOptions,showFilterByType=-1!==$.inArray(this.options.filters,['uploaded','all']);toolbarOptions={controller:this.controller};if(this.controller.isModeActive('grid')){toolbarOptions.className='media-toolbar wp-filter';}
this.toolbar=new wp.media.view.Toolbar(toolbarOptions);this.views.add(this.toolbar);this.toolbar.set('spinner',new wp.media.view.Spinner({priority:-20}));if(showFilterByType||this.options.date){this.toolbar.set('filters-heading',new wp.media.view.Heading({priority:-100,text:l10n.filterAttachments,level:'h2',className:'media-attachments-filter-heading screen-reader-text'}).render());}
if(showFilterByType){this.toolbar.set('filtersLabel',new wp.media.view.Label({value:l10n.filterByType,attributes:{'for':'media-attachment-filters'},priority:-80}).render());if('uploaded'===this.options.filters){this.toolbar.set('filters',new wp.media.view.AttachmentFilters.Uploaded({controller:this.controller,model:this.collection.props,priority:-80}).render());}else{Filters=new wp.media.view.AttachmentFilters.All({controller:this.controller,model:this.collection.props,priority:-80});this.toolbar.set('filters',Filters.render());}}
if(this.controller.isModeActive('grid')){LibraryViewSwitcher=View.extend({className:'view-switch media-grid-view-switch',template:wp.template('media-library-view-switcher')});this.toolbar.set('libraryViewSwitcher',new LibraryViewSwitcher({controller:this.controller,priority:-90}).render());this.toolbar.set('dateFilterLabel',new wp.media.view.Label({value:l10n.filterByDate,attributes:{'for':'media-attachment-date-filters'},priority:-75}).render());this.toolbar.set('dateFilter',new wp.media.view.DateFilter({controller:this.controller,model:this.collection.props,priority:-75,}).render());this.toolbar.set('selectModeToggleButton',new wp.media.view.SelectModeToggleButton({text:l10n.bulkSelect,controller:this.controller,priority:-70}).render());this.toolbar.set('deleteSelectedButton',new wp.media.view.DeleteSelectedButton({filters:Filters,style:'primary',disabled:true,text:mediaTrash?l10n.trashSelected:l10n.deletePermanently,controller:this.controller,priority:-80,click:function(){var changed=[],removed=[],selection=this.controller.state().get('selection'),library=this.controller.state().get('library');if(!selection.length){return;}
if(!mediaTrash&&!window.confirm(l10n.warnBulkDelete)){return;}
if(mediaTrash&&'trash'!==selection.at(0).get('status')&&!window.confirm(l10n.warnBulkTrash)){return;}
selection.each(function(model){if(!model.get('nonces')['delete']){removed.push(model);return;}
if(mediaTrash&&'trash'===model.get('status')){model.set('status','inherit');changed.push(model.save());removed.push(model);}else if(mediaTrash){model.set('status','trash');changed.push(model.save());removed.push(model);}else{model.destroy({wait:true});}});if(changed.length){selection.remove(removed);$.when.apply(null,changed).then(_.bind(function(){library._requery(true);this.controller.trigger('selection:action:done');},this));}else{this.controller.trigger('selection:action:done');}}}).render());if(mediaTrash){this.toolbar.set('deleteSelectedPermanentlyButton',new wp.media.view.DeleteSelectedPermanentlyButton({filters:Filters,style:'link button-link-delete',disabled:true,text:l10n.deletePermanently,controller:this.controller,priority:-55,size:'',click:function(){var removed=[],destroy=[],selection=this.controller.state().get('selection');if(!selection.length||!window.confirm(l10n.warnBulkDelete)){return;}
selection.each(function(model){if(!model.get('nonces')['delete']){removed.push(model);return;}
destroy.push(model);});if(removed.length){selection.remove(removed);}
if(destroy.length){$.when.apply(null,destroy.map(function(item){return item.destroy();})).then(_.bind(function(){this.controller.trigger('selection:action:done');},this));}}}).render());}}else if(this.options.date){this.toolbar.set('dateFilterLabel',new wp.media.view.Label({value:l10n.filterByDate,attributes:{'for':'media-attachment-date-filters'},priority:-75}).render());this.toolbar.set('dateFilter',new wp.media.view.DateFilter({controller:this.controller,model:this.collection.props,priority:-75}).render());}
if(this.options.search){this.toolbar.set('searchLabel',new wp.media.view.Label({value:l10n.searchLabel,className:'media-search-input-label',attributes:{'for':'media-search-input'},priority:60}).render());this.toolbar.set('search',new wp.media.view.Search({controller:this.controller,model:this.collection.props,priority:60}).render());}
if(this.options.dragInfo){this.toolbar.set('dragInfo',new View({el:$('<div class="instructions">'+l10n.dragInfo+'</div>')[0],priority:-40}));}
if(this.options.suggestedWidth&&this.options.suggestedHeight){this.toolbar.set('suggestedDimensions',new View({el:$('<div class="instructions">'+l10n.suggestedDimensions.replace('%1$s',this.options.suggestedWidth).replace('%2$s',this.options.suggestedHeight)+'</div>')[0],priority:-40}));}},updateContent:function(){var view=this,noItemsView;if(this.controller.isModeActive('grid')){noItemsView=view.attachmentsNoResults;}else{noItemsView=view.uploader;}
if(!this.collection.length){this.toolbar.get('spinner').show();this.toolbar.$('.media-bg-overlay').show();this.dfd=this.collection.more().done(function(){if(!view.collection.length){noItemsView.$el.removeClass('hidden');}else{noItemsView.$el.addClass('hidden');}
view.toolbar.get('spinner').hide();view.toolbar.$('.media-bg-overlay').hide();});}else{noItemsView.$el.addClass('hidden');view.toolbar.get('spinner').hide();this.toolbar.$('.media-bg-overlay').hide();}},createUploader:function(){this.uploader=new wp.media.view.UploaderInline({controller:this.controller,status:false,message:this.controller.isModeActive('grid')?'':l10n.noItemsFound,canClose:this.controller.isModeActive('grid')});this.uploader.$el.addClass('hidden');this.views.add(this.uploader);},toggleUploader:function(){if(this.uploader.$el.hasClass('hidden')){this.uploader.show();}else{this.uploader.hide();}},createAttachmentsWrapperView:function(){this.attachmentsWrapper=new wp.media.View({className:'attachments-wrapper'});this.views.add(this.attachmentsWrapper);this.createAttachments();},createAttachments:function(){this.attachments=new wp.media.view.Attachments({controller:this.controller,collection:this.collection,selection:this.options.selection,model:this.model,sortable:this.options.sortable,scrollElement:this.options.scrollElement,idealColumnWidth:this.options.idealColumnWidth,AttachmentView:this.options.AttachmentView});this.controller.on('attachment:keydown:arrow',_.bind(this.attachments.arrowEvent,this.attachments));this.controller.on('attachment:details:shift-tab',_.bind(this.attachments.restoreFocus,this.attachments));this.views.add('.attachments-wrapper',this.attachments);if(this.controller.isModeActive('grid')){this.attachmentsNoResults=new View({controller:this.controller,tagName:'p'});this.attachmentsNoResults.$el.addClass('hidden no-media');this.attachmentsNoResults.$el.html(l10n.noMedia);this.views.add(this.attachmentsNoResults);}},createLoadMoreView:function(){var view=this;this.loadMoreWrapper=new View({controller:this.controller,className:'load-more-wrapper'});this.loadMoreCount=new View({controller:this.controller,tagName:'p',className:'load-more-count hidden'});this.loadMoreButton=new wp.media.view.Button({text:__('Load more'),className:'load-more hidden',style:'primary',size:'',click:function(){view.loadMoreAttachments();}});this.loadMoreSpinner=new wp.media.view.Spinner();this.loadMoreJumpToFirst=new wp.media.view.Button({text:__('Jump to first loaded item'),className:'load-more-jump hidden',size:'',click:function(){view.jumpToFirstAddedItem();}});this.views.add('.attachments-wrapper',this.loadMoreWrapper);this.views.add('.load-more-wrapper',this.loadMoreSpinner);this.views.add('.load-more-wrapper',this.loadMoreCount);this.views.add('.load-more-wrapper',this.loadMoreButton);this.views.add('.load-more-wrapper',this.loadMoreJumpToFirst);},updateLoadMoreView:_.debounce(function(){this.loadMoreButton.$el.addClass('hidden');this.loadMoreCount.$el.addClass('hidden');this.loadMoreJumpToFirst.$el.addClass('hidden').prop('disabled',true);if(!this.collection.getTotalAttachments()){return;}
if(this.collection.length){this.loadMoreCount.$el.text(sprintf(__('Showing %1$s of %2$s media items'),this.collection.length,this.collection.getTotalAttachments()));this.loadMoreCount.$el.removeClass('hidden');}
if(this.collection.hasMore()){this.loadMoreButton.$el.removeClass('hidden');}
this.firstAddedMediaItem=this.$el.find('.attachment').eq(this.firstAddedMediaItemIndex);if(this.firstAddedMediaItem.length){this.firstAddedMediaItem.addClass('new-media');this.loadMoreJumpToFirst.$el.removeClass('hidden').prop('disabled',false);}
if(this.firstAddedMediaItem.length&&!this.collection.hasMore()){this.loadMoreJumpToFirst.$el.trigger('focus');}},10),loadMoreAttachments:function(){var view=this;if(!this.collection.hasMore()){return;}
this.firstAddedMediaItemIndex=this.collection.length;this.$el.addClass('more-loaded');this.collection.each(function(attachment){var attach_id=attachment.attributes.id;$('[data-id="'+attach_id+'"]').addClass('found-media');});view.loadMoreSpinner.show();this.collection.once('attachments:received',function(){view.loadMoreSpinner.hide();});this.collection.more();},jumpToFirstAddedItem:function(){this.firstAddedMediaItem.focus();},createAttachmentsHeading:function(){this.attachmentsHeading=new wp.media.view.Heading({text:l10n.attachmentsList,level:'h2',className:'media-views-heading screen-reader-text'});this.views.add(this.attachmentsHeading);},createSidebar:function(){var options=this.options,selection=options.selection,sidebar=this.sidebar=new wp.media.view.Sidebar({controller:this.controller});this.views.add(sidebar);if(this.controller.uploader){sidebar.set('uploads',new wp.media.view.UploaderStatus({controller:this.controller,priority:40}));}
selection.on('selection:single',this.createSingle,this);selection.on('selection:unsingle',this.disposeSingle,this);if(selection.single()){this.createSingle();}},createSingle:function(){var sidebar=this.sidebar,single=this.options.selection.single();sidebar.set('details',new wp.media.view.Attachment.Details({controller:this.controller,model:single,priority:80}));sidebar.set('compat',new wp.media.view.AttachmentCompat({controller:this.controller,model:single,priority:120}));if(this.options.display){sidebar.set('display',new wp.media.view.Settings.AttachmentDisplay({controller:this.controller,model:this.model.display(single),attachment:single,priority:160,userSettings:this.model.get('displayUserSettings')}));}
if(this.model.id==='insert'){sidebar.$el.addClass('visible');}},disposeSingle:function(){var sidebar=this.sidebar;sidebar.unset('details');sidebar.unset('compat');sidebar.unset('display');sidebar.$el.removeClass('visible');}});module.exports=AttachmentsBrowser;},3479
(module){var Attachments=wp.media.view.Attachments,Selection;Selection=Attachments.extend({events:{},initialize:function(){_.defaults(this.options,{sortable:false,resize:false,AttachmentView:wp.media.view.Attachment.Selection});return Attachments.prototype.initialize.apply(this,arguments);}});module.exports=Selection;},168
(module){var $=Backbone.$,ButtonGroup;ButtonGroup=wp.media.View.extend({tagName:'div',className:'button-group button-large media-button-group',initialize:function(){this.buttons=_.map(this.options.buttons||[],function(button){if(button instanceof Backbone.View){return button;}else{return new wp.media.view.Button(button).render();}});delete this.options.buttons;if(this.options.classes){this.$el.addClass(this.options.classes);}},render:function(){this.$el.html($(_.pluck(this.buttons,'el')).detach());return this;}});module.exports=ButtonGroup;},846
(module){var Button=wp.media.View.extend({tagName:'button',className:'media-button',attributes:{type:'button'},events:{'click':'click'},defaults:{text:'',style:'',size:'large',disabled:false},initialize:function(){this.model=new Backbone.Model(this.defaults);_.each(this.defaults,function(def,key){var value=this.options[key];if(_.isUndefined(value)){return;}
this.model.set(key,value);delete this.options[key];},this);this.listenTo(this.model,'change',this.render);},render:function(){var classes=['button',this.className],model=this.model.toJSON();if(model.style){classes.push('button-'+model.style);}
if(model.size){classes.push('button-'+model.size);}
classes=_.uniq(classes.concat(this.options.classes));this.el.className=classes.join(' ');this.$el.prop('disabled',model.disabled);this.$el.text(this.model.get('text'));return this;},click:function(event){if('#'===this.attributes.href){event.preventDefault();}
if(this.options.click&&!this.model.get('disabled')){this.options.click.apply(this,arguments);}}});module.exports=Button;},7637
(module){var View=wp.media.View,UploaderStatus=wp.media.view.UploaderStatus,l10n=wp.media.view.l10n,$=jQuery,Cropper;Cropper=View.extend({className:'crop-content',template:wp.template('crop-content'),initialize:function(){_.bindAll(this,'onImageLoad');},ready:function(){this.controller.frame.on('content:error:crop',this.onError,this);this.$image=this.$el.find('.crop-image');this.$image.on('load',this.onImageLoad);$(window).on('resize.cropper',_.debounce(this.onImageLoad,250));},remove:function(){$(window).off('resize.cropper');this.$el.remove();this.$el.off();View.prototype.remove.apply(this,arguments);},prepare:function(){return{title:l10n.cropYourImage,url:this.options.attachment.get('url')};},onImageLoad:function(){var imgOptions=this.controller.get('imgSelectOptions'),imgSelect;if(typeof imgOptions==='function'){imgOptions=imgOptions(this.options.attachment,this.controller);}
imgOptions=_.extend(imgOptions,{parent:this.$el,onInit:function(){var setRatio=imgSelect.getOptions().aspectRatio;this.parent.children().on('mousedown touchstart',function(e){if(!setRatio&&e.shiftKey){imgSelect.setOptions({aspectRatio:'1:1'});}});this.parent.children().on('mouseup touchend',function(){imgSelect.setOptions({aspectRatio:setRatio?setRatio:false});});}});this.trigger('image-loaded');imgSelect=this.controller.imgSelect=this.$image.imgAreaSelect(imgOptions);},onError:function(){var filename=this.options.attachment.get('filename');this.views.add('.upload-errors',new wp.media.view.UploaderStatusError({filename:UploaderStatus.prototype.filename(filename),message:window._wpMediaViewsL10n.cropError}),{at:0});}});module.exports=Cropper;},6126
(module){var View=wp.media.View,EditImage;EditImage=View.extend({className:'image-editor',template:wp.template('image-editor'),initialize:function(options){this.editor=window.imageEdit;this.controller=options.controller;View.prototype.initialize.apply(this,arguments);},prepare:function(){return this.model.toJSON();},loadEditor:function(){this.editor.open(this.model.get('id'),this.model.get('nonces').edit,this);},back:function(){var lastState=this.controller.lastState();this.controller.setState(lastState);},refresh:function(){this.model.fetch();},save:function(){var lastState=this.controller.lastState();this.model.fetch().done(_.bind(function(){this.controller.setState(lastState);},this));}});module.exports=EditImage;},5741
(module){var Embed=wp.media.View.extend({className:'media-embed',initialize:function(){this.url=new wp.media.view.EmbedUrl({controller:this.controller,model:this.model.props}).render();this.views.set([this.url]);this.refresh();this.listenTo(this.model,'change:type',this.refresh);this.listenTo(this.model,'change:loading',this.loading);},settings:function(view){if(this._settings){this._settings.remove();}
this._settings=view;this.views.add(view);},refresh:function(){var type=this.model.get('type'),constructor;if('image'===type){constructor=wp.media.view.EmbedImage;}else if('link'===type){constructor=wp.media.view.EmbedLink;}else{return;}
this.settings(new constructor({controller:this.controller,model:this.model.props,priority:40}));},loading:function(){this.$el.toggleClass('embed-loading',this.model.get('loading'));}});module.exports=Embed;},2395
(module){var AttachmentDisplay=wp.media.view.Settings.AttachmentDisplay,EmbedImage;EmbedImage=AttachmentDisplay.extend({className:'embed-media-settings',template:wp.template('embed-image-settings'),initialize:function(){AttachmentDisplay.prototype.initialize.apply(this,arguments);this.listenTo(this.model,'change:url',this.updateImage);},updateImage:function(){this.$('img').attr('src',this.model.get('url'));}});module.exports=EmbedImage;},8232
(module){var $=jQuery,EmbedLink;EmbedLink=wp.media.view.Settings.extend({className:'embed-link-settings',template:wp.template('embed-link-settings'),initialize:function(){this.listenTo(this.model,'change:url',this.updateoEmbed);},updateoEmbed:_.debounce(function(){var url=this.model.get('url');this.$('.embed-container').hide().find('.embed-preview').empty();this.$('.setting').hide();if(url&&(url.length<11||!url.match(/^http(s)?:\/\//))){return;}
this.fetch();},wp.media.controller.Embed.sensitivity),fetch:function(){var url=this.model.get('url'),re,youTubeEmbedMatch;if($('#embed-url-field').val()!==url){return;}
if(this.dfd&&'pending'===this.dfd.state()){this.dfd.abort();}
re=/https?:\/\/www\.youtube\.com\/embed\/([^/]+)/;youTubeEmbedMatch=re.exec(url);if(youTubeEmbedMatch){url='https://www.youtube.com/watch?v='+youTubeEmbedMatch[1];}
this.dfd=wp.apiRequest({url:wp.media.view.settings.oEmbedProxyUrl,data:{url:url,maxwidth:this.model.get('width'),maxheight:this.model.get('height')},type:'GET',dataType:'json',context:this}).done(function(response){this.renderoEmbed({data:{body:response.html||''}});}).fail(this.renderFail);},renderFail:function(response,status){if('abort'===status){return;}
this.$('.link-text').show();},renderoEmbed:function(response){var html=(response&&response.data&&response.data.body)||'';if(html){this.$('.embed-container').show().find('.embed-preview').html(html);}else{this.renderFail();}}});module.exports=EmbedLink;},7327
(module){var View=wp.media.View,$=jQuery,l10n=wp.media.view.l10n,EmbedUrl;EmbedUrl=View.extend({tagName:'span',className:'embed-url',events:{'input':'url'},initialize:function(){this.$input=$('<input id="embed-url-field" type="url" />').attr('aria-label',l10n.insertFromUrlTitle).val(this.model.get('url'));this.input=this.$input[0];this.spinner=$('<span class="spinner" />')[0];this.$el.append([this.input,this.spinner]);this.listenTo(this.model,'change:url',this.render);if(this.model.get('url')){_.delay(_.bind(function(){this.model.trigger('change:url');},this),500);}},render:function(){var $input=this.$input;if($input.is(':focus')){return;}
if(this.model.get('url')){this.input.value=this.model.get('url');}else{this.input.setAttribute('placeholder','https://');}
View.prototype.render.apply(this,arguments);return this;},url:function(event){var url=event.target.value||'';this.model.set('url',url.trim());}});module.exports=EmbedUrl;},718
(module){var $=jQuery;var FocusManager=wp.media.View.extend({events:{'keydown':'focusManagementMode'},initialize:function(options){this.mode=options.mode||'constrainTabbing';this.tabsAutomaticActivation=options.tabsAutomaticActivation||false;},focusManagementMode:function(event){if(this.mode==='constrainTabbing'){this.constrainTabbing(event);}
if(this.mode==='tabsNavigation'){this.tabsNavigation(event);}},getTabbables:function(){return this.$(':tabbable').not('.moxie-shim input[type="file"]');},focus:function(){this.$('.media-modal').trigger('focus');},constrainTabbing:function(event){var tabbables;if(9!==event.keyCode){return;}
tabbables=this.getTabbables();if(tabbables.last()[0]===event.target&&!event.shiftKey){tabbables.first().focus();return false;}else if(tabbables.first()[0]===event.target&&event.shiftKey){tabbables.last().focus();return false;}},setAriaHiddenOnBodyChildren:function(visibleElement){var bodyChildren,self=this;if(this.isBodyAriaHidden){return;}
bodyChildren=document.body.children;_.each(bodyChildren,function(element){if(element===visibleElement[0]){return;}
if(self.elementShouldBeHidden(element)){element.setAttribute('aria-hidden','true');self.ariaHiddenElements.push(element);}});this.isBodyAriaHidden=true;},removeAriaHiddenFromBodyChildren:function(){_.each(this.ariaHiddenElements,function(element){element.removeAttribute('aria-hidden');});this.ariaHiddenElements=[];this.isBodyAriaHidden=false;},elementShouldBeHidden:function(element){var role=element.getAttribute('role'),liveRegionsRoles=['alert','status','log','marquee','timer'];return!(element.tagName==='SCRIPT'||element.hasAttribute('aria-hidden')||element.hasAttribute('aria-live')||liveRegionsRoles.indexOf(role)!==-1);},isBodyAriaHidden:false,ariaHiddenElements:[],tabs:$(),setupAriaTabs:function(){this.tabs=this.$('[role="tab"]');this.tabs.attr({'aria-selected':'false',tabIndex:'-1'});this.tabs.filter('.active').removeAttr('tabindex').attr('aria-selected','true');},tabsNavigation:function(event){var orientation='horizontal',keys=[32,35,36,37,38,39,40];if(keys.indexOf(event.which)===-1){return;}
if(this.$el.attr('aria-orientation')==='vertical'){orientation='vertical';}
if(orientation==='horizontal'&&[38,40].indexOf(event.which)!==-1){return;}
if(orientation==='vertical'&&[37,39].indexOf(event.which)!==-1){return;}
this.switchTabs(event,this.tabs);},switchTabs:function(event){var key=event.which,index=this.tabs.index($(event.target)),newIndex;switch(key){case 32:{this.activateTab(this.tabs[index]);break;}
case 35:{event.preventDefault();this.activateTab(this.tabs[this.tabs.length-1]);break;}
case 36:{event.preventDefault();this.activateTab(this.tabs[0]);break;}
case 37:case 38:{event.preventDefault();newIndex=(index-1)<0?this.tabs.length-1:index-1;this.activateTab(this.tabs[newIndex]);break;}
case 39:case 40:{event.preventDefault();newIndex=(index+1)===this.tabs.length?0:index+1;this.activateTab(this.tabs[newIndex]);break;}}},activateTab:function(tab){if(!tab){return;}
tab.focus();if(this.tabsAutomaticActivation){tab.removeAttribute('tabindex');tab.setAttribute('aria-selected','true');tab.click();return;}
$(tab).on('click',function(){tab.removeAttribute('tabindex');tab.setAttribute('aria-selected','true');});}});module.exports=FocusManager;},1061
(module){var Frame=wp.media.View.extend({initialize:function(){_.defaults(this.options,{mode:['select']});this._createRegions();this._createStates();this._createModes();},_createRegions:function(){this.regions=this.regions?this.regions.slice():[];_.each(this.regions,function(region){this[region]=new wp.media.controller.Region({view:this,id:region,selector:'.media-frame-'+region});},this);},_createStates:function(){this.states=new Backbone.Collection(null,{model:wp.media.controller.State});this.states.on('add',function(model){model.frame=this;model.trigger('ready');},this);if(this.options.states){this.states.add(this.options.states);}},_createModes:function(){this.activeModes=new Backbone.Collection();this.activeModes.on('add remove reset',_.bind(this.triggerModeEvents,this));_.each(this.options.mode,function(mode){this.activateMode(mode);},this);},reset:function(){this.states.invoke('trigger','reset');return this;},triggerModeEvents:function(model,collection,options){var collectionEvent,modeEventMap={add:'activate',remove:'deactivate'},eventToTrigger;_.each(options,function(value,key){if(value){collectionEvent=key;}});if(!_.has(modeEventMap,collectionEvent)){return;}
eventToTrigger=model.get('id')+':'+modeEventMap[collectionEvent];this.trigger(eventToTrigger);},activateMode:function(mode){if(this.isModeActive(mode)){return;}
this.activeModes.add([{id:mode}]);this.$el.addClass('mode-'+mode);return this;},deactivateMode:function(mode){if(!this.isModeActive(mode)){return this;}
this.activeModes.remove(this.activeModes.where({id:mode}));this.$el.removeClass('mode-'+mode);this.trigger(mode+':deactivate');return this;},isModeActive:function(mode){return Boolean(this.activeModes.where({id:mode}).length);}});_.extend(Frame.prototype,wp.media.controller.StateMachine.prototype);module.exports=Frame;},5424
(module){var Select=wp.media.view.MediaFrame.Select,l10n=wp.media.view.l10n,ImageDetails;ImageDetails=Select.extend({defaults:{id:'image',url:'',menu:'image-details',content:'image-details',toolbar:'image-details',type:'link',title:l10n.imageDetailsTitle,priority:120},initialize:function(options){this.image=new wp.media.model.PostImage(options.metadata);this.options.selection=new wp.media.model.Selection(this.image.attachment,{multiple:false});Select.prototype.initialize.apply(this,arguments);},bindHandlers:function(){Select.prototype.bindHandlers.apply(this,arguments);this.on('menu:create:image-details',this.createMenu,this);this.on('content:create:image-details',this.imageDetailsContent,this);this.on('content:render:edit-image',this.editImageContent,this);this.on('toolbar:render:image-details',this.renderImageDetailsToolbar,this);this.on('toolbar:render:replace',this.renderReplaceImageToolbar,this);},createStates:function(){this.states.add([new wp.media.controller.ImageDetails({image:this.image,editable:false}),new wp.media.controller.ReplaceImage({id:'replace-image',library:wp.media.query({type:'image'}),image:this.image,multiple:false,title:l10n.imageReplaceTitle,toolbar:'replace',priority:80,displaySettings:true}),new wp.media.controller.EditImage({image:this.image,selection:this.options.selection})]);},imageDetailsContent:function(options){options.view=new wp.media.view.ImageDetails({controller:this,model:this.state().image,attachment:this.state().image.attachment});},editImageContent:function(){var state=this.state(),model=state.get('image'),view;if(!model){return;}
view=new wp.media.view.EditImage({model:model,controller:this}).render();this.content.set(view);view.loadEditor();},renderImageDetailsToolbar:function(){this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{select:{style:'primary',text:l10n.update,priority:80,click:function(){var controller=this.controller,state=controller.state();controller.close();state.trigger('update',controller.image.toJSON());controller.setState(controller.options.state);controller.reset();}}}}));},renderReplaceImageToolbar:function(){var frame=this,lastState=frame.lastState(),previous=lastState&&lastState.id;this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{back:{text:l10n.back,priority:80,click:function(){if(previous){frame.setState(previous);}else{frame.close();}}},replace:{style:'primary',text:l10n.replace,priority:20,requires:{selection:true},click:function(){var controller=this.controller,state=controller.state(),selection=state.get('selection'),attachment=selection.single();controller.close();controller.image.changeAttachment(attachment,state.display(attachment));state.trigger('replace',controller.image.toJSON());controller.setState(controller.options.state);controller.reset();}}}}));}});module.exports=ImageDetails;},4274
(module){var Select=wp.media.view.MediaFrame.Select,Library=wp.media.controller.Library,l10n=wp.media.view.l10n,Post;Post=Select.extend({initialize:function(){this.counts={audio:{count:wp.media.view.settings.attachmentCounts.audio,state:'playlist'},video:{count:wp.media.view.settings.attachmentCounts.video,state:'video-playlist'}};_.defaults(this.options,{multiple:true,editing:false,state:'insert',metadata:{}});Select.prototype.initialize.apply(this,arguments);this.createIframeStates();},createStates:function(){var options=this.options;this.states.add([new Library({id:'insert',title:l10n.insertMediaTitle,priority:20,toolbar:'main-insert',filterable:'all',library:wp.media.query(options.library),multiple:options.multiple?'reset':false,editable:true,allowLocalEdits:true,displaySettings:true,displayUserSettings:true}),new Library({id:'gallery',title:l10n.createGalleryTitle,priority:40,toolbar:'main-gallery',filterable:'uploaded',multiple:'add',editable:false,library:wp.media.query(_.defaults({type:'image'},options.library))}),new wp.media.controller.Embed({metadata:options.metadata}),new wp.media.controller.EditImage({model:options.editImage}),new wp.media.controller.GalleryEdit({library:options.selection,editing:options.editing,menu:'gallery'}),new wp.media.controller.GalleryAdd(),new Library({id:'playlist',title:l10n.createPlaylistTitle,priority:60,toolbar:'main-playlist',filterable:'uploaded',multiple:'add',editable:false,library:wp.media.query(_.defaults({type:'audio'},options.library))}),new wp.media.controller.CollectionEdit({type:'audio',collectionType:'playlist',title:l10n.editPlaylistTitle,SettingsView:wp.media.view.Settings.Playlist,library:options.selection,editing:options.editing,menu:'playlist',dragInfoText:l10n.playlistDragInfo,dragInfo:false}),new wp.media.controller.CollectionAdd({type:'audio',collectionType:'playlist',title:l10n.addToPlaylistTitle}),new Library({id:'video-playlist',title:l10n.createVideoPlaylistTitle,priority:60,toolbar:'main-video-playlist',filterable:'uploaded',multiple:'add',editable:false,library:wp.media.query(_.defaults({type:'video'},options.library))}),new wp.media.controller.CollectionEdit({type:'video',collectionType:'playlist',title:l10n.editVideoPlaylistTitle,SettingsView:wp.media.view.Settings.Playlist,library:options.selection,editing:options.editing,menu:'video-playlist',dragInfoText:l10n.videoPlaylistDragInfo,dragInfo:false}),new wp.media.controller.CollectionAdd({type:'video',collectionType:'playlist',title:l10n.addToVideoPlaylistTitle})]);if(wp.media.view.settings.post.featuredImageId){this.states.add(new wp.media.controller.FeaturedImage());}},bindHandlers:function(){var handlers,checkCounts;Select.prototype.bindHandlers.apply(this,arguments);this.on('activate',this.activate,this);checkCounts=_.find(this.counts,function(type){return type.count===0;});if(typeof checkCounts!=='undefined'){this.listenTo(wp.media.model.Attachments.all,'change:type',this.mediaTypeCounts);}
this.on('menu:create:gallery',this.createMenu,this);this.on('menu:create:playlist',this.createMenu,this);this.on('menu:create:video-playlist',this.createMenu,this);this.on('toolbar:create:main-insert',this.createToolbar,this);this.on('toolbar:create:main-gallery',this.createToolbar,this);this.on('toolbar:create:main-playlist',this.createToolbar,this);this.on('toolbar:create:main-video-playlist',this.createToolbar,this);this.on('toolbar:create:featured-image',this.featuredImageToolbar,this);this.on('toolbar:create:main-embed',this.mainEmbedToolbar,this);handlers={menu:{'default':'mainMenu','gallery':'galleryMenu','playlist':'playlistMenu','video-playlist':'videoPlaylistMenu'},content:{'embed':'embedContent','edit-image':'editImageContent','edit-selection':'editSelectionContent'},toolbar:{'main-insert':'mainInsertToolbar','main-gallery':'mainGalleryToolbar','gallery-edit':'galleryEditToolbar','gallery-add':'galleryAddToolbar','main-playlist':'mainPlaylistToolbar','playlist-edit':'playlistEditToolbar','playlist-add':'playlistAddToolbar','main-video-playlist':'mainVideoPlaylistToolbar','video-playlist-edit':'videoPlaylistEditToolbar','video-playlist-add':'videoPlaylistAddToolbar'}};_.each(handlers,function(regionHandlers,region){_.each(regionHandlers,function(callback,handler){this.on(region+':render:'+handler,this[callback],this);},this);},this);},activate:function(){_.each(this.counts,function(type){if(type.count<1){this.menuItemVisibility(type.state,'hide');}},this);},mediaTypeCounts:function(model,attr){if(typeof this.counts[attr]!=='undefined'&&this.counts[attr].count<1){this.counts[attr].count++;this.menuItemVisibility(this.counts[attr].state,'show');}},mainMenu:function(view){view.set({'library-separator':new wp.media.View({className:'separator',priority:100,attributes:{role:'presentation'}})});},menuItemVisibility:function(state,visibility){var menu=this.menu.get();if(visibility==='hide'){menu.hide(state);}else if(visibility==='show'){menu.show(state);}},galleryMenu:function(view){var lastState=this.lastState(),previous=lastState&&lastState.id,frame=this;view.set({cancel:{text:l10n.cancelGalleryTitle,priority:20,click:function(){if(previous){frame.setState(previous);}else{frame.close();}
this.controller.modal.focusManager.focus();}},separateCancel:new wp.media.View({className:'separator',priority:40})});},playlistMenu:function(view){var lastState=this.lastState(),previous=lastState&&lastState.id,frame=this;view.set({cancel:{text:l10n.cancelPlaylistTitle,priority:20,click:function(){if(previous){frame.setState(previous);}else{frame.close();}
this.controller.modal.focusManager.focus();}},separateCancel:new wp.media.View({className:'separator',priority:40})});},videoPlaylistMenu:function(view){var lastState=this.lastState(),previous=lastState&&lastState.id,frame=this;view.set({cancel:{text:l10n.cancelVideoPlaylistTitle,priority:20,click:function(){if(previous){frame.setState(previous);}else{frame.close();}
this.controller.modal.focusManager.focus();}},separateCancel:new wp.media.View({className:'separator',priority:40})});},embedContent:function(){var view=new wp.media.view.Embed({controller:this,model:this.state()}).render();this.content.set(view);},editSelectionContent:function(){var state=this.state(),selection=state.get('selection'),view;view=new wp.media.view.AttachmentsBrowser({controller:this,collection:selection,selection:selection,model:state,sortable:true,search:false,date:false,dragInfo:true,AttachmentView:wp.media.view.Attachments.EditSelection}).render();view.toolbar.set('backToLibrary',{text:l10n.returnToLibrary,priority:-100,click:function(){this.controller.content.mode('browse');this.controller.modal.focusManager.focus();}});this.content.set(view);this.trigger('edit:selection',this);},editImageContent:function(){var image=this.state().get('image'),view=new wp.media.view.EditImage({model:image,controller:this}).render();this.content.set(view);view.loadEditor();},selectionStatusToolbar:function(view){var editable=this.state().get('editable');view.set('selection',new wp.media.view.Selection({controller:this,collection:this.state().get('selection'),priority:-40,editable:editable&&function(){this.controller.content.mode('edit-selection');}}).render());},mainInsertToolbar:function(view){var controller=this;this.selectionStatusToolbar(view);view.set('insert',{style:'primary',priority:80,text:l10n.insertIntoPost,requires:{selection:true},click:function(){var state=controller.state(),selection=state.get('selection');controller.close();state.trigger('insert',selection).reset();}});},mainGalleryToolbar:function(view){var controller=this;this.selectionStatusToolbar(view);view.set('gallery',{style:'primary',text:l10n.createNewGallery,priority:60,requires:{selection:true},click:function(){var selection=controller.state().get('selection'),edit=controller.state('gallery-edit'),models=selection.where({type:'image'});edit.set('library',new wp.media.model.Selection(models,{props:selection.props.toJSON(),multiple:true}));this.controller.setState('gallery-edit');this.controller.modal.focusManager.focus();}});},mainPlaylistToolbar:function(view){var controller=this;this.selectionStatusToolbar(view);view.set('playlist',{style:'primary',text:l10n.createNewPlaylist,priority:100,requires:{selection:true},click:function(){var selection=controller.state().get('selection'),edit=controller.state('playlist-edit'),models=selection.where({type:'audio'});edit.set('library',new wp.media.model.Selection(models,{props:selection.props.toJSON(),multiple:true}));this.controller.setState('playlist-edit');this.controller.modal.focusManager.focus();}});},mainVideoPlaylistToolbar:function(view){var controller=this;this.selectionStatusToolbar(view);view.set('video-playlist',{style:'primary',text:l10n.createNewVideoPlaylist,priority:100,requires:{selection:true},click:function(){var selection=controller.state().get('selection'),edit=controller.state('video-playlist-edit'),models=selection.where({type:'video'});edit.set('library',new wp.media.model.Selection(models,{props:selection.props.toJSON(),multiple:true}));this.controller.setState('video-playlist-edit');this.controller.modal.focusManager.focus();}});},featuredImageToolbar:function(toolbar){this.createSelectToolbar(toolbar,{text:l10n.setFeaturedImage,state:this.options.state});},mainEmbedToolbar:function(toolbar){toolbar.view=new wp.media.view.Toolbar.Embed({controller:this});},galleryEditToolbar:function(){var editing=this.state().get('editing');this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{insert:{style:'primary',text:editing?l10n.updateGallery:l10n.insertGallery,priority:80,requires:{library:true,uploadingComplete:true},click:function(){var controller=this.controller,state=controller.state();controller.close();state.trigger('update',state.get('library'));controller.setState(controller.options.state);controller.reset();}}}}));},galleryAddToolbar:function(){this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{insert:{style:'primary',text:l10n.addToGallery,priority:80,requires:{selection:true},click:function(){var controller=this.controller,state=controller.state(),edit=controller.state('gallery-edit');edit.get('library').add(state.get('selection').models);state.trigger('reset');controller.setState('gallery-edit');this.controller.modal.focusManager.focus();}}}}));},playlistEditToolbar:function(){var editing=this.state().get('editing');this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{insert:{style:'primary',text:editing?l10n.updatePlaylist:l10n.insertPlaylist,priority:80,requires:{library:true},click:function(){var controller=this.controller,state=controller.state();controller.close();state.trigger('update',state.get('library'));controller.setState(controller.options.state);controller.reset();}}}}));},playlistAddToolbar:function(){this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{insert:{style:'primary',text:l10n.addToPlaylist,priority:80,requires:{selection:true},click:function(){var controller=this.controller,state=controller.state(),edit=controller.state('playlist-edit');edit.get('library').add(state.get('selection').models);state.trigger('reset');controller.setState('playlist-edit');this.controller.modal.focusManager.focus();}}}}));},videoPlaylistEditToolbar:function(){var editing=this.state().get('editing');this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{insert:{style:'primary',text:editing?l10n.updateVideoPlaylist:l10n.insertVideoPlaylist,priority:140,requires:{library:true},click:function(){var controller=this.controller,state=controller.state(),library=state.get('library');library.type='video';controller.close();state.trigger('update',library);controller.setState(controller.options.state);controller.reset();}}}}));},videoPlaylistAddToolbar:function(){this.toolbar.set(new wp.media.view.Toolbar({controller:this,items:{insert:{style:'primary',text:l10n.addToVideoPlaylist,priority:140,requires:{selection:true},click:function(){var controller=this.controller,state=controller.state(),edit=controller.state('video-playlist-edit');edit.get('library').add(state.get('selection').models);state.trigger('reset');controller.setState('video-playlist-edit');this.controller.modal.focusManager.focus();}}}}));}});module.exports=Post;},455
(module){var MediaFrame=wp.media.view.MediaFrame,l10n=wp.media.view.l10n,Select;Select=MediaFrame.extend({initialize:function(){MediaFrame.prototype.initialize.apply(this,arguments);_.defaults(this.options,{selection:[],library:{},multiple:false,state:'library'});this.createSelection();this.createStates();this.bindHandlers();},createSelection:function(){var selection=this.options.selection;if(!(selection instanceof wp.media.model.Selection)){this.options.selection=new wp.media.model.Selection(selection,{multiple:this.options.multiple});}
this._selection={attachments:new wp.media.model.Attachments(),difference:[]};},editImageContent:function(){var image=this.state().get('image'),view=new wp.media.view.EditImage({model:image,controller:this}).render();this.content.set(view);view.loadEditor();},createStates:function(){var options=this.options;if(this.options.states){return;}
this.states.add([new wp.media.controller.Library({library:wp.media.query(options.library),multiple:options.multiple,title:options.title,priority:20}),new wp.media.controller.EditImage({model:options.editImage})]);},bindHandlers:function(){this.on('router:create:browse',this.createRouter,this);this.on('router:render:browse',this.browseRouter,this);this.on('content:create:browse',this.browseContent,this);this.on('content:render:upload',this.uploadContent,this);this.on('toolbar:create:select',this.createSelectToolbar,this);this.on('content:render:edit-image',this.editImageContent,this);},browseRouter:function(routerView){routerView.set({upload:{text:l10n.uploadFilesTitle,priority:20},browse:{text:l10n.mediaLibraryTitle,priority:40}});},browseContent:function(contentRegion){var state=this.state();this.$el.removeClass('hide-toolbar');contentRegion.view=new wp.media.view.AttachmentsBrowser({controller:this,collection:state.get('library'),selection:state.get('selection'),model:state,sortable:state.get('sortable'),search:state.get('searchable'),filters:state.get('filterable'),date:state.get('date'),display:state.has('display')?state.get('display'):state.get('displaySettings'),dragInfo:state.get('dragInfo'),idealColumnWidth:state.get('idealColumnWidth'),suggestedWidth:state.get('suggestedWidth'),suggestedHeight:state.get('suggestedHeight'),AttachmentView:state.get('AttachmentView')});},uploadContent:function(){this.$el.removeClass('hide-toolbar');this.content.set(new wp.media.view.UploaderInline({controller:this}));},createSelectToolbar:function(toolbar,options){options=options||this.options.button||{};options.controller=this;toolbar.view=new wp.media.view.Toolbar.Select(options);}});module.exports=Select;},170
(module){var Heading=wp.media.View.extend({tagName:function(){return this.options.level||'h1';},className:'media-views-heading',initialize:function(){if(this.options.className){this.$el.addClass(this.options.className);}
this.text=this.options.text;},render:function(){this.$el.html(this.text);return this;}});module.exports=Heading;},1982
(module){var Iframe=wp.media.View.extend({className:'media-iframe',render:function(){this.views.detach();this.$el.html('<iframe src="'+this.controller.state().get('src')+'" />');this.views.render();return this;}});module.exports=Iframe;},2650
(module){var AttachmentDisplay=wp.media.view.Settings.AttachmentDisplay,$=jQuery,ImageDetails;ImageDetails=AttachmentDisplay.extend({className:'image-details',template:wp.template('image-details'),events:_.defaults(AttachmentDisplay.prototype.events,{'click .edit-attachment':'editAttachment','click .replace-attachment':'replaceAttachment','click .advanced-toggle':'onToggleAdvanced','change [data-setting="customWidth"]':'onCustomSize','change [data-setting="customHeight"]':'onCustomSize','keyup [data-setting="customWidth"]':'onCustomSize','keyup [data-setting="customHeight"]':'onCustomSize'}),initialize:function(){this.options.attachment=this.model.attachment;this.listenTo(this.model,'change:url',this.updateUrl);this.listenTo(this.model,'change:link',this.toggleLinkSettings);this.listenTo(this.model,'change:size',this.toggleCustomSize);AttachmentDisplay.prototype.initialize.apply(this,arguments);},prepare:function(){var attachment=false;if(this.model.attachment){attachment=this.model.attachment.toJSON();}
return _.defaults({model:this.model.toJSON(),attachment:attachment},this.options);},render:function(){var args=arguments;if(this.model.attachment&&'pending'===this.model.dfd.state()){this.model.dfd.done(_.bind(function(){AttachmentDisplay.prototype.render.apply(this,args);this.postRender();},this)).fail(_.bind(function(){this.model.attachment=false;AttachmentDisplay.prototype.render.apply(this,args);this.postRender();},this));}else{AttachmentDisplay.prototype.render.apply(this,arguments);this.postRender();}
return this;},postRender:function(){setTimeout(_.bind(this.scrollToTop,this),10);this.toggleLinkSettings();if(window.getUserSetting('advImgDetails')==='show'){this.toggleAdvanced(true);}
this.trigger('post-render');},scrollToTop:function(){this.$('.embed-media-settings').scrollTop(0);},updateUrl:function(){this.$('.image img').attr('src',this.model.get('url'));this.$('.url').val(this.model.get('url'));},toggleLinkSettings:function(){if(this.model.get('link')==='none'){this.$('.link-settings').addClass('hidden');}else{this.$('.link-settings').removeClass('hidden');}},toggleCustomSize:function(){if(this.model.get('size')!=='custom'){this.$('.custom-size').addClass('hidden');}else{this.$('.custom-size').removeClass('hidden');}},onCustomSize:function(event){var dimension=$(event.target).data('setting'),num=$(event.target).val(),value;if(!/^\d+/.test(num)||parseInt(num,10)<1){event.preventDefault();return;}
if(dimension==='customWidth'){value=Math.round(1 / this.model.get('aspectRatio')*num);this.model.set('customHeight',value,{silent:true});this.$('[data-setting="customHeight"]').val(value);}else{value=Math.round(this.model.get('aspectRatio')*num);this.model.set('customWidth',value,{silent:true});this.$('[data-setting="customWidth"]').val(value);}},onToggleAdvanced:function(event){event.preventDefault();this.toggleAdvanced();},toggleAdvanced:function(show){var $advanced=this.$el.find('.advanced-section'),mode;if($advanced.hasClass('advanced-visible')||show===false){$advanced.removeClass('advanced-visible');$advanced.find('.advanced-settings').addClass('hidden');mode='hide';}else{$advanced.addClass('advanced-visible');$advanced.find('.advanced-settings').removeClass('hidden');mode='show';}
window.setUserSetting('advImgDetails',mode);},editAttachment:function(event){var editState=this.controller.states.get('edit-image');if(window.imageEdit&&editState){event.preventDefault();editState.set('image',this.model.attachment);this.controller.setState('edit-image');}},replaceAttachment:function(event){event.preventDefault();this.controller.setState('replace-image');}});module.exports=ImageDetails;},4338
(module){var Label=wp.media.View.extend({tagName:'label',initialize:function(){this.value=this.options.value;},render:function(){this.$el.html(this.value);return this;}});module.exports=Label;},2836
(module){var Frame=wp.media.view.Frame,l10n=wp.media.view.l10n,$=jQuery,MediaFrame;MediaFrame=Frame.extend({className:'media-frame',template:wp.template('media-frame'),regions:['menu','title','content','toolbar','router'],events:{'click .media-frame-menu-toggle':'toggleMenu'},initialize:function(){Frame.prototype.initialize.apply(this,arguments);_.defaults(this.options,{title:l10n.mediaFrameDefaultTitle,modal:true,uploader:true});this.$el.addClass('wp-core-ui');if(this.options.modal){this.modal=new wp.media.view.Modal({controller:this,title:this.options.title});this.modal.content(this);}
if(wp.Uploader.limitExceeded||!wp.Uploader.browser.supported){this.options.uploader=false;}
if(this.options.uploader){this.uploader=new wp.media.view.UploaderWindow({controller:this,uploader:{dropzone:this.modal?this.modal.$el:this.$el,container:this.$el}});this.views.set('.media-frame-uploader',this.uploader);}
this.on('attach',_.bind(this.views.ready,this.views),this);this.on('title:create:default',this.createTitle,this);this.title.mode('default');this.on('menu:create:default',this.createMenu,this);this.on('open',this.setMenuTabPanelAriaAttributes,this);this.on('open',this.setRouterTabPanelAriaAttributes,this);this.on('content:render',this.setMenuTabPanelAriaAttributes,this);this.on('content:render',this.setRouterTabPanelAriaAttributes,this);},setMenuTabPanelAriaAttributes:function(){var stateId=this.state().get('id'),tabPanelEl=this.$el.find('.media-frame-tab-panel'),ariaLabelledby;tabPanelEl.removeAttr('role aria-labelledby');if(this.state().get('menu')&&this.menuView&&this.menuView.isVisible){ariaLabelledby='menu-item-'+stateId;tabPanelEl.attr({role:'tabpanel','aria-labelledby':ariaLabelledby,});}},setRouterTabPanelAriaAttributes:function(){var tabPanelEl=this.$el.find('.media-frame-content'),ariaLabelledby;tabPanelEl.removeAttr('role aria-labelledby');if(this.state().get('router')&&this.routerView&&this.routerView.isVisible&&this.content._mode){ariaLabelledby='menu-item-'+this.content._mode;tabPanelEl.attr({role:'tabpanel','aria-labelledby':ariaLabelledby,});}},render:function(){if(!this.state()&&this.options.state){this.setState(this.options.state);}
return Frame.prototype.render.apply(this,arguments);},createTitle:function(title){title.view=new wp.media.View({controller:this,tagName:'h1'});},createMenu:function(menu){menu.view=new wp.media.view.Menu({controller:this,attributes:{role:'tablist','aria-orientation':'vertical'}});this.menuView=menu.view;},toggleMenu:function(event){var menu=this.$el.find('.media-menu');menu.toggleClass('visible');$(event.target).attr('aria-expanded',menu.hasClass('visible'));},createToolbar:function(toolbar){toolbar.view=new wp.media.view.Toolbar({controller:this});},createRouter:function(router){router.view=new wp.media.view.Router({controller:this,attributes:{role:'tablist','aria-orientation':'horizontal'}});this.routerView=router.view;},createIframeStates:function(options){var settings=wp.media.view.settings,tabs=settings.tabs,tabUrl=settings.tabUrl,$postId;if(!tabs||!tabUrl){return;}
$postId=$('#post_ID');if($postId.length){tabUrl+='&post_id='+$postId.val();}
_.each(tabs,function(title,id){this.state('iframe:'+id).set(_.defaults({tab:id,src:tabUrl+'&tab='+id,title:title,content:'iframe',menu:'default'},options));},this);this.on('content:create:iframe',this.iframeContent,this);this.on('content:deactivate:iframe',this.iframeContentCleanup,this);this.on('menu:render:default',this.iframeMenu,this);this.on('open',this.hijackThickbox,this);this.on('close',this.restoreThickbox,this);},iframeContent:function(content){this.$el.addClass('hide-toolbar');content.view=new wp.media.view.Iframe({controller:this});},iframeContentCleanup:function(){this.$el.removeClass('hide-toolbar');},iframeMenu:function(view){var views={};if(!view){return;}
_.each(wp.media.view.settings.tabs,function(title,id){views['iframe:'+id]={text:this.state('iframe:'+id).get('title'),priority:200};},this);view.set(views);},hijackThickbox:function(){var frame=this;if(!window.tb_remove||this._tb_remove){return;}
this._tb_remove=window.tb_remove;window.tb_remove=function(){frame.close();frame.reset();frame.setState(frame.options.state);frame._tb_remove.call(window);};},restoreThickbox:function(){if(!this._tb_remove){return;}
window.tb_remove=this._tb_remove;delete this._tb_remove;}});_.each(['open','close','attach','detach','escape'],function(method){MediaFrame.prototype[method]=function(){if(this.modal){this.modal[method].apply(this.modal,arguments);}
return this;};});module.exports=MediaFrame;},9013
(module){var MenuItem;MenuItem=wp.media.View.extend({tagName:'button',className:'media-menu-item',attributes:{type:'button',role:'tab'},events:{'click':'_click'},_click:function(){var clickOverride=this.options.click;if(clickOverride){clickOverride.call(this);}else{this.click();}},click:function(){var state=this.options.state;if(state){this.controller.setState(state);this.views.parent.$el.removeClass('visible');}},render:function(){var options=this.options,menuProperty=options.state||options.contentMode;if(options.text){this.$el.text(options.text);}else if(options.html){this.$el.html(options.html);}
this.$el.attr('id','menu-item-'+menuProperty);return this;}});module.exports=MenuItem;},1
(module){var MenuItem=wp.media.view.MenuItem,PriorityList=wp.media.view.PriorityList,Menu;Menu=PriorityList.extend({tagName:'div',className:'media-menu',property:'state',ItemView:MenuItem,region:'menu',attributes:{role:'tablist','aria-orientation':'horizontal'},initialize:function(){this._views={};this.set(_.extend({},this._views,this.options.views),{silent:true});delete this.options.views;if(!this.options.silent){this.render();}
this.focusManager=new wp.media.view.FocusManager({el:this.el,mode:'tabsNavigation'});this.isVisible=true;},toView:function(options,id){options=options||{};options[this.property]=options[this.property]||id;return new this.ItemView(options).render();},ready:function(){PriorityList.prototype.ready.apply(this,arguments);this.visibility();this.focusManager.setupAriaTabs();},set:function(){PriorityList.prototype.set.apply(this,arguments);this.visibility();},unset:function(){PriorityList.prototype.unset.apply(this,arguments);this.visibility();},visibility:function(){var region=this.region,view=this.controller[region].get(),views=this.views.get(),hide=!views||views.length<2;if(this===view){this.isVisible=!hide;this.controller.$el.toggleClass('hide-'+region,hide);}},select:function(id){var view=this.get(id);if(!view){return;}
this.deselect();view.$el.addClass('active');this.focusManager.setupAriaTabs();},deselect:function(){this.$el.children().removeClass('active');},hide:function(id){var view=this.get(id);if(!view){return;}
view.$el.addClass('hidden');},show:function(id){var view=this.get(id);if(!view){return;}
view.$el.removeClass('hidden');}});module.exports=Menu;},2621
(module){var $=jQuery,Modal;Modal=wp.media.View.extend({tagName:'div',template:wp.template('media-modal'),events:{'click .media-modal-backdrop, .media-modal-close':'escapeHandler','keydown':'keydown'},clickedOpenerEl:null,initialize:function(){_.defaults(this.options,{container:document.body,title:'',propagate:true,hasCloseButton:true});this.focusManager=new wp.media.view.FocusManager({el:this.el});},prepare:function(){return{title:this.options.title,hasCloseButton:this.options.hasCloseButton};},attach:function(){if(this.views.attached){return this;}
if(!this.views.rendered){this.render();}
this.$el.appendTo(this.options.container);this.views.attached=true;this.views.ready();return this.propagate('attach');},detach:function(){if(this.$el.is(':visible')){this.close();}
this.$el.detach();this.views.attached=false;return this.propagate('detach');},open:function(){var $el=this.$el,mceEditor;if($el.is(':visible')){return this;}
this.clickedOpenerEl=document.activeElement;if(!this.views.attached){this.attach();}
$('body').addClass('modal-open');$el.show();if('ontouchend'in document){if((mceEditor=window.tinymce&&window.tinymce.activeEditor)&&!mceEditor.isHidden()&&mceEditor.iframeElement){mceEditor.iframeElement.focus();mceEditor.iframeElement.blur();setTimeout(function(){mceEditor.iframeElement.blur();},100);}}
this.$('.media-modal').trigger('focus');this.focusManager.setAriaHiddenOnBodyChildren($el);return this.propagate('open');},close:function(options){if(!this.views.attached||!this.$el.is(':visible')){return this;}
$('.mejs-pause button').trigger('click');$('body').removeClass('modal-open');this.$el.hide();this.focusManager.removeAriaHiddenFromBodyChildren();if(null!==this.clickedOpenerEl){this.clickedOpenerEl.focus();}else{$('#wpbody-content').attr('tabindex','-1').trigger('focus');}
this.propagate('close');if(options&&options.escape){this.propagate('escape');}
return this;},escape:function(){return this.close({escape:true});},escapeHandler:function(event){event.preventDefault();this.escape();},selectHandler:function(event){var selection=this.controller.state().get('selection');if(selection.length<=0){return;}
if('insert'===this.controller.options.state){this.controller.trigger('insert',selection);}else{this.controller.trigger('select',selection);event.preventDefault();this.escape();}},content:function(content){this.views.set('.media-modal-content',content);return this;},propagate:function(id){this.trigger(id);if(this.options.propagate){this.controller.trigger(id);}
return this;},keydown:function(event){if(27===event.which&&this.$el.is(':visible')){this.escape();event.stopImmediatePropagation();}
if((13===event.which||10===event.which)&&(event.metaKey||event.ctrlKey)){this.selectHandler(event);event.stopImmediatePropagation();}}});module.exports=Modal;},8815
(module){var PriorityList=wp.media.View.extend({tagName:'div',initialize:function(){this._views={};this.set(_.extend({},this._views,this.options.views),{silent:true});delete this.options.views;if(!this.options.silent){this.render();}},set:function(id,view,options){var priority,views,index;options=options||{};if(_.isObject(id)){_.each(id,function(view,id){this.set(id,view);},this);return this;}
if(!(view instanceof Backbone.View)){view=this.toView(view,id,options);}
view.controller=view.controller||this.controller;this.unset(id);priority=view.options.priority||10;views=this.views.get()||[];_.find(views,function(existing,i){if(existing.options.priority>priority){index=i;return true;}});this._views[id]=view;this.views.add(view,{at:_.isNumber(index)?index:views.length||0});return this;},get:function(id){return this._views[id];},unset:function(id){var view=this.get(id);if(view){view.remove();}
delete this._views[id];return this;},toView:function(options){return new wp.media.View(options);}});module.exports=PriorityList;},6327
(module){var RouterItem=wp.media.view.MenuItem.extend({click:function(){var contentMode=this.options.contentMode;if(contentMode){this.controller.content.mode(contentMode);}}});module.exports=RouterItem;},4783
(module){var Menu=wp.media.view.Menu,Router;Router=Menu.extend({tagName:'div',className:'media-router',property:'contentMode',ItemView:wp.media.view.RouterItem,region:'router',attributes:{role:'tablist','aria-orientation':'horizontal'},initialize:function(){this.controller.on('content:render',this.update,this);Menu.prototype.initialize.apply(this,arguments);},update:function(){var mode=this.controller.content.mode();if(mode){this.select(mode);}}});module.exports=Router;},2102
(module){var Search;Search=wp.media.View.extend({tagName:'input',className:'search',id:'media-search-input',attributes:{type:'search'},events:{'input':'search'},render:function(){this.el.value=this.model.escape('search');return this;},search:_.debounce(function(event){var searchTerm=event.target.value.trim();if(searchTerm&&searchTerm.length>1){this.model.set('search',searchTerm);}else{this.model.unset('search');}},500)});module.exports=Search;},8282
(module){var _n=wp.i18n._n,sprintf=wp.i18n.sprintf,Selection;Selection=wp.media.View.extend({tagName:'div',className:'media-selection',template:wp.template('media-selection'),events:{'click .edit-selection':'edit','click .clear-selection':'clear'},initialize:function(){_.defaults(this.options,{editable:false,clearable:true});this.attachments=new wp.media.view.Attachments.Selection({controller:this.controller,collection:this.collection,selection:this.collection,model:new Backbone.Model()});this.views.set('.selection-view',this.attachments);this.collection.on('add remove reset',this.refresh,this);this.controller.on('content:activate',this.refresh,this);},ready:function(){this.refresh();},refresh:function(){if(!this.$el.children().length){return;}
var collection=this.collection,editing='edit-selection'===this.controller.content.mode();this.$el.toggleClass('empty',!collection.length);this.$el.toggleClass('one',1===collection.length);this.$el.toggleClass('editing',editing);this.$('.count').text(sprintf(_n('%s item selected','%s items selected',collection.length),collection.length));},edit:function(event){event.preventDefault();if(this.options.editable){this.options.editable.call(this,this.collection);}},clear:function(event){event.preventDefault();this.collection.reset();this.controller.modal.focusManager.focus();}});module.exports=Selection;},1915
(module){var View=wp.media.View,$=Backbone.$,Settings;Settings=View.extend({events:{'click button':'updateHandler','change input':'updateHandler','change select':'updateHandler','change textarea':'updateHandler'},initialize:function(){this.model=this.model||new Backbone.Model();this.listenTo(this.model,'change',this.updateChanges);},prepare:function(){return _.defaults({model:this.model.toJSON()},this.options);},render:function(){View.prototype.render.apply(this,arguments);_(this.model.attributes).chain().keys().each(this.update,this);return this;},update:function(key){var value=this.model.get(key),$setting=this.$('[data-setting="'+key+'"]'),$buttons,$value;if(!$setting.length){return;}
if($setting.is('select')){$value=$setting.find('[value="'+value+'"]');if($value.length){$setting.find('option').prop('selected',false);$value.prop('selected',true);}else{this.model.set(key,$setting.find(':selected').val());}}else if($setting.hasClass('button-group')){$buttons=$setting.find('button').removeClass('active').attr('aria-pressed','false');$buttons.filter('[value="'+value+'"]').addClass('active').attr('aria-pressed','true');}else if($setting.is('input[type="text"], textarea')){if(!$setting.is(':focus')){$setting.val(value);}}else if($setting.is('input[type="checkbox"]')){$setting.prop('checked',!!value&&'false'!==value);}},updateHandler:function(event){var $setting=$(event.target).closest('[data-setting]'),value=event.target.value,userSetting;event.preventDefault();if(!$setting.length){return;}
if($setting.is('input[type="checkbox"]')){value=$setting[0].checked;}
this.model.set($setting.data('setting'),value);userSetting=$setting.data('userSetting');if(userSetting){window.setUserSetting(userSetting,value);}},updateChanges:function(model){if(model.hasChanged()){_(model.changed).chain().keys().each(this.update,this);}}});module.exports=Settings;},7656
(module){var Settings=wp.media.view.Settings,AttachmentDisplay;AttachmentDisplay=Settings.extend({className:'attachment-display-settings',template:wp.template('attachment-display-settings'),initialize:function(){var attachment=this.options.attachment;_.defaults(this.options,{userSettings:false});Settings.prototype.initialize.apply(this,arguments);this.listenTo(this.model,'change:link',this.updateLinkTo);if(attachment){attachment.on('change:uploading',this.render,this);}},dispose:function(){var attachment=this.options.attachment;if(attachment){attachment.off(null,null,this);}
Settings.prototype.dispose.apply(this,arguments);},render:function(){var attachment=this.options.attachment;if(attachment){_.extend(this.options,{sizes:attachment.get('sizes'),type:attachment.get('type')});}
Settings.prototype.render.call(this);this.updateLinkTo();return this;},updateLinkTo:function(){var linkTo=this.model.get('link'),$input=this.$('.link-to-custom'),attachment=this.options.attachment;if('none'===linkTo||'embed'===linkTo||(!attachment&&'custom'!==linkTo)){$input.closest('.setting').addClass('hidden');return;}
if(attachment){if('post'===linkTo){$input.val(attachment.get('link'));}else if('file'===linkTo){$input.val(attachment.get('url'));}else if(!this.model.get('linkUrl')){$input.val('http://');}
$input.prop('readonly','custom'!==linkTo);}
$input.closest('.setting').removeClass('hidden');if($input.length){$input[0].scrollIntoView();}}});module.exports=AttachmentDisplay;},7266
(module){var Gallery=wp.media.view.Settings.extend({className:'collection-settings gallery-settings',template:wp.template('gallery-settings')});module.exports=Gallery;},2356
(module){var Playlist=wp.media.view.Settings.extend({className:'collection-settings playlist-settings',template:wp.template('playlist-settings')});module.exports=Playlist;},1992
(module){var Sidebar=wp.media.view.PriorityList.extend({className:'media-sidebar'});module.exports=Sidebar;},443
(module){var View=wp.media.view,SiteIconCropper;SiteIconCropper=View.Cropper.extend({className:'crop-content site-icon',ready:function(){View.Cropper.prototype.ready.apply(this,arguments);this.$('.crop-image').on('load',_.bind(this.addSidebar,this));},addSidebar:function(){this.sidebar=new wp.media.view.Sidebar({controller:this.controller});this.sidebar.set('preview',new wp.media.view.SiteIconPreview({controller:this.controller,attachment:this.options.attachment}));this.controller.cropperView.views.add(this.sidebar);}});module.exports=SiteIconCropper;},7810
(module){var View=wp.media.View,$=jQuery,SiteIconPreview;SiteIconPreview=View.extend({className:'site-icon-preview-crop-modal',template:wp.template('site-icon-preview-crop'),ready:function(){this.controller.imgSelect.setOptions({onInit:this.updatePreview,onSelectChange:this.updatePreview});},prepare:function(){return{url:this.options.attachment.get('url')};},updatePreview:function(img,coords){var rx=64 / coords.width,ry=64 / coords.height,preview_rx=24 / coords.width,preview_ry=24 / coords.height;$('#preview-app-icon').css({width:Math.round(rx*this.imageWidth)+'px',height:Math.round(ry*this.imageHeight)+'px',marginLeft:'-'+Math.round(rx*coords.x1)+'px',marginTop:'-'+Math.round(ry*coords.y1)+'px'});$('#preview-favicon').css({width:Math.round(preview_rx*this.imageWidth)+'px',height:Math.round(preview_ry*this.imageHeight)+'px',marginLeft:'-'+Math.round(preview_rx*coords.x1)+'px',marginTop:'-'+Math.floor(preview_ry*coords.y1)+'px'});}});module.exports=SiteIconPreview;},9141
(module){var Spinner=wp.media.View.extend({tagName:'span',className:'spinner',spinnerTimeout:false,delay:400,show:function(){if(!this.spinnerTimeout){this.spinnerTimeout=_.delay(function($el){$el.addClass('is-active');},this.delay,this.$el);}
return this;},hide:function(){this.$el.removeClass('is-active');this.spinnerTimeout=clearTimeout(this.spinnerTimeout);return this;}});module.exports=Spinner;},5275
(module){var View=wp.media.View,Toolbar;Toolbar=View.extend({tagName:'div',className:'media-toolbar',initialize:function(){var state=this.controller.state(),selection=this.selection=state.get('selection'),library=this.library=state.get('library');this._views={};this.primary=new wp.media.view.PriorityList();this.secondary=new wp.media.view.PriorityList();this.tertiary=new wp.media.view.PriorityList();this.primary.$el.addClass('media-toolbar-primary search-form');this.secondary.$el.addClass('media-toolbar-secondary');this.tertiary.$el.addClass('media-bg-overlay');this.views.set([this.secondary,this.primary,this.tertiary]);if(this.options.items){this.set(this.options.items,{silent:true});}
if(!this.options.silent){this.render();}
if(selection){selection.on('add remove reset',this.refresh,this);}
if(library){library.on('add remove reset',this.refresh,this);}},dispose:function(){if(this.selection){this.selection.off(null,null,this);}
if(this.library){this.library.off(null,null,this);}
return View.prototype.dispose.apply(this,arguments);},ready:function(){this.refresh();},set:function(id,view,options){var list;options=options||{};if(_.isObject(id)){_.each(id,function(view,id){this.set(id,view,{silent:true});},this);}else{if(!(view instanceof Backbone.View)){view.classes=['media-button-'+id].concat(view.classes||[]);view=new wp.media.view.Button(view).render();}
view.controller=view.controller||this.controller;this._views[id]=view;list=view.options.priority<0?'secondary':'primary';this[list].set(id,view,options);}
if(!options.silent){this.refresh();}
return this;},get:function(id){return this._views[id];},unset:function(id,options){delete this._views[id];this.primary.unset(id,options);this.secondary.unset(id,options);this.tertiary.unset(id,options);if(!options||!options.silent){this.refresh();}
return this;},refresh:function(){var state=this.controller.state(),library=state.get('library'),selection=state.get('selection');_.each(this._views,function(button){if(!button.model||!button.options||!button.options.requires){return;}
var requires=button.options.requires,disabled=false,modelsUploading=library&&!_.isEmpty(library.findWhere({'uploading':true}));if(selection&&selection.models){disabled=_.some(selection.models,function(attachment){return attachment.get('uploading')===true;});}
if(requires.uploadingComplete&&modelsUploading){disabled=true;}
if(requires.selection&&selection&&!selection.length){disabled=true;}else if(requires.library&&library&&!library.length){disabled=true;}
button.model.set('disabled',disabled);});}});module.exports=Toolbar;},397
(module){var Select=wp.media.view.Toolbar.Select,l10n=wp.media.view.l10n,Embed;Embed=Select.extend({initialize:function(){_.defaults(this.options,{text:l10n.insertIntoPost,requires:false});Select.prototype.initialize.apply(this,arguments);},refresh:function(){var url=this.controller.state().props.get('url');this.get('select').model.set('disabled',!url||url==='http://');Select.prototype.refresh.apply(this,arguments);}});module.exports=Embed;},9458
(module){var Toolbar=wp.media.view.Toolbar,l10n=wp.media.view.l10n,Select;Select=Toolbar.extend({initialize:function(){var options=this.options;_.bindAll(this,'clickSelect');_.defaults(options,{event:'select',state:false,reset:true,close:true,text:l10n.select,requires:{selection:true}});options.items=_.defaults(options.items||{},{select:{style:'primary',text:options.text,priority:80,click:this.clickSelect,requires:options.requires}});Toolbar.prototype.initialize.apply(this,arguments);},clickSelect:function(){var options=this.options,controller=this.controller;if(options.close){controller.close();}
if(options.event){controller.state().trigger(options.event);}
if(options.state){controller.setState(options.state);}
if(options.reset){controller.reset();}}});module.exports=Select;},3674
(module){var View=wp.media.View,l10n=wp.media.view.l10n,$=jQuery,EditorUploader;EditorUploader=View.extend({tagName:'div',className:'uploader-editor',template:wp.template('uploader-editor'),localDrag:false,overContainer:false,overDropzone:false,draggingFile:null,initialize:function(){this.initialized=false;if(!window.tinyMCEPreInit||!window.tinyMCEPreInit.dragDropUpload||!this.browserSupport()){return this;}
this.$document=$(document);this.dropzones=[];this.files=[];this.$document.on('drop','.uploader-editor',_.bind(this.drop,this));this.$document.on('dragover','.uploader-editor',_.bind(this.dropzoneDragover,this));this.$document.on('dragleave','.uploader-editor',_.bind(this.dropzoneDragleave,this));this.$document.on('click','.uploader-editor',_.bind(this.click,this));this.$document.on('dragover',_.bind(this.containerDragover,this));this.$document.on('dragleave',_.bind(this.containerDragleave,this));this.$document.on('dragstart dragend drop',_.bind(function(event){this.localDrag=event.type==='dragstart';if(event.type==='drop'){this.containerDragleave();}},this));this.initialized=true;return this;},browserSupport:function(){var supports=false,div=document.createElement('div');supports=('draggable'in div)||('ondragstart'in div&&'ondrop'in div);supports=supports&&!!(window.File&&window.FileList&&window.FileReader);return supports;},isDraggingFile:function(event){if(this.draggingFile!==null){return this.draggingFile;}
if(_.isUndefined(event.originalEvent)||_.isUndefined(event.originalEvent.dataTransfer)){return false;}
this.draggingFile=_.indexOf(event.originalEvent.dataTransfer.types,'Files')>-1&&_.indexOf(event.originalEvent.dataTransfer.types,'text/plain')===-1;return this.draggingFile;},refresh:function(e){var dropzone_id;for(dropzone_id in this.dropzones){this.dropzones[dropzone_id].toggle(this.overContainer||this.overDropzone);}
if(!_.isUndefined(e)){$(e.target).closest('.uploader-editor').toggleClass('droppable',this.overDropzone);}
if(!this.overContainer&&!this.overDropzone){this.draggingFile=null;}
return this;},render:function(){if(!this.initialized){return this;}
View.prototype.render.apply(this,arguments);$('.wp-editor-wrap').each(_.bind(this.attach,this));return this;},attach:function(index,editor){var dropzone=this.$el.clone();this.dropzones.push(dropzone);$(editor).append(dropzone);return this;},drop:function(event){var $wrap,uploadView;this.containerDragleave(event);this.dropzoneDragleave(event);this.files=event.originalEvent.dataTransfer.files;if(this.files.length<1){return;}
$wrap=$(event.target).parents('.wp-editor-wrap');if($wrap.length>0&&$wrap[0].id){window.wpActiveEditor=$wrap[0].id.slice(3,-5);}
if(!this.workflow){this.workflow=wp.media.editor.open(window.wpActiveEditor,{frame:'post',state:'insert',title:l10n.addMedia,multiple:true});uploadView=this.workflow.uploader;if(uploadView.uploader&&uploadView.uploader.ready){this.addFiles.apply(this);}else{this.workflow.on('uploader:ready',this.addFiles,this);}}else{this.workflow.state().reset();this.addFiles.apply(this);this.workflow.open();}
return false;},addFiles:function(){if(this.files.length){this.workflow.uploader.uploader.uploader.addFile(_.toArray(this.files));this.files=[];}
return this;},containerDragover:function(event){if(this.localDrag||!this.isDraggingFile(event)){return;}
this.overContainer=true;this.refresh();},containerDragleave:function(){this.overContainer=false;_.delay(_.bind(this.refresh,this),50);},dropzoneDragover:function(event){if(this.localDrag||!this.isDraggingFile(event)){return;}
this.overDropzone=true;this.refresh(event);return false;},dropzoneDragleave:function(e){this.overDropzone=false;_.delay(_.bind(this.refresh,this,e),50);},click:function(e){this.containerDragleave(e);this.dropzoneDragleave(e);this.localDrag=false;}});module.exports=EditorUploader;},1753
(module){var View=wp.media.View,UploaderInline;UploaderInline=View.extend({tagName:'div',className:'uploader-inline',template:wp.template('uploader-inline'),events:{'click .close':'hide'},initialize:function(){_.defaults(this.options,{message:'',status:true,canClose:false});if(!this.options.$browser&&this.controller.uploader){this.options.$browser=this.controller.uploader.$browser;}
if(_.isUndefined(this.options.postId)){this.options.postId=wp.media.view.settings.post.id;}
if(this.options.status){this.views.set('.upload-inline-status',new wp.media.view.UploaderStatus({controller:this.controller}));}},prepare:function(){var suggestedWidth=this.controller.state().get('suggestedWidth'),suggestedHeight=this.controller.state().get('suggestedHeight'),data={};data.message=this.options.message;data.canClose=this.options.canClose;if(suggestedWidth&&suggestedHeight){data.suggestedWidth=suggestedWidth;data.suggestedHeight=suggestedHeight;}
return data;},dispose:function(){if(this.disposing){return View.prototype.dispose.apply(this,arguments);}
this.disposing=true;return this.remove();},remove:function(){var result=View.prototype.remove.apply(this,arguments);_.defer(_.bind(this.refresh,this));return result;},refresh:function(){var uploader=this.controller.uploader;if(uploader){uploader.refresh();}},ready:function(){var $browser=this.options.$browser,$placeholder;if(this.controller.uploader){$placeholder=this.$('.browser');if($placeholder[0]===$browser[0]){return;}
$browser.detach().text($placeholder.text());$browser[0].className=$placeholder[0].className;$browser[0].setAttribute('aria-describedby',$placeholder[0].getAttribute('aria-describedby'));$placeholder.replaceWith($browser.show());}
this.refresh();return this;},show:function(){this.$el.removeClass('hidden');if(this.controller.$uploaderToggler&&this.controller.$uploaderToggler.length){this.controller.$uploaderToggler.attr('aria-expanded','true');}},hide:function(){this.$el.addClass('hidden');if(this.controller.$uploaderToggler&&this.controller.$uploaderToggler.length){this.controller.$uploaderToggler.attr('aria-expanded','false').trigger('focus');}}});module.exports=UploaderInline;},6442
(module){var UploaderStatusError=wp.media.View.extend({className:'upload-error',template:wp.template('uploader-status-error')});module.exports=UploaderStatusError;},8197
(module){var View=wp.media.View,UploaderStatus;UploaderStatus=View.extend({className:'media-uploader-status',template:wp.template('uploader-status'),events:{'click .upload-dismiss-errors':'dismiss'},initialize:function(){this.queue=wp.Uploader.queue;this.queue.on('add remove reset',this.visibility,this);this.queue.on('add remove reset change:percent',this.progress,this);this.queue.on('add remove reset change:uploading',this.info,this);this.errors=wp.Uploader.errors;this.errors.reset();this.errors.on('add remove reset',this.visibility,this);this.errors.on('add',this.error,this);},dispose:function(){wp.Uploader.queue.off(null,null,this);View.prototype.dispose.apply(this,arguments);return this;},visibility:function(){this.$el.toggleClass('uploading',!!this.queue.length);this.$el.toggleClass('errors',!!this.errors.length);this.$el.toggle(!!this.queue.length||!!this.errors.length);},ready:function(){_.each({'$bar':'.media-progress-bar div','$index':'.upload-index','$total':'.upload-total','$filename':'.upload-filename'},function(selector,key){this[key]=this.$(selector);},this);this.visibility();this.progress();this.info();},progress:function(){var queue=this.queue,$bar=this.$bar;if(!$bar||!queue.length){return;}
$bar.width((queue.reduce(function(memo,attachment){if(!attachment.get('uploading')){return memo+100;}
var percent=attachment.get('percent');return memo+(_.isNumber(percent)?percent:100);},0)/ queue.length)+'%');},info:function(){var queue=this.queue,index=0,active;if(!queue.length){return;}
active=this.queue.find(function(attachment,i){index=i;return attachment.get('uploading');});if(this.$index&&this.$total&&this.$filename){this.$index.text(index+1);this.$total.text(queue.length);this.$filename.html(active?this.filename(active.get('filename')):'');}},filename:function(filename){return _.escape(filename);},error:function(error){var statusError=new wp.media.view.UploaderStatusError({filename:this.filename(error.get('file').name),message:error.get('message')});var buttonClose=this.$el.find('button');this.views.add('.upload-errors',statusError,{at:0});_.delay(function(){buttonClose.trigger('focus');},1000);_.delay(function(){wp.a11y.speak(error.get('message'));},1500);},dismiss:function(){var errors=this.views.get('.upload-errors');if(errors){_.invoke(errors,'remove');}
wp.Uploader.errors.reset();wp.a11y.speak(wp.i18n.__('Error dismissed.'));if(this.controller.modal){this.controller.modal.focusManager.focus();}}});module.exports=UploaderStatus;},8291
(module){var $=jQuery,UploaderWindow;UploaderWindow=wp.media.View.extend({tagName:'div',className:'uploader-window',template:wp.template('uploader-window'),initialize:function(){var uploader;this.$browser=$('<button type="button" class="browser" />').hide().appendTo('body');uploader=this.options.uploader=_.defaults(this.options.uploader||{},{dropzone:this.$el,browser:this.$browser,params:{}});if(uploader.dropzone&&!(uploader.dropzone instanceof $)){uploader.dropzone=$(uploader.dropzone);}
this.controller.on('activate',this.refresh,this);this.controller.on('detach',function(){this.$browser.remove();},this);},refresh:function(){if(this.uploader){this.uploader.refresh();}},ready:function(){var postId=wp.media.view.settings.post.id,dropzone;if(this.uploader){return;}
if(postId){this.options.uploader.params.post_id=postId;}
this.uploader=new wp.Uploader(this.options.uploader);dropzone=this.uploader.dropzone;dropzone.on('dropzone:enter',_.bind(this.show,this));dropzone.on('dropzone:leave',_.bind(this.hide,this));$(this.uploader).on('uploader:ready',_.bind(this._ready,this));},_ready:function(){this.controller.trigger('uploader:ready');},show:function(){var $el=this.$el.show();_.defer(function(){$el.css({opacity:1});});},hide:function(){var $el=this.$el.css({opacity:0});wp.media.transition($el).done(function(){if('0'===$el.css('opacity')){$el.hide();}});_.delay(function(){if('0'===$el.css('opacity')&&$el.is(':visible')){$el.hide();}},500);}});module.exports=UploaderWindow;},4747
(module){var View=wp.Backbone.View.extend({constructor:function(options){if(options&&options.controller){this.controller=options.controller;}
wp.Backbone.View.apply(this,arguments);},dispose:function(){this.undelegateEvents();if(this.model&&this.model.off){this.model.off(null,null,this);}
if(this.collection&&this.collection.off){this.collection.off(null,null,this);}
if(this.controller&&this.controller.off){this.controller.off(null,null,this);}
return this;},remove:function(){this.dispose();return wp.Backbone.View.prototype.remove.apply(this,arguments);}});module.exports=View;}});const __webpack_module_cache__={};function __webpack_require__(moduleId){const cachedModule=__webpack_module_cache__[moduleId];if(cachedModule!==undefined){return cachedModule.exports;}
const module=__webpack_module_cache__[moduleId]={exports:{}};__webpack_modules__[moduleId](module,module.exports,__webpack_require__);return module.exports;}
var media=wp.media,$=jQuery,l10n;media.isTouchDevice=('ontouchend'in document);l10n=media.view.l10n=window._wpMediaViewsL10n||{};media.view.settings=l10n.settings||{};delete l10n.settings;media.model.settings.post=media.view.settings.post;$.support.transition=(function(){var style=document.documentElement.style,transitions={WebkitTransition:'webkitTransitionEnd',MozTransition:'transitionend',OTransition:'oTransitionEnd otransitionend',transition:'transitionend'},transition;transition=_.find(_.keys(transitions),function(transition){return!_.isUndefined(style[transition]);});return transition&&{end:transitions[transition]};}());media.events=_.extend({},Backbone.Events);media.transition=function(selector,sensitivity){var deferred=$.Deferred();sensitivity=sensitivity||2000;if($.support.transition){if(!(selector instanceof $)){selector=$(selector);}
selector.first().one($.support.transition.end,deferred.resolve);_.delay(deferred.resolve,sensitivity);}else{deferred.resolve();}
return deferred.promise();};media.controller.Region=__webpack_require__(9875);media.controller.StateMachine=__webpack_require__(6150);media.controller.State=__webpack_require__(5694);media.selectionSync=__webpack_require__(4181);media.controller.Library=__webpack_require__(472);media.controller.ImageDetails=__webpack_require__(705);media.controller.GalleryEdit=__webpack_require__(2038);media.controller.GalleryAdd=__webpack_require__(7127);media.controller.CollectionEdit=__webpack_require__(8612);media.controller.CollectionAdd=__webpack_require__(7145);media.controller.FeaturedImage=__webpack_require__(1169);media.controller.ReplaceImage=__webpack_require__(2275);media.controller.EditImage=__webpack_require__(5663);media.controller.MediaLibrary=__webpack_require__(8065);media.controller.Embed=__webpack_require__(4910);media.controller.Cropper=__webpack_require__(5422);media.controller.CustomizeImageCropper=__webpack_require__(9660);media.controller.SiteIconCropper=__webpack_require__(6172);media.View=__webpack_require__(4747);media.view.Frame=__webpack_require__(1061);media.view.MediaFrame=__webpack_require__(2836);media.view.MediaFrame.Select=__webpack_require__(455);media.view.MediaFrame.Post=__webpack_require__(4274);media.view.MediaFrame.ImageDetails=__webpack_require__(5424);media.view.Modal=__webpack_require__(2621);media.view.FocusManager=__webpack_require__(718);media.view.UploaderWindow=__webpack_require__(8291);media.view.EditorUploader=__webpack_require__(3674);media.view.UploaderInline=__webpack_require__(1753);media.view.UploaderStatus=__webpack_require__(8197);media.view.UploaderStatusError=__webpack_require__(6442);media.view.Toolbar=__webpack_require__(5275);media.view.Toolbar.Select=__webpack_require__(9458);media.view.Toolbar.Embed=__webpack_require__(397);media.view.Button=__webpack_require__(846);media.view.ButtonGroup=__webpack_require__(168);media.view.PriorityList=__webpack_require__(8815);media.view.MenuItem=__webpack_require__(9013);media.view.Menu=__webpack_require__(1);media.view.RouterItem=__webpack_require__(6327);media.view.Router=__webpack_require__(4783);media.view.Sidebar=__webpack_require__(1992);media.view.Attachment=__webpack_require__(4075);media.view.Attachment.Library=__webpack_require__(3443);media.view.Attachment.EditLibrary=__webpack_require__(5232);media.view.Attachments=__webpack_require__(8142);media.view.Search=__webpack_require__(2102);media.view.AttachmentFilters=__webpack_require__(7709);media.view.DateFilter=__webpack_require__(6472);media.view.AttachmentFilters.Uploaded=__webpack_require__(1368);media.view.AttachmentFilters.All=__webpack_require__(7349);media.view.AttachmentsBrowser=__webpack_require__(6829);media.view.Selection=__webpack_require__(8282);media.view.Attachment.Selection=__webpack_require__(3962);media.view.Attachments.Selection=__webpack_require__(3479);media.view.Attachment.EditSelection=__webpack_require__(4593);media.view.Settings=__webpack_require__(1915);media.view.Settings.AttachmentDisplay=__webpack_require__(7656);media.view.Settings.Gallery=__webpack_require__(7266);media.view.Settings.Playlist=__webpack_require__(2356);media.view.Attachment.Details=__webpack_require__(6090);media.view.AttachmentCompat=__webpack_require__(2982);media.view.Iframe=__webpack_require__(1982);media.view.Embed=__webpack_require__(5741);media.view.Label=__webpack_require__(4338);media.view.EmbedUrl=__webpack_require__(7327);media.view.EmbedLink=__webpack_require__(8232);media.view.EmbedImage=__webpack_require__(2395);media.view.ImageDetails=__webpack_require__(2650);media.view.Cropper=__webpack_require__(7637);media.view.SiteIconCropper=__webpack_require__(443);media.view.SiteIconPreview=__webpack_require__(7810);media.view.EditImage=__webpack_require__(6126);media.view.Spinner=__webpack_require__(9141);media.view.Heading=__webpack_require__(170);})();