/*
 * XenForo jquery.nestable.min.js
 * Copyright 2010-2019 XenForo Ltd.
 * Released under the XenForo License Agreement: https://xenforo.com/license-agreement
 */
/*
 Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
 Dual-licensed under the BSD or MIT licenses
*/
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(d,h,f){d instanceof String&&(d=String(d));for(var g=d.length,k=0;k<g;k++){var m=d[k];if(h.call(f,m,k,d))return{i:k,v:m}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,h,f){d!=Array.prototype&&d!=Object.prototype&&(d[h]=f.value)};
$jscomp.getGlobal=function(d){return"undefined"!=typeof window&&window===d?d:"undefined"!=typeof global&&null!=global?global:d};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(d,h,f,g){if(h){f=$jscomp.global;d=d.split(".");for(g=0;g<d.length-1;g++){var k=d[g];k in f||(f[k]={});f=f[k]}d=d[d.length-1];g=f[d];h=h(g);h!=g&&null!=h&&$jscomp.defineProperty(f,d,{configurable:!0,writable:!0,value:h})}};
$jscomp.polyfill("Array.prototype.find",function(d){return d?d:function(d,f){return $jscomp.findInternal(this,d,f).v}},"es6","es3");
(function(d,h,f,g){function k(a,c){this.w=d(f);this.el=d(a);this.options=d.extend({},r,c);this.isRtl=(a=this.el.closest("[dir]").attr("dir"))&&"RTL"==a.toUpperCase();this.init()}var m="ontouchstart"in h,p=function(){var a=f.createElement("div"),d=f.documentElement;if(!("pointerEvents"in a.style))return!1;a.style.pointerEvents="auto";a.style.pointerEvents="x";d.appendChild(a);var b=h.getComputedStyle&&"auto"===h.getComputedStyle(a,"").pointerEvents;d.removeChild(a);return!!b}(),r={listNodeName:"ol",
itemNodeName:"li",parentID:0,rootClass:"dd",listClass:"dd-list",itemClass:"dd-item",dragClass:"dd-dragel",handleClass:"dd-handle",collapsedClass:"dd-collapsed",placeClass:"dd-placeholder",noDragClass:"dd-nodrag",emptyClass:"dd-empty",expandBtnHTML:'<button data-action="expand" type="button">Expand</button>',collapseBtnHTML:'<button data-action="collapse" type="button">Collapse</button>',group:0,maxDepth:5,threshold:20};k.prototype={init:function(){var a=this;a.reset();a.el.data("nestable-group",this.options.group);
a.placeEl=d('<div class="'+a.options.placeClass+'"/>');var c=this.el.find(a.options.itemNodeName);d.each(c,function(b,c){a.setParent(d(c))});c.length||this.appendEmptyElement(this.el);a.el.on("click","button",function(b){if(!a.dragEl){var c=d(b.currentTarget);b=c.data("action");c=c.parent(a.options.itemNodeName);"collapse"===b&&a.collapseItem(c);"expand"===b&&a.expandItem(c)}});c=function(b){if("touchstart"==b.type||1==b.which){var c="mousedown"!=b.type,e=d(b.target);if(!e.hasClass(a.options.handleClass)){if(e.closest("."+
a.options.noDragClass).length)return;e=e.closest("."+a.options.handleClass)}!e.length||a.dragEl||!c&&0!==b.button||c&&1!==b.touches.length||(b.preventDefault(),a.dragStart(c?b.touches[0]:b))}};var b=function(b){var c="mousemove"!=b.type;a.dragEl&&(b.preventDefault(),a.dragMove(c?b.touches[0]:b))},e=function(b){var c="mouseup"!=b.type;a.dragEl&&(b.preventDefault(),a.dragStop(c?b.touches[0]:b))};m&&(a.el[0].addEventListener("touchstart",c,!1),h.addEventListener("touchmove",b,!1),h.addEventListener("touchend",
e,!1),h.addEventListener("touchcancel",e,!1));a.el.on("mousedown",c);a.w.on("mousemove",b);a.w.on("mouseup",e)},serialize:function(){var a=this;step=function(c,b){var e=[];c.children(a.options.itemNodeName).each(function(){var c=d(this),f=d.extend({},c.data());c=c.children(a.options.listNodeName);c.length&&(f.children=step(c,b+1));e.push(f)});return e};return step(a.el.find(a.options.listNodeName).first(),0)},serialise:function(){return this.serialize()},asNestedSet:function(){function a(e,f,h){var l=
h+1;var g=c.listNodeName;var k=c.itemNodeName,n=d(e);e=n.children(g).children(k);0<e.length&&(f++,e.each(function(){l=a(d(this),f,l)}),f--);e=n.attr("data-id");g=n.parent(g).parent(k).attr("data-id")||c.parentID;e&&b.push({id:e,parent_id:g,depth:f,lft:h,rgt:l});return l+1}var c=this.options,b=[],e=1;this.el.find(c.listNodeName).first().children(c.itemNodeName).each(function(){e=a(this,0,e)});return b=b.sort(function(a,b){return a.lft-b.lft})},reset:function(){this.mouse={offsetX:0,offsetY:0,startX:0,
startY:0,lastX:0,lastY:0,nowX:0,nowY:0,distX:0,distY:0,dirAx:0,dirX:0,dirY:0,lastDirX:0,lastDirY:0,distAxX:0,distAxY:0};this.moving=this.isTouch=!1;this.dragRootEl=this.dragEl=null;this.dragDepth=0;this.hasNewRoot=!1;this.pointEl=null},expandItem:function(a){a.removeClass(this.options.collapsedClass);a.children('[data-action="expand"]').hide();a.children('[data-action="collapse"]').show();a.children(this.options.listNodeName).show()},collapseItem:function(a){a.children(this.options.listNodeName).length&&
(a.addClass(this.options.collapsedClass),a.children('[data-action="collapse"]').hide(),a.children('[data-action="expand"]').show(),a.children(this.options.listNodeName).hide())},expandAll:function(){var a=this;a.el.find(a.options.itemNodeName).each(function(){a.expandItem(d(this))})},collapseAll:function(){var a=this;a.el.find(a.options.itemNodeName).each(function(){a.collapseItem(d(this))})},setParent:function(a){a.children(this.options.listNodeName).length&&(a.prepend(d(this.options.expandBtnHTML)),
a.prepend(d(this.options.collapseBtnHTML)));a.children('[data-action="expand"]').hide()},unsetParent:function(a){a.removeClass(this.options.collapsedClass);a.children("[data-action]").remove();a.children(this.options.listNodeName).remove()},dragStart:function(a){var c=this.mouse,b=d(a.target),e=b.closest(this.options.itemNodeName);this.placeEl.css("height",e.height());c.offsetX=a.offsetX!==g?a.offsetX:a.pageX-b.offset().left;c.offsetY=a.offsetY!==g?a.offsetY:a.pageY-b.offset().top;c.startX=c.lastX=
a.pageX;c.startY=c.lastY=a.pageY;this.dragRootEl=this.el;this.dragEl=d(f.createElement(this.options.listNodeName)).addClass(this.options.listClass+" "+this.options.dragClass);b=e.width();this.dragEl.css("width",b);this.dragEl.data("drag-width",b);e.after(this.placeEl);e[0].parentNode.removeChild(e[0]);e.appendTo(this.dragEl);d(f.body).append(this.dragEl);a={left:a.pageX-c.offsetX,top:a.pageY-c.offsetY};this.isRtl&&(a.left-=this.dragEl.data("drag-width"));this.dragEl.css(a);e=this.dragEl.find(this.options.itemNodeName);
for(a=0;a<e.length;a++)c=d(e[a]).parents(this.options.listNodeName).length,c>this.dragDepth&&(this.dragDepth=c)},dragStop:function(a){a=this.dragEl.children(this.options.itemNodeName).first();a[0].parentNode.removeChild(a[0]);this.placeEl.replaceWith(a);this.dragEl.remove();this.el.trigger("change");this.hasNewRoot&&this.dragRootEl.trigger("change");this.reset()},dragMove:function(a){var c=this.options,b=this.mouse;var e={left:a.pageX-b.offsetX,top:a.pageY-b.offsetY};this.isRtl&&(e.left-=this.dragEl.data("drag-width"));
this.dragEl.css(e);b.lastX=b.nowX;b.lastY=b.nowY;b.nowX=a.pageX;b.nowY=a.pageY;b.distX=b.nowX-b.lastX;b.distY=b.nowY-b.lastY;b.lastDirX=b.dirX;b.lastDirY=b.dirY;b.dirX=0===b.distX?0:0<b.distX?1:-1;b.dirY=0===b.distY?0:0<b.distY?1:-1;e=Math.abs(b.distX)>Math.abs(b.distY)?1:0;if(b.moving){b.dirAx!==e?(b.distAxX=0,b.distAxY=0):(b.distAxX+=Math.abs(b.distX),0!==b.dirX&&b.dirX!==b.lastDirX&&(b.distAxX=0),b.distAxY+=Math.abs(b.distY),0!==b.dirY&&b.dirY!==b.lastDirY&&(b.distAxY=0));b.dirAx=e;if(b.dirAx&&
b.distAxX>=c.threshold){b.distAxX=0;e=this.placeEl.prev(c.itemNodeName);if((this.isRtl?0>b.distX:0<b.distX)&&e.length&&!e.hasClass(c.collapsedClass)){var l=e.find(c.listNodeName).last();var g=this.placeEl.parents(c.listNodeName).length;g+this.dragDepth<=c.maxDepth&&(l.length?(l=e.children(c.listNodeName).last(),l.append(this.placeEl)):(l=d("<"+c.listNodeName+"/>").addClass(c.listClass),l.append(this.placeEl),e.append(l),this.setParent(e)))}if(this.isRtl?0<b.distX:0>b.distX)e=this.placeEl.next(c.itemNodeName),
e.length||(g=this.placeEl.parent(),this.placeEl.closest(c.itemNodeName).after(this.placeEl),g.children().length||this.unsetParent(g.parent()))}l=!1;p||(this.dragEl[0].style.visibility="hidden");this.pointEl=d(f.elementFromPoint(a.pageX-f.body.scrollLeft,a.pageY-(h.pageYOffset||f.documentElement.scrollTop)));p||(this.dragEl[0].style.visibility="visible");this.pointEl.hasClass(c.handleClass)&&(this.pointEl=this.pointEl.closest(c.itemNodeName));if(this.pointEl.hasClass(c.emptyClass))l=!0;else if(!this.pointEl.length||
!this.pointEl.hasClass(c.itemClass))return;e=this.pointEl.closest("."+c.rootClass);var k=this.dragRootEl.data("nestable-id")!==e.data("nestable-id");b.dirAx&&!k&&!l||k&&c.group!==e.data("nestable-group")||(g=this.dragDepth-1+this.pointEl.parents(c.listNodeName).length,g>c.maxDepth||(a=a.pageY<this.pointEl.offset().top+this.pointEl.height()/2,g=this.placeEl.parent(),l?(l=d(f.createElement(c.listNodeName)).addClass(c.listClass),l.append(this.placeEl),this.pointEl.replaceWith(l)):a?this.pointEl.before(this.placeEl):
this.pointEl.after(this.placeEl),g.children().length||this.unsetParent(g.parent()),this.dragRootEl.find(c.itemNodeName).length||this.dragRootEl.find("."+c.emptyClass).length||this.appendEmptyElement(this.dragRootEl),this.dragRootEl=e,k&&(this.hasNewRoot=this.el[0]!==this.dragRootEl[0])))}else b.dirAx=e,b.moving=!0},appendEmptyElement:function(a){a.append('<div class="'+this.options.emptyClass+'"/>')}};var q=0;d.fn.nestable=function(a){var c=this;this.each(function(b){(b=d(this).data("nestable"))?
"string"===typeof a&&"function"===typeof b[a]&&(c=b[a]()):(d(this).data("nestable",new k(this,a)),d(this).data("nestable-id","nestable-uniqueId"+q),q++)});return c||this}})(window.jQuery||window.Zepto,window,document);

var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,c,b){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var f=a[e];if(c.call(b,f,e,a))return{i:e,v:f}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)};
$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(a,c,b,d){if(c){b=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in b||(b[e]={});b=b[e]}a=a[a.length-1];d=b[a];c=c(d);c!=d&&null!=c&&$jscomp.defineProperty(b,a,{configurable:!0,writable:!0,value:c})}};
$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,b){return $jscomp.findInternal(this,a,b).v}},"es6","es3");
!function(a,c,b,d){XF.Nestable=XF.Element.newHandler({options:{rootClass:"nestable-container",listClass:"nestable-list",itemClass:"nestable-item",handleClass:"nestable-handle",dragClass:"nestable-dragel",collapsedClass:"nestable-collapsed",placeClass:"nestable-placeholder",noDragClass:"nestable-nodrag",emptyClass:"nestable-empty",classSuffix:"",maxDepth:1E4,groupId:null,parentId:null,valueInput:'input[type="hidden"]',valueFunction:"asNestedSet"},$valueInput:null,init:function(){if(this.options.classSuffix){var b=
this;a.each(this.options,function(a,c){0<=a.indexOf("Class")&&(b.options[a]=c+b.options.classSuffix)})}this.$valueInput=this.$target.find(this.options.valueInput);if(!this.$valueInput.length)return console.error("No value input found matching selector %s",this.options.valueInput),!1;null===this.options.groupId&&(this.options.groupId=0);null===this.options.parentId&&(this.options.parentId=0);this.$target.nestable({rootClass:this.options.rootClass,listClass:this.options.listClass,itemClass:this.options.itemClass,
handleClass:this.options.handleClass,dragClass:this.options.dragClass,collapsedClass:this.options.collapsedClass,placeClass:this.options.placeClass,noDragClass:this.options.noDragClass,emptyClass:this.options.emptyClass,expandBtnHTML:'<button type="button" class="nestable-button" data-action="expand">\t<i class="far fa-plus-square" aria-hidden="true"></i></button>',collapseBtnHTML:'<button type="button" class="nestable-button" data-action="collapse"><i class="far fa-minus-square" aria-hidden="true"></i></button>',
maxDepth:this.options.maxDepth,group:this.options.groupId,parentID:this.options.parentId});this.$target.on("change",XF.proxy(this,"change"));this.change()},change:function(a){this.$valueInput.val(JSON.stringify(this.$target.nestable(this.options.valueFunction)))}});XF.Element.register("nestable","XF.Nestable")}(jQuery,window,document);