!function(c,d,l){"use strict";function m(e){return e=e||"",e=l("
").text(e).html(),(e=l.trim(e))||c.Menus.data.l10n.unnamed}wpNavMenu.originalInit=wpNavMenu.init,wpNavMenu.options.menuItemDepthPerLevel=20,wpNavMenu.options.sortableItems="> .customize-control-nav_menu_item",wpNavMenu.options.targetTolerance=10,wpNavMenu.init=function(){this.jQueryExtensions()},c.Menus=c.Menus||{},c.Menus.data={itemTypes:[],l10n:{},settingTransport:"refresh",phpIntMax:0,defaultSettingValues:{nav_menu:{},nav_menu_item:{}},locationSlugMappedToName:{}},"undefined"!=typeof _wpCustomizeNavMenusSettings&&l.extend(c.Menus.data,_wpCustomizeNavMenusSettings),c.Menus.generatePlaceholderAutoIncrementId=function(){return-Math.ceil(c.Menus.data.phpIntMax*Math.random())},c.Menus.AvailableItemModel=Backbone.Model.extend(l.extend({id:null},c.Menus.data.defaultSettingValues.nav_menu_item)),c.Menus.AvailableItemCollection=Backbone.Collection.extend({model:c.Menus.AvailableItemModel,sort_key:"order",comparator:function(e){return-e.get(this.sort_key)},sortByField:function(e){this.sort_key=e,this.sort()}}),c.Menus.availableMenuItems=new c.Menus.AvailableItemCollection(c.Menus.data.availableMenuItems),c.Menus.AvailableMenuItemsPanelView=d.Backbone.View.extend({el:"#available-menu-items",events:{"input #menu-items-search":"debounceSearch","keyup #menu-items-search":"debounceSearch","focus .menu-item-tpl":"focus","click .menu-item-tpl":"_submit","click #custom-menu-item-submit":"_submitLink","keypress #custom-menu-item-name":"_submitLink",keydown:"keyboardAccessible"},selected:null,currentMenuControl:null,debounceSearch:null,$search:null,searchTerm:"",rendered:!1,pages:{},sectionContent:"",loading:!1,initialize:function(){var n=this;c.panel.has("nav_menus")&&(this.$search=l("#menu-items-search"),this.sectionContent=this.$el.find(".accordion-section-content"),this.debounceSearch=_.debounce(n.search,500),_.bindAll(this,"close"),l("#customize-controls, .customize-section-back").on("click keydown",function(e){var t=l(e.target).is(".item-delete, .item-delete *"),e=l(e.target).is(".add-new-menu-item, .add-new-menu-item *");!l("body").hasClass("adding-menu-items")||t||e||n.close()}),l(".clear-results").on("click keydown",function(e){"keydown"===e.type&&13!==e.which&&32!==e.which||(e.preventDefault(),l("#menu-items-search").val("").focus(),e.target.value="",n.search(e))}),this.$el.on("input","#custom-menu-item-name.invalid, #custom-menu-item-url.invalid",function(){l(this).removeClass("invalid")}),c.panel("nav_menus").container.bind("expanded",function(){n.rendered||(n.initList(),n.rendered=!0)}),this.sectionContent.scroll(function(){var e=n.$el.find(".accordion-section.open .accordion-section-content").prop("scrollHeight"),t=n.$el.find(".accordion-section.open").height();!n.loading&&l(this).scrollTop()>.75*e-t&&(e=l(this).data("type"),t=l(this).data("object"),"search"===e?n.searchTerm&&n.doSearch(n.pages.search):n.loadItems(e,t))}),c.previewer.bind("url",this.close),n.delegateEvents())},search:function(e){var t=l("#available-menu-items-search"),n=l("#available-menu-items .accordion-section").not(t);e&&this.searchTerm!==e.target.value&&(""===e.target.value||t.hasClass("open")?""===e.target.value&&(t.removeClass("open"),n.show(),t.find(".clear-results").prop("tabIndex",-1).removeClass("is-visible")):(n.fadeOut(100),t.find(".accordion-section-content").slideDown("fast"),t.addClass("open"),t.find(".clear-results").prop("tabIndex",0).addClass("is-visible")),this.searchTerm=e.target.value,this.pages.search=1,this.doSearch(1))},doSearch:function(t){var e,n=this,i=l("#available-menu-items-search"),a=i.find(".accordion-section-content"),o=d.template("available-menu-item");if(n.currentRequest&&n.currentRequest.abort(),!(t<0)){if(1').text(e.message)),d.a11y.speak(e.message)),n.pages.search=-1}),n.currentRequest.always(function(){i.removeClass("loading loading-more"),a.attr("aria-busy","false"),n.loading=!1,n.currentRequest=null})}},initList:function(){var t=this;_.each(c.Menus.data.itemTypes,function(e){t.pages[e.type+":"+e.object]=0,t.loadItems(e.type,e.object)})},loadItems:function(n,i){var e,a,o=this,s=d.template("available-menu-item");-1!==o.pages[n+":"+i]&&((a=l("#available-menu-items-"+n+"-"+i)).find(".accordion-section-title").addClass("loading"),o.loading=!0,e={"customize-menus-nonce":c.settings.nonce["customize-menus"],wp_customize:"on",type:n,object:i,page:o.pages[n+":"+i]},(e=d.ajax.post("load-available-menu-items-customizer",e)).done(function(e){var t,e=e.items;if(0===e.length)return 0===o.pages[n+":"+i]&&a.addClass("cannot-expand").removeClass("loading").find(".accordion-section-title > button").prop("tabIndex",-1),void(o.pages[n+":"+i]=-1);e=new c.Menus.AvailableItemCollection(e),o.collection.add(e.models),t=a.find(".accordion-section-content"),e.each(function(e){t.append(s(e.attributes))}),o.pages[n+":"+i]+=1}),e.fail(function(e){"undefined"!=typeof console&&console.error&&console.error(e)}),e.always(function(){a.find(".accordion-section-title").removeClass("loading"),o.loading=!1}))},itemSectionHeight:function(){var e=window.innerHeight,t=this.$el.find(".accordion-section:not( #available-menu-items-search ) .accordion-section-content"),e=e-(46*(2+t.length)-13);120