wp.customize.controlConstructor["kirki-sortable"]=wp.customize.Control.extend({ready:function(){var e=(this.container[0]||this.container).querySelector("ul.sortable");e&&(e.classList.add("ui-sortable"),this.initSortable(e),this.setupVisibilityHandlers(e),this.setupClickHandlers(e))},initSortable:function(e){var t=this,i=null,r=null,n=e.querySelectorAll("li");n.forEach(function(s){s.draggable=!0,s.style.cursor="move",s.addEventListener("dragstart",function(e){i=this,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/html",this.innerHTML),this.classList.add("dragging")}),s.addEventListener("dragend",function(e){this.classList.remove("dragging"),r&&r.parentNode&&r.parentNode.removeChild(r),n.forEach(function(e){e.classList.remove("drag-over")}),t.setting.set(t.getNewVal()),i=null,r=null}),s.addEventListener("dragover",function(t){if(t.preventDefault&&t.preventDefault(),t.dataTransfer.dropEffect="move",i&&this!==i){n.forEach(function(e){e.classList.remove("drag-over")}),this.classList.add("drag-over");var s=this.getBoundingClientRect(),a=s.top+s.height/2;r&&r.parentNode.removeChild(r),(r=document.createElement("li")).className="sortable-placeholder",r.style.height=i.offsetHeight+"px",r.style.border="2px dashed #ccc",r.style.background="#f0f0f0",r.style.margin="0",r.style.padding="0",r.style.listStyle="none",t.clientY<a?e.insertBefore(r,this):this.nextSibling?e.insertBefore(r,this.nextSibling):e.appendChild(r)}return!1}),s.addEventListener("dragenter",function(e){i&&this!==i&&this.classList.add("drag-over")}),s.addEventListener("dragleave",function(e){this.contains(e.relatedTarget)||this.classList.remove("drag-over")}),s.addEventListener("drop",function(t){return t.stopPropagation&&t.stopPropagation(),i&&this!==i&&r&&r.parentNode&&(i.parentNode===e&&e.removeChild(i),r.parentNode.insertBefore(i,r),r.parentNode.removeChild(r)),this.classList.remove("drag-over"),!1})}),e.addEventListener("dragover",function(e){return e.preventDefault&&e.preventDefault(),e.dataTransfer.dropEffect="move",!1}),e.addEventListener("drop",function(n){return n.stopPropagation&&n.stopPropagation(),i&&r&&r.parentNode&&(i.parentNode===e&&e.removeChild(i),r.parentNode.insertBefore(i,r),r.parentNode.removeChild(r),t.setting.set(t.getNewVal())),!1})},setupVisibilityHandlers:function(e){var t=this;e.querySelectorAll("i.visibility").forEach(function(e){e.addEventListener("click",function(e){e.stopPropagation(),this.classList.toggle("dashicons-visibility-faint");var i=this.closest("li");i&&(i.classList.toggle("invisible"),t.setting.set(t.getNewVal()))})})},setupClickHandlers:function(e){var t=this;e.querySelectorAll("li").forEach(function(e){e.addEventListener("click",function(e){e.target.classList.contains("visibility")||e.target.closest("i.visibility")||t.setting.set(t.getNewVal())})})},getNewVal:function(){var e=(this.container[0]||this.container).querySelectorAll("li"),t=[];return e.forEach(function(e){if(!e.classList.contains("invisible")){var i=e.getAttribute("data-value");i&&t.push(i)}}),t}});