!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("d3-collection"),require("d3-selection")):"function"==typeof define&&define.amd?define(["d3-collection","d3-selection"],e):(t.d3=t.d3||{},t.d3.tip=e(t.d3,t.d3))}(this,(function(t,e){"use strict";return function(){var n=function(){return"n"},r=function(){return[0,0]},o=function(){return" "},l=document.body,i=y(),s=null,f=null,u=null;function c(t){var e;e=t.node(),(s=e?"svg"===e.tagName.toLowerCase()?e:e.ownerSVGElement:null)&&(f=s.createSVGPoint(),l.appendChild(i))}c.show=function(){var t=Array.prototype.slice.call(arguments);t[t.length-1]instanceof SVGElement&&(u=t.pop());var e,i=o.apply(this,t),s=r.apply(this,t),f=n.apply(this,t),y=d(),h=p.length,m=document.documentElement.scrollTop||l.scrollTop,x=document.documentElement.scrollLeft||l.scrollLeft;for(y.html(i).style("opacity",1).style("pointer-events","all");h--;)y.classed(p[h],!1);return e=a.get(f).apply(this),y.classed(f,!0).style("top",e.top+s[0]+m+"px").style("left",e.left+s[1]+x+"px"),c},c.hide=function(){return d().style("opacity",0).style("pointer-events","none"),c},c.attr=function(t,n){if(arguments.length<2&&"string"==typeof t)return d().attr(t);var r=Array.prototype.slice.call(arguments);return e.selection.prototype.attr.apply(d(),r),c},c.style=function(t,n){if(arguments.length<2&&"string"==typeof t)return d().style(t);var r=Array.prototype.slice.call(arguments);return e.selection.prototype.style.apply(d(),r),c},c.direction=function(t){return arguments.length?(n=null==t?t:m(t),c):n},c.offset=function(t){return arguments.length?(r=null==t?t:m(t),c):r},c.html=function(t){return arguments.length?(o=null==t?t:m(t),c):o},c.rootElement=function(t){return arguments.length?(l=null==t?t:m(t),c):l},c.destroy=function(){return i&&(d().remove(),i=null),c};var a=t.map({n:function(){var t=h(this);return{top:t.n.y-i.offsetHeight,left:t.n.x-i.offsetWidth/2}},s:function(){var t=h(this);return{top:t.s.y,left:t.s.x-i.offsetWidth/2}},e:function(){var t=h(this);return{top:t.e.y-i.offsetHeight/2,left:t.e.x}},w:function(){var t=h(this);return{top:t.w.y-i.offsetHeight/2,left:t.w.x-i.offsetWidth}},nw:function(){var t=h(this);return{top:t.nw.y-i.offsetHeight,left:t.nw.x-i.offsetWidth}},ne:function(){var t=h(this);return{top:t.ne.y-i.offsetHeight,left:t.ne.x}},sw:function(){var t=h(this);return{top:t.sw.y,left:t.sw.x-i.offsetWidth}},se:function(){var t=h(this);return{top:t.se.y,left:t.se.x}}}),p=a.keys();function y(){var t=e.select(document.createElement("div"));return t.style("position","absolute").style("top",0).style("opacity",0).style("pointer-events","none").style("box-sizing","border-box"),t.node()}function d(){return null==i&&(i=y(),l.appendChild(i)),e.select(i)}function h(t){for(var e=u||t;null==e.getScreenCTM&&null!=e.parentNode;)e=e.parentNode;var n={},r=e.getScreenCTM(),o=e.getBBox(),l=o.width,i=o.height,s=o.x,c=o.y;return f.x=s,f.y=c,n.nw=f.matrixTransform(r),f.x+=l,n.ne=f.matrixTransform(r),f.y+=i,n.se=f.matrixTransform(r),f.x-=l,n.sw=f.matrixTransform(r),f.y-=i/2,n.w=f.matrixTransform(r),f.x+=l,n.e=f.matrixTransform(r),f.x-=l/2,f.y-=i/2,n.n=f.matrixTransform(r),f.y+=i,n.s=f.matrixTransform(r),n}function m(t){return"function"==typeof t?t:function(){return t}}return c}}));