// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/utils/htmlToSvg/supportClasses/text/TextMeasurer","dojo/dom-construct dojo/dom-geometry dojo/dom-style ./TextStyleBuilder ../TransformUtil ./FlowCalculator ./ReplaceUtil ./SiblingsUtil".split(" "),function(z,p,g,A,w,B,x,y){var q={_linesNode:null,_wordNode:null,createTempLinesNode:function(a){this._linesNode=this._linesNode||this._createTempNode();return this._styleNode(this._linesNode,a,!0)},createTempWordNode:function(a){this._wordNode=this._wordNode||this._createTempNode();
return this._styleNode(this._wordNode,a)},_createTempNode:function(){var a=z.create("div",null,document.body);g.set(a,{position:"absolute",display:"inline-block"});return a},_styleNode:function(a,c,b){A.resetTextStyle(a);g.set(a,"width",b?c.style.cw+"px":"");g.set(a,"display","inline-block");g.set(a,c.style.getTextStyleObject());return a},dispose:function(a){a&&g.set(a,"display","none")}},C={getParagraphs:function(a,c){function b(a){return x.collapseMultipleSpaces(a.trim())}var d=c.style.getTextStyle("whiteSpace"),
e="pre-wrap"===d||"pre"===d||"pre-line"===d;e||(a=x.removeReturns(a));(d="pre-wrap"===d||"pre"===d)||(a=b(a));e=e?a.split(String.fromCharCode(10)):[a];1<e.length&&!d&&(e=e.map(b));return e}},t={measureWidth:function(a,c){c.innerHTML=a;return g.get(c,"width")}},m={getLinesForWords:function(a,c,b,d){function e(){var a=b.innerHTML;b.innerHTML="";a=a.split("");return m.getLinesForWords(a,c,b,{checkBreaking:!1,separator:""}).lines}function g(a){a=a.split("");return m.getLinesForWords(a,c,b,{checkBreaking:!1,
separator:"",clearLinesNodeBeforeMeasure:!d.isBreakAll}).lines}var f,l,n=0;d.checkBreaking&&(b.innerHTML="a",l=p.position(b).h);var h=0,k="";d.clearLinesNodeBeforeMeasure&&(b.innerHTML="");a.some(function(a){if(f){var q;d.checkBreaking&&(q=b.innerHTML);b.innerHTML+=d.separator+a;var r=p.position(b).h;if(0<h&&r>h){f.push({text:k,w:t.measureWidth(k,c),lineHeight:n});var m;if(d.checkBreaking&&(r-h>1.2*l||d.isBreakAll)){b.innerHTML=k+d.separator;var u=g(a);b.innerHTML=q+d.separator+a;1<u.length&&(m=!0,
u.forEach(function(a,b){if(b<u.length-1)if(0===b&&d.isBreakAll){var e=f[f.length-1];e.text+=d.separator+a.text;e.w=t.measureWidth(e.text,c)}else f.push(a);else n=a.lineHeight,k=a.text}),h=r)}m||(k=a,n=r-h,h=r)}else k+=d.separator+a,0===h&&(n=h=p.position(b).h)}else if(f=[],b.innerHTML=d.clearLinesNodeBeforeMeasure?a:b.innerHTML+a,k=a,n=h=p.position(b).h,d.checkBreaking&&h>1.2*l){var v=e();1<v.length&&v.forEach(function(a,b){b<v.length-1?f.push(a):(n=a.lineHeight,k=a.text)})}});f.push({text:k,w:t.measureWidth(k,
c),lineHeight:n});a=p.position(b).w;return{lines:f,textWidth:a,lineHeight:n}}},D={getLinesForParagraph:function(a,c,b,d){a=a.split(" ");var e="break-word"===c.style.getTextStyle("overflowWrap");c="break-all"===c.style.getTextStyle("wordBreak");return m.getLinesForWords(a,b,d,{checkBreaking:e||c,isBreakAll:c,clearLinesNodeBeforeMeasure:!0,separator:" "})}},l={_node:null,_originalInnerHTML:null,_nextSiblingsHideInfo:null,setNode:function(a){this._node=a;this._nextSiblingsHideInfo=this._originalInnerHTML=
null},doPresets:function(){this._originalInnerHTML=this._node.innerHTML;this.hideNextSibling()},undoPresets:function(){this.showNextSibling();this._node.innerHTML=this._originalInnerHTML},hideNextSibling:function(){this._nextSiblingsHideInfo||(this._nextSiblingsHideInfo=y.hideNextSiblings(this._node))},showNextSibling:function(){y.showNextSiblings(this._nextSiblingsHideInfo);this._nextSiblingsHideInfo=null}};return{getLines:function(a,c,b){if(a.innerHTML&&a.innerHTML.trim()){b=w.disableTransform(a,
c.parentVs);l.setNode(a);l.doPresets();var d=c.isSpanLike?a:q.createTempLinesNode(c),e=q.createTempWordNode(c),g,f=[];C.getParagraphs(a.innerHTML,c).forEach(function(a){a=D.getLinesForParagraph(a,c,e,d);g=a.textWidth;f=f.concat(a.lines)});if(c.isSpanLike){d.innerHTML=l._originalInnerHTML;a=p.position(d).h;l.showNextSibling();var m=p.position(d).h;m>a&&(f[f.length-1].lineHeight+=(m-a)/2);l.hideNextSibling()}l.undoPresets();q.dispose(e);!c.isSpanLike&&q.dispose(d);w.restoreTransform(b);return{lines:f,
textWidth:g}}},getSpanFlowOffsets:function(a,c){return B.getSpanFlowOffsets(a,c)}}});