"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),e="top",i="bottom",r="top-left",o="top-right",n="bottom-left",h="bottom-right",a={maxWidth:320,estimatedHeight:140,estimatedHeightWithAction:170},c=29,u=18,f=[i,e,n,h,r,o];exports.TOOLTIP_DIMENSIONS=a,exports.useTooltipAnchor=function(s){var l=s.mapRef,d=s.coords,p=s.isSubjectWell,g=s.isViewOnly,b=s.isClickable,m=s.hintsWidth,v=void 0===m?0:m,k=s.hintsHeight,w=void 0===k?0:k;return t.useMemo((function(){var t=i,s=p?c:u;if(!d||!l.current)return{anchor:t,offset:s};var m=l.current,k=m.getCanvas(),W=k.clientWidth,x=k.clientHeight,H=m.project([d.longitude,d.latitude]),O=H.x,j=H.y,y=!g&&!p&&b?a.estimatedHeightWithAction:a.estimatedHeight,A=a.maxWidth,I=function(t,e){var i=t>0?t+8+8:170;return[{top:0,left:0,width:170,height:50},{top:0,left:-i,width:i,height:e>0?e+8+8:50},{top:-90,left:0,width:90,height:90},{top:-110,left:-110,width:110,height:110}]}(v,w),M=f.find((function(t){var a=function(t,a,c,u,f,s){var l,d;switch(c){case i:l=a-s-f,d=t-u/2;break;case e:l=a+s,d=t-u/2;break;case n:l=a-s-f,d=t;break;case h:l=a-s-f,d=t-u;break;case r:l=a+s,d=t;break;case o:l=a+s,d=t-u;break;default:l=a-s-f,d=t-u/2}return{top:l,left:d,right:d+u,bottom:l+f}}(O,j,t,A,y,s);return function(t,e,i){return t.top>=0&&t.left>=0&&t.right<=e&&t.bottom<=i}(a,W,x)&&!function(t,e,i,r){return e.some((function(e){return function(t,e,i,r){var o=e.left>=0?e.left:i+e.left,n=e.top>=0?e.top:r+e.top,h=o+e.width,a=n+e.height;return!(t.right<o||t.left>h||t.bottom<n||t.top>a)}(t,e,i,r)}))}(a,I,W,x)}));return{anchor:null!=M?M:t,offset:s}}),[d,l,p,g,b,v,w])};
//# sourceMappingURL=useTooltipAnchor.js.map
