@arcgis/core 5.1.0-next.58 → 5.1.0-next.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/applications/Components/SelectionOperation.d.ts +2 -2
  2. package/applications/Components/SelectionOperation.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/04ea806b933d4dd41609.js +1 -0
  5. package/assets/esri/core/workers/chunks/{45b7266580f9ce4fab6c.js → 0622e238693c257abacb.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{05bc675c029ed311427f.js → 155c741a9839d24f04a2.js} +1 -1
  7. package/assets/esri/core/workers/chunks/1ae4e43a399e1974f106.js +1 -0
  8. package/assets/esri/core/workers/chunks/1f8e22df08c2f5fbb8c8.js +1 -0
  9. package/assets/esri/core/workers/chunks/{2327b368673a974dee8b.js → 2339465190c9d5ede25f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/23f6d24bf850bc3280ec.js +1 -0
  11. package/assets/esri/core/workers/chunks/2541ac6e0ed1184edc9b.js +1 -0
  12. package/assets/esri/core/workers/chunks/34207774bc371e95ba3c.js +1 -0
  13. package/assets/esri/core/workers/chunks/{01777e91cd4e0bf04fd0.js → 35217befc8f9882d139e.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{40bcfc4f8efe7de7ec9d.js → 3de17e89973160b42923.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{666e1e79fcb309b0b9b1.js → 48d289db3145ce6c02bb.js} +1 -1
  16. package/assets/esri/core/workers/chunks/4c73c2f4331351e2a50c.js +1 -0
  17. package/assets/esri/core/workers/chunks/{2757cf54656b5d318b11.js → 55a0b69cf034ac32fc25.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{4d54beab8ae5ff31e7b0.js → 5a9f5a49dc68b42762bb.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{7cec3252e3ee56424b9e.js → 5c6e5f22450dd0583074.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{b39b4db86a1049f0b901.js → 6be9d00839002f24fafd.js} +1 -1
  21. package/assets/esri/core/workers/chunks/6c886f19875291d02407.js +1 -0
  22. package/assets/esri/core/workers/chunks/75e28458e08b0738b35a.js +2 -0
  23. package/assets/esri/core/workers/chunks/{c460ca93ed8e20d8b53a.js → 86a6dd19903fa5023cc7.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{6c571008bee8376ea50a.js → 8ccf2f65d8ed3c48ffff.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{fcfaaced184f8da3e28d.js → 9b53aa2429573f1b977f.js} +1 -1
  26. package/assets/esri/core/workers/chunks/9d580b5bcd59857a5702.js +1405 -0
  27. package/assets/esri/core/workers/chunks/a37697ef360e2425768a.js +1 -0
  28. package/assets/esri/core/workers/chunks/{a787fe09d3df9d4254ba.js → ab3183f2327ff26e2b45.js} +1 -1
  29. package/assets/esri/core/workers/chunks/b0f2ce61d3cad413898e.js +1 -0
  30. package/assets/esri/core/workers/chunks/{53c149bca42595b7dd1e.js → bbdf27bc34fadbe8e6fe.js} +1 -1
  31. package/assets/esri/core/workers/chunks/be42fe0b7ba0e27030b2.js +1 -0
  32. package/assets/esri/core/workers/chunks/d0c3ab70f390cd579fed.js +1 -0
  33. package/assets/esri/core/workers/chunks/{5a573fa1012092328b88.js → d816d1a4220d827faf63.js} +1 -1
  34. package/assets/esri/core/workers/chunks/e26894655823849947f4.js +1 -0
  35. package/assets/esri/core/workers/chunks/e59f5dc8c85bcea66e98.js +1 -0
  36. package/assets/esri/core/workers/chunks/{ccf845ac0ac354507a25.js → ec1b2eb05410848081c9.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{851dd71d28681d4eccfd.js → f7af90c5f9d371eb7009.js} +1 -1
  38. package/assets/esri/core/workers/chunks/fa6e1ad099b43a6f5501.js +1 -0
  39. package/assets/esri/core/workers/chunks/{4a6186001323b47c23a4.js → fee1d873127dca02459f.js} +1 -1
  40. package/chunks/GlobalIllumination.glsl.js +101 -0
  41. package/chunks/GlobalIlluminationBlur.glsl.js +68 -0
  42. package/config.js +1 -1
  43. package/geometry/Mesh.js +1 -1
  44. package/geometry/support/polygonUtils.js +1 -1
  45. package/geometry/support/{triangulationUtils.js → triangulationUtilsDeprecated.js} +1 -1
  46. package/kernel.js +1 -1
  47. package/layers/support/SceneModification.js +1 -1
  48. package/package.json +2 -2
  49. package/renderers/ClassBreaksRenderer.js +1 -1
  50. package/renderers/DictionaryRenderer.js +1 -1
  51. package/renderers/DotDensityRenderer.js +1 -1
  52. package/renderers/HeatmapRenderer.js +1 -1
  53. package/renderers/PieChartRenderer.js +1 -1
  54. package/renderers/Renderer.js +1 -1
  55. package/renderers/SimpleRenderer.js +1 -1
  56. package/renderers/UniqueValueRenderer.js +1 -1
  57. package/renderers/support/AttributeColorInfo.js +1 -1
  58. package/renderers/support/ClassBreakInfo.d.ts +6 -0
  59. package/renderers/support/ClassBreakInfo.js +1 -1
  60. package/renderers/support/UniqueValueClass.d.ts +12 -0
  61. package/renderers/support/UniqueValueClass.js +1 -1
  62. package/renderers/support/UniqueValueInfo.d.ts +12 -0
  63. package/renderers/support/UniqueValueInfo.js +1 -1
  64. package/renderers/visualVariables/ColorVariable.js +1 -1
  65. package/renderers/visualVariables/OpacityVariable.js +1 -1
  66. package/renderers/visualVariables/SizeVariable.js +1 -1
  67. package/renderers/visualVariables/VisualVariable.js +1 -1
  68. package/support/revision.js +1 -1
  69. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  70. package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
  71. package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
  72. package/views/2d/engine/webgl/GlyphSource.js +1 -1
  73. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  74. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  75. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  76. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
  78. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  79. package/views/2d/engine/webgl/util/IntervalMatcher.js +1 -1
  80. package/views/2d/engine/webgl/util/MapMatcher.js +1 -1
  81. package/views/2d/layers/features/schema/processor/MatcherSchema.js +1 -1
  82. package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
  83. package/views/3d/FocusAreasView.js +1 -1
  84. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  85. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  86. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  87. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  88. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  89. package/views/3d/layers/Lyr3DWorker.js +1 -1
  90. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  91. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  93. package/views/3d/layers/graphics/extrudeUtils.js +1 -1
  94. package/views/3d/layers/graphics/extrudeUtilsDeprecated.js +2 -0
  95. package/views/3d/layers/graphics/tessellationUtils.js +2 -0
  96. package/views/3d/layers/i3s/PointCloudHighlights.js +1 -1
  97. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  98. package/views/3d/layers/i3s/PointCloudRendererNode.js +1 -1
  99. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  100. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  101. package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
  102. package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
  103. package/views/3d/support/renderInfoUtils/line.js +1 -1
  104. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  105. package/views/3d/support/renderInfoUtils/polygonDeprecated.js +2 -0
  106. package/views/3d/terrain/OverlayRenderer.js +1 -1
  107. package/views/3d/terrain/TerrainRenderer.js +1 -1
  108. package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  110. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  111. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  112. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  113. package/views/3d/webgl-engine/collections/Component/RenderGeometry.js +1 -1
  114. package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
  115. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  116. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  117. package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js +6 -5
  118. package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepthLastFrame.glsl.js +4 -0
  119. package/views/3d/webgl-engine/core/shaderLibrary/shading/EncodingColor.glsl.js +7 -0
  120. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +6 -6
  121. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +93 -50
  122. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadGlobalIllumination.glsl.js +20 -0
  123. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +23 -9
  124. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +1 -1
  125. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +1 -1
  126. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  127. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  128. package/views/3d/webgl-engine/effects/emissive/emissions.js +2 -0
  129. package/views/3d/webgl-engine/effects/globalIllumination/BlueNoise.js +2 -0
  130. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +2 -0
  131. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlurTechnique.js +2 -0
  132. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechnique.js +2 -0
  133. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechniqueConfiguration.js +2 -0
  134. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  135. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  136. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  137. package/views/3d/webgl-engine/lib/Material.js +1 -1
  138. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  139. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  140. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  141. package/views/3d/webgl-engine/lib/ReprojectionUniforms.js +1 -1
  142. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  143. package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
  144. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  145. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  146. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
  150. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  151. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  152. package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
  153. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  154. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  155. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  156. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  157. package/views/3d/webgl-engine/shaders/GlobalIllumination.glsl.js +2 -0
  158. package/views/3d/webgl-engine/shaders/GlobalIlluminationBlur.glsl.js +2 -0
  159. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  160. package/views/3d/webgl-engine/shaders/MeasurementArrowTechniqueConfiguration.js +1 -1
  161. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  162. package/{widgets/support/Selector2D → views/selection}/SelectionOperation.d.ts +10 -11
  163. package/views/selection/SelectionOperation.js +2 -0
  164. package/views/selection/types.d.ts +138 -2
  165. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  166. package/assets/esri/core/workers/chunks/009db7b459b18f6a668b.js +0 -1
  167. package/assets/esri/core/workers/chunks/0fc60b4c44c4e865b699.js +0 -2
  168. package/assets/esri/core/workers/chunks/34484afe767d60f85982.js +0 -1
  169. package/assets/esri/core/workers/chunks/55bb5b7817c2963c8bfa.js +0 -1
  170. package/assets/esri/core/workers/chunks/572fcd33ae3648ed4f9c.js +0 -1
  171. package/assets/esri/core/workers/chunks/66a4d764937918a2779f.js +0 -1
  172. package/assets/esri/core/workers/chunks/6b56c8ba978ec6edd6b8.js +0 -1
  173. package/assets/esri/core/workers/chunks/92fb6519b01d110ee947.js +0 -1041
  174. package/assets/esri/core/workers/chunks/9806cc96414065ae0afe.js +0 -1
  175. package/assets/esri/core/workers/chunks/9b365a6242b0287f8727.js +0 -1
  176. package/assets/esri/core/workers/chunks/a029db48079af4b5cccd.js +0 -1
  177. package/assets/esri/core/workers/chunks/ec91d5081f423755cb07.js +0 -1
  178. package/assets/esri/core/workers/chunks/f9fe89ced41b49608667.js +0 -1
  179. package/assets/esri/core/workers/chunks/fce30184f354fb7d11af.js +0 -1
  180. package/widgets/support/Selector2D/SelectionOperation.js +0 -2
  181. package/widgets/support/Selector2D/types.d.ts +0 -139
  182. /package/assets/esri/core/workers/chunks/{0fc60b4c44c4e865b699.js.LICENSE.txt → 75e28458e08b0738b35a.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as s,subclass as o}from"../../core/accessorSupport/decorators.js";import{requiredRendererSymbolProperty as r}from"./commonProperties.js";var i;let l=i=class extends t{constructor(e){super(e),this.description=null,this.label=null,this.minValue=null,this.maxValue=0,this.symbol=null}clone(){return new i({description:this.description,label:this.label,minValue:this.minValue,maxValue:this.maxValue,symbol:this.symbol?.clone()??null})}getMeshHash(){const e=JSON.stringify(this.symbol);return`${this.minValue}.${this.maxValue}.${e}`}};e([s({type:String,json:{write:!0}})],l.prototype,"description",void 0),e([s({type:String,json:{write:!0}})],l.prototype,"label",void 0),e([s({type:Number,json:{read:{source:"classMinValue"},write:{target:"classMinValue"}}})],l.prototype,"minValue",void 0),e([s({type:Number,json:{read:{source:"classMaxValue"},write:{target:"classMaxValue"}}})],l.prototype,"maxValue",void 0),e([s(r)],l.prototype,"symbol",void 0),l=i=e([o("esri.renderers.support.ClassBreakInfo")],l);export{l as default};
2
+ import{__decorate as e}from"tslib";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as o,subclass as r}from"../../core/accessorSupport/decorators.js";import{requiredRendererSymbolProperty as s}from"./commonProperties.js";import l from"../../symbols/CIMSymbol.js";var i;let a=i=class extends t{constructor(e){super(e),this.description=null,this.label=null,this.minValue=null,this.maxValue=0,this.symbol=null,this.alternateSymbols=null}clone(){return new i({alternateSymbols:this.alternateSymbols?.map(e=>e.clone()),description:this.description,label:this.label,minValue:this.minValue,maxValue:this.maxValue,symbol:this.symbol?.clone()??null})}};e([o({type:String,json:{write:!0}})],a.prototype,"description",void 0),e([o({type:String,json:{write:!0}})],a.prototype,"label",void 0),e([o({type:Number,json:{read:{source:"classMinValue"},write:{target:"classMinValue"}}})],a.prototype,"minValue",void 0),e([o({type:Number,json:{read:{source:"classMaxValue"},write:{target:"classMaxValue"}}})],a.prototype,"maxValue",void 0),e([o(s)],a.prototype,"symbol",void 0),e([o({type:[l],json:{write:!0,origins:{"web-scene":{write:!1}}}})],a.prototype,"alternateSymbols",void 0),a=i=e([r("esri.renderers.support.ClassBreakInfo")],a);export{a as default};
@@ -1,4 +1,5 @@
1
1
  import type UniqueValue from "./UniqueValue.js";
2
+ import type CIMSymbol from "../../symbols/CIMSymbol.js";
2
3
  import type { ClonableMixin } from "../../core/Clonable.js";
3
4
  import type { JSONSupport } from "../../core/JSONSupport.js";
4
5
  import type { UniqueValueProperties } from "./UniqueValue.js";
@@ -18,6 +19,11 @@ import type { PictureMarkerSymbolProperties } from "../../symbols/PictureMarkerS
18
19
  import type { PictureFillSymbolProperties } from "../../symbols/PictureFillSymbol.js";
19
20
 
20
21
  export interface UniqueValueClassProperties extends Partial<Pick<UniqueValueClass, "label">> {
22
+ /**
23
+ * Defines alternate CIM symbols used to represent features containing the given
24
+ * [values](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueClass/#values) at different scales.
25
+ */
26
+ alternateSymbols?: CIMSymbolProperties[] | null;
21
27
  /**
22
28
  * Defines the symbol used to represent features containing the given [values](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueClass/#values).
23
29
  *
@@ -96,6 +102,12 @@ export interface UniqueValueClassProperties extends Partial<Pick<UniqueValueClas
96
102
  */
97
103
  export default class UniqueValueClass extends UniqueValueClassSuperclass {
98
104
  constructor(properties?: UniqueValueClassProperties);
105
+ /**
106
+ * Defines alternate CIM symbols used to represent features containing the given
107
+ * [values](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueClass/#values) at different scales.
108
+ */
109
+ get alternateSymbols(): CIMSymbol[] | null | undefined;
110
+ set alternateSymbols(value: CIMSymbolProperties[] | null | undefined);
99
111
  /**
100
112
  * Describes the [values](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueClass/#values) represented by the [symbol](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueClass/#symbol) in the
101
113
  * [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/).
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as r}from"../../core/arrayUtils.js";import{ClonableMixin as t}from"../../core/Clonable.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{property as s,subclass as l}from"../../core/accessorSupport/decorators.js";import{rendererSymbolProperty as i}from"./commonProperties.js";import a from"./UniqueValue.js";let n=class extends(t(o)){constructor(e){super(e),this.description=null,this.label=null,this.symbol=null}get values(){return this._get("values")}set values(e){if(null!=e){const r=typeof(e=Array.isArray(e)?e:[e])[0];e="string"===r||"number"===r?e.map(e=>new a({value:e})):"object"===r?e[0]instanceof a?e:e.map(e=>new a(e)):null}this._set("values",e)}};e([s({type:String,json:{write:!0}})],n.prototype,"description",void 0),e([s({type:String,json:{write:!0}})],n.prototype,"label",void 0),e([s(i)],n.prototype,"symbol",void 0),e([s({json:{type:[[String]],read:{reader:e=>e?e.map(e=>new a({value:e[0],value2:e[1],value3:e[2]})):null},write:{writer:(e,t)=>{const o=[];for(const s of e){const e=[s.value,s.value2,s.value3].filter(r).map(e=>e.toString());o.push(e)}t.values=o}}}})],n.prototype,"values",null),n=e([l("esri.renderers.support.UniqueValueClass")],n);export{n as default};
2
+ import{__decorate as e}from"tslib";import{isSome as r}from"../../core/arrayUtils.js";import{ClonableMixin as t}from"../../core/Clonable.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{property as s,subclass as l}from"../../core/accessorSupport/decorators.js";import{rendererSymbolProperty as i}from"./commonProperties.js";import n from"./UniqueValue.js";import a from"../../symbols/CIMSymbol.js";let p=class extends(t(o)){constructor(e){super(e),this.description=null,this.label=null,this.symbol=null,this.alternateSymbols=null}get values(){return this._get("values")}set values(e){if(null!=e){const r=typeof(e=Array.isArray(e)?e:[e])[0];e="string"===r||"number"===r?e.map(e=>new n({value:e})):"object"===r?e[0]instanceof n?e:e.map(e=>new n(e)):null}this._set("values",e)}};e([s({type:String,json:{write:!0}})],p.prototype,"description",void 0),e([s({type:String,json:{write:!0}})],p.prototype,"label",void 0),e([s(i)],p.prototype,"symbol",void 0),e([s({type:[a],json:{write:!0,origins:{"web-scene":{write:!1}}}})],p.prototype,"alternateSymbols",void 0),e([s({json:{type:[[String]],read:{reader:e=>e?e.map(e=>new n({value:e[0],value2:e[1],value3:e[2]})):null},write:{writer:(e,t)=>{const o=[];for(const s of e){const e=[s.value,s.value2,s.value3].filter(r).map(e=>e.toString());o.push(e)}t.values=o}}}})],p.prototype,"values",null),p=e([l("esri.renderers.support.UniqueValueClass")],p);export{p as default};
@@ -1,3 +1,4 @@
1
+ import type CIMSymbol from "../../symbols/CIMSymbol.js";
1
2
  import type { JSONSupport } from "../../core/JSONSupport.js";
2
3
  import type { SymbolUnion } from "../../symbols/types.js";
3
4
  import type { WebStyleSymbolProperties } from "../../symbols/WebStyleSymbol.js";
@@ -15,6 +16,11 @@ import type { PictureMarkerSymbolProperties } from "../../symbols/PictureMarkerS
15
16
  import type { PictureFillSymbolProperties } from "../../symbols/PictureFillSymbol.js";
16
17
 
17
18
  export interface UniqueValueInfoProperties extends Partial<Pick<UniqueValueInfo, "label" | "value">> {
19
+ /**
20
+ * Defines alternate CIM symbols used to represent features with the provided [value](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueInfo/#value)
21
+ * at different scales.
22
+ */
23
+ alternateSymbols?: CIMSymbolProperties[] | null;
18
24
  /**
19
25
  * Defines the symbol used to render features with the provided [value](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueInfo/#value).
20
26
  *
@@ -41,6 +47,12 @@ export interface UniqueValueInfoProperties extends Partial<Pick<UniqueValueInfo,
41
47
  */
42
48
  export default class UniqueValueInfo extends JSONSupport {
43
49
  constructor(properties?: UniqueValueInfoProperties);
50
+ /**
51
+ * Defines alternate CIM symbols used to represent features with the provided [value](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueInfo/#value)
52
+ * at different scales.
53
+ */
54
+ get alternateSymbols(): CIMSymbol[] | null | undefined;
55
+ set alternateSymbols(value: CIMSymbolProperties[] | null | undefined);
44
56
  /**
45
57
  * Describes the [value](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueInfo/#value) represented by the [symbol](https://developers.arcgis.com/javascript/latest/references/core/renderers/support/UniqueValueInfo/#symbol). This label will appear in the
46
58
  * [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/) next to the symbol representing the value.
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as o}from"tslib";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as e,subclass as r}from"../../core/accessorSupport/decorators.js";import{requiredRendererSymbolProperty as s,uniqueValueProperty as i}from"./commonProperties.js";var l;let p=l=class extends t{constructor(o){super(o),this.description=null,this.label=null,this.symbol=null,this.value=null}clone(){return new l({value:this.value,description:this.description,label:this.label,symbol:this.symbol?this.symbol.clone():null})}getMeshHash(){const o=JSON.stringify(this.symbol?.toJSON());return`${this.value}.${o}`}};o([e({type:String,json:{write:!0}})],p.prototype,"description",void 0),o([e({type:String,json:{write:!0}})],p.prototype,"label",void 0),o([e(s)],p.prototype,"symbol",void 0),o([e(i)],p.prototype,"value",void 0),p=l=o([r("esri.renderers.support.UniqueValueInfo")],p);export{p as default};
2
+ import{__decorate as o}from"tslib";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as e,subclass as r}from"../../core/accessorSupport/decorators.js";import{requiredRendererSymbolProperty as s,uniqueValueProperty as l}from"./commonProperties.js";import i from"../../symbols/CIMSymbol.js";var n;let p=n=class extends t{constructor(o){super(o),this.description=null,this.label=null,this.symbol=null,this.alternateSymbols=null,this.value=null}clone(){return new n({alternateSymbols:this.alternateSymbols?.map(o=>o.clone()),value:this.value,description:this.description,label:this.label,symbol:this.symbol?this.symbol.clone():null})}};o([e({type:String,json:{write:!0}})],p.prototype,"description",void 0),o([e({type:String,json:{write:!0}})],p.prototype,"label",void 0),o([e(s)],p.prototype,"symbol",void 0),o([e({type:[i],json:{write:!0,origins:{"web-scene":{write:!1}}}})],p.prototype,"alternateSymbols",void 0),o([e(l)],p.prototype,"value",void 0),p=n=o([r("esri.renderers.support.UniqueValueInfo")],p);export{p as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as e,subclass as o}from"../../core/accessorSupport/decorators.js";import s from"./VisualVariable.js";import r from"./support/ColorStop.js";var i;let l=i=class extends s{constructor(t){super(t),this.type="color",this.normalizationField=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null}}set stops(t){t&&Array.isArray(t)&&(t=t.filter(t=>!!t)).sort((t,e)=>t.value-e.value),this._set("stops",t)}clone(){return new i({field:this.field,normalizationField:this.normalizationField,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,stops:this.stops&&this.stops.map(t=>t.clone()),legendOptions:this.legendOptions?.clone()})}getAttributeHash(){return`${super.getAttributeHash()}-${this.normalizationField}`}_interpolateData(){return this.stops&&this.stops.map(t=>t.value||0)}};t([e({readOnly:!0})],l.prototype,"cache",null),t([e({type:["color"],json:{type:["colorInfo"]}})],l.prototype,"type",void 0),t([e({type:String,json:{write:!0}})],l.prototype,"normalizationField",void 0),t([e({type:[r],json:{write:!0}})],l.prototype,"stops",null),l=i=t([o("esri.renderers.visualVariables.ColorVariable")],l);export{l as default};
2
+ import{__decorate as t}from"tslib";import{property as e,subclass as o}from"../../core/accessorSupport/decorators.js";import s from"./VisualVariable.js";import r from"./support/ColorStop.js";var i;let l=i=class extends s{constructor(t){super(t),this.type="color",this.normalizationField=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null}}set stops(t){t&&Array.isArray(t)&&(t=t.filter(t=>!!t)).sort((t,e)=>t.value-e.value),this._set("stops",t)}clone(){return new i({field:this.field,normalizationField:this.normalizationField,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,stops:this.stops&&this.stops.map(t=>t.clone()),legendOptions:this.legendOptions?.clone()})}_interpolateData(){return this.stops&&this.stops.map(t=>t.value||0)}};t([e({readOnly:!0})],l.prototype,"cache",null),t([e({type:["color"],json:{type:["colorInfo"]}})],l.prototype,"type",void 0),t([e({type:String,json:{write:!0}})],l.prototype,"normalizationField",void 0),t([e({type:[r],json:{write:!0}})],l.prototype,"stops",null),l=i=t([o("esri.renderers.visualVariables.ColorVariable")],l);export{l as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{property as e,subclass as s}from"../../core/accessorSupport/decorators.js";import i from"./VisualVariable.js";import o from"./support/OpacityStop.js";var r;let a=r=class extends i{constructor(t){super(t),this.type="opacity",this.normalizationField=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null}}set stops(t){t&&Array.isArray(t)&&(t=t.filter(t=>!!t)).sort((t,e)=>t.value-e.value),this._set("stops",t)}clone(){return new r({field:this.field,normalizationField:this.normalizationField,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,stops:this.stops&&this.stops.map(t=>t.clone()),legendOptions:this.legendOptions?.clone()})}getAttributeHash(){return`${super.getAttributeHash()}-${this.normalizationField}`}_interpolateData(){return this.stops&&this.stops.map(t=>t.value||0)}};t([e({readOnly:!0})],a.prototype,"cache",null),t([e({type:["opacity"],json:{type:["transparencyInfo"]}})],a.prototype,"type",void 0),t([e({type:String,json:{write:!0}})],a.prototype,"normalizationField",void 0),t([e({type:[o],json:{write:!0}})],a.prototype,"stops",null),a=r=t([s("esri.renderers.visualVariables.OpacityVariable")],a);export{a as default};
2
+ import{__decorate as t}from"tslib";import{property as e,subclass as s}from"../../core/accessorSupport/decorators.js";import o from"./VisualVariable.js";import i from"./support/OpacityStop.js";var r;let a=r=class extends o{constructor(t){super(t),this.type="opacity",this.normalizationField=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null}}set stops(t){t&&Array.isArray(t)&&(t=t.filter(t=>!!t)).sort((t,e)=>t.value-e.value),this._set("stops",t)}clone(){return new r({field:this.field,normalizationField:this.normalizationField,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,stops:this.stops&&this.stops.map(t=>t.clone()),legendOptions:this.legendOptions?.clone()})}_interpolateData(){return this.stops&&this.stops.map(t=>t.value||0)}};t([e({readOnly:!0})],a.prototype,"cache",null),t([e({type:["opacity"],json:{type:["transparencyInfo"]}})],a.prototype,"type",void 0),t([e({type:String,json:{write:!0}})],a.prototype,"normalizationField",void 0),t([e({type:[i],json:{write:!0}})],a.prototype,"stops",null),a=r=t([s("esri.renderers.visualVariables.OpacityVariable")],a);export{a as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{JSONMap as t}from"../../core/jsonMap.js";import i from"../../core/Logger.js";import{property as s,subclass as r}from"../../core/accessorSupport/decorators.js";import n from"./VisualVariable.js";import{castSizeFromStringOrNumber as a}from"./support/castSizeVariable.js";import o from"./support/SizeStop.js";import l from"./support/SizeVariableLegendOptions.js";import{isSizeVariable as p,getInputValueType as u,getTransformationType as m}from"./support/sizeVariableUtils.js";import{viewScaleRE as h}from"./support/visualVariableUtils.js";import{addPropertyUnsupportedError as d,addUnsupportedMessage as y}from"../../webdoc/support/unsupportedErrors.js";import{reader as c}from"../../core/accessorSupport/decorators/reader.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";var z;const x=new t({width:"width",depth:"depth",height:"height",widthAndDepth:"width-and-depth",all:"all"}),w=new t({unknown:"unknown",inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});function v(e){if(null!=e)return"string"==typeof e||"number"==typeof e?a(e):"size"===e.type?p(e)?e:(delete(e={...e}).type,new V(e)):void 0}function g(e,t,i){if("object"!=typeof e)return e;if("web-scene"===i.origin)return;const s=new V;return s.read(e,i),s}function f(e,t,i,s){"number"!=typeof e?"web-scene"!==s?.origin?t[i]=e.toJSON(s):y(s,"error","property",`Size variable '${i}' can only be a number in web scenes.`):t[i]=e}let V=z=class extends n{constructor(e){super(e),this.axis=null,this.legendOptions=null,this.normalizationField=null,this.scaleBy=null,this.target=null,this.type="size",this.useSymbolValue=null,this.valueExpression=null,this.valueRepresentation=null,this.valueUnit=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null,isScaleDriven:null!=this.valueExpression&&h.test(this.valueExpression)}}set index(e){p(this.maxSize)&&(this.maxSize.index=`visualVariables[${e}].maxSize`),p(this.minSize)&&(this.minSize.index=`visualVariables[${e}].minSize`),this._set("index",e)}get inputValueType(){return u(this)}set maxDataValue(e){e&&this.stops&&(i.getLogger(this).warn("cannot set maxDataValue when stops is not null."),e=null),this._set("maxDataValue",e)}get maxSize(){return this._get("maxSize")}set maxSize(e){e&&this.stops&&(i.getLogger(this).warn("cannot set maxSize when stops is not null."),e=null),this._set("maxSize",v(e))}readMaxSize(e,t,i){return g(e,t,i)}writeMaxSize(e,t,i,s){return f(e,t,i,s)}set minDataValue(e){e&&this.stops&&(i.getLogger(this).warn("cannot set minDataValue when stops is not null."),e=null),this._set("minDataValue",e)}get minSize(){return this._get("minSize")}set minSize(e){e&&this.stops&&(i.getLogger(this).warn("cannot set minSize when stops is not null."),e=null),this._set("minSize",v(e))}readMinSize(e,t,i){return g(e,t,i)}writeMinSize(e,t,i,s){return f(e,t,i,s)}get arcadeRequired(){return!!this.valueExpression||(null!=this.minSize&&"object"==typeof this.minSize&&this.minSize.arcadeRequired||null!=this.maxSize&&"object"==typeof this.maxSize&&this.maxSize.arcadeRequired)}set stops(e){null==this.minDataValue&&null==this.maxDataValue&&null==this.minSize&&null==this.maxSize?e&&Array.isArray(e)&&(e=e.filter(e=>!!e)).sort((e,t)=>e.value-t.value):e&&(i.getLogger(this).warn("cannot set stops when one of minDataValue, maxDataValue, minSize or maxSize is not null."),e=null),this._set("stops",e)}get transformationType(){return m(this,this.inputValueType)}readValueExpression(e,t){return e||t.expression&&"$view.scale"}writeValueExpressionWebScene(e,t,i,s){if(h.test(e)){if(s?.messages){const e=this.index;d(s,`visualVariables[${"string"==typeof e?e:`visualVariables[${e}]`}].valueExpression`,"SizeVariable with '$view.scale' valueExpression is not supported in Web Scene. Please remove this property to save the Web Scene.")}}else t[i]=e}readValueUnit(e){return e?w.read(e):null}clone(){return new z({axis:this.axis,field:this.field,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,maxDataValue:this.maxDataValue,maxSize:p(this.maxSize)?this.maxSize.clone():this.maxSize,minDataValue:this.minDataValue,minSize:p(this.minSize)?this.minSize.clone():this.minSize,normalizationField:this.normalizationField,stops:this.stops?.map(e=>e.clone()),target:this.target,useSymbolValue:this.useSymbolValue,valueRepresentation:this.valueRepresentation,valueUnit:this.valueUnit,legendOptions:this.legendOptions?.clone()})}flipSizes(){if("clamped-linear"===this.transformationType){const{minSize:e,maxSize:t}=this;return this.minSize=t,this.maxSize=e,this}if("stops"===this.transformationType){const e=this.stops;if(!e)return this;const t=e.map(e=>e.size).reverse(),i=e.length;for(let s=0;s<i;s++)e[s].size=t[s];return this}return this}getAttributeHash(){return`${super.getAttributeHash()}-${this.target}-${this.normalizationField}`}_interpolateData(){return this.stops?.map(e=>e.value||0)}};e([s({readOnly:!0})],V.prototype,"cache",null),e([s({type:x.apiValues,json:{type:x.jsonValues,origins:{"web-map":{read:!1}},read:x.read,write:x.write}})],V.prototype,"axis",void 0),e([s()],V.prototype,"index",null),e([s({type:String,readOnly:!0})],V.prototype,"inputValueType",null),e([s({type:l,json:{write:!0}})],V.prototype,"legendOptions",void 0),e([s({type:Number,value:null,json:{write:!0}})],V.prototype,"maxDataValue",null),e([s({type:Number,useTypeForAutocast:!1,value:null,json:{write:!0}})],V.prototype,"maxSize",null),e([c("maxSize")],V.prototype,"readMaxSize",null),e([S("maxSize")],V.prototype,"writeMaxSize",null),e([s({type:Number,value:null,json:{write:!0}})],V.prototype,"minDataValue",null),e([s({type:Number,useTypeForAutocast:!1,value:null,json:{write:!0}})],V.prototype,"minSize",null),e([c("minSize")],V.prototype,"readMinSize",null),e([S("minSize")],V.prototype,"writeMinSize",null),e([s({type:String,json:{write:!0}})],V.prototype,"normalizationField",void 0),e([s({readOnly:!0})],V.prototype,"arcadeRequired",null),e([s({type:String})],V.prototype,"scaleBy",void 0),e([s({type:[o],value:null,json:{write:!0}})],V.prototype,"stops",null),e([s({type:["outline"],json:{write:!0}})],V.prototype,"target",void 0),e([s({type:String,readOnly:!0})],V.prototype,"transformationType",null),e([s({type:["size"],json:{type:["sizeInfo"]}})],V.prototype,"type",void 0),e([s({type:Boolean,json:{write:!0,origins:{"web-map":{read:!1}}}})],V.prototype,"useSymbolValue",void 0),e([s({type:String,json:{write:!0}})],V.prototype,"valueExpression",void 0),e([c("valueExpression",["valueExpression","expression"])],V.prototype,"readValueExpression",null),e([S("web-scene","valueExpression")],V.prototype,"writeValueExpressionWebScene",null),e([s({type:["radius","diameter","area","width","distance"],json:{write:!0}})],V.prototype,"valueRepresentation",void 0),e([s({type:w.apiValues,json:{write:w.write,origins:{"web-map":{read:!1},"web-scene":{write:!0},"portal-item":{write:!0}}}})],V.prototype,"valueUnit",void 0),e([c("valueUnit")],V.prototype,"readValueUnit",null),V=z=e([r("esri.renderers.visualVariables.SizeVariable")],V);export{V as default};
2
+ import{__decorate as e}from"tslib";import{JSONMap as t}from"../../core/jsonMap.js";import i from"../../core/Logger.js";import{property as s,subclass as r}from"../../core/accessorSupport/decorators.js";import n from"./VisualVariable.js";import{castSizeFromStringOrNumber as a}from"./support/castSizeVariable.js";import o from"./support/SizeStop.js";import l from"./support/SizeVariableLegendOptions.js";import{isSizeVariable as p,getInputValueType as u,getTransformationType as m}from"./support/sizeVariableUtils.js";import{viewScaleRE as h}from"./support/visualVariableUtils.js";import{addPropertyUnsupportedError as d,addUnsupportedMessage as y}from"../../webdoc/support/unsupportedErrors.js";import{reader as c}from"../../core/accessorSupport/decorators/reader.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";var z;const x=new t({width:"width",depth:"depth",height:"height",widthAndDepth:"width-and-depth",all:"all"}),w=new t({unknown:"unknown",inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"});function v(e){if(null!=e)return"string"==typeof e||"number"==typeof e?a(e):"size"===e.type?p(e)?e:(delete(e={...e}).type,new V(e)):void 0}function g(e,t,i){if("object"!=typeof e)return e;if("web-scene"===i.origin)return;const s=new V;return s.read(e,i),s}function f(e,t,i,s){"number"!=typeof e?"web-scene"!==s?.origin?t[i]=e.toJSON(s):y(s,"error","property",`Size variable '${i}' can only be a number in web scenes.`):t[i]=e}let V=z=class extends n{constructor(e){super(e),this.axis=null,this.legendOptions=null,this.normalizationField=null,this.scaleBy=null,this.target=null,this.type="size",this.useSymbolValue=null,this.valueExpression=null,this.valueRepresentation=null,this.valueUnit=null}get cache(){return{ipData:this._interpolateData(),hasExpression:!!this.valueExpression,compiledFunc:null,isScaleDriven:null!=this.valueExpression&&h.test(this.valueExpression)}}set index(e){p(this.maxSize)&&(this.maxSize.index=`visualVariables[${e}].maxSize`),p(this.minSize)&&(this.minSize.index=`visualVariables[${e}].minSize`),this._set("index",e)}get inputValueType(){return u(this)}set maxDataValue(e){e&&this.stops&&(i.getLogger(this).warn("cannot set maxDataValue when stops is not null."),e=null),this._set("maxDataValue",e)}get maxSize(){return this._get("maxSize")}set maxSize(e){e&&this.stops&&(i.getLogger(this).warn("cannot set maxSize when stops is not null."),e=null),this._set("maxSize",v(e))}readMaxSize(e,t,i){return g(e,t,i)}writeMaxSize(e,t,i,s){return f(e,t,i,s)}set minDataValue(e){e&&this.stops&&(i.getLogger(this).warn("cannot set minDataValue when stops is not null."),e=null),this._set("minDataValue",e)}get minSize(){return this._get("minSize")}set minSize(e){e&&this.stops&&(i.getLogger(this).warn("cannot set minSize when stops is not null."),e=null),this._set("minSize",v(e))}readMinSize(e,t,i){return g(e,t,i)}writeMinSize(e,t,i,s){return f(e,t,i,s)}get arcadeRequired(){return!!this.valueExpression||(null!=this.minSize&&"object"==typeof this.minSize&&this.minSize.arcadeRequired||null!=this.maxSize&&"object"==typeof this.maxSize&&this.maxSize.arcadeRequired)}set stops(e){null==this.minDataValue&&null==this.maxDataValue&&null==this.minSize&&null==this.maxSize?e&&Array.isArray(e)&&(e=e.filter(e=>!!e)).sort((e,t)=>e.value-t.value):e&&(i.getLogger(this).warn("cannot set stops when one of minDataValue, maxDataValue, minSize or maxSize is not null."),e=null),this._set("stops",e)}get transformationType(){return m(this,this.inputValueType)}readValueExpression(e,t){return e||t.expression&&"$view.scale"}writeValueExpressionWebScene(e,t,i,s){if(h.test(e)){if(s?.messages){const e=this.index;d(s,`visualVariables[${"string"==typeof e?e:`visualVariables[${e}]`}].valueExpression`,"SizeVariable with '$view.scale' valueExpression is not supported in Web Scene. Please remove this property to save the Web Scene.")}}else t[i]=e}readValueUnit(e){return e?w.read(e):null}clone(){return new z({axis:this.axis,field:this.field,valueExpression:this.valueExpression,valueExpressionTitle:this.valueExpressionTitle,maxDataValue:this.maxDataValue,maxSize:p(this.maxSize)?this.maxSize.clone():this.maxSize,minDataValue:this.minDataValue,minSize:p(this.minSize)?this.minSize.clone():this.minSize,normalizationField:this.normalizationField,stops:this.stops?.map(e=>e.clone()),target:this.target,useSymbolValue:this.useSymbolValue,valueRepresentation:this.valueRepresentation,valueUnit:this.valueUnit,legendOptions:this.legendOptions?.clone()})}flipSizes(){if("clamped-linear"===this.transformationType){const{minSize:e,maxSize:t}=this;return this.minSize=t,this.maxSize=e,this}if("stops"===this.transformationType){const e=this.stops;if(!e)return this;const t=e.map(e=>e.size).reverse(),i=e.length;for(let s=0;s<i;s++)e[s].size=t[s];return this}return this}_interpolateData(){return this.stops?.map(e=>e.value||0)}};e([s({readOnly:!0})],V.prototype,"cache",null),e([s({type:x.apiValues,json:{type:x.jsonValues,origins:{"web-map":{read:!1}},read:x.read,write:x.write}})],V.prototype,"axis",void 0),e([s()],V.prototype,"index",null),e([s({type:String,readOnly:!0})],V.prototype,"inputValueType",null),e([s({type:l,json:{write:!0}})],V.prototype,"legendOptions",void 0),e([s({type:Number,value:null,json:{write:!0}})],V.prototype,"maxDataValue",null),e([s({type:Number,useTypeForAutocast:!1,value:null,json:{write:!0}})],V.prototype,"maxSize",null),e([c("maxSize")],V.prototype,"readMaxSize",null),e([S("maxSize")],V.prototype,"writeMaxSize",null),e([s({type:Number,value:null,json:{write:!0}})],V.prototype,"minDataValue",null),e([s({type:Number,useTypeForAutocast:!1,value:null,json:{write:!0}})],V.prototype,"minSize",null),e([c("minSize")],V.prototype,"readMinSize",null),e([S("minSize")],V.prototype,"writeMinSize",null),e([s({type:String,json:{write:!0}})],V.prototype,"normalizationField",void 0),e([s({readOnly:!0})],V.prototype,"arcadeRequired",null),e([s({type:String})],V.prototype,"scaleBy",void 0),e([s({type:[o],value:null,json:{write:!0}})],V.prototype,"stops",null),e([s({type:["outline"],json:{write:!0}})],V.prototype,"target",void 0),e([s({type:String,readOnly:!0})],V.prototype,"transformationType",null),e([s({type:["size"],json:{type:["sizeInfo"]}})],V.prototype,"type",void 0),e([s({type:Boolean,json:{write:!0,origins:{"web-map":{read:!1}}}})],V.prototype,"useSymbolValue",void 0),e([s({type:String,json:{write:!0}})],V.prototype,"valueExpression",void 0),e([c("valueExpression",["valueExpression","expression"])],V.prototype,"readValueExpression",null),e([S("web-scene","valueExpression")],V.prototype,"writeValueExpressionWebScene",null),e([s({type:["radius","diameter","area","width","distance"],json:{write:!0}})],V.prototype,"valueRepresentation",void 0),e([s({type:w.apiValues,json:{write:w.write,origins:{"web-map":{read:!1},"web-scene":{write:!0},"portal-item":{write:!0}}}})],V.prototype,"valueUnit",void 0),e([c("valueUnit")],V.prototype,"readValueUnit",null),V=z=e([r("esri.renderers.visualVariables.SizeVariable")],V);export{V as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{JSONMap as r}from"../../core/jsonMap.js";import{JSONSupport as t}from"../../core/JSONSupport.js";import o from"../../core/Logger.js";import{property as i,cast as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{ensureString as p}from"../../core/accessorSupport/ensureType.js";import l from"./support/VisualVariableLegendOptions.js";const a=new r({colorInfo:"color",transparencyInfo:"opacity",rotationInfo:"rotation",sizeInfo:"size"});let u=class extends t{constructor(e){super(e),this.index=null,this.type=null,this.field=null,this.valueExpression=null,this.valueExpressionTitle=null,this.legendOptions=null}castField(e){return null==e?e:"function"==typeof e?(o.getLogger(this).error(".field: field must be a string value"),null):p(e)}get arcadeRequired(){return!!this.valueExpression}clone(){}getAttributeHash(){return`${this.type}-${this.field}-${this.valueExpression}`}};e([i()],u.prototype,"index",void 0),e([i({type:a.apiValues,readOnly:!0,json:{read:a.read,write:{writer:a.write,isRequired:!0}}})],u.prototype,"type",void 0),e([i({type:String,json:{write:!0}})],u.prototype,"field",void 0),e([s("field")],u.prototype,"castField",null),e([i({type:String,json:{write:!0}})],u.prototype,"valueExpression",void 0),e([i({type:String,json:{write:!0}})],u.prototype,"valueExpressionTitle",void 0),e([i({readOnly:!0})],u.prototype,"arcadeRequired",null),e([i({type:l,json:{write:!0}})],u.prototype,"legendOptions",void 0),u=e([n("esri.renderers.visualVariables.VisualVariable")],u);export{u as default};
2
+ import{__decorate as e}from"tslib";import{JSONMap as r}from"../../core/jsonMap.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import t from"../../core/Logger.js";import{property as i,cast as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{ensureString as p}from"../../core/accessorSupport/ensureType.js";import l from"./support/VisualVariableLegendOptions.js";const a=new r({colorInfo:"color",transparencyInfo:"opacity",rotationInfo:"rotation",sizeInfo:"size"});let u=class extends o{constructor(e){super(e),this.index=null,this.type=null,this.field=null,this.valueExpression=null,this.valueExpressionTitle=null,this.legendOptions=null}castField(e){return null==e?e:"function"==typeof e?(t.getLogger(this).error(".field: field must be a string value"),null):p(e)}get arcadeRequired(){return!!this.valueExpression}clone(){}};e([i()],u.prototype,"index",void 0),e([i({type:a.apiValues,readOnly:!0,json:{read:a.read,write:{writer:a.write,isRequired:!0}}})],u.prototype,"type",void 0),e([i({type:String,json:{write:!0}})],u.prototype,"field",void 0),e([s("field")],u.prototype,"castField",null),e([i({type:String,json:{write:!0}})],u.prototype,"valueExpression",void 0),e([i({type:String,json:{write:!0}})],u.prototype,"valueExpressionTitle",void 0),e([i({readOnly:!0})],u.prototype,"arcadeRequired",null),e([i({type:l,json:{write:!0}})],u.prototype,"legendOptions",void 0),u=e([n("esri.renderers.visualVariables.VisualVariable")],u);export{u as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- const f="20260331",c="f9b7efec25a442d8085459e02b0f879cfa7cff9c";export{f as buildDate,c as commitHash};
2
+ const f="20260401",c="5c0bf29a9b919987019fc938829b00cf4effd24e";export{f as buildDate,c as commitHash};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{defaultFontFamily as t}from"../../core/fontUtils.js";import has from"../../core/has.js";import{clone as e}from"../../core/lang.js";import r from"../../core/Logger.js";import{deg2rad as i}from"../../core/mathUtils.js";import s from"../../core/ObjectPool.js";import{pt2px as o,px2pt as n}from"../../core/screenUtils.js";import{GeometryCursor as a}from"../../geometry/GeometryCursor.js";import{create as l,fromValues as h,empty as c,expandPointInPlace as m,center as f,width as u,height as d,diagonal as p}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as _}from"../../geometry/support/centroid.js";import{isExtent as y,isPolygon as P,isPolyline as S,isPoint as w,isMultipoint as x}from"../../geometry/support/jsonTypeUtils.js";import{SimpleEffectCursor as M}from"./CIMEffects.js";import b from"./CIMImageColorSubstitutionHelper.js";import{getEffectOperator as k,getPlacementOperator as C}from"./CIMOperators.js";import{Placement as v}from"./CIMPlacements.js";import{defaultCIMValues as I}from"./defaultCIMValues.js";import{getFirstFrame as T}from"./imageUtils.js";import{rotate as R}from"./mathUtils.js";import{addColorStops as z}from"./rasterizingUtils.js";import L from"./Rect.js";import F from"./TextRasterizer.js";import{isMarkerScreenAligned as U,isCIMFill as A,getSize as j,getNumericValue as G,isSVGImage as D,getRelativeGradientSize as H,fromCIMFontDecoration as B,fromCIMFontStyle as E,fromCIMHorizontalAlignment as X,fromCIMVerticalAlignment as J,getFillColor as N,getStrokeColor as O,getStrokeWidth as q,getFontWeight as V,getFontStyle as W}from"./utils.js";import{destroyHiddenSvg as Y,createHiddenSvg as $,createSvgElement as K}from"../../views/2d/engine/svgUtils.js";import{magicLabelLineHeight as Q,glyphSize as Z,hittestToleranceSmallSymbol as tt,hittestSmallSymbolThreshold as et}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as rt}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as it,getLineWidth as st}from"../../views/2d/layers/graphics/graphicsUtils.js";const ot=Math.PI/180,nt=.5,at=()=>r.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class lt{constructor(t){this._t=t}static createIdentity(){return new lt([1,0,0,0,1,0])}clone(){const t=this._t;return new lt(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new lt([t,0,0,0,e,0])}scale(t,e){const r=this._t;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=e,r[4]*=e,r[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new lt([0,0,t,0,0,e])}translate(t,e){const r=this._t;return r[2]+=t,r[5]+=e,this}static createRotate(t){const e=Math.cos(t),r=Math.sin(t);return new lt([e,-r,0,r,e,0])}rotate(t){return lt.multiply(this,lt.createRotate(t),this)}angle(){const t=this._t[0],e=this._t[3],r=Math.sqrt(t*t+e*e);return[t/r,e/r]}static multiply(t,e,r){const i=t._t,s=e._t,o=i[0]*s[0]+i[3]*s[1],n=i[1]*s[0]+i[4]*s[1],a=i[2]*s[0]+i[5]*s[1]+s[2],l=i[0]*s[3]+i[3]*s[4],h=i[1]*s[3]+i[4]*s[4],c=i[2]*s[3]+i[5]*s[4]+s[5],m=r._t;return m[0]=o,m[1]=n,m[2]=a,m[3]=l,m[4]=h,m[5]=c,r}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new lt([0,0,0,0,0,0]);e=1/e;const r=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,s=t[4]*e,o=-t[1]*e,n=-t[3]*e,a=t[0]*e;return new lt([s,o,r,n,a,i])}}class ht{constructor(t,e){this._resourceManager=t,this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new s(()=>new v,void 0,void 0,100),this._earlyReturn=!1,this._mapRotation=0,this._transfos.push(e||lt.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||lt.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformScalar(t){return t/this._transfos[this._transfos.length-1].scaleRatio()}getTransformAngle(){return this._transfos[this._transfos.length-1].angle()}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}prevGeomUnitsPerPoint(){return this._transfos.length>2?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const r=e?t.scaleRatio():1;lt.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*r)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,r){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,r)}}drawMultiLayerSymbol(t,e){if(!t||!e)return;const r=t.symbolLayers;if(!r)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(r,e.asJSON()),e=t.next()}}else this.drawSymbolLayers(r,e)}executeEffects(t,e){let r=new M(a.fromJSONCIM(e));for(const i of t){const t=k(i);t&&(r=t.execute(r,i,this.geomUnitsPerPoint(),null))}return r}drawSymbolLayers(t,e){let r=t.length;for(;r--;){const i=t[r];if(!i||!1===i.enable)continue;const s=i.effects;if(s&&s.length>0){const t=this.executeEffects(s,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e.asJSON()),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color,t.path);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit,t.path);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const r=ut(e,t,this.geomUnitsPerPoint());r&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,r),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const r=t.markerPlacement;if(r){const i=C(r);if(i){const s="CIMMarkerPlacementInsidePolygon"===r.type||"CIMMarkerPlacementPolygonCenter"===r.type&&r.clipAtBoundary;s&&this.pushClipPath(e);const o=i.execute(a.fromJSONCIM(e),r,this.geomUnitsPerPoint(),null);if(o){let e=null;for(;(e=o.next())&&(this.drawMarker(t,e),!this._earlyReturn););}s&&this.popClipPath()}}else{const r=this._placementPool.acquire();if(w(e))r.tx=e.x,r.ty=e.y,this.drawMarker(t,r);else if(P(e)){const i=_(e);i&&([r.tx,r.ty]=i,this.drawMarker(t,r))}else if(S(e)){for(const i of e.paths)for(const e of i)if(r.tx=e[0],r.ty=e[1],this.drawMarker(t,r),this._earlyReturn)break}else for(const i of e.points)if(r.tx=i[0],r.ty=i[1],this.drawMarker(t,r),this._earlyReturn)break;this._placementPool.release(r)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const r=this._resourceManager.getResource(t.url),i=G(t.size,I.CIMPictureMarker.size);if(null==r||i<=0)return;const s=r.width,o=r.height;if(!s||!o)return;const n=s/o,a=G(t.scaleX,1),l=lt.createIdentity(),h=t.anchorPoint;if(h){let e=h.x,r=h.y;"Absolute"!==t.anchorPointUnits&&(e*=i*n*a,r*=i),l.translate(-e,-r)}let c=G(t.rotation);t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&l.rotate(c*ot);let m=G(t.offsetX),f=G(t.offsetY);if(m||f){if(this._mapRotation){const t=ot*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=m*r+f*e;m=m*e-f*r,f=i}l.translate(m,f)}const u=this.geomUnitsPerPoint();1!==u&&l.scale(u,u);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){if(!t)return;const r=t.markerGraphics;if(!r)return;const i=G(t.size,I.CIMVectorMarker.size),s=t.frame,o=s?s.ymax-s.ymin:0,n=i&&o?i/o:1,a=lt.createIdentity();s&&a.translate(.5*-(s.xmax+s.xmin),.5*-(s.ymax+s.ymin));const l=t.anchorPoint;if(l){let e=l.x,r=l.y;"Absolute"!==t.anchorPointUnits?s&&(e*=s.xmax-s.xmin,r*=s.ymax-s.ymin):(e/=n,r/=n),a.translate(-e,-r)}1!==n&&a.scale(n,n);let h=G(t.rotation);t.rotateClockwise&&(h=-h),this._mapRotation&&(h+=this._mapRotation),h&&a.rotate(h*ot);let c=G(t.offsetX),m=G(t.offsetY);if(c||m){if(this._mapRotation){const t=ot*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=c*r+m*e;c=c*e-m*r,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const d of r){d?.symbol&&d.geometry||at().error("Invalid marker graphic",d);let t=d.textString;if("number"==typeof t&&(t=t.toString()),this.drawSymbol(d.symbol,d.geometry,t),this._earlyReturn)break}this.pop()}drawTextSymbol(t,e,r){if(!t)return;if(!w(e))return;if(G(t.height,I.CIMTextSymbol.height)<=0)return;const i=lt.createIdentity();let s=G(t.angle);s=-s,s&&i.rotate(s*ot);const o=G(t.offsetX),n=G(t.offsetY);(o||n)&&i.translate(o,n);const a=this.geomUnitsPerPoint();1!==a&&i.scale(a,a),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,r),this.pop()}}class ct extends ht{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new L(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return h(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(P(t))this._processPath(t.rings,0);else if(S(t))this._processPath(t.paths,0);else if(y(t)){const e=_t(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,r){if(!t||this._clipCount>0||null==r||r<=0)return;const i=Math.max(.5*this.transformSize(G(r,I.CIMSolidStroke.width)),.5*nt);if(P(t))this._processPath(t.rings,i);else if(S(t))this._processPath(t.paths,i);else if(y(t)){const e=_t(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){P(e)&&t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){const{url:r}=t,i=G(t.scaleX,1);let s=i*e,o=e;const n=this._resourceManager.getResource(r);if(null!=n){const t=n.height/n.width;s=i*(e?t>1?e:e/t:n.width),o=e?t>1?e*t:e:n.height}this._merge(this.transformPt([-s/2,-o/2]),0),this._merge(this.transformPt([-s/2,o/2]),0),this._merge(this.transformPt([s/2,-o/2]),0),this._merge(this.transformPt([s/2,o/2]),0)}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=Pt(t);let[i,s]=this._textRasterizer.computeTextSize(e,r);i=n(i),s=n(s);const o=this.transformSize(1)*this.reverseTransformScalar(1);i*=o,s*=o;let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let l=0;switch(t.verticalAlignment){case"Bottom":l=s/2;break;case"Top":l=-s/2;break;case"Baseline":l=s/6}this._merge(this.transformPt([-i/2+a,-s/2+l]),0),this._merge(this.transformPt([-i/2+a,s/2+l]),0),this._merge(this.transformPt([i/2+a,-s/2+l]),0),this._merge(this.transformPt([i/2+a,s/2+l]),0)}_processPath(t,e){if(t)for(const r of t){const t=r?r.length:0;if(t>1){this._merge(this.transformPt(r[0]),e);for(let i=1;i<t;i++)this._merge(this.transformPt(r[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class mt extends ht{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0,this._textInfo=null,this._svg=null,this._path=null,this._canvas=null}destroy(){this._svg=Y(this._svg),this._path=null,this._canvas=null}hitTest(t,e,r,i,s,a){const l=a*o(1);this.setTransform(),this.setGeomUnitsPerPoint(l),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/l,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type||e.symbolLayers?.some(t=>U(t)));if(this._mapRotation=h?s:0,!has("esri-mobile")){const t=n(tt*window.devicePixelRatio),r=n(et);!(("CIMLineSymbol"===e?.type||"CIMPolygonSymbol"===e?.type)&&e.symbolLayers?.some(A))&&"CIMMeshSymbol"!==e?.type&&(j(e)??0)<r&&(this._searchDistPoint=t)}return this._earlyReturn=!1,this.drawSymbol(e,r),this._earlyReturn}executeEffects(t,e){return"CIMGeometricEffectDashes"===t.at(-1)?.type&&(t=t.slice(0,-1)),super.executeEffects(t,e)}drawSolidFill(t,e,r){null!=r?this._hittestSvgPath(t,r,!0):this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,r,i,s,o,n){null!=n?this._hittestSvgPath(t,n,!1,r):this._hitTestStroke(t,r)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){const{url:r}=t,i=G(t.scaleX,1),s=this._resourceManager.getResource(r);if(null==s||0===s.height||0===e)return;const o=e*this.geomUnitsPerPoint(),n=o*i*(s.width/s.height),a=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(a[0])<n/2+l&&Math.abs(a[1])<o/2+l&&(this._earlyReturn=!0)}drawText(t,e){const r=this._textInfo;if(!r)return;const i=r.get(t);if(!i)return;if(!i.glyphMosaicItems.glyphs.length)return;const s=it(G(t.height,I.CIMTextSymbol.height)),{lineGapType:o,lineGap:n}=t,a=o?yt(o,G(n),s):0,l="CIMBackgroundCallout"===t.callout?.type,h=rt(i.glyphMosaicItems,{scale:s/Z,angle:0,xOffset:0,yOffset:0,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:st(t.lineWidth),lineHeight:Q*Math.max(.25,Math.min(a||1,4)),decoration:t.font.decoration||"none",useCIMAngleBehavior:!0,hasBackground:l}),c=this.reverseTransformPt(this._searchPoint),m=c[0],f=c[1];for(const u of h.glyphs)if(m>u.xTopLeft&&m<u.xBottomRight&&f>-u.yBottomRight&&f<-u.yTopLeft){this._earlyReturn=!0;break}}_hitTestFill(t){let e=null;if(y(t)){const r=t;e=[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}else if(P(t))e=t.rings;else{if(!S(t))return;e=t.paths}const r=this.reverseTransformPt(this._searchPoint);if(dt(r,e)&&(this._earlyReturn=!0),!this._earlyReturn){pt(r,e,this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}_getSvgPath(){return null!=this._svg&&null!=this._path||(this._svg??=$(),this._path??=K("path"),this._svg.appendChild(this._path)),this._path}_getCanvasContext(t,e){return this._canvas??=document.createElement("canvas"),this._canvas.width=t,this._canvas.height=e,this._canvas.getContext("2d",{willReadFrequently:!0})}_hittestSvgPath(t,e,r,i=0){const s=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint(),o=this.reverseTransformPt(this._searchPoint),n=l();g(n,t);const a={x:n[0],y:n[1],width:n[2]-n[0],height:n[3]-n[1]},h=this._getSvgPath();h.setAttribute("d",e);const c=h.getBBox();let m=Math.max(c.width/a.width,c.height/a.height),f=1;const u=2*s*m;u<1&&(f=2/u,m*=f,c.x*=f,c.y*=f,c.width*=f,c.height*=f);const d=1+i*m/2,p=this._getCanvasContext(c.width+2*d,c.height+2*d);p.setTransform(f,0,0,f,-c.x+d,-c.y+d);const _=new Path2D(e);r?p.fill(_):(p.lineWidth=i*(m/f),p.stroke(_));const y=(a.width*m-c.width)/2,P=(a.height*m-c.height)/2,S=Math.floor((o[0]-a.x-s)*m-y+d),w=Math.floor((a.height-(o[1]-a.y)-s)*m+P+d),x=Math.ceil(2*s*m),M=Math.ceil(2*s*m),b=p.getImageData(S,w,x,M).data;for(let l=3;l<b.length;l+=4)if(b[l]>127.5)return void(this._earlyReturn=!0)}_hitTestStroke(t,e){let r=null;if(y(t)){const e=t;r=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(P(t))r=t.rings;else{if(!S(t))return;r=t.paths}pt(this.reverseTransformPt(this._searchPoint),r,G(e,I.CIMSolidStroke.width)*this.geomUnitsPerPoint()/2+this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}class ft extends ht{constructor(t,e,r,i){super(e,r),this._applyAdditionalRenderProps=i,this._colorSubstitutionHelper=new b,this._ctx=t}drawSolidFill(t,e){if(!t)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(_t(t).rings,!0);else{if(!x(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const r=this._ctx;r.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",r.fill("evenodd")}drawSolidStroke(t,e,r,i,s,o){if(!t||!e||0===r)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!1);else{if(!y(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(_t(t).rings,!0)}const n=this._ctx;n.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",n.lineWidth=Math.max(this.transformSize(r),nt),this._setCapStyle(i),this._setJoinStyle(s),n.miterLimit=o,n.stroke()}pushClipPath(t){if(this._ctx.save(),P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else{if(!y(t))return;this._buildPath(_t(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e){const{colorSubstitutions:r,url:i,tintColor:s}=t,o=G(t.scaleX,1),n=this._resourceManager.getResource(i);if(null==n)return;let a=e*(n.width/n.height),l=e;e||(a=n.width,l=n.height);const h=D(i)||"src"in n&&D(n.src);let c="getFrame"in n?T(n):n;r&&(c=this._colorSubstitutionHelper.applyColorSubstitution(c,r)),this._applyAdditionalRenderProps&&!h&&s&&(c=this._colorSubstitutionHelper.tintImageData(c,s));const m=this.transformPt([0,0]),[f,u]=this.getTransformAngle(),d=this.transformSize(1),p=this._ctx;p.save(),p.setTransform({m11:o*d*f,m12:o*d*u,m21:-d*u,m22:d*f,m41:m[0],m42:m[1]}),p.drawImage(c,-a/2,-l/2,a,l),p.restore()}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=Pt(t,this.transformSize(n(1))),i=this._textRasterizer.rasterizeText(e,r);if(!i)return;const{size:s,anchorX:o,anchorY:a,canvas:l}=i,h=s[0]*(o+.5),c=s[1]*(a-.5),m=this._ctx,f=this.transformPt([0,0]),[u,d]=this.getTransformAngle(),p=1;m.save(),m.setTransform({m11:p*u,m12:p*d,m21:-p*d,m22:p*u,m41:f[0]-p*h,m42:f[1]+p*c}),m.drawImage(l,0,0),m.restore()}drawPictureFill(t,e){if(!t)return;let{colorSubstitutions:r,height:i,offsetX:s,offsetY:o,rotation:n,scaleX:a,tintColor:l,url:h}=e;const c=this._resourceManager.getResource(h);if(null==c)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(_t(t).rings,!0);else{if(!x(t))return;console.log("CanvasDrawHelper.drawPictureFill - No implementation!")}const m=this._ctx,f=D(h)||"src"in c&&D(c.src);let u,d="getFrame"in c?T(c):c;if(r&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,r)),this._applyAdditionalRenderProps){f||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)),u=m.createPattern(d,"repeat");const t=this.transformSize(1);n||(n=0),s?s*=t:s=0,o?o*=t:o=0,i&&(i*=t);const e=i?i/c.height:1,r=a&&i?a*i/c.width:1;if(0!==n||1!==e||1!==r||0!==s||0!==o){const t=new DOMMatrix;t.rotateSelf(0,0,-n).translateSelf(s,o).scaleSelf(r,e,1),u.setTransform(t)}}else u=m.createPattern(d,"repeat");m.save(),m.fillStyle=u,m.fill("evenodd"),m.restore()}drawPictureStroke(t,r){if(!t)return;let{colorSubstitutions:i,capStyle:s,joinStyle:n,miterLimit:a,tintColor:l,url:h,width:c}=r;const m=this._resourceManager.getResource(h);if(null==m)return;let f;if(P(t))f=t.rings;else if(S(t))f=t.paths;else{if(!y(t))return x(t)?void console.log("CanvasDrawHelper.drawPictureStroke - No implementation!"):void 0;f=_t(t).rings}c||(c=m.width);const u=D(h)||"src"in m&&D(m.src);let d="getFrame"in m?T(m):m;i&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,i)),this._applyAdditionalRenderProps&&(u||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)));const p=Math.max(this.transformSize(o(c)),.5),g=p/d.width,_=this._ctx,w=_.createPattern(d,"repeat-y");let M,b;_.save(),this._setCapStyle(s),this._setJoinStyle(n),void 0!==a&&(_.miterLimit=a),_.lineWidth=p;for(let o of f)if(o=e(o),wt(o),o&&!(o.length<=1)){M=this.transformPt(o[0]);for(let t=1;t<o.length;t++){b=this.transformPt(o[t]);const e=gt(M,b),r=new DOMMatrix;r.translateSelf(0,M[1]-p/2).scaleSelf(g,g,1).rotateSelf(0,0,90-e),w.setTransform(r),_.strokeStyle=w,_.beginPath(),_.moveTo(M[0],M[1]),_.lineTo(b[0],b[1]),_.stroke(),M=b}}_.restore()}drawGradientFill(t,e){if(!t)return;let r;if(P(t))r=t.rings;else if(S(t))r=t.paths;else{if(!y(t))return void at().error("Unable to draw gradient fill");r=_t(t).rings}this._buildPath(r,!0);const{angle:s,gradientMethod:n,gradientSize:a,gradientSizeUnits:l}=e,h=I.CIMGradientFill,g=e.gradientType??h.gradientType,_=-i(s??0),w=c();for(const i of r){const t=i?i.length:0;if(t>1)for(let e=0;e<t;e++){let t=this.transformPt(i[e]);"Linear"!==n&&"Rectangular"!==n||(t=R(t,-_)),m(w,t)}}const[x,M,b,k]=w,C=this._ctx;switch(C.save(),n){case"Buffered":at().error(`Gradient method "${n}" currently unsupported.`);break;case"Linear":{const t=(M+k)/2,r="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*(b-x),[i,s]="Discrete"===g?[b,b-r]:[x+r,x],n=R([i,t],_),c=R([s,t],_),m=C.createLinearGradient(n[0],n[1],c[0],c[1]);z(m,e),C.fillStyle=m,C.fill("evenodd");break}case"Circular":{const t=f(w),r=p(w)/2,i="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*r,[s,n]="Discrete"===g?[r,r-i]:[i,0],c=C.createRadialGradient(t[0],t[1],s,t[0],t[1],n);z(c,e),C.fillStyle=c,C.fill("evenodd");break}case"Rectangular":{const r=f(w),i=r[0],s=r[1],n=R(r,_),c=(r,i,s,o,a,l,h,c)=>{C.save(),this.pushClipPath(t);const m=R([a,l],_),f=R([h,c],_);C.beginPath(),C.moveTo(n[0],n[1]),C.lineTo(m[0],m[1]),C.lineTo(f[0],f[1]),C.lineTo(n[0],n[1]),C.clip();const u=R([r,i],_),d=R([s,o],_),p=C.createLinearGradient(u[0],u[1],d[0],d[1]);z(p,e),C.fillStyle=p,C.fill("evenodd"),C.restore()};let m="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*(u(w)/2),[p,y]="Discrete"===g?[b,b-m]:[i+m,i];c(p,s,y,s,b,M,b,k),[p,y]="Discrete"===g?[x,x+m]:[i-m,i],c(p,s,y,s,x,k,x,M),m="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*(d(w)/2);let[P,S]="Discrete"===g?[k,k-m]:[s+m,s];c(i,P,i,S,b,k,x,k),[P,S]="Discrete"===g?[M,M+m]:[s-m,s],c(i,P,i,S,x,M,b,M);break}}C.restore()}drawGradientStroke(t,r){const{capStyle:i,gradientMethod:s,gradientSize:n,gradientSizeUnits:a,joinStyle:l,miterLimit:h,width:c}=r;if(!t||0===c)return;let m;if(P(t))m=t.rings;else if(S(t))m=t.paths;else{if(!y(t))return void at().error("Unable to draw gradient stroke");m=_t(t).rings}const f=r.gradientType??I.CIMGradientStroke.gradientType,u=Math.max(this.transformSize(o(c)),.5),d=this._ctx;let p,g;d.save(),this._setCapStyle(i),this._setJoinStyle(l),void 0!==h&&(d.miterLimit=h),d.lineWidth=u;for(let _ of m){if(_=e(_),wt(_),!_||_.length<=1)continue;let t=0;p=this.transformPt(_[0]);for(let e=1;e<_.length;e++){g=this.transformPt(_[e]);const r=g[0]-p[0],i=g[1]-p[1];t+=Math.sqrt(r*r+i*i),p=g}const i="Absolute"===a?this.transformSize(o(n)):H(n,I.CIMGradientStroke.gradientSize)*("AcrossLine"===s?u:t);let l=0;p=this.transformPt(_[0]);for(let e=1;e<_.length;e++){g=this.transformPt(_[e]);const o=g[0]-p[0],n=g[1]-p[1],a=Math.sqrt(o*o+n*n);let h,c,m,y;switch(s){case"AcrossLine":{const[t,e]=R([o/a,n/a],-Math.PI/2),r=u/2,s="Discrete"===f?r:i-r;h=(p[0]+g[0])/2+t*s,c=(p[1]+g[1])/2+e*s,m=h-t*i,y=c-e*i;break}case"AlongLine":{const e=o/a,r=n/a;"Discrete"===f?(h=p[0]-e*l,c=p[1]-r*l,m=h+e*i,y=c+r*i):(m=p[0]+e*(t-l),y=p[1]+r*(t-l),h=m-e*i,c=y-r*i);break}default:return at().error("Unrecognized gradient method:",s),void d.restore()}const P=d.createLinearGradient(h,c,m,y);z(P,r),d.strokeStyle=P,d.beginPath(),d.moveTo(p[0],p[1]),d.lineTo(g[0],g[1]),d.stroke(),l+=a,p=g}}d.restore()}_buildPath(t,e){const r=this._ctx;if(r.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let s=this.transformPt(i[0]);r.moveTo(s[0],s[1]);for(let e=1;e<t;e++)s=this.transformPt(i[e]),r.lineTo(s[0],s[1]);e&&r.closePath()}}}_setCapStyle(t){switch(t){case"Butt":this._ctx.lineCap="butt";break;case"Round":this._ctx.lineCap="round";break;case"Square":this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case"Bevel":this._ctx.lineJoin="bevel";break;case"Round":this._ctx.lineJoin="round";break;case"Miter":this._ctx.lineJoin="miter"}}}function ut(t,e,r){let i=G(t.separation,I.CIMHatchFill.separation)*r,s=G(t.rotation);if(0===i)return null;i<0&&(i=-i);let o=0;const n=.5*i;for(;o>n;)o-=i;for(;o<-n;)o+=i;const a=l();g(a,e),a[0]-=n,a[1]-=n,a[2]+=n,a[3]+=n;const h=[[a[0],a[1]],[a[0],a[3]],[a[2],a[3]],[a[2],a[1]]];for(;s>180;)s-=180;for(;s<0;)s+=180;const c=Math.cos(s*ot),m=Math.sin(s*ot),f=-i*m,u=i*c;let d,p,_,y;o=G(t.offsetX)*r*m-G(t.offsetY)*r*c,d=_=Number.MAX_VALUE,p=y=-Number.MAX_VALUE;for(const l of h){const t=l[0],e=l[1],r=c*t+m*e,i=-m*t+c*e;d=Math.min(d,r),_=Math.min(_,i),p=Math.max(p,r),y=Math.max(y,i)}_=Math.floor(_/i)*i;let P=c*d-m*_-f*o/i,S=m*d+c*_-u*o/i,w=c*p-m*_-f*o/i,x=m*p+c*_-u*o/i;const M=1+Math.round((y-_)/i),b=[];for(let l=0;l<M;l++)P+=f,S+=u,w+=f,x+=u,b.push([[P,S],[w,x]]);return{paths:b}}function dt(t,e){let r=0;for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];if(e[1]>t[1]==o[1]>t[1])continue;(o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0])>0?r++:r--}}return 0!==r}function pt(t,e,r){for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];let n=(o[0]-e[0])*(o[0]-e[0])+(o[1]-e[1])*(o[1]-e[1]);if(0===n)continue;n=Math.sqrt(n);const a=((o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0]))/n;if(Math.abs(a)<r){const i=((o[0]-e[0])*(t[0]-e[0])+(o[1]-e[1])*(t[1]-e[1]))/n;if(i>-r&&i<n+r)return!0}}}return!1}function gt(t,e){const r=e[0]-t[0],i=e[1]-t[1];return 180/Math.PI*Math.atan2(i,r)}const _t=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,yt=(t,e,r)=>{switch(t){case"ExtraLeading":return 1+e/r;case"Multiple":return e;case"Exact":return e/r}};function Pt(e,r=1){const i=B(e),s=E(e.fontStyleName),o=e.fontFamilyName??t,{weight:n,style:a}=s,l=r*(e.height||5),h=X(e.horizontalAlignment),c=J(e.verticalAlignment),m=N(e),f=N(e.haloSymbol),u=null!=f?r*(e.haloSize??0):0,d=O(e.symbol),p=r*(q(e.symbol)||0),g="CIMBackgroundCallout"===e.callout?.type?e.callout.backgroundSymbol:null,_=N(g),y=q(g),P=O(g);return{color:m,size:l,horizontalAlignment:h,verticalAlignment:c,font:{family:o,style:W(a),weight:V(n),decoration:i},outline:{size:p||0,color:d},halo:{size:u||0,color:f,style:a},backgroundColor:_,borderLine:null!=y&&null!=P?{size:y,color:P}:null,pixelRatio:1,premultiplyColors:!0}}const St=1e-4;function wt(t){let e,r,i,s,o,n=t[0],a=1;for(;a<t.length;)e=t[a][0]-n[0],r=t[a][1]-n[1],s=0!==e?r/e:Math.PI/2,void 0!==i&&Math.abs(s-i)<=St?(t.splice(a-1,1),n=o):(o=n,n=t[a],a++),i=s}export{ht as CIMSymbolDrawHelper,ft as CanvasDrawHelper,ct as EnvDrawHelper,mt as HittestDrawHelper,lt as Transformation,ot as cDegToRad,yt as lineGapType2LineHeight};
2
+ import{defaultFontFamily as t}from"../../core/fontUtils.js";import has from"../../core/has.js";import{clone as e}from"../../core/lang.js";import r from"../../core/Logger.js";import{deg2rad as i}from"../../core/mathUtils.js";import s from"../../core/ObjectPool.js";import{pt2px as o,px2pt as n}from"../../core/screenUtils.js";import{GeometryCursor as a}from"../../geometry/GeometryCursor.js";import{create as l,fromValues as h,empty as c,expandPointInPlace as m,center as f,width as u,height as d,diagonal as p}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as g}from"../../geometry/support/boundsUtils.js";import{polygonCentroid as _}from"../../geometry/support/centroid.js";import{isExtent as y,isPolygon as P,isPolyline as S,isPoint as w,isMultipoint as x}from"../../geometry/support/jsonTypeUtils.js";import{SimpleEffectCursor as M}from"./CIMEffects.js";import b from"./CIMImageColorSubstitutionHelper.js";import{getEffectOperator as k,getPlacementOperator as C}from"./CIMOperators.js";import{Placement as v}from"./CIMPlacements.js";import{defaultCIMValues as I}from"./defaultCIMValues.js";import{getFirstFrame as T}from"./imageUtils.js";import{rotate as R}from"./mathUtils.js";import{addColorStops as z}from"./rasterizingUtils.js";import L from"./Rect.js";import F from"./TextRasterizer.js";import{isMarkerScreenAligned as U,isCIMFill as A,getSize as j,getNumericValue as G,isSVGImage as D,getRelativeGradientSize as H,fromCIMFontDecoration as B,fromCIMFontStyle as E,fromCIMHorizontalAlignment as X,fromCIMVerticalAlignment as J,getFillColor as N,getStrokeColor as O,getStrokeWidth as q,getFontWeight as V,getFontStyle as W}from"./utils.js";import{destroyHiddenSvg as Y,createHiddenSvg as $,createSvgElement as K}from"../../views/2d/engine/svgUtils.js";import{magicLabelLineHeight as Q,glyphSize as Z,hittestToleranceSmallSymbol as tt,hittestSmallSymbolThreshold as et}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as rt}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as it,getLineWidth as st}from"../../views/2d/layers/graphics/graphicsUtils.js";const ot=Math.PI/180,nt=.5,at=()=>r.getLogger("esri.symbols.cim.CIMSymbolDrawHelper");class lt{constructor(t){this._t=t}static createIdentity(){return new lt([1,0,0,0,1,0])}clone(){const t=this._t;return new lt(t.slice())}transform(t){const e=this._t;return[e[0]*t[0]+e[1]*t[1]+e[2],e[3]*t[0]+e[4]*t[1]+e[5]]}static createScale(t,e){return new lt([t,0,0,0,e,0])}scale(t,e){const r=this._t;return r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=e,r[4]*=e,r[5]*=e,this}scaleRatio(){return Math.sqrt(this._t[0]*this._t[0]+this._t[1]*this._t[1])}static createTranslate(t,e){return new lt([0,0,t,0,0,e])}translate(t,e){const r=this._t;return r[2]+=t,r[5]+=e,this}static createRotate(t){const e=Math.cos(t),r=Math.sin(t);return new lt([e,-r,0,r,e,0])}rotate(t){return lt.multiply(this,lt.createRotate(t),this)}angle(){const t=this._t[0],e=this._t[3],r=Math.sqrt(t*t+e*e);return[t/r,e/r]}static multiply(t,e,r){const i=t._t,s=e._t,o=i[0]*s[0]+i[3]*s[1],n=i[1]*s[0]+i[4]*s[1],a=i[2]*s[0]+i[5]*s[1]+s[2],l=i[0]*s[3]+i[3]*s[4],h=i[1]*s[3]+i[4]*s[4],c=i[2]*s[3]+i[5]*s[4]+s[5],m=r._t;return m[0]=o,m[1]=n,m[2]=a,m[3]=l,m[4]=h,m[5]=c,r}invert(){const t=this._t;let e=t[0]*t[4]-t[1]*t[3];if(0===e)return new lt([0,0,0,0,0,0]);e=1/e;const r=(t[1]*t[5]-t[2]*t[4])*e,i=(t[2]*t[3]-t[0]*t[5])*e,s=t[4]*e,o=-t[1]*e,n=-t[3]*e,a=t[0]*e;return new lt([s,o,r,n,a,i])}}class ht{constructor(t,e){this._resourceManager=t,this._transfos=[],this._sizeTransfos=[],this._geomUnitsPerPoint=1,this._placementPool=new s(()=>new v,void 0,void 0,100),this._earlyReturn=!1,this._mapRotation=0,this._transfos.push(e||lt.createIdentity()),this._sizeTransfos.push(e?e.scaleRatio():1)}setTransform(t,e){this._transfos=[t||lt.createIdentity()],this._sizeTransfos=[e||(t?t.scaleRatio():1)]}setGeomUnitsPerPoint(t){this._geomUnitsPerPoint=t}transformPt(t){return this._transfos[this._transfos.length-1].transform(t)}transformSize(t){return t*this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformPt(t){return this._transfos[this._transfos.length-1].invert().transform(t)}reverseTransformSize(t){return t/this._sizeTransfos[this._sizeTransfos.length-1]}reverseTransformScalar(t){return t/this._transfos[this._transfos.length-1].scaleRatio()}getTransformAngle(){return this._transfos[this._transfos.length-1].angle()}geomUnitsPerPoint(){return this.isEmbedded()?1:this._geomUnitsPerPoint}prevGeomUnitsPerPoint(){return this._transfos.length>2?1:this._geomUnitsPerPoint}isEmbedded(){return this._transfos.length>1}back(){return this._transfos[this._transfos.length-1]}push(t,e){const r=e?t.scaleRatio():1;lt.multiply(t,this.back(),t),this._transfos.push(t),this._sizeTransfos.push(this._sizeTransfos[this._sizeTransfos.length-1]*r)}pop(){this._transfos.splice(-1,1),this._sizeTransfos.splice(-1,1)}drawSymbol(t,e,r){if(t)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this.drawMultiLayerSymbol(t,e);break;case"CIMTextSymbol":this.drawTextSymbol(t,e,r)}}drawMultiLayerSymbol(t,e){if(!t||!e)return;const r=t.symbolLayers;if(!r)return;const i=t.effects;if(i&&i.length>0){const t=this.executeEffects(i,e);if(t){let e=t.next();for(;e;)this.drawSymbolLayers(r,e.asJSON()),e=t.next()}}else this.drawSymbolLayers(r,e)}executeEffects(t,e){let r=new M(a.fromJSONCIM(e));for(const i of t){const t=k(i);t&&(r=t.execute(r,i,this.geomUnitsPerPoint(),null))}return r}drawSymbolLayers(t,e){let r=t.length;for(;r--;){const i=t[r];if(!i||!1===i.enable)continue;const s=i.effects;if(s&&s.length>0){const t=this.executeEffects(s,e);if(t){let e=null;for(;(e=t.next())&&(this.drawSymbolLayer(i,e.asJSON()),!this._earlyReturn););}}else this.drawSymbolLayer(i,e);if(this._earlyReturn)return}}drawSymbolLayer(t,e){switch(t.type){case"CIMSolidFill":this.drawSolidFill(e,t.color,t.path);break;case"CIMHatchFill":this.drawHatchFill(e,t);break;case"CIMPictureFill":this.drawPictureFill(e,t);break;case"CIMGradientFill":this.drawGradientFill(e,t);break;case"CIMSolidStroke":this.drawSolidStroke(e,t.color,t.width,t.capStyle,t.joinStyle,t.miterLimit,t.path);break;case"CIMPictureStroke":this.drawPictureStroke(e,t);break;case"CIMGradientStroke":this.drawGradientStroke(e,t);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":this.drawMarkerLayer(t,e)}}drawHatchFill(t,e){const r=ut(e,t,this.geomUnitsPerPoint());r&&(this.pushClipPath(t),this.drawMultiLayerSymbol(e.lineSymbol,r),this.popClipPath())}drawPictureFill(t,e){}drawGradientFill(t,e){}drawPictureStroke(t,e){}drawGradientStroke(t,e){}drawMarkerLayer(t,e){const r=t.markerPlacement;if(r){const i=C(r);if(i){const s="CIMMarkerPlacementInsidePolygon"===r.type||"CIMMarkerPlacementPolygonCenter"===r.type&&r.clipAtBoundary;s&&this.pushClipPath(e);const o=i.execute(a.fromJSONCIM(e),r,this.geomUnitsPerPoint(),null);if(o){let e=null;for(;(e=o.next())&&(this.drawMarker(t,e),!this._earlyReturn););}s&&this.popClipPath()}}else{const r=this._placementPool.acquire();if(w(e))r.tx=e.x,r.ty=e.y,this.drawMarker(t,r);else if(P(e)){const i=_(e);i&&([r.tx,r.ty]=i,this.drawMarker(t,r))}else if(S(e)){for(const i of e.paths)for(const e of i)if(r.tx=e[0],r.ty=e[1],this.drawMarker(t,r),this._earlyReturn)break}else for(const i of e.points)if(r.tx=i[0],r.ty=i[1],this.drawMarker(t,r),this._earlyReturn)break;this._placementPool.release(r)}}drawMarker(t,e){switch(t.type){case"CIMCharacterMarker":case"CIMPictureMarker":this.drawPictureMarker(t,e);break;case"CIMVectorMarker":this.drawVectorMarker(t,e)}}drawPictureMarker(t,e){if(!t)return;const r=this._resourceManager.getResource(t.url),i=G(t.size,I.CIMPictureMarker.size);if(null==r||i<=0)return;const s=r.width,o=r.height;if(!s||!o)return;const n=s/o,a=G(t.scaleX,1),l=lt.createIdentity(),h=t.anchorPoint;if(h){let e=h.x,r=h.y;"Absolute"!==t.anchorPointUnits&&(e*=i*n*a,r*=i),l.translate(-e,-r)}let c=G(t.rotation);t.rotateClockwise&&(c=-c),this._mapRotation&&(c+=this._mapRotation),c&&l.rotate(c*ot);let m=G(t.offsetX),f=G(t.offsetY);if(m||f){if(this._mapRotation){const t=ot*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=m*r+f*e;m=m*e-f*r,f=i}l.translate(m,f)}const u=this.geomUnitsPerPoint();1!==u&&l.scale(u,u);const d=e.getAngle();d&&l.rotate(d),l.translate(e.tx,e.ty),this.push(l,!1),this.drawImage(t,i),this.pop()}drawVectorMarker(t,e){if(!t)return;const r=t.markerGraphics;if(!r)return;const i=G(t.size,I.CIMVectorMarker.size),s=t.frame,o=s?s.ymax-s.ymin:0,n=i&&o?i/o:1,a=lt.createIdentity();s&&a.translate(.5*-(s.xmax+s.xmin),.5*-(s.ymax+s.ymin));const l=t.anchorPoint;if(l){let e=l.x,r=l.y;"Absolute"!==t.anchorPointUnits?s&&(e*=s.xmax-s.xmin,r*=s.ymax-s.ymin):(e/=n,r/=n),a.translate(-e,-r)}1!==n&&a.scale(n,n);let h=G(t.rotation);t.rotateClockwise&&(h=-h),this._mapRotation&&(h+=this._mapRotation),h&&a.rotate(h*ot);let c=G(t.offsetX),m=G(t.offsetY);if(c||m){if(this._mapRotation){const t=ot*this._mapRotation,e=Math.cos(t),r=Math.sin(t),i=c*r+m*e;c=c*e-m*r,m=i}a.translate(c,m)}const f=this.geomUnitsPerPoint();1!==f&&a.scale(f,f);const u=e.getAngle();u&&a.rotate(u),a.translate(e.tx,e.ty),this.push(a,t.scaleSymbolsProportionally);for(const d of r){d?.symbol&&d.geometry||at().error("Invalid marker graphic",d);let t=d.textString;if("number"==typeof t&&(t=t.toString()),this.drawSymbol(d.symbol,d.geometry,t),this._earlyReturn)break}this.pop()}drawTextSymbol(t,e,r){if(!t)return;if(!w(e))return;if(G(t.height,I.CIMTextSymbol.height)<=0)return;const i=lt.createIdentity();let s=G(t.angle);s=-s,s&&i.rotate(s*ot);const o=G(t.offsetX),n=G(t.offsetY);(o||n)&&i.translate(o,n);const a=this.geomUnitsPerPoint();1!==a&&i.scale(a,a),i.translate(e.x,e.y),this.push(i,!1),this.drawText(t,r),this.pop()}}class ct extends ht{constructor(t,e){super(t,e),this.reset()}reset(){this._xmin=this._ymin=1/0,this._xmax=this._ymax=-1/0,this._clipCount=0}envelope(){return new L(this._xmin,this._ymin,this._xmax-this._xmin,this._ymax-this._ymin)}bounds(){return h(this._xmin,this._ymin,this._xmax,this._ymax)}drawSolidFill(t){if(t&&!(this._clipCount>0))if(P(t))this._processPath(t.rings,0);else if(S(t))this._processPath(t.paths,0);else if(y(t)){const e=_t(t);e&&this._processPath(e.rings,0)}else console.error("drawSolidFill Unexpected geometry type!")}drawSolidStroke(t,e,r){if(!t||this._clipCount>0||null==r||r<=0)return;const i=Math.max(.5*this.transformSize(G(r,I.CIMSolidStroke.width)),.5*nt);if(P(t))this._processPath(t.rings,i);else if(S(t))this._processPath(t.paths,i);else if(y(t)){const e=_t(t);e&&this._processPath(e.rings,i)}else console.error("drawSolidStroke unexpected geometry type!")}drawMarkerLayer(t,e){P(e)&&t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._processPath(e.rings,0):super.drawMarkerLayer(t,e)}drawHatchFill(t,e){this.drawSolidFill(t)}drawPictureFill(t,e){this.drawSolidFill(t)}drawGradientFill(t,e){this.drawSolidFill(t)}drawPictureStroke(t,e){this.drawSolidStroke(t,null,e.width)}drawGradientStroke(t,e){this.drawSolidStroke(t,null,e.width)}pushClipPath(t){this.drawSolidFill(t),this._clipCount++}popClipPath(){this._clipCount--}drawImage(t,e){const{url:r}=t,i=G(t.scaleX,1);let s=i*e,o=e;const n=this._resourceManager.getResource(r);if(null!=n){const t=n.height/n.width;s=i*(e?t>1?e:e/t:n.width),o=e?t>1?e*t:e:n.height}this._merge(this.transformPt([-s/2,-o/2]),0),this._merge(this.transformPt([-s/2,o/2]),0),this._merge(this.transformPt([s/2,-o/2]),0),this._merge(this.transformPt([s/2,o/2]),0)}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=Pt(t);let[i,s]=this._textRasterizer.computeTextSize(e,r);i=n(i),s=n(s);const o=this.transformSize(1)*this.reverseTransformScalar(1);i*=o,s*=o;let a=0;switch(t.horizontalAlignment){case"Left":a=i/2;break;case"Right":a=-i/2}let l=0;switch(t.verticalAlignment){case"Bottom":l=s/2;break;case"Top":l=-s/2;break;case"Baseline":l=s/6}this._merge(this.transformPt([-i/2+a,-s/2+l]),0),this._merge(this.transformPt([-i/2+a,s/2+l]),0),this._merge(this.transformPt([i/2+a,-s/2+l]),0),this._merge(this.transformPt([i/2+a,s/2+l]),0)}_processPath(t,e){if(t)for(const r of t){const t=r?r.length:0;if(t>1){this._merge(this.transformPt(r[0]),e);for(let i=1;i<t;i++)this._merge(this.transformPt(r[i]),e)}}}_merge(t,e){t[0]-e<this._xmin&&(this._xmin=t[0]-e),t[0]+e>this._xmax&&(this._xmax=t[0]+e),t[1]-e<this._ymin&&(this._ymin=t[1]-e),t[1]+e>this._ymax&&(this._ymax=t[1]+e)}}class mt extends ht{constructor(){super(...arguments),this._searchPoint=[0,0],this._searchDistPoint=0,this._textInfo=null,this._svg=null,this._path=null,this._canvas=null}destroy(){this._svg=Y(this._svg),this._path=null,this._canvas=null}hitTest(t,e,r,i,s,a){const l=a*o(1);this.setTransform(),this.setGeomUnitsPerPoint(l),this._searchPoint=[(t[0]+t[2])/2,(t[1]+t[3])/2],this._searchDistPoint=(t[2]-t[0])/2/l,this._textInfo=i;const h=e&&("CIMPointSymbol"===e.type&&"Map"!==e.angleAlignment||"CIMTextSymbol"===e.type||e.symbolLayers?.some(t=>U(t)));if(this._mapRotation=h?s:0,!has("esri-mobile")){const t=n(tt*window.devicePixelRatio),r=n(et);!(("CIMLineSymbol"===e?.type||"CIMPolygonSymbol"===e?.type)&&e.symbolLayers?.some(A))&&"CIMMeshSymbol"!==e?.type&&(j(e)??0)<r&&(this._searchDistPoint=t)}return this._earlyReturn=!1,this.drawSymbol(e,r),this._earlyReturn}executeEffects(t,e){return"CIMGeometricEffectDashes"===t.at(-1)?.type&&(t=t.slice(0,-1)),super.executeEffects(t,e)}drawSolidFill(t,e,r){null!=r?this._hittestSvgPath(t,r,!0):this._hitTestFill(t)}drawHatchFill(t,e){this._hitTestFill(t)}drawPictureFill(t,e){this._hitTestFill(t)}drawGradientFill(t,e){this._hitTestFill(t)}drawSolidStroke(t,e,r,i,s,o,n){null!=n?this._hittestSvgPath(t,n,!1,r):this._hitTestStroke(t,r)}drawPictureStroke(t,e){this._hitTestStroke(t,e.width)}drawGradientStroke(t,e){this._hitTestStroke(t,e.width)}drawMarkerLayer(t,e){t.markerPlacement&&("CIMMarkerPlacementInsidePolygon"===t.markerPlacement.type||"CIMMarkerPlacementPolygonCenter"===t.markerPlacement.type&&t.markerPlacement.clipAtBoundary)?this._hitTestFill(e):super.drawMarkerLayer(t,e)}pushClipPath(t){}popClipPath(){}drawImage(t,e){const{url:r}=t,i=G(t.scaleX,1),s=this._resourceManager.getResource(r);if(null==s||0===s.height||0===e)return;const o=e*this.geomUnitsPerPoint(),n=o*i*(s.width/s.height),a=this.reverseTransformPt(this._searchPoint),l=this._searchDistPoint;Math.abs(a[0])<n/2+l&&Math.abs(a[1])<o/2+l&&(this._earlyReturn=!0)}drawText(t,e){const r=this._textInfo;if(!r)return;const i=r.get(t);if(!i)return;if(!i.glyphMosaicItems.glyphs.length)return;const s=it(G(t.height,I.CIMTextSymbol.height)),{lineGapType:o,lineGap:n}=t,a=o?yt(o,G(n),s):0,l="CIMBackgroundCallout"===t.callout?.type,h=rt(i.glyphMosaicItems,{scale:s/Z,angle:0,xOffset:0,yOffset:0,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:st(t.lineWidth),lineHeight:Q*Math.max(.25,Math.min(a||1,4)),decoration:t.font.decoration||"none",useCIMAngleBehavior:!0,hasBackground:l}),c=this.reverseTransformPt(this._searchPoint),m=c[0],f=c[1];for(const u of h.glyphs){const[t,e]=u.offsets.topLeft,[r,i]=u.offsets.bottomRight;if(m>t&&m<r&&f>-i&&f<-e){this._earlyReturn=!0;break}}}_hitTestFill(t){let e=null;if(y(t)){const r=t;e=[[[r.xmin,r.ymin],[r.xmin,r.ymax],[r.xmax,r.ymax],[r.xmax,r.ymin],[r.xmin,r.ymin]]]}else if(P(t))e=t.rings;else{if(!S(t))return;e=t.paths}const r=this.reverseTransformPt(this._searchPoint);if(dt(r,e)&&(this._earlyReturn=!0),!this._earlyReturn){pt(r,e,this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}_getSvgPath(){return null!=this._svg&&null!=this._path||(this._svg??=$(),this._path??=K("path"),this._svg.appendChild(this._path)),this._path}_getCanvasContext(t,e){return this._canvas??=document.createElement("canvas"),this._canvas.width=t,this._canvas.height=e,this._canvas.getContext("2d",{willReadFrequently:!0})}_hittestSvgPath(t,e,r,i=0){const s=this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint(),o=this.reverseTransformPt(this._searchPoint),n=l();g(n,t);const a={x:n[0],y:n[1],width:n[2]-n[0],height:n[3]-n[1]},h=this._getSvgPath();h.setAttribute("d",e);const c=h.getBBox();let m=Math.max(c.width/a.width,c.height/a.height),f=1;const u=2*s*m;u<1&&(f=2/u,m*=f,c.x*=f,c.y*=f,c.width*=f,c.height*=f);const d=1+i*m/2,p=this._getCanvasContext(c.width+2*d,c.height+2*d);p.setTransform(f,0,0,f,-c.x+d,-c.y+d);const _=new Path2D(e);r?p.fill(_):(p.lineWidth=i*(m/f),p.stroke(_));const y=(a.width*m-c.width)/2,P=(a.height*m-c.height)/2,S=Math.floor((o[0]-a.x-s)*m-y+d),w=Math.floor((a.height-(o[1]-a.y)-s)*m+P+d),x=Math.ceil(2*s*m),M=Math.ceil(2*s*m),b=p.getImageData(S,w,x,M).data;for(let l=3;l<b.length;l+=4)if(b[l]>127.5)return void(this._earlyReturn=!0)}_hitTestStroke(t,e){let r=null;if(y(t)){const e=t;r=[[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]}else if(P(t))r=t.rings;else{if(!S(t))return;r=t.paths}pt(this.reverseTransformPt(this._searchPoint),r,G(e,I.CIMSolidStroke.width)*this.geomUnitsPerPoint()/2+this.reverseTransformScalar(this._searchDistPoint)*this.prevGeomUnitsPerPoint())&&(this._earlyReturn=!0)}}class ft extends ht{constructor(t,e,r,i){super(e,r),this._applyAdditionalRenderProps=i,this._colorSubstitutionHelper=new b,this._ctx=t}drawSolidFill(t,e){if(!t)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(_t(t).rings,!0);else{if(!x(t))return;console.log("CanvasDrawHelper.drawSolidFill - No implementation!")}const r=this._ctx;r.fillStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",r.fill("evenodd")}drawSolidStroke(t,e,r,i,s,o){if(!t||!e||0===r)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!1);else{if(!y(t))return void console.log("CanvasDrawHelper.drawSolidStroke isn't implemented!");this._buildPath(_t(t).rings,!0)}const n=this._ctx;n.strokeStyle="string"==typeof e?e:"rgba("+Math.round(e[0])+","+Math.round(e[1])+","+Math.round(e[2])+","+(e[3]??255)/255+")",n.lineWidth=Math.max(this.transformSize(r),nt),this._setCapStyle(i),this._setJoinStyle(s),n.miterLimit=o,n.stroke()}pushClipPath(t){if(this._ctx.save(),P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else{if(!y(t))return;this._buildPath(_t(t).rings,!0)}this._ctx.clip("evenodd")}popClipPath(){this._ctx.restore()}drawImage(t,e){const{colorSubstitutions:r,url:i,tintColor:s}=t,o=G(t.scaleX,1),n=this._resourceManager.getResource(i);if(null==n)return;let a=e*(n.width/n.height),l=e;e||(a=n.width,l=n.height);const h=D(i)||"src"in n&&D(n.src);let c="getFrame"in n?T(n):n;r&&(c=this._colorSubstitutionHelper.applyColorSubstitution(c,r)),this._applyAdditionalRenderProps&&!h&&s&&(c=this._colorSubstitutionHelper.tintImageData(c,s));const m=this.transformPt([0,0]),[f,u]=this.getTransformAngle(),d=this.transformSize(1),p=this._ctx;p.save(),p.setTransform({m11:o*d*f,m12:o*d*u,m21:-d*u,m22:d*f,m41:m[0],m42:m[1]}),p.drawImage(c,-a/2,-l/2,a,l),p.restore()}drawText(t,e){if(!e||0===e.length)return;this._textRasterizer||(this._textRasterizer=new F);const r=Pt(t,this.transformSize(n(1))),i=this._textRasterizer.rasterizeText(e,r);if(!i)return;const{size:s,anchorX:o,anchorY:a,canvas:l}=i,h=s[0]*(o+.5),c=s[1]*(a-.5),m=this._ctx,f=this.transformPt([0,0]),[u,d]=this.getTransformAngle(),p=1;m.save(),m.setTransform({m11:p*u,m12:p*d,m21:-p*d,m22:p*u,m41:f[0]-p*h,m42:f[1]+p*c}),m.drawImage(l,0,0),m.restore()}drawPictureFill(t,e){if(!t)return;let{colorSubstitutions:r,height:i,offsetX:s,offsetY:o,rotation:n,scaleX:a,tintColor:l,url:h}=e;const c=this._resourceManager.getResource(h);if(null==c)return;if(P(t))this._buildPath(t.rings,!0);else if(S(t))this._buildPath(t.paths,!0);else if(y(t))this._buildPath(_t(t).rings,!0);else{if(!x(t))return;console.log("CanvasDrawHelper.drawPictureFill - No implementation!")}const m=this._ctx,f=D(h)||"src"in c&&D(c.src);let u,d="getFrame"in c?T(c):c;if(r&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,r)),this._applyAdditionalRenderProps){f||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)),u=m.createPattern(d,"repeat");const t=this.transformSize(1);n||(n=0),s?s*=t:s=0,o?o*=t:o=0,i&&(i*=t);const e=i?i/c.height:1,r=a&&i?a*i/c.width:1;if(0!==n||1!==e||1!==r||0!==s||0!==o){const t=new DOMMatrix;t.rotateSelf(0,0,-n).translateSelf(s,o).scaleSelf(r,e,1),u.setTransform(t)}}else u=m.createPattern(d,"repeat");m.save(),m.fillStyle=u,m.fill("evenodd"),m.restore()}drawPictureStroke(t,r){if(!t)return;let{colorSubstitutions:i,capStyle:s,joinStyle:n,miterLimit:a,tintColor:l,url:h,width:c}=r;const m=this._resourceManager.getResource(h);if(null==m)return;let f;if(P(t))f=t.rings;else if(S(t))f=t.paths;else{if(!y(t))return x(t)?void console.log("CanvasDrawHelper.drawPictureStroke - No implementation!"):void 0;f=_t(t).rings}c||(c=m.width);const u=D(h)||"src"in m&&D(m.src);let d="getFrame"in m?T(m):m;i&&(d=this._colorSubstitutionHelper.applyColorSubstitution(d,i)),this._applyAdditionalRenderProps&&(u||l&&(d=this._colorSubstitutionHelper.tintImageData(d,l)));const p=Math.max(this.transformSize(o(c)),.5),g=p/d.width,_=this._ctx,w=_.createPattern(d,"repeat-y");let M,b;_.save(),this._setCapStyle(s),this._setJoinStyle(n),void 0!==a&&(_.miterLimit=a),_.lineWidth=p;for(let o of f)if(o=e(o),wt(o),o&&!(o.length<=1)){M=this.transformPt(o[0]);for(let t=1;t<o.length;t++){b=this.transformPt(o[t]);const e=gt(M,b),r=new DOMMatrix;r.translateSelf(0,M[1]-p/2).scaleSelf(g,g,1).rotateSelf(0,0,90-e),w.setTransform(r),_.strokeStyle=w,_.beginPath(),_.moveTo(M[0],M[1]),_.lineTo(b[0],b[1]),_.stroke(),M=b}}_.restore()}drawGradientFill(t,e){if(!t)return;let r;if(P(t))r=t.rings;else if(S(t))r=t.paths;else{if(!y(t))return void at().error("Unable to draw gradient fill");r=_t(t).rings}this._buildPath(r,!0);const{angle:s,gradientMethod:n,gradientSize:a,gradientSizeUnits:l}=e,h=I.CIMGradientFill,g=e.gradientType??h.gradientType,_=-i(s??0),w=c();for(const i of r){const t=i?i.length:0;if(t>1)for(let e=0;e<t;e++){let t=this.transformPt(i[e]);"Linear"!==n&&"Rectangular"!==n||(t=R(t,-_)),m(w,t)}}const[x,M,b,k]=w,C=this._ctx;switch(C.save(),n){case"Buffered":at().error(`Gradient method "${n}" currently unsupported.`);break;case"Linear":{const t=(M+k)/2,r="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*(b-x),[i,s]="Discrete"===g?[b,b-r]:[x+r,x],n=R([i,t],_),c=R([s,t],_),m=C.createLinearGradient(n[0],n[1],c[0],c[1]);z(m,e),C.fillStyle=m,C.fill("evenodd");break}case"Circular":{const t=f(w),r=p(w)/2,i="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*r,[s,n]="Discrete"===g?[r,r-i]:[i,0],c=C.createRadialGradient(t[0],t[1],s,t[0],t[1],n);z(c,e),C.fillStyle=c,C.fill("evenodd");break}case"Rectangular":{const r=f(w),i=r[0],s=r[1],n=R(r,_),c=(r,i,s,o,a,l,h,c)=>{C.save(),this.pushClipPath(t);const m=R([a,l],_),f=R([h,c],_);C.beginPath(),C.moveTo(n[0],n[1]),C.lineTo(m[0],m[1]),C.lineTo(f[0],f[1]),C.lineTo(n[0],n[1]),C.clip();const u=R([r,i],_),d=R([s,o],_),p=C.createLinearGradient(u[0],u[1],d[0],d[1]);z(p,e),C.fillStyle=p,C.fill("evenodd"),C.restore()};let m="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*(u(w)/2),[p,y]="Discrete"===g?[b,b-m]:[i+m,i];c(p,s,y,s,b,M,b,k),[p,y]="Discrete"===g?[x,x+m]:[i-m,i],c(p,s,y,s,x,k,x,M),m="Absolute"===l?this.transformSize(o(a)):H(a,h.gradientSize)*(d(w)/2);let[P,S]="Discrete"===g?[k,k-m]:[s+m,s];c(i,P,i,S,b,k,x,k),[P,S]="Discrete"===g?[M,M+m]:[s-m,s],c(i,P,i,S,x,M,b,M);break}}C.restore()}drawGradientStroke(t,r){const{capStyle:i,gradientMethod:s,gradientSize:n,gradientSizeUnits:a,joinStyle:l,miterLimit:h,width:c}=r;if(!t||0===c)return;let m;if(P(t))m=t.rings;else if(S(t))m=t.paths;else{if(!y(t))return void at().error("Unable to draw gradient stroke");m=_t(t).rings}const f=r.gradientType??I.CIMGradientStroke.gradientType,u=Math.max(this.transformSize(o(c)),.5),d=this._ctx;let p,g;d.save(),this._setCapStyle(i),this._setJoinStyle(l),void 0!==h&&(d.miterLimit=h),d.lineWidth=u;for(let _ of m){if(_=e(_),wt(_),!_||_.length<=1)continue;let t=0;p=this.transformPt(_[0]);for(let e=1;e<_.length;e++){g=this.transformPt(_[e]);const r=g[0]-p[0],i=g[1]-p[1];t+=Math.sqrt(r*r+i*i),p=g}const i="Absolute"===a?this.transformSize(o(n)):H(n,I.CIMGradientStroke.gradientSize)*("AcrossLine"===s?u:t);let l=0;p=this.transformPt(_[0]);for(let e=1;e<_.length;e++){g=this.transformPt(_[e]);const o=g[0]-p[0],n=g[1]-p[1],a=Math.sqrt(o*o+n*n);let h,c,m,y;switch(s){case"AcrossLine":{const[t,e]=R([o/a,n/a],-Math.PI/2),r=u/2,s="Discrete"===f?r:i-r;h=(p[0]+g[0])/2+t*s,c=(p[1]+g[1])/2+e*s,m=h-t*i,y=c-e*i;break}case"AlongLine":{const e=o/a,r=n/a;"Discrete"===f?(h=p[0]-e*l,c=p[1]-r*l,m=h+e*i,y=c+r*i):(m=p[0]+e*(t-l),y=p[1]+r*(t-l),h=m-e*i,c=y-r*i);break}default:return at().error("Unrecognized gradient method:",s),void d.restore()}const P=d.createLinearGradient(h,c,m,y);z(P,r),d.strokeStyle=P,d.beginPath(),d.moveTo(p[0],p[1]),d.lineTo(g[0],g[1]),d.stroke(),l+=a,p=g}}d.restore()}_buildPath(t,e){const r=this._ctx;if(r.beginPath(),t)for(const i of t){const t=i?i.length:0;if(t>1){let s=this.transformPt(i[0]);r.moveTo(s[0],s[1]);for(let e=1;e<t;e++)s=this.transformPt(i[e]),r.lineTo(s[0],s[1]);e&&r.closePath()}}}_setCapStyle(t){switch(t){case"Butt":this._ctx.lineCap="butt";break;case"Round":this._ctx.lineCap="round";break;case"Square":this._ctx.lineCap="square"}}_setJoinStyle(t){switch(t){case"Bevel":this._ctx.lineJoin="bevel";break;case"Round":this._ctx.lineJoin="round";break;case"Miter":this._ctx.lineJoin="miter"}}}function ut(t,e,r){let i=G(t.separation,I.CIMHatchFill.separation)*r,s=G(t.rotation);if(0===i)return null;i<0&&(i=-i);let o=0;const n=.5*i;for(;o>n;)o-=i;for(;o<-n;)o+=i;const a=l();g(a,e),a[0]-=n,a[1]-=n,a[2]+=n,a[3]+=n;const h=[[a[0],a[1]],[a[0],a[3]],[a[2],a[3]],[a[2],a[1]]];for(;s>180;)s-=180;for(;s<0;)s+=180;const c=Math.cos(s*ot),m=Math.sin(s*ot),f=-i*m,u=i*c;let d,p,_,y;o=G(t.offsetX)*r*m-G(t.offsetY)*r*c,d=_=Number.MAX_VALUE,p=y=-Number.MAX_VALUE;for(const l of h){const t=l[0],e=l[1],r=c*t+m*e,i=-m*t+c*e;d=Math.min(d,r),_=Math.min(_,i),p=Math.max(p,r),y=Math.max(y,i)}_=Math.floor(_/i)*i;let P=c*d-m*_-f*o/i,S=m*d+c*_-u*o/i,w=c*p-m*_-f*o/i,x=m*p+c*_-u*o/i;const M=1+Math.round((y-_)/i),b=[];for(let l=0;l<M;l++)P+=f,S+=u,w+=f,x+=u,b.push([[P,S],[w,x]]);return{paths:b}}function dt(t,e){let r=0;for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];if(e[1]>t[1]==o[1]>t[1])continue;(o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0])>0?r++:r--}}return 0!==r}function pt(t,e,r){for(const i of e){const e=i.length;for(let s=1;s<e;s++){const e=i[s-1],o=i[s];let n=(o[0]-e[0])*(o[0]-e[0])+(o[1]-e[1])*(o[1]-e[1]);if(0===n)continue;n=Math.sqrt(n);const a=((o[0]-e[0])*(t[1]-e[1])-(o[1]-e[1])*(t[0]-e[0]))/n;if(Math.abs(a)<r){const i=((o[0]-e[0])*(t[0]-e[0])+(o[1]-e[1])*(t[1]-e[1]))/n;if(i>-r&&i<n+r)return!0}}}return!1}function gt(t,e){const r=e[0]-t[0],i=e[1]-t[1];return 180/Math.PI*Math.atan2(i,r)}const _t=t=>t?{spatialReference:t.spatialReference,rings:[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]]}:null,yt=(t,e,r)=>{switch(t){case"ExtraLeading":return 1+e/r;case"Multiple":return e;case"Exact":return e/r}};function Pt(e,r=1){const i=B(e),s=E(e.fontStyleName),o=e.fontFamilyName??t,{weight:n,style:a}=s,l=r*(e.height||5),h=X(e.horizontalAlignment),c=J(e.verticalAlignment),m=N(e),f=N(e.haloSymbol),u=null!=f?r*(e.haloSize??0):0,d=O(e.symbol),p=r*(q(e.symbol)||0),g="CIMBackgroundCallout"===e.callout?.type?e.callout.backgroundSymbol:null,_=N(g),y=q(g),P=O(g);return{color:m,size:l,horizontalAlignment:h,verticalAlignment:c,font:{family:o,style:W(a),weight:V(n),decoration:i},outline:{size:p||0,color:d},halo:{size:u||0,color:f,style:a},backgroundColor:_,borderLine:null!=y&&null!=P?{size:y,color:P}:null,pixelRatio:1,premultiplyColors:!0}}const St=1e-4;function wt(t){let e,r,i,s,o,n=t[0],a=1;for(;a<t.length;)e=t[a][0]-n[0],r=t[a][1]-n[1],s=0!==e?r/e:Math.PI/2,void 0!==i&&Math.abs(s-i)<=St?(t.splice(a-1,1),n=o):(o=n,n=t[a],a++),i=s}export{ht as CIMSymbolDrawHelper,ft as CanvasDrawHelper,ct as EnvDrawHelper,mt as HittestDrawHelper,lt as Transformation,ot as cDegToRad,yt as lineGapType2LineHeight};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{RenderingDevice as e}from"../webgl/RenderingDevice.js";import{simplePipelineState as t}from"../webgl/shaderGraph/utils.js";import{VTLTechniquesRepo as i}from"../webgl/shaderGraph/techniques/vectorTiles/VTLTechniques.js";const r=1e-6;class s{constructor(t,r){this.spriteMosaic=t,this.glyphMosaic=r,this._vtlTechniques=new i,this._context=null,this._vtlTechniques.startup(),this._renderingDevice=new e}dispose(){this._vtlTechniques&&this._vtlTechniques.shutdown(this._context),this.spriteMosaic.dispose(),this.glyphMosaic.dispose(),this._renderingDevice.dispose(),this._context=null}drawSymbols(e,t,i){const s=i.layers;e.renderPass="translucent";const o=this._vtlTechniques.getTechnique(3);n[0]=t;for(let l=0;l<s.length;l++){const t=s[l];if(3!==t.type)continue;const i=t.getLayoutProperty("visibility");if(i&&1===i.getValue())continue;const a=e.displayLevel;void 0!==t.minzoom&&t.minzoom>a+r||void 0!==t.maxzoom&&t.maxzoom<=a-r||(e.styleLayerUID=t.uid,e.styleLayer=t,o.render(e,{tiles:n}))}n[0]=null}drawBackground(e,t,i){if(0===i.backgroundBucketIds.length)return;const{displayLevel:s,requiredLevel:o}=e;t.key.level=o,this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:!1}),e.renderPass="background";const l=this._vtlTechniques.getTechnique(0);n[0]=t,i.backgroundBucketIds.forEach(t=>{const o=i.getLayerById(t);if(0!==o.type)return;const a=o.getLayoutProperty("visibility");a&&1===a.getValue()||void 0!==o.minzoom&&o.minzoom>s+r||void 0!==o.maxzoom&&o.maxzoom<=s-r||(e.styleLayerUID=o.uid,e.styleLayer=o,l.render(e,{tiles:n}))}),n[0]=null}drawTile(e,i,r,s){const n=r.layers,{context:o}=e,l=o.getPipelineState(),{depthWrite:a}=l;let c=0,u=1;void 0!==a?.zNear&&void 0!==a.zFar&&(c=a.zNear,u=a.zFar),this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:{write:{zNear:c,zFar:u},test:515}});const d=n.filter(e=>{if(null!=s&&s!==e.type||!i.layerData.has(e.uid))return!1;const t=e.getLayoutProperty("visibility");return 1!==t?.getValue()});e.renderPass="opaque";for(let t=d.length-1;t>=0;--t)this._renderStyleLayer(d[t],e,i);this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:{write:!1,test:515}}),e.renderPass="translucent",d.forEach(t=>this._renderStyleLayer(t,e,i)),this._renderingDevice.setPipelineState(t),this._context||(this._context=e.context)}setShader(e){return this._renderingDevice.setShader(e)}setPipelineState(e){return this._renderingDevice.setPipelineState(e)}getPipelineState(){return this._renderingDevice.getPipelineState()}submitDraw(e,t,i){return this._renderingDevice.submitDraw(e,t,i)}submitDrawMesh(e,t,i,r){this._renderingDevice.submitDrawMesh(e,t,i,r)}submitDrawMeshUntyped(e,t,i,r){this._renderingDevice.submitDrawMeshUntyped(e,t,i,r)}updatePipelineState(e){return this._renderingDevice.updatePipelineState(e)}setStencilRef(e,t){return this._renderingDevice.setStencilRef(e,t)}_renderStyleLayer(e,t,i){const{renderPass:s}=t;let o;switch(e.type){case 0:if("background"!==s)return;o=this._vtlTechniques.getTechnique(0);break;case 1:if("opaque"!==s&&"translucent"!==t.renderPass)return;o=this._vtlTechniques.getTechnique(1);break;case 2:if("translucent"!==s)return;o=this._vtlTechniques.getTechnique(2);break;case 4:if("translucent"!==s)return;o=this._vtlTechniques.getTechnique(4);break;case 3:if("translucent"!==s)return;o=this._vtlTechniques.getTechnique(3)}const{displayLevel:l}=t,{minzoom:a,maxzoom:c}=e;void 0!==a&&a>l+r||void 0!==c&&c<=l-r||!o||(this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:{write:{mask:0},test:!1},depth:!1}),t.styleLayerUID=e.uid,t.styleLayer=e,n[0]=i,o.render(t,{tiles:n}),n[0]=null)}}const n=[null];export{s as default};
2
+ import{RenderingDevice as e}from"../webgl/RenderingDevice.js";import{simplePipelineState as t}from"../webgl/shaderGraph/utils.js";import{VTLTechniquesRepo as i}from"../webgl/shaderGraph/techniques/vectorTiles/VTLTechniques.js";const r=1e-6;class n{constructor(t,r){this.spriteMosaic=t,this.glyphMosaic=r,this._vtlTechniques=new i,this._context=null,this._vtlTechniques.startup(),this._renderingDevice=new e}dispose(){this._vtlTechniques&&this._vtlTechniques.shutdown(this._context),this.spriteMosaic.dispose(),this.glyphMosaic.dispose(),this._renderingDevice.dispose(),this._context=null}drawSymbols(e,t,i){const n=i.layers;e.renderPass="translucent";const o=this._vtlTechniques.getTechnique(3);s[0]=t;for(let l=0;l<n.length;l++){const t=n[l];if(3!==t.type)continue;const i=t.getLayoutProperty("visibility");if(i&&1===i.getValue())continue;const a=e.displayLevel;void 0!==t.minzoom&&t.minzoom>a+r||void 0!==t.maxzoom&&t.maxzoom<=a-r||(e.styleLayerUID=t.uid,e.styleLayer=t,o.render(e,{tiles:s}))}s[0]=null}drawBackground(e,t,i){if(0===i.backgroundBucketIds.length)return;const{displayLevel:n,requiredLevel:o}=e;t.key.level=o,this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:{write:!1,test:519}}),e.renderPass="background";const l=this._vtlTechniques.getTechnique(0);s[0]=t,i.backgroundBucketIds.forEach(t=>{const o=i.getLayerById(t);if(0!==o.type)return;const a=o.getLayoutProperty("visibility");a&&1===a.getValue()||void 0!==o.minzoom&&o.minzoom>n+r||void 0!==o.maxzoom&&o.maxzoom<=n-r||(e.styleLayerUID=o.uid,e.styleLayer=o,l.render(e,{tiles:s}))}),s[0]=null}drawTile(e,i,r,n){const s=r.layers.filter(e=>{if(null!=n&&n!==e.type||!i.layerData.has(e.uid))return!1;const t=e.getLayoutProperty("visibility");return 1!==t?.getValue()}),{context:o}=e,l=o.getPipelineState(),{depthWrite:a}=l;let c=0,u=1;void 0!==a?.zNear&&void 0!==a.zFar&&(c=a.zNear,u=a.zFar),this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"none"},stencil:!1,depth:{write:{zNear:c,zFar:u},test:515}}),e.renderPass="opaque";for(let t=s.length-1;t>=0;--t)this._renderStyleLayer(s[t],e,i);this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:{write:!1,test:515}}),e.renderPass="translucent",s.forEach(t=>this._renderStyleLayer(t,e,i)),this._renderingDevice.setPipelineState(t),this._context||(this._context=e.context)}setShader(e){return this._renderingDevice.setShader(e)}setPipelineState(e){return this._renderingDevice.setPipelineState(e)}getPipelineState(){return this._renderingDevice.getPipelineState()}submitDraw(e,t,i){return this._renderingDevice.submitDraw(e,t,i)}submitDrawMesh(e,t,i,r){this._renderingDevice.submitDrawMesh(e,t,i,r)}submitDrawMeshUntyped(e,t,i,r){this._renderingDevice.submitDrawMeshUntyped(e,t,i,r)}updatePipelineState(e){return this._renderingDevice.updatePipelineState(e)}setStencilRef(e,t){return this._renderingDevice.setStencilRef(e,t)}_renderStyleLayer(e,t,i){const{renderPass:n}=t;let o;switch(e.type){case 0:if("background"!==n)return;o=this._vtlTechniques.getTechnique(0);break;case 1:if("opaque"!==n&&"translucent"!==n)return;o=this._vtlTechniques.getTechnique(1);break;case 2:if("translucent"!==n)return;o=this._vtlTechniques.getTechnique(2);break;case 4:if("translucent"!==n)return;o=this._vtlTechniques.getTechnique(4);break;case 3:if("translucent"!==n)return;o=this._vtlTechniques.getTechnique(3)}const{displayLevel:l}=t,{minzoom:a,maxzoom:c}=e;void 0!==a&&a>l+r||void 0!==c&&c<=l-r||!o||(3===e.type&&this._renderingDevice.setPipelineState({color:{write:[!0,!0,!0,!0],blendMode:"composite"},stencil:!1,depth:!1}),t.styleLayerUID=e.uid,t.styleLayer=e,s[0]=i,o.render(t,{tiles:s}),s[0]=null)}}const s=[null];export{n as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../../request.js";import{bidiText as e}from"../../../../core/BidiText.js";import has from"../../../../core/has.js";import{throwIfNotAbortError as s}from"../../../../core/promiseUtils.js";import{loadTextModule as i}from"../../../../libs/text/loadTextModule.js";import{sdfRadiusComplex as h,sdfBufferGlyphSDFCreator as a,sdfSizeComplex as r,sdfBufferServer as n,sdfRadiusSimple as o,sdfSizeSimple as c}from"./definitions.js";import{GlyphSDFCreator as l}from"./GlyphSDFCreator.js";import p from"./Rect.js";import g from"./RectangleBinPack.js";import{charCodes as d}from"./Utils.js";import _ from"../../../webgl/Texture.js";import{TextureDescriptor as f}from"../../../webgl/TextureDescriptor.js";const u=256,y=.25,m=t=>Math.floor(t/256);function w(t){const e=new Set;for(const s of t)e.add(m(s));return e}function C(t,e,i){return t.has(e)||t.set(e,i().then(()=>{t.delete(e)}).catch(i=>{t.delete(e),s(i)})),t.get(e)}const x=t=>({rect:new p(0,0,0,0),page:0,metrics:{left:0,width:0,height:0,advance:0,top:0},code:t,sdf:!0});class P{constructor(t,e,s,i=!1){this._snapCoords=i,this.width=0,this.height=0,this._dirties=[],this._pageData=[],this._currentPage=0,this._glyphCache={},this._glyphCacheById={},this._textures=[],this._rangePromises=new Map,this._facePromises=new Map,this._preloadCache={},this._glyphSDFCreator=new l({sdfSizePx:r,sdfBufferPx:a,radius:h,cutoff:y}),this._faces=new Map,this.width=t,this.height=e,this._glyphSource=s,this._binPack=new g(t,e),this._pageData.push(new Uint8Array(t*e)),this._dirties.push(!0),this._textures.push(null),this._initDecorationGlyphs()}dispose(){this._binPack=null;for(const t of this._textures)t&&t.dispose();this._textures.length=0,this._pageData.length=0}_initDecorationGlyphs(){const t=[117,149,181,207,207,181,149,117],e=[],s=[];for(let a=0;a<t.length;a++){const i=t[a];for(let t=0;t<11;t++){const h=a>=3&&a<5&&t>=3&&t<8?255:0;e.push(i),s.push(h)}}const i={metrics:{width:5,height:2,left:0,top:0,advance:0},bitmap:new Uint8Array(e)},h={metrics:{width:5,height:2,left:0,top:0,advance:0},bitmap:new Uint8Array(s)};this._recordGlyph(i,n),this._recordGlyph(h,n)}getTexture(t,e){if(!this._textures[e]){const s=new f(this.width,this.height);s.pixelFormat=6406,s.wrapMode=33071,this._textures[e]=new _(t,s,new Uint8Array(this.width*this.height))}return this._dirties[e]&&(this._textures[e].setData(this._pageData[e]),this._dirties[e]=!1),this._textures[e]}async getGlyphItems(t,s,i,l){const p=s?r:c,g=s?h:o,_=s?a:n;let f,u,y=!1;if(s){const s=this._getGlyphCacheById(i),h=await this.getFace(i);if(!h)return null;const a=this._glyphSDFCreator.sdfSizePx,[r,n,o]=e(t,!1);y=n;const c=new Uint32Array(Array.from(r).map((t,e)=>o.levels[o.targetToSource[e]]));f={baseline:h.baseline()/a,midline:h.midline()/a},u=h.shape(r,c,a).map(t=>this._getMosaicItemComplex(s,t,h))}else{const[s,h,a]=e(t);y=h;const r=this._getGlyphCache(i),n=d(s);try{await this._fetchRanges(i,n,l)}catch{return null}u=n.map(t=>this._getMosaicItem(r,i,t))}return{type:"glyphs",isRightToLeft:y,glyphs:u,faceInfo:f,sdfSize:p,sdfRadius:g,sdfPadding:_}}async getGlyphItemsVTL(t,e){const s=this._getGlyphCache(t);await this._fetchRanges(t,e,null);const i=[];for(const h of e)i[h]=this._getMosaicItem(s,t,h);return i}async getFace(e){if(this._faces.has(e))return this._faces.get(e);const s=this._glyphSource.woffURL(e);return await C(this._facePromises,e,async()=>{const h=await t(s,{responseType:"array-buffer"}),a=(await i()).Face.parseWoff2(new Uint8Array(h.data));this._faces.set(e,a)}),this._faces.get(e)}_getMosaicItem(t,e,s){if(!t[s]){const i=this._glyphSource.getGlyph(e,s);if(!i?.metrics)return x(s);const h=this._recordGlyph(i,n),a=this._currentPage,r=i.metrics;t[s]={rect:h,page:a,metrics:r,code:s,sdf:!0},this._invalidate()}return t[s]}_getMosaicItemComplex(t,e,s){if(!t[e.glyphId]){const i=this._glyphSDFCreator.draw(s,e.glyphId),h={width:i?.width??0,height:i?.height??0,left:i?.left??0,top:i?.top??0,advance:e.xAdvance};let r=new p(0,0,0,0);if(i){const t={bitmap:i.buffer,metrics:h};r=this._recordGlyph(t,a)}const n=e.isNewline?10:e.isWhitespace?32:NaN;t[e.glyphId]={rect:r,page:this._currentPage,metrics:h,sdf:!0,code:n}}return t[e.glyphId]}bind(t,e,s,i){const h=this.getTexture(t,s);h.setSamplingMode(e),t.bindTexture(h,i)}preloadASCIIGlyphCache(t){const e=this._preloadCache[t];if(null!=e)return e;const s=this._glyphSource.preloadASCIIRange(t).then(()=>{const e=this._getGlyphCache(t);for(let s=0;s<256;s++)this._getMosaicItem(e,t,s)});return this._preloadCache[t]=s,s}_getGlyphCache(t){return this._glyphCache[t]||(this._glyphCache[t]={}),this._glyphCache[t]}_getGlyphCacheById(t){return this._glyphCacheById[t]||(this._glyphCacheById[t]={}),this._glyphCacheById[t]}_invalidate(){this._dirties[this._currentPage]=!0}async _fetchRanges(t,e,s){const i=w(e),h=[];i.forEach(e=>{h.push(this._fetchRange(t,e,s))}),await Promise.all(h)}async _fetchRange(t,e,s){if(e>u)return;const i=t+e;return C(this._rangePromises,i,()=>this._glyphSource.getRange(t,e,s))}_allocNewPage(){this._dirties[this._currentPage]||(this._pageData[this._currentPage]=null),this._currentPage=this._pageData.length,this._pageData.push(new Uint8Array(this.width*this.height)),this._dirties.push(!0),this._textures.push(null),this._initDecorationGlyphs(),this._binPack=new g(this.width,this.height)}_recordGlyph(t,e){const s=t.metrics;let i;if(0===s.width)i=new p(0,0,0,0);else{const h=s.width+2*e,a=s.height+2*e;let r=h,n=a;if(this._snapCoords){r+=h%4?4-h%4:4,n+=a%4?4-a%4:4}i=this._binPack.allocate(r,n),i.isEmpty&&(this._allocNewPage(),i=this._binPack.allocate(r,n));const o=this._pageData[this._currentPage],c=t.bitmap;for(let t=0;t<a;t++){const e=h*t,s=this.width*(i.y+t)+i.x;for(let t=0;t<h;t++)o[s+t]=c[e+t]}has("esri-glyph-debug")&&this._showDebugPage(o)}return i}_showDebugPage(t){const e=document.createElement("canvas"),s=e.getContext("2d"),i=new ImageData(this.width,this.height),h=i.data;e.width=this.width,e.height=this.height,e.style.border="1px solid black";for(let a=0;a<t.length;++a)h[4*a]=t[a],h[4*a+1]=0,h[4*a+2]=0,h[4*a+3]=255;s.putImageData(i,0,0),document.body.appendChild(e)}}export{P as default};
2
+ import t from"../../../../request.js";import{bidiText as e}from"../../../../core/BidiText.js";import has from"../../../../core/has.js";import{throwIfNotAbortError as s}from"../../../../core/promiseUtils.js";import{loadTextModule as i}from"../../../../libs/text/loadTextModule.js";import{sdfRadiusComplex as h,sdfBufferGlyphSDFCreator as r,sdfSizeComplex as a,sdfBufferServer as n,sdfRadiusSimple as o,sdfSizeSimple as c}from"./definitions.js";import{GlyphSDFCreator as l}from"./GlyphSDFCreator.js";import p from"./Rect.js";import g from"./RectangleBinPack.js";import{charCodes as _}from"./Utils.js";import d from"../../../webgl/Texture.js";import{TextureDescriptor as f}from"../../../webgl/TextureDescriptor.js";const u=256,y=.25,m=t=>Math.floor(t/256);function w(t){const e=new Set;for(const s of t)e.add(m(s));return e}function C(t,e,i){return t.has(e)||t.set(e,i().then(()=>{t.delete(e)}).catch(i=>{t.delete(e),s(i)})),t.get(e)}const x=t=>({rect:new p(0,0,0,0),page:0,metrics:{left:0,width:0,height:0,advance:0,top:0},code:t,sdf:!0});class P{constructor(t,e,s,i=!1){this._snapCoords=i,this.width=0,this.height=0,this._dirties=[],this._pageData=[],this._currentPage=0,this._glyphCache={},this._glyphCacheById={},this._textures=[],this._rangePromises=new Map,this._facePromises=new Map,this._preloadCache={},this._glyphSDFCreator=new l({sdfSizePx:a,sdfBufferPx:r,radius:h,cutoff:y}),this._faces=new Map,this.width=t,this.height=e,this._glyphSource=s,this._binPack=new g(t,e),this._pageData.push(new Uint8Array(t*e)),this._dirties.push(!0),this._textures.push(null),this._initDecorationGlyphs()}dispose(){this._binPack=null;for(const t of this._textures)t&&t.dispose();this._textures.length=0,this._pageData.length=0}_initDecorationGlyphs(){const t=[117,149,181,207,207,181,149,117],e=[],s=[];for(let a=0;a<t.length;a++){const i=t[a];for(let t=0;t<11;t++){const h=a>=3&&a<5&&t>=3&&t<8?255:0;e.push(i),s.push(h)}}const i={width:5,height:2,left:0,top:0,advance:0},h=new Uint8Array(e),r=new Uint8Array(s);this._recordGlyph(i,h,n),this._recordGlyph(i,r,n)}getTexture(t,e){if(!this._textures[e]){const s=new f(this.width,this.height);s.pixelFormat=6406,s.wrapMode=33071,this._textures[e]=new d(t,s,new Uint8Array(this.width*this.height))}return this._dirties[e]&&(this._textures[e].setData(this._pageData[e]),this._dirties[e]=!1),this._textures[e]}async getGlyphItems(t,s,i,l){const p=s?a:c,g=s?h:o,d=s?r:n;let f,u=[],y=!1;if(s){const s=this._getGlyphCacheById(i),h=await this.getFace(i);if(!h)return null;const r=this._glyphSDFCreator.sdfSizePx,[a,n,o]=e(t,!1);y=n;const c=new Uint32Array(Array.from(a).map((t,e)=>o.levels[o.targetToSource[e]]));f={baseline:h.baseline()/r,midline:h.midline()/r},u=h.shape(a,c,r).map(t=>this._getMosaicItemComplex(s,t,h))}else{const[s,h,r]=e(t);y=h;const a=this._getGlyphCache(i),n=_(s);try{await this._fetchRanges(i,n,l)}catch{return null}for(const t of n){const e=this._getMosaicItem(a,i,t);e&&u.push(e)}}return{type:"glyphs",isRightToLeft:y,glyphs:u,faceInfo:f,sdfSize:p,sdfRadius:g,sdfPadding:d}}async getGlyphItemsVTL(t,e){const s=this._getGlyphCache(t);await this._fetchRanges(t,e,null);const i=[];for(const h of e){const e=this._getMosaicItem(s,t,h,!0);e&&(i[h]=e)}return i}async getFace(e){if(this._faces.has(e))return this._faces.get(e);const s=this._glyphSource.woffURL(e);return await C(this._facePromises,e,async()=>{const h=await t(s,{responseType:"array-buffer"}),r=(await i()).Face.parseWoff2(new Uint8Array(h.data));this._faces.set(e,r)}),this._faces.get(e)}_getMosaicItem(t,e,s,i=!1){if(!t[s]){const{metrics:h,bitmap:r}=this._glyphSource.getGlyph(e,s);if(i&&!h)return;if(!h)return x(s);const a=r?this._recordGlyph(h,r,n):new p(0,0,0,0),o=this._currentPage;t[s]={rect:a,page:o,metrics:h,code:s,sdf:!0},this._invalidate()}return t[s]}_getMosaicItemComplex(t,e,s){if(!t[e.glyphId]){const i=this._glyphSDFCreator.draw(s,e.glyphId),h={width:i?.width??0,height:i?.height??0,left:i?.left??0,top:i?.top??0,advance:e.xAdvance},a=i?this._recordGlyph(h,i.buffer,r):new p(0,0,0,0),n=e.isNewline?10:e.isWhitespace?32:NaN;t[e.glyphId]={rect:a,page:this._currentPage,metrics:h,sdf:!0,code:n}}return t[e.glyphId]}bind(t,e,s,i){const h=this.getTexture(t,s);h.setSamplingMode(e),t.bindTexture(h,i)}preloadASCIIGlyphCache(t){const e=this._preloadCache[t];if(null!=e)return e;const s=this._glyphSource.preloadASCIIRange(t).then(()=>{const e=this._getGlyphCache(t);for(let s=0;s<256;s++)this._getMosaicItem(e,t,s)});return this._preloadCache[t]=s,s}_getGlyphCache(t){return this._glyphCache[t]||(this._glyphCache[t]={}),this._glyphCache[t]}_getGlyphCacheById(t){return this._glyphCacheById[t]||(this._glyphCacheById[t]={}),this._glyphCacheById[t]}_invalidate(){this._dirties[this._currentPage]=!0}async _fetchRanges(t,e,s){const i=w(e),h=[];i.forEach(e=>{h.push(this._fetchRange(t,e,s))}),await Promise.all(h)}async _fetchRange(t,e,s){if(e>u)return;const i=t+e;return C(this._rangePromises,i,()=>this._glyphSource.getRange(t,e,s))}_allocNewPage(){this._dirties[this._currentPage]||(this._pageData[this._currentPage]=null),this._currentPage=this._pageData.length,this._pageData.push(new Uint8Array(this.width*this.height)),this._dirties.push(!0),this._textures.push(null),this._initDecorationGlyphs(),this._binPack=new g(this.width,this.height)}_recordGlyph(t,e,s){let i;if(0===t.width)i=new p(0,0,0,0);else{const h=t.width+2*s,r=t.height+2*s;let a=h,n=r;if(this._snapCoords){a+=h%4?4-h%4:4,n+=r%4?4-r%4:4}i=this._binPack.allocate(a,n),i.isEmpty&&(this._allocNewPage(),i=this._binPack.allocate(a,n));const o=this._pageData[this._currentPage];for(let t=0;t<r;t++){const s=h*t,r=this.width*(i.y+t)+i.x;for(let t=0;t<h;t++)o[r+t]=e[s+t]}has("esri-glyph-debug")&&this._showDebugPage(o)}return i}_showDebugPage(t){const e=document.createElement("canvas"),s=e.getContext("2d"),i=new ImageData(this.width,this.height),h=i.data;e.width=this.width,e.height=this.height,e.style.border="1px solid black";for(let r=0;r<t.length;++r)h[4*r]=t[r],h[4*r+1]=0,h[4*r+2]=0,h[4*r+3]=255;s.putImageData(i,0,0),document.body.appendChild(e)}}export{P as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import t from"../../../../config.js";import e from"../../../../request.js";import a from"../../../../core/pbf.js";class s{constructor(t){this._metrics=[],this._bitmaps=[];const e=new Map;let a=0;for(;t.next();)switch(t.tag()){case 1:{const s=t.getMessage();for(;s.next();)switch(s.tag()){case 3:{const t=s.getMessage();let r,n,i,o,c,g,f;for(;t.next();)switch(t.tag()){case 1:r=t.getUInt32();break;case 2:n=t.getBytes();break;case 3:i=t.getUInt32();break;case 4:o=t.getUInt32();break;case 5:c=t.getSInt32();break;case 6:g=t.getSInt32();break;case 7:f=t.getUInt32();break;default:t.skip()}if(t.release(),r&&(this._metrics[r]={width:i,height:o,left:c,top:g,advance:f},n)){const t=n.length;e.set(r,n),this._bitmaps[r]={start:a,length:t},a+=t}break}default:s.skip()}s.release();break}default:t.skip()}this._buffer=new Uint8Array(a);for(const[s,r]of e)this._buffer.set(r,this._bitmaps[s].start)}getMetrics(t){return this._metrics[t]}getBitmap(t){const e=this._bitmaps.at(t);if(void 0!==e&&0!==e.length)return this._buffer.subarray(e.start,e.start+e.length)}}class r{constructor(){this._ranges=[]}getRange(t){return this._ranges[t]}addRange(t,e){this._ranges[t]=e}}class n{constructor(e){this._glyphInfo={},this._baseURL=e,this._woff2URL=`${t.fontsUrl}/woff2/{fontstack}.woff2`}async getRange(t,r,n){const i=this._getFontStack(t);if(i.getRange(r))return;const o=256*r,c=o+255,g=this._baseURL.replace("{fontstack}",t).replace("{range}",o+"-"+c);return e(g,{responseType:"array-buffer",...n}).then(t=>{i.addRange(r,new s(new a(new Uint8Array(t.data),new DataView(t.data))))})}async preloadASCIIRange(t){const r=this._getFontStack(t),n=0,i=255,o=this._baseURL.replace("{fontstack}",t).replace("{range}",n+"-"+i),c=await e(o,{responseType:"array-buffer"}),g=new s(new a(new Uint8Array(c.data),new DataView(c.data)));for(let e=n;e<=i;e++)r.getRange(e)||r.addRange(e,g)}getGlyph(t,e){const a=this._getFontStack(t);if(!a)return;const s=Math.floor(e/256),r=a.getRange(s);return r?{metrics:r.getMetrics(e),bitmap:r.getBitmap(e)}:void 0}woffURL(t){return this._woff2URL.replace("{fontstack}",t)}_getFontStack(t){let e=this._glyphInfo[t];return e||(e=this._glyphInfo[t]=new r),e}}export{n as default};
2
+ import t from"../../../../config.js";import e from"../../../../request.js";import a from"../../../../core/pbf.js";class s{constructor(t){this._metrics=[],this._bitmaps=[];const e=new Map;let a=0;for(;t.next();)switch(t.tag()){case 1:{const s=t.getMessage();for(;s.next();)switch(s.tag()){case 3:{const t=s.getMessage();let r,n,i,c,o,g,f;for(;t.next();)switch(t.tag()){case 1:r=t.getUInt32();break;case 2:n=t.getBytes();break;case 3:i=t.getUInt32();break;case 4:c=t.getUInt32();break;case 5:o=t.getSInt32();break;case 6:g=t.getSInt32();break;case 7:f=t.getUInt32();break;default:t.skip()}if(t.release(),r&&(this._metrics[r]={width:i,height:c,left:o,top:g,advance:f},n)){const t=n.length;e.set(r,n),this._bitmaps[r]={start:a,length:t},a+=t}break}default:s.skip()}s.release();break}default:t.skip()}this._buffer=new Uint8Array(a);for(const[s,r]of e)this._buffer.set(r,this._bitmaps[s].start)}getMetrics(t){return this._metrics.at(t)}getBitmap(t){const e=this._bitmaps.at(t);if(void 0!==e&&0!==e.length)return this._buffer.subarray(e.start,e.start+e.length)}}class r{constructor(){this._ranges=[]}getRange(t){return this._ranges.at(t)}addRange(t,e){this._ranges[t]=e}}class n{constructor(e){this._glyphInfo={},this._baseURL=e,this._woff2URL=`${t.fontsUrl}/woff2/{fontstack}.woff2`}async getRange(t,r,n){const i=this._getFontStack(t);if(i.getRange(r))return;const c=256*r,o=c+255,g=this._baseURL.replace("{fontstack}",t).replace("{range}",c+"-"+o);return e(g,{responseType:"array-buffer",...n}).then(t=>{i.addRange(r,new s(new a(new Uint8Array(t.data),new DataView(t.data))))})}async preloadASCIIRange(t){const r=this._getFontStack(t),n=0,i=255,c=this._baseURL.replace("{fontstack}",t).replace("{range}",n+"-"+i),o=await e(c,{responseType:"array-buffer"}),g=new s(new a(new Uint8Array(o.data),new DataView(o.data)));for(let e=n;e<=i;e++)r.getRange(e)||r.addRange(e,g)}getGlyph(t,e){let a,s;const r=this._getFontStack(t).getRange(Math.floor(e/256));return r&&(a=r.getMetrics(e),s=r.getBitmap(e)),{metrics:a,bitmap:s}}woffURL(t){return this._woff2URL.replace("{fontstack}",t)}_getFontStack(t){let e=this._glyphInfo[t];return e||(e=this._glyphInfo[t]=new r),e}}export{n as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{fromRotation as t,multiply as s,translate as e,rotate as i}from"../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o,transformMany as h}from"../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as r}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{getXAnchorDirection as f,getYAnchorDirection as c}from"../../alignmentUtils.js";import d from"../../Rect.js";import m from"../../collisions/BoundingBox.js";const g=22,l=4,_=g+l,u=g-6,x=Math.PI/180,p=8,b=1.5;class y{constructor(t,s,e,i){this._rotationT=o(),this._bounds=null;const h=e.rect,n=new Float32Array(8);t*=i,s*=i;const r=0===e.code?e.metrics.width:h.width*i,a=0===e.code?e.metrics.height:h.height*i;this.width=r,this.height=a,n[0]=t,n[1]=s,n[2]=t+r,n[3]=s,n[4]=t,n[5]=s+a,n[6]=t+r,n[7]=s+a,this._data=n,this._setTextureCoords(h),this._scale=i,this._mosaic=e,this.x=t,this.y=s,this.maxOffset=Math.max(t+r,s+a)}get mosaic(){return this._mosaic}set angle(s){this._angle=s,t(this._rotationT,-s),this._setOffsets()}get angle(){return this._angle}get xTopLeft(){return this._data[0]}get yTopLeft(){return this._data[1]}get xBottomRight(){return this._data[6]}get yBottomRight(){return this._data[7]}get texcoords(){return this._texcoords}get textureBinding(){return this._mosaic.textureBinding}get offsets(){return this._offsets||this._setOffsets(),this._offsets}get bounds(){if(!this._bounds){const{height:t,width:e}=this._mosaic.metrics,i=e*this._scale,n=Math.abs(t)*this._scale,r=new Float32Array(8);r[0]=this.x,r[1]=this.y,r[2]=this.x+i,r[3]=this.y,r[4]=this.x,r[5]=this.y+n,r[6]=this.x+i,r[7]=this.y+n;const a=s(o(),this._rotationT,this._transform);h(r,r,a);let f=1/0,c=1/0,d=-1/0,g=-1/0;for(let s=0;s<4;s++){const t=r[2*s],e=r[2*s+1];f=Math.min(f,t),c=Math.min(c,e),d=Math.max(d,t),g=Math.max(g,e)}const l=d-f,_=g-c,u=f+l/2,x=c+_/2;this._bounds=new m(u,x,l,_)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}_setOffsets(){this._offsets||(this._offsets={topLeft:[0,0],topRight:[0,0],bottomLeft:[0,0],bottomRight:[0,0]});const t=s(o(),this._rotationT,this._transform);this._offsets.topLeft[0]=this._data[0],this._offsets.topLeft[1]=this._data[1],this._offsets.topRight[0]=this._data[2],this._offsets.topRight[1]=this._data[3],this._offsets.bottomLeft[0]=this._data[4],this._offsets.bottomLeft[1]=this._data[5],this._offsets.bottomRight[0]=this._data[6],this._offsets.bottomRight[1]=this._data[7],n(this._offsets.topLeft,this._offsets.topLeft,t),n(this._offsets.topRight,this._offsets.topRight,t),n(this._offsets.bottomLeft,this._offsets.bottomLeft,t),n(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:s,width:e,height:i}){this._texcoords={topLeft:[t,s],topRight:[t+e,s],bottomLeft:[t,s+i],bottomRight:[t+e,s+i]}}}const w=(t,s)=>({code:0,page:0,sdf:!0,rect:new d(0,0,11,8),textureBinding:s,metrics:{advance:0,height:4,width:t,left:0,top:0}});function L(t,s){return t.forEach(t=>n(t,t,s)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class M{constructor(t,s,e,i){this._rotation=0,this._decorate(t,s,e,i),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=s.length>1,this._hasRotation=0!==e.angle,this._transform=this._createGlyphTransform(this.bounds,e),this._borderLineSizePx=e.borderLineSizePx,(e.borderLineSizePx||e.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const o of t)o.setTransform(this._transform)}setRotation(e){if(0===e&&0===this._rotation)return;this._rotation=e;const i=this._transform,h=t(o(),e);s(i,h,i);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,s,e,i){if(!e.decoration||"none"===e.decoration||!t.length)return;const o=e.scale,h="underline"===e.decoration?i?.baseline??_:i?.midline??u,n=t[0].textureBinding;for(const r of s){const s=r.startX*o,e=r.startY*o,i=(r.width+r.glyphWidthEnd)*o;t.push(new y(s,e+h*o,w(i,n),1))}}shapeBackground(t){const s=this._borderLineSizePx||0,e=(b+s)/2,i=this._borderLineSizePx?e:0,{xmin:o,ymin:h,xmax:n,ymax:r,x:a,y:f,width:c,height:d}=this.bounds,g=[o-p,h-p],l=[n+p,h-p],_=[o-p,r+p],u=[n+p,r+p],x=L([[g[0]-e,g[1]-e],[l[0]+e,l[1]-e],[g[0]+i,g[1]+i],[l[0]-i,l[1]+i]],t),y=L([[_[0]+i,_[1]-i],[u[0]-i,u[1]-i],[_[0]-e,_[1]+e],[u[0]+e,u[1]+e]],t),w=L([[g[0]-e,g[1]-e],[g[0]+i,g[1]+i],[_[0]-e,_[1]+e],[_[0]+i,_[1]-i]],t),M=L([[l[0]-i,l[1]+i],[l[0]+e,l[1]-e],[u[0]-i,u[1]-i],[u[0]+e,u[1]+e]],t),R={main:L([g,l,_,u],t),top:x,bot:y,left:w,right:M};return[new m(a,f,c+2*e,d+2*e),R]}get boundsT(){const t=this.bounds,s=r(a(),t.x,t.y);if(n(s,s,this._transform),this._hasRotation){const e=Math.max(t.width,t.height);return new m(s[0],s[1],e,e)}return new m(s[0],s[1],t.width,t.height)}_createBounds(t){let s=1/0,e=1/0,i=0,o=0;for(const r of t)s=Math.min(s,r.xTopLeft),e=Math.min(e,r.yTopLeft),i=Math.max(i,r.xBottomRight),o=Math.max(o,r.yBottomRight);const h=i-s,n=o-e;return new m(s+h/2,e+n/2,h,n)}_createGlyphTransform(t,s){const h=x*s.angle,n=o(),f=a();return e(n,n,r(f,s.xOffset,-s.yOffset)),s.useCIMAngleBehavior?i(n,n,h):(e(n,n,r(f,t.x,t.y)),i(n,n,h),e(n,n,r(f,-t.x,-t.y))),n}}class R{constructor(t,s,e,i,o,h){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(s,e)),this.end=Math.max(0,Math.max(s,e)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=i,this.yMin=o,this.yMax=h}}const T=t=>10===t,B=t=>32===t;function v(t,s,e){const i=new Array,o=1/e.scale,h=e.maxLineWidth*o,n=s?t.length-1:0,r=s?-1:t.length,a=s?-1:1;let f=n,c=0,d=0,m=f,g=m,l=0,_=1/0,u=0;for(;f!==r;){const{code:s,metrics:e}=t[f],o=Math.abs(e.top);if(T(s)||B(s)||(_=Math.min(_,o),u=Math.max(u,o+e.height)),T(s))f!==n&&(i.push(new R(t,m,f-a,c,_===1/0?0:_,u)),_=1/0,u=0),c=0,m=f+a,g=f+a,d=0;else if(B(s))g=f+a,d=0,l=e.advance,c+=e.advance;else if(c>h){if(g!==m){const s=g-2*a;c-=l,i.push(new R(t,m,s,c-d,_,u)),_=1/0,u=0,m=g,c=d}else i.push(new R(t,m,f-a,c,_,u)),_=1/0,u=0,m=f,g=f,c=0;c+=e.advance,d+=e.advance}else c+=e.advance,d+=e.advance;f+=a}const x=new R(t,m,f-a,c,_,u);return x.start>=0&&x.end<t.length&&i.push(x),i}function j(t,s){let e=0;for(let h=0;h<t.length;h++){const{width:s}=t[h];e=Math.max(s,e)}const i="underline"===s.decoration?l:0,o=t[0].yMin;return{x:0,y:o,height:t[t.length-1].yMax+s.lineHeight*(t.length-1)+i-o,width:e}}function A(t,s){const e=s.scale,i=new Array,o=t.sdfPadding,{faceInfo:h,glyphs:n,isRightToLeft:r}=t,a=v(n,r,s),d=a.length?j(a,s):{y:0,height:0},m=f(s.horizontalAlignment),l=c(s.verticalAlignment),_=2===l?1:0,u=_?0:l-1,x=(1-_)*-d.y+u*(d.height/2)+_*-g;for(let f=0;f<a.length;f++){const{start:h,end:r,width:c}=a[f];let d=-1*(m+1)*(c/2)-o;const g=(t.isRightToLeft?a.length-1-f:f)*s.lineHeight+x-o;a[f].startX=d,a[f].startY=g;for(let t=h;t<=r;t++){const s=n[t];if(T(s.code))continue;const o=new y(d+s.metrics.left,g-s.metrics.top,s,e);d+=s.metrics.advance,i.push(o)}}return new M(i,a,s,h)}export{y as ShapedGlyph,M as ShapingInfo,A as shapeGlyphs};
2
+ import{fromRotation as t,multiply as e,translate as s,rotate as i}from"../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as n}from"../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as o,set as h}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{getXAnchorDirection as a,getYAnchorDirection as f}from"../../alignmentUtils.js";import c from"../../Rect.js";import d from"../../collisions/BoundingBox.js";const l=22,m=4,g=l+m,u=l-6,x=Math.PI/180,p=8,_=1.5;class b{constructor(t,e,s,i){this._rotationT=n(),this._transform=n(),this._angle=0,this._bounds=null;const o=s.rect;t*=i,e*=i,this.width=0===s.code?s.metrics.width:o.width*i,this.height=0===s.code?s.metrics.height:o.height*i,this.x=t,this.y=e,this.textureBinding=s.textureBinding,this.texcoords={topLeft:[o.x,o.y],topRight:[o.x+o.width,o.y],bottomLeft:[o.x,o.y+o.height],bottomRight:[o.x+o.width,o.y+o.height]}}set angle(e){this._angle=e,t(this._rotationT,-e),this._offsets=this._bounds=null}get angle(){return this._angle}get offsets(){if(!this._offsets){const{x:s,y:i,width:h,height:r}=this,a=t(n(),-this.angle),f=e(n(),a,this._transform);this._offsets={topLeft:o([0,0],[s,i],f),topRight:o([0,0],[s+h,i],f),bottomLeft:o([0,0],[s,i+r],f),bottomRight:o([0,0],[s+h,i+r],f)}}return this._offsets}get bounds(){if(this.width<=0)return null;if(!this._bounds){const t=this.offsets;let e=1/0,s=1/0,i=-1/0,n=-1/0;for(const[f,c]of[t.topLeft,t.topRight,t.bottomLeft,t.bottomRight])e=Math.min(e,f),s=Math.min(s,c),i=Math.max(i,f),n=Math.max(n,c);const o=i-e,h=n-s,r=e+o/2,a=s+h/2;this._bounds=new d(r,a,o,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const w=(t,e)=>({code:0,page:0,sdf:!0,rect:new c(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function y(t,e){return t.forEach(t=>o(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class M{constructor(t,e,s,i){this._rotation=0,this._decorate(t,e,s,i),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==s.angle,this._transform=this._createGlyphTransform(this.bounds,s),this._borderLineSizePx=s.borderLineSizePx,(s.borderLineSizePx||s.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const n of t)n.setTransform(this._transform)}setRotation(s){if(0===s&&0===this._rotation)return;this._rotation=s;const i=this._transform,o=t(n(),s);e(i,o,i);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,s,i){if(!s.decoration||"none"===s.decoration||!t.length)return;const n=s.scale,o="underline"===s.decoration?i?.baseline??g:i?.midline??u,h=t[0].textureBinding;for(const r of e){const e=r.startX*n,s=r.startY*n,i=(r.width+r.glyphWidthEnd)*n;t.push(new b(e,s+o*n,w(i,h),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,s=(_+e)/2,i=this._borderLineSizePx?s:0,{xmin:n,ymin:o,xmax:h,ymax:r,x:a,y:f,width:c,height:l}=this.bounds,m=[n-p,o-p],g=[h+p,o-p],u=[n-p,r+p],x=[h+p,r+p],b=y([[m[0]-s,m[1]-s],[g[0]+s,g[1]-s],[m[0]+i,m[1]+i],[g[0]-i,g[1]+i]],t),w=y([[u[0]+i,u[1]-i],[x[0]-i,x[1]-i],[u[0]-s,u[1]+s],[x[0]+s,x[1]+s]],t),M=y([[m[0]-s,m[1]-s],[m[0]+i,m[1]+i],[u[0]-s,u[1]+s],[u[0]+i,u[1]-i]],t),L=y([[g[0]-i,g[1]+i],[g[0]+s,g[1]-s],[x[0]-i,x[1]-i],[x[0]+s,x[1]+s]],t),R={main:y([m,g,u,x],t),top:b,bot:w,left:M,right:L};return[new d(a,f,c+2*s,l+2*s),R]}get boundsT(){const t=this.bounds,e=h(r(),t.x,t.y);if(o(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new d(e[0],e[1],s,s)}return new d(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,n=0;for(const r of t)e=Math.min(e,r.offsets.topLeft[0]),s=Math.min(s,r.offsets.topLeft[1]),i=Math.max(i,r.offsets.bottomRight[0]),n=Math.max(n,r.offsets.bottomRight[1]);const o=i-e,h=n-s;return new d(e+o/2,s+h/2,o,h)}_createGlyphTransform(t,e){const o=x*e.angle,a=n(),f=r();return s(a,a,h(f,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?i(a,a,o):(s(a,a,h(f,t.x,t.y)),i(a,a,o),s(a,a,h(f,-t.x,-t.y))),a}}class L{constructor(t,e,s,i,n,o){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=i,this.yMin=n,this.yMax=o}}const R=t=>10===t,B=t=>32===t;function v(t,e,s){const i=new Array,n=1/s.scale,o=s.maxLineWidth*n,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let f=h,c=0,d=0,l=f,m=l,g=0,u=1/0,x=0;for(;f!==r;){const{code:e,metrics:s}=t[f],n=Math.abs(s.top);if(R(e)||B(e)||(u=Math.min(u,n),x=Math.max(x,n+s.height)),R(e))f!==h&&(i.push(new L(t,l,f-a,c,u===1/0?0:u,x)),u=1/0,x=0),c=0,l=f+a,m=f+a,d=0;else if(B(e))m=f+a,d=0,g=s.advance,c+=s.advance;else if(c>o){if(m!==l){const e=m-2*a;c-=g,i.push(new L(t,l,e,c-d,u,x)),u=1/0,x=0,l=m,c=d}else i.push(new L(t,l,f-a,c,u,x)),u=1/0,x=0,l=f,m=f,c=0;c+=s.advance,d+=s.advance}else c+=s.advance,d+=s.advance;f+=a}const p=new L(t,l,f-a,c,u,x);return p.start>=0&&p.end<t.length&&i.push(p),i}function T(t,e){let s=0;for(let o=0;o<t.length;o++){const{width:e}=t[o];s=Math.max(e,s)}const i="underline"===e.decoration?m:0,n=t[0].yMin;return{x:0,y:n,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-n,width:s}}function j(t,e){const s=e.scale,i=new Array,n=t.sdfPadding,{faceInfo:o,glyphs:h,isRightToLeft:r}=t,c=v(h,r,e),d=c.length?T(c,e):{y:0,height:0},m=a(e.horizontalAlignment),g=f(e.verticalAlignment),u=2===g?1:0,x=u?0:g-1,p=(1-u)*-d.y+x*(d.height/2)+u*-l;for(let a=0;a<c.length;a++){const{start:o,end:r,width:f}=c[a];let d=-1*(m+1)*(f/2)-n;const l=(t.isRightToLeft?c.length-1-a:a)*e.lineHeight+p-n;c[a].startX=d,c[a].startY=l;for(let t=o;t<=r;t++){const e=h[t];if(R(e.code))continue;const n=new b(d+e.metrics.left,l-e.metrics.top,e,s);d+=e.metrics.advance,i.push(n)}}return new M(i,c,e,o)}export{b as ShapedGlyph,M as ShapingInfo,j as shapeGlyphs};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{getLabelPoint as x}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as b}from"../../../../../../../layers/graphics/featureConversionUtils.js";import v from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{importLazily as M}from"../../../../../../../symbols/cim/utils.js";import{tileSize as w,minMaxZoomPrecisionFactor as L}from"../../../definitions.js";import I from"../../../collisions/BoundingBox.js";import{LabelMetric as B}from"../../../collisions/LabelMetric.js";import{smoothPaths as S,pathDivide as z}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as G,processColorInput as j}from"../fill/meshWriterUtils.js";import{TextMeshWriter as D,maxLabelZoom as A}from"../text/TextMeshWriter.js";const F=1,k=0,R=128,$=w*w/16,C=M(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),O=M(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function Z(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(A-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function W(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(A-s)}`)}const U=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class X extends D{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),C.getImportPromise(),O.getImportPromise()])}_write(e,t,i,r,s){if(this._zoomLevel=r||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new B(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=C.module,s=O.module.constructFromFlatGeometry,o=t.readGeometryForDisplay(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const P=p(new _(d.toFlatGeometry())),b=y.fromOptimized(P,"esriGeometryPolygon",1),v=x(b)??n;this._writePoint(e,v[0],v[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new B(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<F);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:G(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new v,l=Y(a,o),c=Y(a,-o),h=b(c,"esriGeometryPolyline",!1,!1),m=b(l,"esriGeometryPolyline",!1,!1),u=S(m.paths,s.bounds.width),d=S(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,z(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,z(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=S(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,z(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=U(t),f=this._current.shaping.bounds.width/(1<<F),g=Math.sqrt(n||R)/(1<<F),p=Math.min(i,r-i),_=h.isMultiline?A:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+F-y),P=this._zoomLevel-x,b=h.bounds.width/2*2**P,v=Z(a,c,m,t,this._zoomLevel),M=W(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,v,M):s&&P<0?this._placeStraightAlong(e,u,v,M):"parallel"===o?this._placeStraightAlong(e,x,v,M):"curved"===o&&this._placeCurved(e,x,b,v,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(A,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+k;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+k}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+k;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+k}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+k))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],A)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u.bounds,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+k)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p.bounds,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,{sdfSize:d,sdfRadius:f}=this.evaluatedMeshParams.glyphs;this._writeQuad(e,t,i,r,{sdfSize:d,sdfRadius:f,texcoords:l,offsets:c,fontSize:h,haloSize:m,outlineSize:u,color:j(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)){const i=new I(t.x+s[0],t.y+s[1],t.width,t.height);e.metricBoxWrite(i)}}_packedZoom(e){return Math.floor(e*L)/L}_isVisible(e){let t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]);t=this._packedZoom(t),i=this._packedZoom(i);const r=this._packedZoom(this._zoomLevel);return t<=r&&r<=i}}function Y(e,t){const i=new v,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const b=p[0]*g[0]+p[1]*g[1];0!==b&&m(p,p,b),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{X as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,Z as lineLabelIdHash,W as lineLabelMetricHash};
2
+ import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{getLabelPoint as x}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as b}from"../../../../../../../layers/graphics/featureConversionUtils.js";import v from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{importLazily as M}from"../../../../../../../symbols/cim/utils.js";import{tileSize as w,minMaxZoomPrecisionFactor as L}from"../../../definitions.js";import I from"../../../collisions/BoundingBox.js";import{LabelMetric as B}from"../../../collisions/LabelMetric.js";import{smoothPaths as S,pathDivide as z}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as G,processColorInput as j}from"../fill/meshWriterUtils.js";import{TextMeshWriter as D,maxLabelZoom as A}from"../text/TextMeshWriter.js";const F=1,k=0,R=128,$=w*w/16,C=M(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),O=M(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function Z(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(A-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function W(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(A-s)}`)}const U=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class X extends D{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),C.getImportPromise(),O.getImportPromise()])}_write(e,t,i,r,s){if(this._zoomLevel=r||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new B(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=C.module,s=O.module.constructFromFlatGeometry,o=t.readGeometryForDisplay(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const P=p(new _(d.toFlatGeometry())),b=y.fromOptimized(P,"esriGeometryPolygon",1),v=x(b)??n;this._writePoint(e,v[0],v[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new B(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<F);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:G(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new v,l=Y(a,o),c=Y(a,-o),h=b(c,"esriGeometryPolyline",!1,!1),m=b(l,"esriGeometryPolyline",!1,!1),u=S(m.paths,s.bounds.width),d=S(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,z(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,z(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=S(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,z(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=U(t),f=this._current.shaping.bounds.width/(1<<F),g=Math.sqrt(n||R)/(1<<F),p=Math.min(i,r-i),_=h.isMultiline?A:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+F-y),P=this._zoomLevel-x,b=h.bounds.width/2*2**P,v=Z(a,c,m,t,this._zoomLevel),M=W(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,v,M):s&&P<0?this._placeStraightAlong(e,u,v,M):"parallel"===o?this._placeStraightAlong(e,x,v,M):"curved"===o&&this._placeCurved(e,x,b,v,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(A,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+k;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+k}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+k;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+k}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+k))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],A)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+k)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,{sdfSize:d,sdfRadius:f}=this.evaluatedMeshParams.glyphs;this._writeQuad(e,t,i,r,{sdfSize:d,sdfRadius:f,texcoords:l,offsets:c,fontSize:h,haloSize:m,outlineSize:u,color:j(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)&&t.bounds){const i=t.bounds,r=new I(i.x+s[0],i.y+s[1],i.width,i.height);e.metricBoxWrite(r)}}_packedZoom(e){return Math.floor(e*L)/L}_isVisible(e){let t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]);t=this._packedZoom(t),i=this._packedZoom(i);const r=this._packedZoom(this._zoomLevel);return t<=r&&r<=i}}function Y(e,t){const i=new v,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const b=p[0]*g[0]+p[1]*g[1];0!==b&&m(p,p,b),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{X as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,Z as lineLabelIdHash,W as lineLabelMetricHash};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{CIMMarkerPlacementHelper as i}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as s,getYDirection as r}from"../../../alignmentUtils.js";import{minMaxZoomPrecisionFactor as n,maxTextLineWidth as a,minTextLineWidth as l,magicLabelLineHeight as c}from"../../../definitions.js";import{shapeGlyphs as d}from"../../../mesh/templates/shapingUtils.js";import{getMinMaxZoom as h,processColorInput as f,packBitset as p}from"../fill/meshWriterUtils.js";import{MeshWriter as m}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as u,bitsetTextIsMapAligned as g}from"../shaders/constants.js";import{TextMeshTransformProps as x}from"./TextParams.js";import{DataType as y}from"../../../../../../webgl/enums.js";const S=28,_=[4,4],z=[16,4],P={topLeft:z,topRight:z,bottomLeft:z,bottomRight:z},b=[4,2],R=[4,6],T={topLeft:b,topRight:b,bottomLeft:R,bottomRight:R},B={topLeft:b,topRight:R,bottomLeft:b,bottomRight:R},k={topLeft:R,topRight:R,bottomLeft:_,bottomRight:_},M={topLeft:_,topRight:_,bottomLeft:R,bottomRight:R},L={topLeft:R,topRight:_,bottomLeft:R,bottomRight:_},w={topLeft:_,topRight:R,bottomLeft:_,bottomRight:R},A={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:n,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||S]},clipAngle:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>I(t||0)},referenceSymbol:{type:y.BYTE,count:4,packTessellation:(t,o)=>{const i=t.isLineLabel||!t.referenceBounds,n=s(i?"center":o.horizontalAlignment),a=r(i?"middle":o.verticalAlignment),{offsetX:l,offsetY:c,size:d}=i?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[e(l),-e(c),Math.round(e(d)),n+1<<2|a+1]}},visibility:{type:y.FLOAT,count:1,otherSource:!0}},attributes:{pos:{type:y.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:y.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>p([[u,t],[g,!!e]])},offset:{type:y.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},textureUV:{type:y.UNSIGNED_SHORT,count:2,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},color:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontAndReferenceSize:{type:y.UNSIGNED_SHORT,count:4,packPrecisionFactor:4,packTessellation:({fontSize:t,sdfSize:o,sdfRadius:i},{referenceSize:s})=>[Math.round(e(t)),Math.round(e(s??t)),o,i]},outlineColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>f(t)},haloColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>f(t)},outlineAndHaloSize:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:o})=>[Math.round(e(t)),Math.round(e(o))]}}};class v extends m{constructor(){super(...arguments),this.vertexSpec=A,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new x(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,o){const i=this._getShaping();if(!i)return;const s=1===this.evaluatedMeshParams.alignment,r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,o);if(o?.nextPath())return o.nextPoint(),this._writeGlyphs(t,r,o.x,o.y,i,0,void 0,{mapAligned:s});if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[n,a]=o.coords;return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex((e,o)=>this._writeGlyphs(t,r,e,o,i,0,void 0,{mapAligned:s}))}const n=e.readXForDisplay(),a=e.readYForDisplay();return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}_writePlacedTextMarkers(t,s,r,n){const a=n??o.fromFeatureSetReaderCIM(s);if(!a)return;const l=-1,c=i.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!c)return;const d=s.getDisplayId();let h=c.next();for(;null!=h;){const e=h.tx,o=-h.ty,i=-h.getAngle();this._writeGlyphs(t,d,e,o,r,i,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),h=c.next()}}_getShaping(o){const i=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const r=e(i.fontSize),n=e(i.offsetX),h=e(i.offsetY),f=s.glyphs.sdfSize,p=t(e(s.lineWidth),l,a),m=f/24*c*t(s.lineHeightRatio,.25,4);return d(s.glyphs,{scale:r/f,angle:i.postAngle,xOffset:n,yOffset:h,horizontalAlignment:s.horizontalAlignment,verticalAlignment:o||s.verticalAlignment,maxLineWidth:p,lineHeight:m,decoration:s.decoration,borderLineSizePx:e(s.boxBorderLineSize),hasBackground:!!s.boxBackgroundColor,useCIMAngleBehavior:s.useCIMAngleBehavior})}_writeGlyphs(t,o,i,s,r,n,a,l,c=!0){const d=this.evaluatedMeshParams,p=this._textMeshTransformProps,m=e(p.fontSize),u=p.haloSize,g=p.outlineSize,x=e(p.offsetX),y=e(p.offsetY),{sdfSize:S,sdfRadius:_}=d.glyphs,[z,P]=h(d.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const b=r.bounds,R=i+b.x+x,T=s+b.y-y,B=2*(d.minPixelBuffer?d.minPixelBuffer/m:1),k=Math.max(b.width,b.height)*B;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),c&&t.recordBounds(R,T,k,k),this._writeTextBox(t,o,i,s,r.textBox,a,l),t.recordEnd());for(const e of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),c&&t.recordBounds(R,T,k,k);const{texcoords:r,offsets:n}=e;this._writeQuad(t,o,i,s,{texcoords:r,offsets:n,fontSize:m,haloSize:u,outlineSize:g,sdfSize:S,sdfRadius:_,color:f(d.color),isBackground:!1,referenceBounds:a,minZoom:z,maxZoom:P,...l}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,o,i,s,r,n){const a=this.evaluatedMeshParams,{fontSize:l,haloSize:c,outlineSize:d}=this._textMeshTransformProps,{boxBackgroundColor:h,boxBorderLineColor:p,boxBorderLineSize:m}=a,{sdfSize:u,sdfRadius:g}=a.glyphs,x=!!p&&m>0,y={isBackground:!0,fontSize:l,haloSize:c,outlineSize:d,referenceBounds:r,sdfSize:u,sdfRadius:g,...n};h&&(this._writeQuad(t,e,o,i,{texcoords:P,offsets:s.main,color:f(h),...y}),x||(this._writeQuad(t,e,o,i,{texcoords:k,offsets:s.top,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:M,offsets:s.bot,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:L,offsets:s.left,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:w,offsets:s.right,color:f(h),...y}))),x&&(this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.top,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.bot,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.left,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.right,color:f(p),...y}))}_writeQuad(t,e,o,i,s){const r=t.vertexCount();this._writeVertex(t,e,o,i,s),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}const I=t=>Math.round(t*(254/360));export{v as TextMeshWriter,A as TextVertexSpec,S as maxLabelZoom};
2
+ import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{CIMMarkerPlacementHelper as i}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as s,getYDirection as r}from"../../../alignmentUtils.js";import{minMaxZoomPrecisionFactor as n,maxTextLineWidth as a,minTextLineWidth as l,magicLabelLineHeight as c}from"../../../definitions.js";import{shapeGlyphs as d}from"../../../mesh/templates/shapingUtils.js";import{getMinMaxZoom as h,processColorInput as f,packBitset as p}from"../fill/meshWriterUtils.js";import{MeshWriter as m}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as u,bitsetTextIsMapAligned as g}from"../shaders/constants.js";import{TextMeshTransformProps as x}from"./TextParams.js";import{DataType as y}from"../../../../../../webgl/enums.js";const S=28,_=[4,4],z=[16,4],P={topLeft:z,topRight:z,bottomLeft:z,bottomRight:z},b=[4,2],R=[4,6],T={topLeft:b,topRight:b,bottomLeft:R,bottomRight:R},B={topLeft:b,topRight:R,bottomLeft:b,bottomRight:R},k={topLeft:R,topRight:R,bottomLeft:_,bottomRight:_},M={topLeft:_,topRight:_,bottomLeft:R,bottomRight:R},L={topLeft:R,topRight:_,bottomLeft:R,bottomRight:_},w={topLeft:_,topRight:R,bottomLeft:_,bottomRight:R},A={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:n,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||S]},clipAngle:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>I(t||0)},referenceSymbol:{type:y.BYTE,count:4,packTessellation:(t,o)=>{const i=t.isLineLabel||!t.referenceBounds,n=s(i?"center":o.horizontalAlignment),a=r(i?"middle":o.verticalAlignment),{offsetX:l,offsetY:c,size:d}=i?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[e(l),-e(c),Math.round(e(d)),n+1<<2|a+1]}},visibility:{type:y.FLOAT,count:1,otherSource:!0}},attributes:{pos:{type:y.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:y.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>p([[u,t],[g,!!e]])},offset:{type:y.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},textureUV:{type:y.UNSIGNED_SHORT,count:2,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},color:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontAndReferenceSize:{type:y.UNSIGNED_SHORT,count:4,packPrecisionFactor:4,packTessellation:({fontSize:t,sdfSize:o,sdfRadius:i},{referenceSize:s})=>[Math.round(e(t)),Math.round(e(s??t)),o,i]},outlineColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>f(t)},haloColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>f(t)},outlineAndHaloSize:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:o})=>[Math.round(e(t)),Math.round(e(o))]}}};class v extends m{constructor(){super(...arguments),this.vertexSpec=A,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new x(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,o){const i=this._getShaping();if(!i)return;const s=1===this.evaluatedMeshParams.alignment,r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,o);if(o?.nextPath())return o.nextPoint(),this._writeGlyphs(t,r,o.x,o.y,i,0,void 0,{mapAligned:s});if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[n,a]=o.coords;return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex((e,o)=>this._writeGlyphs(t,r,e,o,i,0,void 0,{mapAligned:s}))}const n=e.readXForDisplay(),a=e.readYForDisplay();return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}_writePlacedTextMarkers(t,s,r,n){const a=n??o.fromFeatureSetReaderCIM(s);if(!a)return;const l=-1,c=i.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!c)return;const d=s.getDisplayId();let h=c.next();for(;null!=h;){const e=h.tx,o=-h.ty,i=-h.getAngle();this._writeGlyphs(t,d,e,o,r,i,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),h=c.next()}}_getShaping(o){const i=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const r=e(i.fontSize),n=e(i.offsetX),h=e(i.offsetY),f=s.glyphs.sdfSize,p=t(e(s.lineWidth),l,a),m=f/24*c*t(s.lineHeightRatio,.25,4);return d(s.glyphs,{scale:r/f,angle:i.postAngle,xOffset:n,yOffset:h,horizontalAlignment:s.horizontalAlignment,verticalAlignment:o||s.verticalAlignment,maxLineWidth:p,lineHeight:m,decoration:s.decoration,borderLineSizePx:e(s.boxBorderLineSize),hasBackground:!!s.boxBackgroundColor,useCIMAngleBehavior:s.useCIMAngleBehavior})}_writeGlyphs(t,o,i,s,r,n,a,l,c=!0){const d=this.evaluatedMeshParams,p=this._textMeshTransformProps,m=e(p.fontSize),u=p.haloSize,g=p.outlineSize,x=e(p.offsetX),y=e(p.offsetY),{sdfSize:S,sdfRadius:_}=d.glyphs,[z,P]=h(d.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const b=r.bounds,R=i+b.x+x,T=s+b.y-y,B=2*(d.minPixelBuffer?d.minPixelBuffer/m:1),k=Math.max(b.width,b.height)*B;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),c&&t.recordBounds(R,T,k,k),this._writeTextBox(t,o,i,s,r.textBox,a,l),t.recordEnd());for(const e of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),c&&t.recordBounds(R,T,k,k);const{texcoords:r,offsets:n}=e;this._writeQuad(t,o,i,s,{texcoords:r,offsets:n,fontSize:m,haloSize:u,outlineSize:g,sdfSize:S,sdfRadius:_,color:f(d.color),isBackground:!1,referenceBounds:a,minZoom:z,maxZoom:P,...l}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,o,i,s,r,n){const a=this.evaluatedMeshParams,{fontSize:l,haloSize:c,outlineSize:d}=this._textMeshTransformProps,{boxBackgroundColor:h,boxBorderLineColor:p,boxBorderLineSize:m}=a,{sdfSize:u,sdfRadius:g}=a.glyphs,x=!!p&&m>0,y={isBackground:!0,fontSize:l,haloSize:c,outlineSize:d,referenceBounds:r,sdfSize:u,sdfRadius:g,...n};h&&(this._writeQuad(t,e,o,i,{texcoords:P,offsets:s.main,color:f(h),...y}),x||(this._writeQuad(t,e,o,i,{texcoords:k,offsets:s.top,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:M,offsets:s.bot,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:L,offsets:s.left,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:w,offsets:s.right,color:f(h),...y}))),x&&(this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.top,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.bot,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.left,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.right,color:f(p),...y}))}_writeQuad(t,e,o,i,s){const r=t.vertexCount();this._writeVertex(t,e,o,i,s),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}const I=t=>Math.round(t*(256/360));export{v as TextMeshWriter,A as TextVertexSpec,S as maxLabelZoom};