// 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/layers/vectorTiles/views/vectorTiles/TextShaping",["require","exports","./Placement"],function(v,w,u){return function(){function p(k,e,c,a,f,b,l,d){this._glyphItems=k;this._maxWidth=e;this._lineHeight=c;this._letterSpacing=a;this._offset=f;this._hAnchor=b;this._vAnchor=l;this._justify=d}p.prototype.getShaping=function(k,e){for(var c=this._letterSpacing,a=this._offset[0],f=this._offset[1],b=[],l=k.length,d=0;d<l;d++){for(var q=k.charCodeAt(d),g=void 0,r=0,h=this._glyphItems;r<h.length&&
!(g=h[r][q]);r++);g&&(b.push(new u.ShapedGlyph(q,a,f,g)),a+=g.metrics.advance+c)}if(0<b.length){r=this._maxWidth;c=this._lineHeight;f=this._justify;l=b.length;g=q=a=0;if(0!==r)for(var p=h=0,d=0;d<l;d++){var m=b[d];m.x-=p;m.y=e?m.y-c*a:m.y+c*a;if(m.x>r&&0<h){for(var t=b[h+1].x,g=Math.max(t,g),n=h+1;n<=d;n++)b[n].y=e?b[n].y-c:b[n].y+c,b[n].x-=t;f&&this._applyJustification(b,q,h-1);q=h+1;h=0;p+=t;a++}32===m.glyph&&(h=d)}d=b[l-1];g=Math.max(g,d.x+d.glyphItem.metrics.advance);f&&this._applyJustification(b,
q,l-1);d=(f-this._hAnchor)*g;f=(-this._vAnchor*(a+1)+.5)*c;e&&a&&(f+=a*c);for(c=0;c<b.length;c++)a=b[c],a.x+=d,a.y+=f}return b};p.prototype._applyJustification=function(k,e,c){for(var a=k[c],a=(a.x+a.glyphItem.metrics.advance)*this._justify;e<=c;e++)k[e].x-=a};return p}()});