(function(d){"function"===typeof define&&define.amd?define(["jquery","./core","./widget","./mouse","./draggable"],d):d(jQuery)})(function(d){d.widget("ui.droppable",{version:"1.11.4",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var a,b=this.options,c=b.accept;this.isover=!1;this.isout=!0;this.accept=d.isFunction(c)?c:function(a){return a.is(c)};
this.proportions=function(){if(arguments.length)a=arguments[0];else return a?a:a={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}};this._addToManager(b.scope);b.addClasses&&this.element.addClass("ui-droppable")},_addToManager:function(a){d.ui.ddmanager.droppables[a]=d.ui.ddmanager.droppables[a]||[];d.ui.ddmanager.droppables[a].push(this)},_splice:function(a){for(var b=0;b<a.length;b++)a[b]===this&&a.splice(b,1)},_destroy:function(){this._splice(d.ui.ddmanager.droppables[this.options.scope]);
this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(a,b){"accept"===a?this.accept=d.isFunction(b)?b:function(a){return a.is(b)}:"scope"===a&&(this._splice(d.ui.ddmanager.droppables[this.options.scope]),this._addToManager(b));this._super(a,b)},_activate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass);b&&this._trigger("activate",a,this.ui(b))},_deactivate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&
this.element.removeClass(this.options.activeClass);b&&this._trigger("deactivate",a,this.ui(b))},_over:function(a){var b=d.ui.ddmanager.current;b&&(b.currentItem||b.element)[0]!==this.element[0]&&this.accept.call(this.element[0],b.currentItem||b.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",a,this.ui(b)))},_out:function(a){var b=d.ui.ddmanager.current;b&&(b.currentItem||b.element)[0]!==this.element[0]&&this.accept.call(this.element[0],b.currentItem||
b.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",a,this.ui(b)))},_drop:function(a,b){var c=b||d.ui.ddmanager.current,h=!1;if(!c||(c.currentItem||c.element)[0]===this.element[0])return!1;this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var b=d(this).droppable("instance");if(b.options.greedy&&!b.options.disabled&&b.options.scope===c.options.scope&&b.accept.call(b.element[0],c.currentItem||c.element)&&d.ui.intersect(c,
d.extend(b,{offset:b.element.offset()}),b.options.tolerance,a))return h=!0,!1});return h?!1:this.accept.call(this.element[0],c.currentItem||c.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",a,this.ui(c)),this.element):!1},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}});d.ui.intersect=function(){return function(a,
b,c,d){if(!b.offset)return!1;var e=(a.positionAbs||a.position.absolute).left+a.margins.left,f=(a.positionAbs||a.position.absolute).top+a.margins.top,k=e+a.helperProportions.width,m=f+a.helperProportions.height,l=b.offset.left,g=b.offset.top,n=l+b.proportions().width,p=g+b.proportions().height;switch(c){case "fit":return l<=e&&k<=n&&g<=f&&m<=p;case "intersect":return l<e+a.helperProportions.width/2&&k-a.helperProportions.width/2<n&&g<f+a.helperProportions.height/2&&m-a.helperProportions.height/2<p;
case "pointer":a=d.pageY;c=b.proportions().height;if(g=a>=g&&a<g+c)d=d.pageX,b=b.proportions().width,g=d>=l&&d<l+b;return g;case "touch":return(f>=g&&f<=p||m>=g&&m<=p||f<g&&m>p)&&(e>=l&&e<=n||k>=l&&k<=n||e<l&&k>n);default:return!1}}}();d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c,h,e=d.ui.ddmanager.droppables[a.options.scope]||[],f=b?b.type:null,k=(a.currentItem||a.element).find(":data(ui-droppable)").addBack();c=0;a:for(;c<e.length;c++)if(!(e[c].options.disabled||
a&&!e[c].accept.call(e[c].element[0],a.currentItem||a.element))){for(h=0;h<k.length;h++)if(k[h]===e[c].element[0]){e[c].proportions().height=0;continue a}e[c].visible="none"!==e[c].element.css("display");e[c].visible&&("mousedown"===f&&e[c]._activate.call(e[c],b),e[c].offset=e[c].element.offset(),e[c].proportions({width:e[c].element[0].offsetWidth,height:e[c].element[0].offsetHeight}))}},drop:function(a,b){var c=!1;d.each((d.ui.ddmanager.droppables[a.options.scope]||[]).slice(),function(){this.options&&
(!this.options.disabled&&this.visible&&d.ui.intersect(a,this,this.options.tolerance,b)&&(c=this._drop.call(this,b)||c),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],a.currentItem||a.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,b)))});return c},dragStart:function(a,b){a.element.parentsUntil("body").bind("scroll.droppable",function(){a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)})},drag:function(a,b){a.options.refreshPositions&&d.ui.ddmanager.prepareOffsets(a,
b);d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var c,h,e;e=d.ui.intersect(a,this,this.options.tolerance,b);var f=!e&&this.isover?"isout":e&&!this.isover?"isover":null;f&&(this.options.greedy&&(h=this.options.scope,e=this.element.parents(":data(ui-droppable)").filter(function(){return d(this).droppable("instance").options.scope===h}),e.length&&(c=d(e[0]).droppable("instance"),c.greedyChild="isover"===f)),c&&"isover"===
f&&(c.isover=!1,c.isout=!0,c._out.call(c,b)),this[f]=!0,this["isout"===f?"isover":"isout"]=!1,this["isover"===f?"_over":"_out"].call(this,b),c&&"isout"===f&&(c.isout=!1,c.isover=!0,c._over.call(c,b)))}})},dragStop:function(a,b){a.element.parentsUntil("body").unbind("scroll.droppable");a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)}};return d.ui.droppable});