// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/dom-construct dojo/dom-style dojo/dom-geometry dojo/dom-class dojo/query dojo/on dojox/gfx dojo/sniff dojo/aspect dojox/uuid/generateRandomUuid dijit/Tooltip ../utils/DomUtil ../utils/MouseUtil esri/dijit/geoenrichment/utils/TooltipUtil dojo/domReady!".split(" "),function(q,t,v,E,P,r,Q,R,J,F,A,z,S,K){function D(){h&&(h.isMultilineContainer?m.hideTooltipForNode(h):(clearInterval(h.__autoTooltipInLayoutCheckHandle),delete h.__autoTooltipInLayoutCheckHandle,A.hide(h)),h=null)}function L(a,
b){b=b||"";var e=q.create("div",{class:"esriMapsAnalystXValidationTooltip"+b},document.body);!b&&q.create("div",{class:"esriMapsAnalystXValidationTooltipTip"+b},e);q.create("div",{innerHTML:a,class:"esriMapsAnalystXValidationTooltipBody"+b},e);t.set(e,"position","fixed");return e}function M(a,b){function e(){a&&(document.body.removeChild(a),f.forEach(function(k){k.remove()}),a=f=null)}b=b.textbox||b;var c=v.getMarginBox(a),d=v.position(b);"rtl"===document.dir?t.set(a,{left:d.x-c.w+"px",top:d.y+d.h/
2-c.h/2+"px"}):t.set(a,{left:d.x+d.w+"px",top:d.y+d.h/2-c.h/2+"px"});var f=[r(document.body,"mousedown, keydown",e),r(b,"blur",e)];return{remove:e}}function N(a,b,e){function c(){var l=q.create("div",{class:"esriMapsAnalystXClosableTooltipTip"},f);E.add(l,"right"===e?"esriMapsAnalystXClosableTooltipTipRight":"esriMapsAnalystXClosableTooltipTipLeft")}function d(){k=q.create("div",{class:"esriMapsAnalystXClosableTooltipBody"},f);q.create("div",{innerHTML:a,class:"esriMapsAnalystXClosableTooltipLabel"},
k);g=q.create("div",{class:"esriMapsAnalystXClosableTooltipCloseButton esriMapsAnalystXCloseWindow esriMapsAnalystXCloseWindowWhite"},k)}b={class:"esriMapsAnalystXClosableTooltip "+(b||"")};b.id=F();var f=q.create("div",b,document.body),k,g;"right"!==e?(d(),c()):(c(),d());t.set(f,"position","fixed");return{tooltip:f,body:k,closeButton:g}}function O(a,b,e,c){var d=v.getMarginBox(a.tooltip),f=v.position(b);"rtl"===document.dir&&"right"!==c||"rtl"!==document.dir&&"right"===c?t.set(a.tooltip,{left:f.x+
f.w+"px",top:f.y+f.h/2-d.h/2+"px"}):t.set(a.tooltip,{left:f.x-d.w+"px",top:f.y+f.h/2-d.h/2+"px"});var k,g=function(){k&&clearTimeout(k);l&&clearInterval(l);p&&p.remove();a.tooltip.parentNode===document.body&&document.body.removeChild(a.tooltip)};var l=setInterval(function(){z.isNodeInLayout(b)||g();z.isNodeVisible(b)?z.show(a.tooltip):z.hide(a.tooltip)},300);e&&(k=setTimeout(g,e));var p=r(a.closeButton,"click",function(){g()});a.tooltip._removeFunc=g;return a.tooltip}var m={},G={};m.hideTooltipForNode=
K.hideTooltipForNode;m.setTooltipToNode=K.setTooltipToNode;m.createTooltip=function(a,b,e){var c={orientation:v.isBodyLtr(document)?"right":"left",offset:{x:15,y:0}};b&&(c.innerHTML=b);e&&(c=Object.assign(c,e));c.id=F();c.toMouseCursor&&(c.mouseEvent=S.getCursorPosition(),delete c.toMouseCursor);b=c.mouseEvent;delete c.mouseEvent;e=c.htmlFragment;delete c.htmlFragment;var d=c.widget;delete c.widget;var f=c.orientation;delete c.orientation;var k=c.offset;delete c.offset;var g=c.horizontalOffset;delete c.horizontalOffset;
var l=q.create("div",c,a?a.container:document.body);e?q.place(e,l):d&&d.placeAt(l);t.set(l,"position","fixed");var p=v.getMarginBox(l),x=function(n,u){var w=n.touches?event.touches[0].clientX:n.clientX;n=n.touches?event.touches[0].clientY:n.clientY;var y,C,B=k.x,H=k.y;"left"===f?0>w-p.w-B&&(y="right"):w+p.w+B>document.body.clientWidth&&(y="left");n+p.h+H>document.body.clientHeight&&(C="above");y=y||f;t.set(l,{left:u?u+"px":w+("left"===y?-p.w-B:B)+"px",top:n+("above"===C?-p.h-H:H)+"px"});l.style.display=
""};b&&x(b,g);c=[];c.push(r(a?a:document.body,a?"mouse-move, mousemove":"mousemove, touchmove",function(n){x(n,g)}));c.push(r(a?a:document.body,a?"mouse-out, mouseout":"mouseout, touchend",function(n){l.style.display="none"}));a={};a.handlers=c;a.tooltip=l;G[l.id]=a;return l};m.removeTooltip=function(a){if(a){a="string"===typeof a?a:a.id;var b=G[a];delete G[a];b&&(b.handlers.forEach(function(e){e.remove()}),q.destroy(b.tooltip))}};var I={};m.registerTooltipForSlider=function(a,b,e,c){var d={offsetX:0,
offsetY:0,class:"esriMapsAnalystXTooltip"};b&&(d=Object.assign(d,b));d.id=F();var f=q.create("div",d,document.body);f.style.display="none";t.set(f,"position","fixed");var k=!1,g=function(p,x){if(!k){k=!0;f.style.display="";f.innerHTML=x();var n=v.getMarginBox(f),u=v.position(p);t.set(f,{left:u.x+u.w/2-n.w/2+d.offsetX+"px",top:u.y-n.h-5+d.offsetY+"px"});var w=[];w.push(J.after(a,"onChange",function(){f.innerHTML=x();u=v.position(p);t.set(f,{left:u.x+u.w/2-n.w/2+"px",top:u.y-n.h-5+"px"})}));var y=function(){f.style.display=
"none";w.forEach(function(B){B.remove()});k=!1},C=!1;w.push(r(p,"mousedown, mouseDown, mouse-down",function(){C=!0;w.push(r(document,"mouseup, mouseUp, mouse-up",function(){y()}))}));w.push(r(p,"mouseout, mouseOut, mouse-out",function(){C||y()}))}};b=[];b.push(r(a.sliderHandle,"mouseover, mouseOver, mouse-over",function(){c&&a.isSliderDisabled&&a.isSliderDisabled()||g(a.sliderHandle,function(){var p=c?a.get("value")[0]:a.get("value");return e?e(p):p})}));c&&b.push(r(a.sliderHandleMax,"mouseover, mouseOver, mouse-over",
function(){a.isSliderDisabled&&a.isSliderDisabled()||g(a.sliderHandleMax,function(){return e?e(a.get("value")[1]):a.get("value")[1]})}));b.push(J.before(a,"destroy",function(){m.unregisterTooltipForSlider(a)}));a.tooltipId=f.id;var l={};l.tooltip=f;l.handlers=b;I[f.id]=l};m.unregisterTooltipForSlider=function(a){var b=I[a.tooltipId];b&&(b.handlers.forEach(function(e){e.remove()}),q.destroy(b.tooltip));delete I[a.tooltipId];delete a.tooltipId};var h=null;m.autoTooltip=function(a,b,e){"string"===typeof b&&
(b=b.split(" ").filter(function(d){return d&&!!d.trim().length}));b=b||[];b.push("TrimWithEllipses");e=e||[];e.push("esriMapsAnalystXInfoIcon");for(var c=0;c<b.length;c++)r(a,"."+b[c]+":mouseover, "+b[c]+":touchstart, ",function(d){this!==h&&this.offsetWidth<this.scrollWidth&&!this.noAutoTooltip&&(d=getComputedStyle(this).width,d=Number(d.substr(0,d.length-2)),0>d-Math.round(d)&&this.offsetWidth==this.scrollWidth-1||(D(),h=this,d=h.autoTooltip||h.textContent||h.value,h.title&&(d+=" ("+h.title+")"),
d&&A.show(d,h,["above","below"]),r.once(h,"mouseout, touchstart, touchout",function(){D()}),h.__autoTooltipInLayoutCheckHandle=setInterval(function(){z.isNodeInLayout(h)||D()},500)))});if(R("touch"))for(c=0;c<e.length;c++)r(a,"."+e[c]+":touchstart ",function(d){this!==h&&(h=this,h.title&&(A.show(h.title,h,["above","below"]),r.once(h,"touchstart, touchout",function(){A.hide(h);h=null})))})};m.addAutoTooltipsToTabContainer=function(a){P(".tabLabel",a.domNode).forEach(function(b){E.add(b,"TrimWithEllipses")});
m.autoTooltip(a)};m.setMultilineText=function(a,b,e,c){e=e||2;b=b.trim();c=c||["above","below"];E.remove(a,"TrimWithEllipses");a.style.overflow="hidden";a.innerHTML="";for(var d=b,f=!1;d;){e--;var k=q.create("div",null,a);k.style.overflow="hidden";k.style.whiteSpace="nowrap";for(var g=d;g;)if(k.textContent=g,k.offsetWidth<k.scrollWidth-1)g=(g=g.match(/^(.*[^\s]+)\s+[^\s]+$/))&&g[1]||"";else break;!g||!e&&g!==d?(k.textContent=d,d="",k.style.textOverflow="ellipsis",f=!0):d=d.substr(g.length).trim()}f&&
m.setTooltipToNode(a,function(){D();h=a;h.isMultilineContainer=!0;return b},{position:c})};m.showErrorTip=function(a,b){return M(L(b),a.domNode||a)};m.showNewStyleErrorTip=function(a,b,e){return M(L(b,"NewStyle"+(e?" esriMapsAnalystXWarningStyle":"")),a.domNode||a)};m.showAlertTooltip=function(a){a&&a.node&&a.message&&(A.show(a.message,a.node,a.position||["above","below"]),setTimeout(function(){A.hide(a.node)},a.timeout||5E3))};m.showClosableTooltip=function(a){var b=N(a.message,a.tooltipClass,a.position);
return O(b,a.component,a.timeout,a.position)};m.removeClosableTooltip=function(a){a&&a._removeFunc&&a._removeFunc()};m.showClosableTooltipOnVerticalBracket=function(a){var b=a.below||a.above,e=v.position(a.above,!0),c=v.position(b,!0),d="rtl"!==document.dir?"start"===a.direction:"end"===a.direction,f=e.x+e.w*(d?0:1);e=e.y;var k=c.y+c.h,g=q.create("div",{class:"esriMapsAnalystFlexibleTooltip_tooltip esriMapsAnalystXNonSelectable"},document.body),l=q.create("div",{class:"esriMapsAnalystFlexibleTooltip_surfaceContainer"},
g);c={};f={top:e-2,left:f+(d?-3:3),height:k-e+4,width:10};for(var p in f)c[p]=f[p]+"px";t.set(g,c);var x=Q.createSurface(l,f.width,f.height);x.clear();x.createPolyline([{x:d?f.width:0,y:0},{x:d?0:f.width,y:0},{x:d?0:f.width,y:f.height},{x:d?f.width:0,y:f.height}]).setStroke({color:"#6E6E6E",width:6});a.component=g;d=N(a.message,a.tooltipClass,a.position);var n=function(){clickHandler&&clickHandler.remove();u&&clearInterval(u);x&&x.clear();q.destroy(l);q.destroy(g)},u=setInterval(function(){z.isNodeInLayout(b)||
n();z.isNodeVisible(b)?t.set(g,"visibility","visible"):t.set(g,"visibility","hidden")},300);a.timeout&&setTimeout(n,a.timeout);clickHandler=r(d.closeButton,"click",n);tooltip=O(d,a.component,a.timeout,a.position);var w=tooltip._removeFunc;tooltip._removeFunc=function(){w();n()};return tooltip};return m});