// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../../core/BidiText ../../core/has ../../core/lang ../../core/Logger ../../core/RandomLCG ../../core/screenUtils ../../geometry/support/aaBoundingRect ../../geometry/support/boundsUtils ../Font ./CIMPlacements ./CIMSymbolDrawHelper ./defaultCIMValues ./enums ./utils ../support/defaults ../../views/2d/engine/vectorTiles/GeometryUtils ../../views/2d/engine/webgl/definitions ../../views/2d/engine/webgl/mesh/templates/shapingUtils ../../views/2d/layers/graphics/graphicsUtils".split(" "), function(x,aa,ba,J,ca,da,P,A,ea,fa,Q,E,R,m,n,ha,F,K,ia,S){function G(a,b,c){switch(b.type){case "CIMSymbolReference":return G(a,b.symbol,c);case "CIMPointSymbol":null==c&&(c={x:0,y:0});a.drawSymbol(b,c);break;case "CIMLineSymbol":null==c&&(c={paths:[[[0,0],[10,0]]]});a.drawSymbol(b,c);break;case "CIMPolygonSymbol":null==c&&(c={rings:[[[0,0],[0,10],[10,10],[10,0],[0,0]]]});a.drawSymbol(b,c);break;case "CIMTextSymbol":a.drawSymbol(b,{x:0,y:0});break;case "CIMVectorMarker":c=new Q.Placement,a.drawMarker(b, c)}return a.envelope()}function ja(a){if(!a)return 0;switch(a.type){case "CIMMarkerPlacementAlongLineSameSize":return Math.abs(a.offset);case "CIMMarkerPlacementAlongLineRandomSize":return Math.abs(a.offset);case "CIMMarkerPlacementAtExtremities":return Math.abs(a.offset);case "CIMMarkerPlacementAtMeasuredUnits":return Math.abs(a.offset);case "CIMMarkerPlacementAtRatioPositions":return Math.abs(a.offset);case "CIMMarkerPlacementInsidePolygon":return 0;case "CIMMarkerPlacementOnLine":return Math.abs(a.offset); case "CIMMarkerPlacementOnVertices":return Math.abs(a.offset);case "CIMMarkerPlacementPolygonCenter":return 0;default:return 0}}function ka(a){if(!a)return 0;switch(a.type){case "CIMGeometricEffectArrow":return Math.abs(.5*a.width);case "CIMGeometricEffectBuffer":return Math.abs(a.size);case "CIMGeometricEffectControlMeasureLine":return 500;case "CIMGeometricEffectExtension":return Math.abs(a.length);case "CIMGeometricEffectJog":return Math.abs(.5*a.length);case "CIMGeometricEffectMove":return Math.max(Math.abs(n.getNumericValue(a.offsetX)), Math.abs(n.getNumericValue(a.offsetY)));case "CIMGeometricEffectOffset":return Math.abs(a.offset);case "CIMGeometricEffectOffsetTangent":return Math.abs(a.offset);case "CIMGeometricEffectRadial":return Math.abs(a.length);case "CIMGeometricEffectRegularPolygon":return Math.abs(a.radius);case "CIMGeometricEffectRotate":return 0;case "CIMGeometricEffectScale":return 0;case "CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(a.fromWidth),Math.abs(a.toWidth));case "CIMGeometricEffectWave":return Math.abs(a.amplitude); case "CIMGeometricEffectDonut":return Math.abs(a.width);default:return 0}}function L(a){if(!a)return 0;let b=0;for(const c of a)b+=ka(c);return b}function T(a,b){if(a)switch(a.type){case "CIMPointSymbol":case "CIMLineSymbol":case "CIMPolygonSymbol":if(a=a.symbolLayers)for(const c of a)switch(b(c),c.type){case "CIMVectorMarker":if(a=c.markerGraphics)for(const d of a)d&&(a=d.symbol)&&T(a,b)}}}function la(a,b,c){a.effects&&null==b.geometryEngine&&(b.geometryEnginePromise?c.push(b.geometryEnginePromise): n.isGeometryEngineRequired(a.effects)&&(b.geometryEnginePromise=n.importGeometryEngine(),c.push(b.geometryEnginePromise),b.geometryEnginePromise.then(d=>b.geometryEngine=d)))}function U(a){if(!a)return null;let b=null;const {cap:c,color:d,join:h,miterLimit:f,style:g,width:e}=a;"solid"!==g&&"none"!==g&&"esriSLSSolid"!==g&&"esriSLSNull"!==g&&(b=[{type:"CIMGeometricEffectDashes",dashTemplate:H(g,c),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]);return{type:"CIMSolidStroke",color:"esriSLSNull"!== g&&"none"!==g?r(d):[0,0,0,0],capStyle:M(c),joinStyle:V(h),miterLimit:f,width:e,effects:b}}const W=Math.PI,ma=W/2,X=Math.PI/180,u=96/72,I=()=>ca.getLogger("esri.symbols.cim.CIMSymbolHelper");class na{static getSymbolInflateSize(a,b,c,d,h){a||=[0,0,0,0];return b?this._getInflateSize(a,b,c,d,h):a}static safeSize(a){const b=Math.max(Math.abs(a[0]),Math.abs(a[2]));a=Math.max(Math.abs(a[1]),Math.abs(a[3]));return Math.sqrt(b*b+a*a)}static _vectorMarkerBounds(a,b,c,d){let h=!0;const f=A.create();if(b?.markerGraphics)for(const g of b.markerGraphics)b= [0,0,0,0],g.geometry&&(ea.getBoundsXY(f,g.geometry),b[0]=0,b[1]=0,b[2]=0,b[3]=0,this.getSymbolInflateSize(b,g.symbol,c,0,d),f[0]+=b[0],f[1]+=b[1],f[2]+=b[2],f[3]+=b[3],h?(a[0]=f[0],a[1]=f[1],a[2]=f[2],a[3]=f[3],h=!1):(a[0]=Math.min(a[0],f[0]),a[1]=Math.min(a[1],f[1]),a[2]=Math.max(a[2],f[2]),a[3]=Math.max(a[3],f[3])));return a}static _getInflateSize(a,b,c,d,h){return void 0!==b.symbolLayers?(a=this._getLayersInflateSize(a,b.symbolLayers,c,d,h),b=L(b.effects),0l.width&&0{switch(f.type){case "CIMSolidStroke":null!=f.width&&(f.width*=b);f.effects?.forEach(g=>{"CIMGeometricEffectDashes"===g.type&&(g.dashTemplate=g.dashTemplate?.map(e=>e*b))});break;case "CIMVectorMarker":null!=f.size&&(f.size*=b),f=f.markerPlacement,null!=f&&"placementTemplate"in f&&(f.placementTemplate=f.placementTemplate.map(g=> g*b))}});for(var h=this._getLineSymbolPeriod(a)||4;4>h;)h*=2;h/=2;return{type:"CIMVectorMarker",frame:{xmin:-h,xmax:h,ymin:-d,ymax:d},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[-h,0],[h,0]]]},symbol:a}],size:c}}static fetchResources(a,b,c,d=null){if(!a||!b)return c;T(a,h=>{la(h,b,c);"url"in h&&h.url&&c.push(b.fetchResource(h.url,{signal:d}))});return c}static fetchFonts(a,b,c){if(a&&b)if("symbolLayers"in a&&a.symbolLayers)for(const f of a.symbolLayers){if("CIMVectorMarker"===f.type&& f.markerGraphics)for(const g of f.markerGraphics)g?.symbol&&v.fetchFonts(g.symbol,b,c)}else if("CIMTextSymbol"===a.type){const {fontFamilyName:f,fontStyleName:g}=a;if(f&&"calcitewebcoreicons"!==f.toLowerCase()){var {style:d,weight:h}=n.fromCIMFontStyle(g);a=n.fromCIMFontDecoration(a);a=new fa({family:f,style:d,weight:h,decoration:a});c.push(b.loadFont(a).catch(()=>{I().error(`Unsupported font ${f} in CIM symbol`)}))}}}static _getLineSymbolPeriod(a){if(a){const b=this._getEffectsRepeat(a.effects); if(b)return b;if(a.symbolLayers)for(const c of a.symbolLayers)if(c){if(a=this._getEffectsRepeat(c.effects))return a;switch(c.type){case "CIMCharacterMarker":case "CIMPictureMarker":case "CIMVectorMarker":case "CIMObjectMarker3D":case "CIMglTFMarker3D":if(a=this._getPlacementRepeat(c.markerPlacement))return a}}}return 0}static _getEffectsRepeat(a){if(a)for(var b of a)if(b)switch(b.type){case "CIMGeometricEffectDashes":if((a=b.dashTemplate)&&a.length){b=0;for(const c of a)b+=c;a.length&1&&(b*=2);return b}break; case "CIMGeometricEffectWave":return b.period;default:I().error(`unsupported geometric effect type ${b.type}`)}return 0}static _getPlacementRepeat(a){if(a)switch(a.type){case "CIMMarkerPlacementAlongLineSameSize":case "CIMMarkerPlacementAlongLineRandomSize":case "CIMMarkerPlacementAlongLineVariableSize":if((a=a.placementTemplate)&&a.length){let b=0;for(const c of a)b+=+c;a.length&1&&(b*=2);return b}}return 0}static fromCIMInsidePolygon(a){var b=a.markerPlacement;const c={...a,markerPlacement:null, anchorPoint:null};a=Math.abs(b.stepX);const d=Math.abs(b.stepY);var h=(b.randomness??100)/100;let f,g;if("Random"===b.gridType){var e=P.px2pt(K.randomInsidePolygonTextureSize);const k=Math.max(Math.floor(e/a),1),l=Math.max(Math.floor(e/d),1);e=k*a/2;f=l*d/2;g=2*f;b=new da(b.seed);const p=h*a/1.5,q=h*d/1.5;h=[];for(let t=0;t({type:"CIMMarkerGraphic",geometry:k,symbol:{type:"CIMPointSymbol",symbolLayers:[c]}}));return{type:"CIMVectorMarker",frame:{xmin:-e,xmax:e,ymin:-f,ymax:f},markerGraphics:a,size:g}}}const M=a=>{if(!a)return m.LineCapStyle.Butt;switch(a){case "butt":return m.LineCapStyle.Butt;case "square":return m.LineCapStyle.Square; case "round":return m.LineCapStyle.Round}},V=a=>{if(!a)return m.LineJoinStyle.Miter;switch(a){case "miter":return m.LineJoinStyle.Miter;case "round":return m.LineJoinStyle.Round;case "bevel":return m.LineJoinStyle.Bevel}},ra=a=>{if(null==a)return"Center";switch(a){case "left":return"Left";case "right":return"Right";case "center":return"Center"}},sa=a=>{if(null==a)return"Center";switch(a){case "baseline":return"Baseline";case "top":return"Top";case "middle":return"Center";case "bottom":return"Bottom"}}, r=a=>{if(!a)return[0,0,0,0];const {r:b,g:c,b:d,a:h}=a;return[b,c,d,255*h]},H=(a,b)=>{const c=ba("safari")?.001:0;b="butt"===b;switch(a){case "dash":case "esriSLSDash":return b?[4,3]:[3,4];case "dash-dot":case "esriSLSDashDot":return b?[4,3,1,3]:[3,4,c,4];case "dot":case "esriSLSDot":return b?[1,3]:[c,4];case "long-dash":case "esriSLSLongDash":return b?[8,3]:[7,4];case "long-dash-dot":case "esriSLSLongDashDot":return b?[8,3,1,3]:[7,4,c,4];case "long-dash-dot-dot":case "esriSLSDashDotDot":return b? [8,3,1,3,1,3]:[7,4,c,4,c,4];case "short-dash":case "esriSLSShortDash":return b?[4,1]:[3,2];case "short-dash-dot":case "esriSLSShortDashDot":return b?[4,1,1,1]:[3,2,c,2];case "short-dash-dot-dot":case "esriSLSShortDashDotDot":return b?[4,1,1,1,1,1]:[3,2,c,2,c,2];case "short-dot":case "esriSLSShortDot":return b?[1,1]:[c,2];case "solid":case "esriSLSSolid":case "none":return I().error("Unexpected: style does not require rasterization"),[0,0];default:return I().error(`Tried to rasterize SLS, but found an unexpected style: ${a}!`), [0,0]}},D=(a,b=100)=>{var c=b/2,d;if("circle"===a||"esriSMSCircle"===a){var h=Math.acos(1-.25/c);b=Math.ceil(W/h/4);0===b&&(b=1);h=ma/b;b*=4;a=[];a.push([c,0]);for(d=1;d