@arcgis/core 5.2.0-next.70 → 5.2.0-next.71

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 (34) hide show
  1. package/arcgisGlobal.d.ts +0 -2
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/43de723f765ec8f268ac.js +1 -0
  4. package/assets/esri/core/workers/chunks/{7ca9c908432b1afa0367.js → 5f31b375971ab067121e.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{f5cf338cecfc81f23128.js → da484787bd9fd3b13d15.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{de3d0973cff1e0858c52.js → fc2cae359d571690d754.js} +4 -4
  7. package/chunks/GaussianSplatDepth.glsl.js +4 -4
  8. package/chunks/GlobalIllumination.glsl.js +7 -7
  9. package/chunks/Viewshed.glsl.js +9 -5
  10. package/config.js +1 -1
  11. package/interfaces.d.ts +0 -14
  12. package/kernel.js +1 -1
  13. package/package.json +1 -1
  14. package/support/revision.js +1 -1
  15. package/symbols/cim/TextRasterizer.js +1 -1
  16. package/symbols/cim/richTextUtils.js +1 -1
  17. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  18. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  19. package/views/3d/interactive/Manipulator3D.js +1 -1
  20. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  21. package/views/3d/webgl-engine/lib/GaussianSplatDepthRenderer.js +1 -1
  22. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
  23. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  24. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  25. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  26. package/views/3d/webgl-engine/parts/Model.js +1 -1
  27. package/views/3d/webgl-engine/shaders/GaussianSplatDepthPolicy.js +1 -1
  28. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +1 -1
  29. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  30. package/assets/esri/core/workers/chunks/7f4a592bcf4ecb55949a.js +0 -1
  31. package/popup/Feature.d.ts +0 -311
  32. package/popup/Feature.js +0 -2
  33. package/popup/Features.d.ts +0 -569
  34. package/popup/Features.js +0 -2
@@ -155,17 +155,17 @@
155
155
  // Get the normal of current fragment
156
156
  ivec2 iuv = ivec2(uv * vec2(textureSize(normalMap, 0)));
157
157
 
158
- vec4 normal4 = texelFetch(normalMap, iuv, 0);
158
+ vec4 normalTexel= texelFetch(normalMap, iuv, 0);
159
159
 
160
160
  // 0.0 alpha excludes the surface as a receiver (e.g. water)
161
- if (normal4.a == 0.0) {
161
+ if (normalTexel.a == 0.0) {
162
162
  fragGlobalIllumination = vec4(0.0, 0.0, 0.0, 1.0);
163
163
  fragWeight = vec2(0.0);
164
164
  return;
165
165
  }
166
166
 
167
- float receiverOpacity = normal4.a;
168
- vec3 normal = normalize(normal4.xyz * 2.0 - 1.0);
167
+ float receiverOpacity = normalTexel.a;
168
+ vec3 normal = normalize(normalTexel.xyz * 2.0 - 1.0);
169
169
 
170
170
  // Reconstruct view space position of current fragment
171
171
  float currentPixelDepth = linearizeDepth(depth);
@@ -1,11 +1,11 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{If as e,glsl as a}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{gaussianSplatFirstHitAlpha as s}from"../views/3d/webgl-engine/shaders/GaussianSplatDepthPolicy.js";import{GaussianSplatPerspectivePass as n,GaussianSplatFading as i,gaussianSplatPerspectiveVertex as t}from"../views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js";import{ShaderBuilder as d}from"../views/webgl/ShaderBuilder.js";function l(l){const{fadingEnabled:r}=l,o=new d,{vertex:u}=o;return o.include(n,l),l.fadingEnabled&&o.vertex.include(i),u.main.add(a`
2
+ import{If as e,glsl as a}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{gaussianSplatFirstHitAlpha as s}from"../views/3d/webgl-engine/shaders/GaussianSplatDepthPolicy.js";import{GaussianSplatPerspectivePass as n,GaussianSplatFading as i,gaussianSplatPerspectiveVertex as t}from"../views/3d/webgl-engine/shaders/GaussianSplatPass.glsl.js";import{ShaderBuilder as r}from"../views/webgl/ShaderBuilder.js";function d(d){const{fadingEnabled:l}=d,o=new r,{vertex:u}=o;return o.include(n,d),d.fadingEnabled&&o.vertex.include(i),d.writeNormals&&o.outputs.add("fragNormal","vec4",0),u.main.add(a`
3
3
  uint gaussianIndex = fetchOrderedGaussianIndex(uint(gl_InstanceID));
4
4
  uvec4 packedGaussian = fetchPackedGaussian(gaussianIndex);
5
5
 
6
6
  float opacity = unpackOpacity(packedGaussian);
7
7
 
8
- ${e(r,a`opacity = applyGaussianSplatFading(opacity, gaussianIndex);`)}
8
+ ${e(l,a`opacity = applyGaussianSplatFading(opacity, gaussianIndex);`)}
9
9
 
10
- ${t(l,s)}
11
- `),o}const r=Object.freeze(Object.defineProperty({__proto__:null,build:l},Symbol.toStringTag,{value:"Module"}));export{r as G,l as b};
10
+ ${t(d,s)}
11
+ `),d.writeNormals&&o.fragment.main.add("fragNormal = vec4(0.0);"),o}const l=Object.freeze(Object.defineProperty({__proto__:null,build:d},Symbol.toStringTag,{value:"Module"}));export{l as G,d as b};
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{ReadDepthLastFrame as a}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadDepthLastFrame.glsl.js";import{Gamma as t}from"../views/3d/webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import{addMainLightDirection as r}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{ScreenSpaceRayMarching as i}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js";import{CameraSpace as o}from"../views/3d/webgl-engine/core/shaderLibrary/util/CameraSpace.glsl.js";import{FloatBindUniform as l}from"../views/3d/webgl-engine/core/shaderModules/FloatBindUniform.js";import{FloatPassUniform as n}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as c,If as s}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Matrix4BindUniform as m}from"../views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js";import{Texture2DBindUniform as h}from"../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DPassUniform as d}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{GlobalIlluminationColorQuantization as u}from"../views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationColorQuantization.glsl.js";import{floatBlendReductionFactor as p}from"../views/3d/webgl-engine/shaders/floatBlendScale.glsl.js";import{ColorAttachment1 as g,SizedPixelFormat as f}from"../views/webgl/enums.js";import{NoParameters as x}from"../views/webgl/NoParameters.js";import{ShaderBuilder as v}from"../views/webgl/ShaderBuilder.js";const y=.01,M=.008,b=.002,w=.5,S=.02,W=.1,F=.008,D=.3,R=.008,B=150,I=.095,j=.008,C=60,z=2,G=.0039,P=.25,O=.012,T=0,$=6,E=.15,L=25,V=.15,U=.5,H=1,N=1,k=16;class Q extends x{constructor(){super(...arguments),this.projScale=1,this.scaleGlobalIllumination=1,this.accumulatedFrames=0,this.temporalSampleFrame=0,this.rayMarchMinReach=V,this.rayMarchMaxReach=U,this.rayMarchWorldReach=L,this.rayMarchMinReachEmissionWeight=H,this.rayMarchMaxReachEmissionWeight=N,this.rayMarchMaxSteps=k,this.colorBleedWeight=E,this.highQualityIdleColorBlendStart=D}}function _(x){const D=new v,E=D.fragment;D.include(e),D.include(o),r(E),E.include(a),E.include(t),E.include(u),D.include(i,x),E.uniforms.add(new d("normalMap",e=>e.normalTexture),new d("depthMap",e=>e.depthTexture),new h("lastFrameColorTexture",e=>e.reprojection.lastFrameColor?.getTexture()),new h("lastFrameDepthTexture",e=>e.reprojection.lastFrameDepth?.attachment),new h("lastFrameGlobalIlluminationTexture",e=>e.globalIllumination?.getTexture()),new h("lastFrameGlobalIlluminationWeightTexture",e=>e.globalIllumination?.getTexture(g)),new m("reprojectionViewMatrix",e=>e.reprojection.viewMatrix),new m("view",e=>e.camera.viewMatrix),new n("accumulatedFrames",e=>e.accumulatedFrames),new n("temporalSampleFrame",e=>e.temporalSampleFrame),new n("scaleGlobalIllumination",e=>e.scaleGlobalIllumination)),E.uniforms.add(new n("rayMarchMinReach",e=>e.rayMarchMinReach),new n("rayMarchMaxReach",e=>e.rayMarchMaxReach),new n("rayMarchWorldReach",e=>e.rayMarchWorldReach),new n("rayMarchMinReachEmissionWeight",e=>e.rayMarchMinReachEmissionWeight),new n("rayMarchMaxReachEmissionWeight",e=>e.rayMarchMaxReachEmissionWeight),new n("rayMarchMaxSteps",e=>e.rayMarchMaxSteps),new n("colorBleedWeight",e=>e.colorBleedWeight),new n("highQualityIdleColorBlendStart",e=>e.highQualityIdleColorBlendStart));const{hasEmission:L,hasColor:V}=x;return L&&E.uniforms.add(new l("inputScale",e=>e.reprojection.lastFrameEmission?.attachment.descriptor.internalFormat===f.RGBA8?p:1),new h("lastFrameEmissionTexture",e=>e.reprojection.lastFrameEmission?.attachment)),E.code.add(c`
2
+ import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{ReadDepthLastFrame as a}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadDepthLastFrame.glsl.js";import{Gamma as t}from"../views/3d/webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import{addMainLightDirection as r}from"../views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import{ScreenSpaceRayMarching as i}from"../views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js";import{CameraSpace as o}from"../views/3d/webgl-engine/core/shaderLibrary/util/CameraSpace.glsl.js";import{FloatBindUniform as l}from"../views/3d/webgl-engine/core/shaderModules/FloatBindUniform.js";import{FloatPassUniform as n}from"../views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js";import{glsl as c,If as s}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{Matrix4BindUniform as m}from"../views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js";import{Texture2DBindUniform as h}from"../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DPassUniform as d}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{GlobalIlluminationColorQuantization as u}from"../views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationColorQuantization.glsl.js";import{floatBlendReductionFactor as p}from"../views/3d/webgl-engine/shaders/floatBlendScale.glsl.js";import{ColorAttachment1 as g,SizedPixelFormat as f}from"../views/webgl/enums.js";import{NoParameters as x}from"../views/webgl/NoParameters.js";import{ShaderBuilder as v}from"../views/webgl/ShaderBuilder.js";const y=.01,M=.008,b=.002,w=.5,S=.02,W=.1,F=.008,D=.3,R=.008,B=150,I=.095,j=.008,C=60,z=2,G=.0039,P=.25,T=.012,O=0,$=6,E=.15,L=25,V=.15,U=.5,H=1,N=1,k=16;class Q extends x{constructor(){super(...arguments),this.projScale=1,this.scaleGlobalIllumination=1,this.accumulatedFrames=0,this.temporalSampleFrame=0,this.rayMarchMinReach=V,this.rayMarchMaxReach=U,this.rayMarchWorldReach=L,this.rayMarchMinReachEmissionWeight=H,this.rayMarchMaxReachEmissionWeight=N,this.rayMarchMaxSteps=k,this.colorBleedWeight=E,this.highQualityIdleColorBlendStart=D}}function _(x){const D=new v,E=D.fragment;D.include(e),D.include(o),r(E),E.include(a),E.include(t),E.include(u),D.include(i,x),E.uniforms.add(new d("normalMap",e=>e.normalTexture),new d("depthMap",e=>e.depthTexture),new h("lastFrameColorTexture",e=>e.reprojection.lastFrameColor?.getTexture()),new h("lastFrameDepthTexture",e=>e.reprojection.lastFrameDepth?.attachment),new h("lastFrameGlobalIlluminationTexture",e=>e.globalIllumination?.getTexture()),new h("lastFrameGlobalIlluminationWeightTexture",e=>e.globalIllumination?.getTexture(g)),new m("reprojectionViewMatrix",e=>e.reprojection.viewMatrix),new m("view",e=>e.camera.viewMatrix),new n("accumulatedFrames",e=>e.accumulatedFrames),new n("temporalSampleFrame",e=>e.temporalSampleFrame),new n("scaleGlobalIllumination",e=>e.scaleGlobalIllumination)),E.uniforms.add(new n("rayMarchMinReach",e=>e.rayMarchMinReach),new n("rayMarchMaxReach",e=>e.rayMarchMaxReach),new n("rayMarchWorldReach",e=>e.rayMarchWorldReach),new n("rayMarchMinReachEmissionWeight",e=>e.rayMarchMinReachEmissionWeight),new n("rayMarchMaxReachEmissionWeight",e=>e.rayMarchMaxReachEmissionWeight),new n("rayMarchMaxSteps",e=>e.rayMarchMaxSteps),new n("colorBleedWeight",e=>e.colorBleedWeight),new n("highQualityIdleColorBlendStart",e=>e.highQualityIdleColorBlendStart));const{hasEmission:L,hasColor:V}=x;return L&&E.uniforms.add(new l("inputScale",e=>e.reprojection.lastFrameEmission?.attachment.descriptor.internalFormat===f.RGBA8?p:1),new h("lastFrameEmissionTexture",e=>e.reprojection.lastFrameEmission?.attachment)),E.code.add(c`
3
3
  float computeIdleColorBlendWeight(float accumulatedFrames) {
4
4
  float idleColorBlendProgress = clamp(
5
5
  accumulatedFrames / ${c.float(B)},
@@ -90,17 +90,17 @@ import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/Scr
90
90
  // Get the normal of current fragment
91
91
  ivec2 iuv = ivec2(uv * vec2(textureSize(normalMap, 0)));
92
92
 
93
- vec4 normal4 = texelFetch(normalMap, iuv, 0);
93
+ vec4 normalTexel= texelFetch(normalMap, iuv, 0);
94
94
 
95
95
  // 0.0 alpha excludes the surface as a receiver (e.g. water)
96
- if (normal4.a == 0.0) {
96
+ if (normalTexel.a == 0.0) {
97
97
  fragGlobalIllumination = vec4(0.0, 0.0, 0.0, 1.0);
98
98
  fragWeight = vec2(0.0);
99
99
  return;
100
100
  }
101
101
 
102
- float receiverOpacity = normal4.a;
103
- vec3 normal = normalize(normal4.xyz * 2.0 - 1.0);
102
+ float receiverOpacity = normalTexel.a;
103
+ vec3 normal = normalize(normalTexel.xyz * 2.0 - 1.0);
104
104
 
105
105
  // Reconstruct view space position of current fragment
106
106
  float currentPixelDepth = linearizeDepth(depth);
@@ -162,9 +162,9 @@ import{ScreenSpacePass as e}from"../views/3d/webgl-engine/core/shaderLibrary/Scr
162
162
  ${s(V,c`
163
163
  float colorBleedScale = mix(
164
164
  1.0,
165
- ${c.float(T)},
165
+ ${c.float(O)},
166
166
  smoothstep(
167
- ${c.float(O)},
167
+ ${c.float(T)},
168
168
  highQualityIdleColorBlendStart,
169
169
  colorBlendWeight
170
170
  )
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{invertOrIdentity as e}from"../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as o}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as t}from"../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as s,UNIT_Z as a}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{ScreenSpacePass as r}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{ReadDepth as n}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js";import{PiUtils as d}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PiUtils.glsl.js";import{LocalFromScreenSpaceDrawParameters as l,localFromScreenSpace as h}from"../views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js";import{Float2DrawUniform as v}from"../views/3d/webgl-engine/core/shaderModules/Float2DrawUniform.js";import{Float3DrawUniform as c}from"../views/3d/webgl-engine/core/shaderModules/Float3DrawUniform.js";import{FloatDrawUniform as w}from"../views/3d/webgl-engine/core/shaderModules/FloatDrawUniform.js";import{FloatsDrawUniform as f}from"../views/3d/webgl-engine/core/shaderModules/FloatsDrawUniform.js";import{glsl as p}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{IntegerDrawUniform as m}from"../views/3d/webgl-engine/core/shaderModules/IntegerDrawUniform.js";import{Matrix4BindUniform as g}from"../views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js";import{Matrix4sDrawUniform as u}from"../views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js";import{Texture2DBindUniform as x}from"../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DDrawUniform as V}from"../views/3d/webgl-engine/core/shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as b}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{NoParameters as M}from"../views/webgl/NoParameters.js";import{ShaderBuilder as D}from"../views/webgl/ShaderBuilder.js";class P extends M{}class F extends l{constructor(){super(...arguments),this.observerOffset=s(),this.fovs=t(),this.headingAndTilt=t(),this.upVector=a,this.targetVector=s(),this.projectionMatrices=i.flat(),this.viewMatrices=i.flat(),this.volumeOffset=0}}function S(i){const o=new D,t=o.fragment;o.include(r),o.include(h),o.outputs.add("fragColor","vec4",0),t.include(n),t.include(d),t.uniforms.add(new g("inverseProjectionMatrix",e=>e.camera.inverseProjectionMatrix),new g("inverseViewNormalMatrix",({camera:i})=>e(T,i.viewInverseTransposeMatrix)),new x("depthTexture",e=>e.mainDepth),new b("normalMap",e=>e.normals),new c("viewshedObserverOffset",e=>e.observerOffset),new c("viewshedTargetVector",e=>e.targetVector),new c("viewshedUpVector",e=>e.upVector),new v("viewshedFOVs",e=>e.fovs),new v("viewshedHeadingAndTilt",e=>e.headingAndTilt),new v("viewshedNearFar",e=>e.shadowMap?.nearFar??[1,100]),new w("viewshedVolumeOffset",e=>e.volumeOffset),new V("viewshedShadowMap",e=>e.shadowMap?.depthTexture),new u("viewshedProjectionMatrices",e=>e.projectionMatrices,6),new u("viewshedViewMatrices",e=>e.viewMatrices,6),new m("viewshedNumFaces",e=>e.shadowMap?.numActiveFaces??0),new f("viewshedAtlasRegions",24,e=>e.shadowMap?.atlasRegions.flat()??U));const s=.5;return t.constants.add("viewshedAlpha","float",s),t.constants.add("visibleColor","vec4",[0,s,0,s]),t.constants.add("occludedColor","vec4",[s,0,0,s]),t.code.add(p`vec2 getViewshedUv(vec4 worldPosition, int face) {
2
+ import{invertOrIdentity as e}from"../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as o}from"../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as t}from"../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as s,UNIT_Z as a}from"../core/libs/gl-matrix-2/factories/vec3f64.js";import{ScreenSpacePass as r}from"../views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js";import{ReadDepth as n}from"../views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js";import{PiUtils as d}from"../views/3d/webgl-engine/core/shaderLibrary/shading/PiUtils.glsl.js";import{LocalFromScreenSpaceDrawParameters as l,localFromScreenSpace as v}from"../views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js";import{Float2DrawUniform as h}from"../views/3d/webgl-engine/core/shaderModules/Float2DrawUniform.js";import{Float3DrawUniform as c}from"../views/3d/webgl-engine/core/shaderModules/Float3DrawUniform.js";import{FloatDrawUniform as w}from"../views/3d/webgl-engine/core/shaderModules/FloatDrawUniform.js";import{FloatsDrawUniform as f}from"../views/3d/webgl-engine/core/shaderModules/FloatsDrawUniform.js";import{glsl as m}from"../views/3d/webgl-engine/core/shaderModules/glsl.js";import{IntegerDrawUniform as p}from"../views/3d/webgl-engine/core/shaderModules/IntegerDrawUniform.js";import{Matrix4BindUniform as g}from"../views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js";import{Matrix4sDrawUniform as u}from"../views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js";import{Texture2DBindUniform as x}from"../views/3d/webgl-engine/core/shaderModules/Texture2DBindUniform.js";import{Texture2DDrawUniform as V}from"../views/3d/webgl-engine/core/shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as b}from"../views/3d/webgl-engine/core/shaderModules/Texture2DPassUniform.js";import{NoParameters as M}from"../views/webgl/NoParameters.js";import{ShaderBuilder as D}from"../views/webgl/ShaderBuilder.js";class P extends M{}class F extends l{constructor(){super(...arguments),this.observerOffset=s(),this.fovs=t(),this.headingAndTilt=t(),this.upVector=a,this.targetVector=s(),this.projectionMatrices=i.flat(),this.viewMatrices=i.flat(),this.volumeOffset=0}}function T(i){const o=new D,t=o.fragment;o.include(r),o.include(v),o.outputs.add("fragColor","vec4",0),t.include(n),t.include(d),t.uniforms.add(new g("inverseProjectionMatrix",e=>e.camera.inverseProjectionMatrix),new g("inverseViewNormalMatrix",({camera:i})=>e(S,i.viewInverseTransposeMatrix)),new x("depthTexture",e=>e.mainDepth),new b("normalMap",e=>e.normals),new c("viewshedObserverOffset",e=>e.observerOffset),new c("viewshedTargetVector",e=>e.targetVector),new c("viewshedUpVector",e=>e.upVector),new h("viewshedFOVs",e=>e.fovs),new h("viewshedHeadingAndTilt",e=>e.headingAndTilt),new h("viewshedNearFar",e=>e.shadowMap?.nearFar??[1,100]),new w("viewshedVolumeOffset",e=>e.volumeOffset),new V("viewshedShadowMap",e=>e.shadowMap?.depthTexture),new u("viewshedProjectionMatrices",e=>e.projectionMatrices,6),new u("viewshedViewMatrices",e=>e.viewMatrices,6),new p("viewshedNumFaces",e=>e.shadowMap?.numActiveFaces??0),new f("viewshedAtlasRegions",24,e=>e.shadowMap?.atlasRegions.flat()??U));const s=.5;return t.constants.add("viewshedAlpha","float",s),t.constants.add("visibleColor","vec4",[0,s,0,s]),t.constants.add("occludedColor","vec4",[s,0,0,s]),t.code.add(m`vec2 getViewshedUv(vec4 worldPosition, int face) {
3
3
  mat4 viewshedMatrix = viewshedProjectionMatrices[face];
4
4
  vec4 viewshedUv4 = viewshedMatrix * worldPosition;
5
5
  vec3 viewshedUv = viewshedUv4.xyz / viewshedUv4.w;
@@ -116,12 +116,16 @@ return true;
116
116
  return false;
117
117
  }
118
118
  float normalCosAngle(float linearDepth, vec3 localPosition) {
119
- vec4 normal4 = texture(normalMap, uv);
120
- vec3 normalN = normalize(normal4.xyz * 2.0 - 1.0);
119
+ ivec2 normalIuv = ivec2(uv * vec2(textureSize(normalMap, 0)));
120
+ vec4 normalTexel = texelFetch(normalMap, normalIuv, 0);
121
+ if (normalTexel.a == 0.0) {
122
+ return -1.0;
123
+ }
124
+ vec3 normalN = normalize(normalTexel.xyz * 2.0 - 1.0);
121
125
  vec3 normal = normalize((inverseViewNormalMatrix * vec4(normalN, 1.0)).xyz);
122
126
  vec3 viewingDir = normalize(localPosition);
123
127
  return dot(normal, viewingDir);
124
- }`),t.main.add(p`float depth = depthFromTexture(depthTexture, uv);
128
+ }`),t.main.add(m`float depth = depthFromTexture(depthTexture, uv);
125
129
  if (depth >= 1.0 || depth <= 0.0) {
126
130
  return;
127
131
  }
@@ -140,4 +144,4 @@ float cosAngle = normalCosAngle(linearDepth, localPosition.xyz);
140
144
  float threshold = -0.01;
141
145
  if (cosAngle > threshold) {
142
146
  fragColor = occludedColor;
143
- }`),i.hasEmissive&&(o.outputs.add("fragEmission","vec4",1),t.constants.add("viewshedEmissiveAlpha","float",s**.1),t.main.add("fragEmission = vec4(vec3(0.0), viewshedEmissiveAlpha);")),o}const T=o(),U=new Array(24).fill(0),y=Object.freeze(Object.defineProperty({__proto__:null,ViewshedDrawParameters:F,ViewshedPassParameters:P,build:S},Symbol.toStringTag,{value:"Module"}));export{P as V,F as a,y as b,S as c};
147
+ }`),i.hasEmissive&&(o.outputs.add("fragEmission","vec4",1),t.constants.add("viewshedEmissiveAlpha","float",s**.1),t.main.add("fragEmission = vec4(vec3(0.0), viewshedEmissiveAlpha);")),o}const S=o(),U=new Array(24).fill(0),y=Object.freeze(Object.defineProperty({__proto__:null,ViewshedDrawParameters:F,ViewshedPassParameters:P,build:T},Symbol.toStringTag,{value:"Module"}));export{P as V,F as a,y as b,T as c};
package/config.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="5.2.0-next.70";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
2
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="5.2.0-next.71";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
package/interfaces.d.ts CHANGED
@@ -6383,20 +6383,6 @@ declare namespace __esri {
6383
6383
  export type popupExpressionInfo = import("./popup/ExpressionInfo.js").default;
6384
6384
  export const popupExpressionInfo: typeof import("./popup/ExpressionInfo.js").default;
6385
6385
 
6386
- /** @deprecated since 5.0. Refactor using \@arcgis/codemod */
6387
- export type PopupFeatureProperties = import("./popup/Feature.js").FeatureProperties;
6388
-
6389
- /** @deprecated since 5.0. Refactor using \@arcgis/codemod */
6390
- export type PopupFeature = import("./popup/Feature.js").default;
6391
- export const PopupFeature: typeof import("./popup/Feature.js").default;
6392
-
6393
- /** @deprecated since 5.0. Refactor using \@arcgis/codemod */
6394
- export type PopupFeaturesProperties = import("./popup/Features.js").FeaturesProperties;
6395
-
6396
- /** @deprecated since 5.0. Refactor using \@arcgis/codemod */
6397
- export type PopupFeatures = import("./popup/Features.js").default;
6398
- export const PopupFeatures: typeof import("./popup/Features.js").default;
6399
-
6400
6386
  /** @deprecated since 5.0. Refactor using \@arcgis/codemod */
6401
6387
  export type FieldInfoProperties = import("./popup/FieldInfo.js").FieldInfoProperties;
6402
6388
 
package/kernel.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.2";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.2.0-next.70",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
2
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.2";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.2.0-next.71",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.0-next.70",
3
+ "version": "5.2.0-next.71",
4
4
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
5
5
  "keywords": [
6
6
  "ArcGIS",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const d="20260807",c="43add78fd01debfbebc7d1425f2392480ec35cdc";export{d as buildDate,c as commitHash};
2
+ const a="20260808",c="081fde3c3263c915ae51917fab8a6278a695a75a";export{a as buildDate,c as commitHash};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{pt2px as t}from"../../core/screenUtils.js";import{backgroundPadding as e}from"../support/textUtils.js";function i(t){return`rgb(${t.slice(0,3).toString()})`}function n(t){return`rgba(${t.slice(0,3).toString()},${t[3]})`}class r{constructor(t){t&&(this._textRasterizationCanvas=t)}rasterizeRichText(t,r){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const h=this._textRasterizationCanvas,a=h.getContext("2d",{willReadFrequently:!0}),l=this._layoutRichTextRuns(a,t,r);this._parameters=r,this._lineHeight=Math.max(...l.map(t=>t.height),this._measureLineHeight(r));const{decoration:d,weight:c}=r.font;this._lineThroughWidthOffset=d&&"line-through"===d?.1*this._lineHeight:0;const _=null!=r.backgroundColor||null!=r.borderLine,g=_?e:0,u=Math.max(...l.map(t=>t.width),0)+2*g,f=l.reduce((t,e)=>t+e.height,0)+2*g;if(h.width=u+2*this._lineThroughWidthOffset,h.height=f,0===h.width||0===h.height)return h.width=h.height=1,{size:[0,0],image:new Uint32Array(0),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,canvas:h};this._renderedWidth=u,this._renderedHeight=f,this._renderedOutlineSize=(r.outline.size||0)*r.pixelRatio,this._renderedHaloSize=(r.halo.size||0)*r.pixelRatio,this._lineThroughWidthOffset*=r.pixelRatio;const m=(r.outline&&r.outline.color)??[0,0,0,0],p=r.color??[0,0,0,0],x=r.halo&&r.halo.color?r.halo.color:[0,0,0,0];this._fillStyle=n(p),this._outlineStyle=n(m),this._haloStyle=i(x);const z=this._renderedOutlineSize,w=this._renderedHaloSize;a.save(),a.clearRect(0,0,h.width,h.height);const R=g*r.pixelRatio,y=o("left",this._renderedWidth-2*R,w+z)+R,S=w+z+R;let b=this._lineThroughWidthOffset,v=0;if(_){a.save();const t=r.backgroundColor??[0,0,0,0],e=r.borderLine?.color??[0,0,0,0],i=2*(r.borderLine?.size??0);a.fillStyle=n(t),a.strokeStyle=n(e),a.lineWidth=i,a.fillRect(0,0,h.width,h.height),a.strokeRect(0,0,h.width,h.height),a.restore()}v+=S,b+=y,w>0&&this._renderRichTextOutline(a,l,b,v,r,this._renderedHaloSize+this._renderedOutlineSize),z>0&&this._renderRichTextOutline(a,l,b,v,r,this._renderedOutlineSize);for(const e of l){let t=b;"center"===r.horizontalAlignment?t+=(this._renderedWidth-2*R-e.width)/2:"right"===r.horizontalAlignment&&(t+=this._renderedWidth-2*R-e.width-w-z);let i=t;for(const r of e.segments)s(a,r.parameters,"left"),w>0&&(a.globalCompositeOperation="destination-out",a.fillStyle="rgb(0, 0, 0)",a.fillText(r.text,i,v),a.globalCompositeOperation="source-over"),a.fillStyle=n(r.parameters.color??p),a.fillText(r.text,i,v),i+=r.width;if(d&&"none"!==d){const i=this._renderedWidth;this._renderedWidth=e.width,a.textAlign="left",this._renderDecoration(a,t,v,d,c),this._renderedWidth=i}v+=e.height}a.restore();const W=this._renderedWidth+2*this._lineThroughWidthOffset,C=this._renderedHeight,H=a.getImageData(0,0,W,C),T=new Uint8Array(H.data);if(r.premultiplyColors){let t;for(let e=0;e<T.length;e+=4)t=T[e+3]/255,T[e]=T[e]*t,T[e+1]=T[e+1]*t,T[e+2]=T[e+2]*t}let O,L;switch(r.horizontalAlignment){case"left":O=-.5;break;case"right":O=.5;break;default:O=0}switch(r.verticalAlignment){case"bottom":L=-.5;break;case"top":L=.5;break;case"baseline":L=-1/6;break;default:L=0}return{size:[W,C],image:new Uint32Array(T.buffer),sdf:!1,simplePattern:!1,anchorX:O,anchorY:L,canvas:h}}rasterizeText(t,r){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const h=this._textRasterizationCanvas,a=h.getContext("2d",{willReadFrequently:!0});s(a,r),this._parameters=r,this._textLines=t.split(/\r?\n/),this._lineHeight=this._computeLineHeight();const{decoration:l,weight:d}=r.font;this._lineThroughWidthOffset=l&&"line-through"===l?.1*this._lineHeight:0;const c=null!=r.backgroundColor||null!=r.borderLine,_=c?e:0,g=this._computeTextWidth(a,r)+2*_,u=this._lineHeight*this._textLines.length+2*_;if(h.width=g+2*this._lineThroughWidthOffset,h.height=u,0===h.width||0===h.height)return h.width=h.height=1,{size:[0,0],image:new Uint32Array(0),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,canvas:h};this._renderedLineHeight=Math.round(this._lineHeight),this._renderedOutlineSize=(r.outline.size||0)*r.pixelRatio,this._renderedHaloSize=(r.halo.size||0)*r.pixelRatio,this._renderedWidth=g,this._renderedHeight=u,this._lineThroughWidthOffset*=r.pixelRatio;const f=(r.outline&&r.outline.color)??[0,0,0,0],m=r.color??[0,0,0,0],p=r.halo&&r.halo.color?r.halo.color:[0,0,0,0];this._fillStyle=n(m),this._outlineStyle=n(f),this._haloStyle=i(p);const x=this._renderedLineHeight,z=this._renderedOutlineSize,w=this._renderedHaloSize;a.save(),a.clearRect(0,0,h.width,h.height),s(a,r);const R=_*r.pixelRatio,y=o(a.textAlign,this._renderedWidth-2*R,this._renderedHaloSize+this._renderedOutlineSize)+R,S=w+z+R,b=w>0;let v=this._lineThroughWidthOffset,W=0;if(c){a.save();const t=r.backgroundColor??[0,0,0,0],e=r.borderLine?.color??[0,0,0,0],i=2*(r.borderLine?.size??0);a.fillStyle=n(t),a.strokeStyle=n(e),a.lineWidth=i,a.fillRect(0,0,h.width,h.height),a.strokeRect(0,0,h.width,h.height),a.restore()}b&&this._renderHalo(a,y,S,v,W,r),z>0&&this._renderOutline(a,y,S,v,W,r),W+=S,v+=y;for(const e of this._textLines)b?(a.globalCompositeOperation="destination-out",a.fillStyle="rgb(0, 0, 0)",a.fillText(e,v,W),a.globalCompositeOperation="source-over",a.fillStyle=this._fillStyle,a.fillText(e,v,W)):(a.fillStyle=this._fillStyle,a.fillText(e,v,W)),l&&"none"!==l&&this._renderDecoration(a,v,W,l,d),W+=x;a.restore();const C=this._renderedWidth+2*this._lineThroughWidthOffset,H=this._renderedHeight,T=a.getImageData(0,0,C,H),O=new Uint8Array(T.data);if(r.premultiplyColors){let t;for(let e=0;e<O.length;e+=4)t=O[e+3]/255,O[e]=O[e]*t,O[e+1]=O[e+1]*t,O[e+2]=O[e+2]*t}let L,k;switch(r.horizontalAlignment){case"left":L=-.5;break;case"right":L=.5;break;default:L=0}switch(r.verticalAlignment){case"bottom":k=-.5;break;case"top":k=.5;break;case"baseline":k=-1/6;break;default:k=0}return{size:[C,H],image:new Uint32Array(O.buffer),sdf:!1,simplePattern:!1,anchorX:L,anchorY:k,canvas:h}}_renderHalo(t,e,i,n,r,h){const o=this._renderedWidth,a=this._renderedHeight;this._outlineRasterizationCanvas||(this._outlineRasterizationCanvas=document.createElement("canvas")),this._outlineRasterizationCanvas.width=o,this._outlineRasterizationCanvas.height=a;const l=this._outlineRasterizationCanvas,d=l.getContext("2d");d.clearRect(0,0,o,a),s(d,h);const{decoration:c,weight:_}=h.font;d.fillStyle=this._haloStyle,d.strokeStyle=this._haloStyle,d.lineJoin="round",this._renderOutlineNative(d,e,i,c,_,this._renderedHaloSize+this._renderedOutlineSize),t.globalAlpha=this._parameters.halo.color[3],t.drawImage(l,0,0,o,a,n,r,o,a),t.globalAlpha=1}_renderOutline(t,e,i,n,r,h){const o=this._renderedWidth,a=this._renderedHeight;this._outlineRasterizationCanvas||(this._outlineRasterizationCanvas=document.createElement("canvas")),this._outlineRasterizationCanvas.width=o,this._outlineRasterizationCanvas.height=a;const l=this._outlineRasterizationCanvas,d=l.getContext("2d");d.clearRect(0,0,o,a),s(d,h);const{decoration:c,weight:_}=h.font;d.fillStyle=this._outlineStyle,d.strokeStyle=this._outlineStyle,d.lineJoin="round",this._renderOutlineNative(d,e,i,c,_,this._renderedOutlineSize),t.globalAlpha=this._parameters.outline.color[3],t.drawImage(l,0,0,o,a,n,r,o,a),t.globalAlpha=1}_renderOutlineNative(t,e,i,n,r,s){const h=this._renderedLineHeight;for(const o of this._textLines){const a=2*s,l=5,d=.1;for(let s=0;s<l;s++){const h=(1-(l-1)*d+s*d)*a;t.lineWidth=h,t.strokeText(o,e,i),n&&"none"!==n&&this._renderDecoration(t,e,i,n,r,h)}i+=h}}computeTextSize(t,e){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const i=this._textRasterizationCanvas,n=i.getContext("2d");s(n,e),this._parameters=e,this._textLines=t.split(/\r?\n/),this._lineHeight=this._computeLineHeight();const r=this._computeTextWidth(n,e),h=this._lineHeight*this._textLines.length;return i.width=r,i.height=h,[r*e.pixelRatio,h*e.pixelRatio]}computeRichTextSize(t,e){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const i=this._textRasterizationCanvas.getContext("2d"),n=this._layoutRichTextRuns(i,t,e),r=Math.max(...n.map(t=>t.width),0),s=n.reduce((t,e)=>t+e.height,0);return[r*e.pixelRatio,s*e.pixelRatio]}_renderRichTextOutline(t,e,i,n,r,h){const o=this._renderedWidth,a=this._renderedHeight;this._outlineRasterizationCanvas||(this._outlineRasterizationCanvas=document.createElement("canvas")),this._outlineRasterizationCanvas.width=o,this._outlineRasterizationCanvas.height=a;const l=this._outlineRasterizationCanvas,d=l.getContext("2d");d.clearRect(0,0,o,a),d.fillStyle=h===this._renderedOutlineSize?this._outlineStyle:this._haloStyle,d.strokeStyle=d.fillStyle,d.lineJoin="round";let c=n;for(const _ of e){let t=i;"center"===r.horizontalAlignment?t+=(this._renderedWidth-_.width)/2:"right"===r.horizontalAlignment&&(t+=this._renderedWidth-_.width-this._renderedHaloSize-this._renderedOutlineSize);let e=t;for(const i of _.segments){s(d,i.parameters,"left");const t=2*h,n=5,r=.1;for(let s=0;s<n;s++){const h=1-(n-1)*r+s*r;d.lineWidth=h*t,d.strokeText(i.text,e,c)}e+=i.width}if(r.font.decoration&&"none"!==r.font.decoration){const e=this._renderedWidth;this._renderedWidth=_.width,d.textAlign="left",this._renderDecoration(d,t,c,r.font.decoration,r.font.weight,2*h),this._renderedWidth=e}c+=_.height}h===this._renderedOutlineSize?t.globalAlpha=this._parameters.outline.color[3]:t.globalAlpha=this._parameters.halo.color[3],t.drawImage(l,0,0,o,a,this._lineThroughWidthOffset,0,o,a),t.globalAlpha=1}_layoutRichTextRuns(t,e,i){const n=[{segments:[],width:0,height:this._measureLineHeight(i)}];for(const r of e){const e=r.text.split(/\r?\n/),s=h(i,r);for(let r=0;r<e.length;r++){const h=e[r],o=n[n.length-1];if(h.length>0){const e=this._measureTextWidth(t,h,s);o.segments.push({text:h,width:e,parameters:s}),o.width+=e,o.height=Math.max(o.height,this._measureLineHeight(s))}r<e.length-1&&n.push({segments:[],width:0,height:this._measureLineHeight(i)})}}return n}_measureTextWidth(t,e,i){const n=this._parameters,r=this._textLines;this._parameters=i,this._textLines=[e],s(t,i,"left");const h=this._computeTextWidth(t,i);return this._parameters=n,this._textLines=r,h}_measureLineHeight(t){const e=this._parameters;this._parameters=t;const i=this._computeLineHeight();return this._parameters=e,i}_computeTextWidth(e,i){let n=0;for(const t of this._textLines)n=Math.max(n,e.measureText(t).width);const r=i.font;return("italic"===r.style||"oblique"===r.style||"string"==typeof r.weight&&("bold"===r.weight||"bolder"===r.weight)||"number"==typeof r.weight&&r.weight>600)&&(n+=.3*e.measureText("w").width),n+=2*t(this._parameters.halo.size),Math.round(n)}_computeLineHeightBase(){return 1.275*this._parameters.size}_computeLineHeight(){let e=this._computeLineHeightBase();const i=this._parameters.font.decoration;return i&&"underline"===i&&(e*=1.3),Math.round(e+2*t(this._parameters.halo.size))}_renderDecoration(t,e,i,n,r,s){let h=.9*this._lineHeight;const o="bold"===r?.06:"bolder"===r?.09:.04;switch(t.textAlign){case"center":e-=this._renderedWidth/2;break;case"right":e-=this._renderedWidth}const a=t.textBaseline;if("underline"===n)switch(h=.9*this._computeLineHeightBase(),a){case"top":i+=h;break;case"middle":i+=h/2}else if("line-through"===n)switch(a){case"top":i+=h/1.5;break;case"middle":i+=h/3}const l=s?1.5*s:Math.ceil(h*o);t.save(),t.beginPath(),t.strokeStyle=t.fillStyle,t.lineWidth=l,t.moveTo(e-this._lineThroughWidthOffset,i),t.lineTo(e+this._renderedWidth+2*this._lineThroughWidthOffset,i),t.stroke(),t.restore()}}function s(e,i,n){const r=Math.max(i.size,.5),s=i.font,h=`${s.style} ${s.weight} ${t(r).toFixed(1)}px ${s.family}, sans-serif`;e.font=h,e.textBaseline="top";let o=n??"left";if(!n)switch(i.horizontalAlignment){case"left":default:o="left";break;case"right":o="right";break;case"center":o="center"}e.textAlign=o}function h(t,e){return{...t,color:e.color??t.color,font:{...t.font,family:e.font.family??t.font.family,style:e.font.style??t.font.style,weight:e.font.weight??t.font.weight},size:e.fontSize}}function o(t,e,i){return"center"===t?.5*e:"right"===t?e-i:i}export{r as default};
2
+ import{pt2px as e}from"../../core/screenUtils.js";import{backgroundPadding as t}from"../support/textUtils.js";function i(e){return`rgb(${e.slice(0,3).toString()})`}function n(e){return`rgba(${e.slice(0,3).toString()},${e[3]})`}class r{constructor(e){e&&(this._textRasterizationCanvas=e)}rasterizeRichText(e,r){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const h=this._textRasterizationCanvas,o=h.getContext("2d",{willReadFrequently:!0}),l=this._layoutRichTextRuns(o,e,r);this._parameters=r,this._lineHeight=Math.max(...l.map(e=>e.height),this._measureLineHeight(r));const{decoration:d,weight:c}=r.font;this._lineThroughWidthOffset=d&&"line-through"===d?.1*this._lineHeight:0;const _=null!=r.backgroundColor||null!=r.borderLine,g=_?t:0,u=Math.max(...l.map(e=>e.width),0)+2*g,f=l.reduce((e,t)=>e+t.height,0)+2*g;if(h.width=u+2*this._lineThroughWidthOffset,h.height=f,0===h.width||0===h.height)return h.width=h.height=1,{size:[0,0],image:new Uint32Array(0),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,canvas:h};this._renderedWidth=u,this._renderedHeight=f,this._renderedOutlineSize=(r.outline.size||0)*r.pixelRatio,this._renderedHaloSize=(r.halo.size||0)*r.pixelRatio,this._lineThroughWidthOffset*=r.pixelRatio;const m=(r.outline&&r.outline.color)??[0,0,0,0],p=r.color??[0,0,0,0],x=r.halo&&r.halo.color?r.halo.color:[0,0,0,0];this._fillStyle=n(p),this._outlineStyle=n(m),this._haloStyle=i(x);const z=this._renderedOutlineSize,S=this._renderedHaloSize;o.save(),o.clearRect(0,0,h.width,h.height);const R=g*r.pixelRatio,w=a("left",this._renderedWidth-2*R,S+z)+R,y=S+z+R;let b=this._lineThroughWidthOffset,v=0;if(_){o.save();const e=r.backgroundColor??[0,0,0,0],t=r.borderLine?.color??[0,0,0,0],i=2*(r.borderLine?.size??0);o.fillStyle=n(e),o.strokeStyle=n(t),o.lineWidth=i,o.fillRect(0,0,h.width,h.height),o.strokeRect(0,0,h.width,h.height),o.restore()}v+=y,b+=w,S>0&&this._renderRichTextOutline(o,l,b,v,r,this._renderedHaloSize+this._renderedOutlineSize),z>0&&this._renderRichTextOutline(o,l,b,v,r,this._renderedOutlineSize);for(const t of l){let e=b;"center"===r.horizontalAlignment?e+=(this._renderedWidth-2*R-t.width)/2:"right"===r.horizontalAlignment&&(e+=this._renderedWidth-2*R-t.width-S-z);let i=e;for(const r of t.segments)s(o,r.parameters,"left",r.characterSpacing),S>0&&(o.globalCompositeOperation="destination-out",o.fillStyle="rgb(0, 0, 0)",this._renderRichTextSegment(o,r,i,v,"fill"),o.globalCompositeOperation="source-over"),o.fillStyle=n(r.parameters.color??p),this._renderRichTextSegment(o,r,i,v,"fill"),i+=r.width;if(d&&"none"!==d){const i=this._renderedWidth;this._renderedWidth=t.width,o.textAlign="left",this._renderDecoration(o,e,v,d,c),this._renderedWidth=i}v+=t.height}o.restore();const W=this._renderedWidth+2*this._lineThroughWidthOffset,C=this._renderedHeight,T=o.getImageData(0,0,W,C),H=new Uint8Array(T.data);if(r.premultiplyColors){let e;for(let t=0;t<H.length;t+=4)e=H[t+3]/255,H[t]=H[t]*e,H[t+1]=H[t+1]*e,H[t+2]=H[t+2]*e}let O,k;switch(r.horizontalAlignment){case"left":O=-.5;break;case"right":O=.5;break;default:O=0}switch(r.verticalAlignment){case"bottom":k=-.5;break;case"top":k=.5;break;case"baseline":k=-1/6;break;default:k=0}return{size:[W,C],image:new Uint32Array(H.buffer),sdf:!1,simplePattern:!1,anchorX:O,anchorY:k,canvas:h}}rasterizeText(e,r){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const h=this._textRasterizationCanvas,o=h.getContext("2d",{willReadFrequently:!0});s(o,r),this._parameters=r,this._textLines=e.split(/\r?\n/),this._lineHeight=this._computeLineHeight();const{decoration:l,weight:d}=r.font;this._lineThroughWidthOffset=l&&"line-through"===l?.1*this._lineHeight:0;const c=null!=r.backgroundColor||null!=r.borderLine,_=c?t:0,g=this._computeTextWidth(o,r)+2*_,u=this._lineHeight*this._textLines.length+2*_;if(h.width=g+2*this._lineThroughWidthOffset,h.height=u,0===h.width||0===h.height)return h.width=h.height=1,{size:[0,0],image:new Uint32Array(0),sdf:!1,simplePattern:!1,anchorX:0,anchorY:0,canvas:h};this._renderedLineHeight=Math.round(this._lineHeight),this._renderedOutlineSize=(r.outline.size||0)*r.pixelRatio,this._renderedHaloSize=(r.halo.size||0)*r.pixelRatio,this._renderedWidth=g,this._renderedHeight=u,this._lineThroughWidthOffset*=r.pixelRatio;const f=(r.outline&&r.outline.color)??[0,0,0,0],m=r.color??[0,0,0,0],p=r.halo&&r.halo.color?r.halo.color:[0,0,0,0];this._fillStyle=n(m),this._outlineStyle=n(f),this._haloStyle=i(p);const x=this._renderedLineHeight,z=this._renderedOutlineSize,S=this._renderedHaloSize;o.save(),o.clearRect(0,0,h.width,h.height),s(o,r);const R=_*r.pixelRatio,w=a(o.textAlign,this._renderedWidth-2*R,this._renderedHaloSize+this._renderedOutlineSize)+R,y=S+z+R,b=S>0;let v=this._lineThroughWidthOffset,W=0;if(c){o.save();const e=r.backgroundColor??[0,0,0,0],t=r.borderLine?.color??[0,0,0,0],i=2*(r.borderLine?.size??0);o.fillStyle=n(e),o.strokeStyle=n(t),o.lineWidth=i,o.fillRect(0,0,h.width,h.height),o.strokeRect(0,0,h.width,h.height),o.restore()}b&&this._renderHalo(o,w,y,v,W,r),z>0&&this._renderOutline(o,w,y,v,W,r),W+=y,v+=w;for(const t of this._textLines)b?(o.globalCompositeOperation="destination-out",o.fillStyle="rgb(0, 0, 0)",o.fillText(t,v,W),o.globalCompositeOperation="source-over",o.fillStyle=this._fillStyle,o.fillText(t,v,W)):(o.fillStyle=this._fillStyle,o.fillText(t,v,W)),l&&"none"!==l&&this._renderDecoration(o,v,W,l,d),W+=x;o.restore();const C=this._renderedWidth+2*this._lineThroughWidthOffset,T=this._renderedHeight,H=o.getImageData(0,0,C,T),O=new Uint8Array(H.data);if(r.premultiplyColors){let e;for(let t=0;t<O.length;t+=4)e=O[t+3]/255,O[t]=O[t]*e,O[t+1]=O[t+1]*e,O[t+2]=O[t+2]*e}let k,L;switch(r.horizontalAlignment){case"left":k=-.5;break;case"right":k=.5;break;default:k=0}switch(r.verticalAlignment){case"bottom":L=-.5;break;case"top":L=.5;break;case"baseline":L=-1/6;break;default:L=0}return{size:[C,T],image:new Uint32Array(O.buffer),sdf:!1,simplePattern:!1,anchorX:k,anchorY:L,canvas:h}}_renderHalo(e,t,i,n,r,h){const o=this._renderedWidth,a=this._renderedHeight;this._outlineRasterizationCanvas||(this._outlineRasterizationCanvas=document.createElement("canvas")),this._outlineRasterizationCanvas.width=o,this._outlineRasterizationCanvas.height=a;const l=this._outlineRasterizationCanvas,d=l.getContext("2d");d.clearRect(0,0,o,a),s(d,h);const{decoration:c,weight:_}=h.font;d.fillStyle=this._haloStyle,d.strokeStyle=this._haloStyle,d.lineJoin="round",this._renderOutlineNative(d,t,i,c,_,this._renderedHaloSize+this._renderedOutlineSize),e.globalAlpha=this._parameters.halo.color[3],e.drawImage(l,0,0,o,a,n,r,o,a),e.globalAlpha=1}_renderOutline(e,t,i,n,r,h){const o=this._renderedWidth,a=this._renderedHeight;this._outlineRasterizationCanvas||(this._outlineRasterizationCanvas=document.createElement("canvas")),this._outlineRasterizationCanvas.width=o,this._outlineRasterizationCanvas.height=a;const l=this._outlineRasterizationCanvas,d=l.getContext("2d");d.clearRect(0,0,o,a),s(d,h);const{decoration:c,weight:_}=h.font;d.fillStyle=this._outlineStyle,d.strokeStyle=this._outlineStyle,d.lineJoin="round",this._renderOutlineNative(d,t,i,c,_,this._renderedOutlineSize),e.globalAlpha=this._parameters.outline.color[3],e.drawImage(l,0,0,o,a,n,r,o,a),e.globalAlpha=1}_renderOutlineNative(e,t,i,n,r,s){const h=this._renderedLineHeight;for(const o of this._textLines){const a=2*s,l=5,d=.1;for(let s=0;s<l;s++){const h=(1-(l-1)*d+s*d)*a;e.lineWidth=h,e.strokeText(o,t,i),n&&"none"!==n&&this._renderDecoration(e,t,i,n,r,h)}i+=h}}computeTextSize(e,t){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const i=this._textRasterizationCanvas,n=i.getContext("2d");s(n,t),this._parameters=t,this._textLines=e.split(/\r?\n/),this._lineHeight=this._computeLineHeight();const r=this._computeTextWidth(n,t),h=this._lineHeight*this._textLines.length;return i.width=r,i.height=h,[r*t.pixelRatio,h*t.pixelRatio]}computeRichTextSize(e,t){this._textRasterizationCanvas||(this._textRasterizationCanvas=document.createElement("canvas"));const i=this._textRasterizationCanvas.getContext("2d"),n=this._layoutRichTextRuns(i,e,t),r=Math.max(...n.map(e=>e.width),0),s=n.reduce((e,t)=>e+t.height,0);return[r*t.pixelRatio,s*t.pixelRatio]}_renderRichTextOutline(e,t,i,n,r,h){const o=this._renderedWidth,a=this._renderedHeight;this._outlineRasterizationCanvas||(this._outlineRasterizationCanvas=document.createElement("canvas")),this._outlineRasterizationCanvas.width=o,this._outlineRasterizationCanvas.height=a;const l=this._outlineRasterizationCanvas,d=l.getContext("2d");d.clearRect(0,0,o,a),d.fillStyle=h===this._renderedOutlineSize?this._outlineStyle:this._haloStyle,d.strokeStyle=d.fillStyle,d.lineJoin="round";let c=n;for(const _ of t){let e=i;"center"===r.horizontalAlignment?e+=(this._renderedWidth-_.width)/2:"right"===r.horizontalAlignment&&(e+=this._renderedWidth-_.width-this._renderedHaloSize-this._renderedOutlineSize);let t=e;for(const i of _.segments){s(d,i.parameters,"left",i.characterSpacing);const e=2*h,n=5,r=.1;for(let s=0;s<n;s++){const h=1-(n-1)*r+s*r;d.lineWidth=h*e,this._renderRichTextSegment(d,i,t,c,"stroke")}t+=i.width}if(r.font.decoration&&"none"!==r.font.decoration){const t=this._renderedWidth;this._renderedWidth=_.width,d.textAlign="left",this._renderDecoration(d,e,c,r.font.decoration,r.font.weight,2*h),this._renderedWidth=t}c+=_.height}h===this._renderedOutlineSize?e.globalAlpha=this._parameters.outline.color[3]:e.globalAlpha=this._parameters.halo.color[3],e.drawImage(l,0,0,o,a,this._lineThroughWidthOffset,0,o,a),e.globalAlpha=1}_layoutRichTextRuns(e,t,i){const n=[{segments:[],width:0,height:this._measureLineHeight(i)}];for(const r of t){const t=r.text.split(/\r?\n/),s=o(i,r);for(let h=0;h<t.length;h++){const o=t[h],a=n[n.length-1];if(o.length>0){const t=this._measureRichTextSegmentWidth(e,o,s,r.characterSpacing);a.segments.push({text:o,width:t,parameters:s,characterSpacing:r.characterSpacing}),a.width+=t,a.height=Math.max(a.height,this._measureLineHeight(s))}h<t.length-1&&n.push({segments:[],width:0,height:this._measureLineHeight(i)})}}return n}_measureTextWidthWithSpacing(e,t,i,n){const r=this._parameters,h=this._textLines;this._parameters=i,this._textLines=[t],s(e,i,"left",n);const o=this._computeTextWidth(e,i);return this._parameters=r,this._textLines=h,o}_measureRichTextSegmentWidth(e,t,i,n){return this._measureTextWidthWithSpacing(e,t,i,n)}_renderRichTextSegment(e,t,i,n,r){"fill"===r?e.fillText(t.text,i,n):e.strokeText(t.text,i,n)}_measureLineHeight(e){const t=this._parameters;this._parameters=e;const i=this._computeLineHeight();return this._parameters=t,i}_computeTextWidth(t,i){let n=0;for(const e of this._textLines)n=Math.max(n,t.measureText(e).width);const r=i.font;return("italic"===r.style||"oblique"===r.style||"string"==typeof r.weight&&("bold"===r.weight||"bolder"===r.weight)||"number"==typeof r.weight&&r.weight>600)&&(n+=.3*t.measureText("w").width),n+=2*e(this._parameters.halo.size),Math.round(n)}_computeLineHeightBase(){return 1.275*this._parameters.size}_computeLineHeight(){let t=this._computeLineHeightBase();const i=this._parameters.font.decoration;return i&&"underline"===i&&(t*=1.3),Math.round(t+2*e(this._parameters.halo.size))}_renderDecoration(e,t,i,n,r,s){let h=.9*this._lineHeight;const o="bold"===r?.06:"bolder"===r?.09:.04;switch(e.textAlign){case"center":t-=this._renderedWidth/2;break;case"right":t-=this._renderedWidth}const a=e.textBaseline;if("underline"===n)switch(h=.9*this._computeLineHeightBase(),a){case"top":i+=h;break;case"middle":i+=h/2}else if("line-through"===n)switch(a){case"top":i+=h/1.5;break;case"middle":i+=h/3}const l=s?1.5*s:Math.ceil(h*o);e.save(),e.beginPath(),e.strokeStyle=e.fillStyle,e.lineWidth=l,e.moveTo(t-this._lineThroughWidthOffset,i),e.lineTo(t+this._renderedWidth+2*this._lineThroughWidthOffset,i),e.stroke(),e.restore()}}function s(t,i,n,r=0){const s=Math.max(i.size,.5),o=i.font,a=`${o.style} ${o.weight} ${e(s).toFixed(1)}px ${o.family}, sans-serif`;t.font=a,t.textBaseline="top",h(t,r);let l=n??"left";if(!n)switch(i.horizontalAlignment){case"left":default:l="left";break;case"right":l="right";break;case"center":l="center"}t.textAlign=l}function h(e,t){e.letterSpacing=t>0?`${t}em`:"0px"}function o(e,t){return{...e,color:t.color??e.color,font:{...e.font,family:t.font.family??e.font.family,style:t.font.style??e.font.style,weight:t.font.weight??e.font.weight},size:t.fontSize}}function a(e,t,i){return"center"===e?.5*t:"right"===e?t-i:i}export{r as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import t from"../../Color.js";import{fromCIMFontStyle as n}from"./utils.js";const e=/([A-Za-z_][\w-]*)\s*=\s*(['"])(.*?)\2/g,o=/&(amp|lt|gt|quot|apos);/g,r=/<\s*\/?\s*(?:CLR|BOL|_BOL|ITA|_ITA|FNT)\b/i;function i(t){return r.test(t)}function s(t){if(!t.supportsRichText||!t.textString.includes("<"))return null;const n=u(t),e=[],o=[];let r=l(n),i="",s=!1;const c=t.textString,g=()=>{if(!i)return;const t=f(i);if(!t)return void(i="");const n=o[o.length-1];n&&a(n,r)?n.text+=t:o.push({text:t,font:{...r.font},fontSize:r.fontSize,color:r.color}),i=""};let b=0;for(;b<c.length;){const t=c[b];if("<"!==t){i+=t,b++;continue}const n=c.indexOf(">",b+1);if(-1===n)return null;const o=h(c.slice(b+1,n));if(!o)return null;if(s=!0,g(),o.isEnd){const t=e.pop();if(!t||t.name!==o.name)return null;r=t.previous}else{const t=l(r);r=m(r,o),e.push({name:o.name,previous:t})}b=n+1}return e.length?null:(g(),s?o.filter(t=>t.text.length>0):null)}function u(t){return{font:{...t.font},fontSize:t.symbol?.height&&!isNaN(t.symbol.height)?t.symbol.height:10}}function l(t){return{font:{...t.font},fontSize:t.fontSize,color:t.color}}function a(t,n){return t.fontSize===n.fontSize&&t.font.family===n.font.family&&t.font.style===n.font.style&&t.font.weight===n.font.weight&&c(t.color,n.color)}function c(t,n){return t===n||!!t&&!!n&&t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function f(t){return t.replaceAll(o,(t,n)=>{switch(n){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";default:return t}})}function h(t){const n=t.trim();if(!n)return null;const o=n.startsWith("/"),r=o?n.slice(1).trim():n,i=/^([A-Za-z_][\w-]*)/.exec(r);if(!i)return null;const s=i[1],u=r.slice(s.length),l={};let a;for(e.lastIndex=0;a=e.exec(u);)l[a[1]]=a[3];return{isEnd:o,name:s,attributes:l}}function m(t,n){const e=l(t);switch(n.name.toUpperCase()){case"BOL":e.font.weight="bold";break;case"_BOL":e.font.weight="normal";break;case"ITA":e.font.style="italic";break;case"_ITA":e.font.style="normal";break;case"FNT":g(e,n.attributes);break;case"CLR":e.color=b(n.attributes)}return e}function g(t,e){const{name:o,style:r,size:i,scale:s,wght:u,ital:l}=e;if(o&&(t.font.family=o),r){const e=n(r);t.font.style=e.style,t.font.weight=e.weight}if(u){const n=Number(u);t.font.weight=n>=600?"bold":"normal"}if(l){const n=Number(l);isNaN(n)||(t.font.style=0!==n?"italic":"normal")}if(i){const n=Number(i);!isNaN(n)&&n>0&&(t.fontSize=n)}if(s){const n=Number(s);!isNaN(n)&&n>0&&(t.fontSize*=n/100)}}function b(n){if(n.hex){const e=t.fromHex(n.hex)?.toArray();if(e){const t="alpha"in n?y(n.alpha):e[3];return[e[0],e[1],e[2],t]}}if("red"in n||"green"in n||"blue"in n)return[p(n.red),p(n.green),p(n.blue),y(n.alpha)];const e=N(n.cyan),o=N(n.magenta),r=N(n.yellow),i=N(n.black),s=y(n.alpha),u=N(n.tint,100)/100,l=1-i;return[Math.round(255*(1-e)*l*u),Math.round(255*(1-o)*l*u),Math.round(255*(1-r)*l*u),s]}function p(t){const n=Number(t);return d(isNaN(n)?0:n)}function N(t,n=0){const e=Number(t);return x((isNaN(e)?n:e)/100)}function y(t){return Math.round(255*N(t,100))}function d(t){return Math.max(0,Math.min(255,Math.round(t)))}function x(t){return Math.max(0,Math.min(1,t))}export{i as hasRichTextFormattingTags,s as parseRichTextRuns};
2
+ import t from"../../Color.js";import{fromCIMFontStyle as n}from"./utils.js";const e=/([A-Za-z_][\w-]*)\s*=\s*(['"])(.*?)\2/g,r=/&(amp|lt|gt|quot|apos);/g,o=/<\s*\/?\s*(?:CLR|BOL|_BOL|ITA|_ITA|FNT|CHR)\b/i;function i(t){return o.test(t)}function a(t){if(!t.supportsRichText||!t.textString.includes("<"))return null;const n=c(t),e=[],r=[];let o=s(n),i="",a=!1;const l=t.textString,g=()=>{if(!i)return;const t=f(i);if(!t)return void(i="");const n=r[r.length-1];n&&u(n,o)?n.text+=t:r.push({text:t,font:{...o.font},fontSize:o.fontSize,characterSpacing:o.characterSpacing,color:o.color}),i=""};let p=0;for(;p<l.length;){const t=l[p];if("<"!==t){i+=t,p++;continue}const n=l.indexOf(">",p+1);if(-1===n)return null;const r=h(l.slice(p+1,n));if(!r)return null;if(a=!0,g(),r.isEnd){const t=e.pop();if(!t||t.name!==r.name)return null;o=t.previous}else{const t=s(o);o=m(o,r),e.push({name:r.name,previous:t})}p=n+1}return e.length?null:(g(),a?r.filter(t=>t.text.length>0):null)}function c(t){return{font:{...t.font},fontSize:t.symbol?.height&&!isNaN(t.symbol.height)?t.symbol.height:10,characterSpacing:0}}function s(t){return{font:{...t.font},fontSize:t.fontSize,characterSpacing:t.characterSpacing,color:t.color}}function u(t,n){return t.fontSize===n.fontSize&&t.characterSpacing===n.characterSpacing&&t.font.family===n.font.family&&t.font.style===n.font.style&&t.font.weight===n.font.weight&&l(t.color,n.color)}function l(t,n){return t===n||!!t&&!!n&&t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function f(t){return t.replaceAll(r,(t,n)=>{switch(n){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";default:return t}})}function h(t){const n=t.trim();if(!n)return null;const r=n.startsWith("/"),o=r?n.slice(1).trim():n,i=/^([A-Za-z_][\w-]*)/.exec(o);if(!i)return null;const a=i[1],c=o.slice(a.length),s={};let u;for(e.lastIndex=0;u=e.exec(c);)s[u[1]]=u[3];return{isEnd:r,name:a,attributes:s}}function m(t,n){const e=s(t);switch(n.name.toUpperCase()){case"BOL":e.font.weight="bold";break;case"_BOL":e.font.weight="normal";break;case"ITA":e.font.style="italic";break;case"_ITA":e.font.style="normal";break;case"FNT":p(e,n.attributes);break;case"CLR":e.color=b(n.attributes);break;case"CHR":g(e,n.attributes)}return e}function g(t,n){const e=Number(n.spacing);!isNaN(e)&&e>=0&&(t.characterSpacing=e/100)}function p(t,e){const{name:r,style:o,size:i,scale:a,wght:c,ital:s}=e;if(r&&(t.font.family=r),o){const e=n(o);t.font.style=e.style,t.font.weight=e.weight}if(c){const n=Number(c);t.font.weight=n>=600?"bold":"normal"}if(s){const n=Number(s);isNaN(n)||(t.font.style=0!==n?"italic":"normal")}if(i){const n=Number(i);!isNaN(n)&&n>0&&(t.fontSize=n)}if(a){const n=Number(a);!isNaN(n)&&n>0&&(t.fontSize*=n/100)}}function b(n){if(n.hex){const e=t.fromHex(n.hex)?.toArray();if(e){const t="alpha"in n?y(n.alpha):e[3];return[e[0],e[1],e[2],t]}}if("red"in n||"green"in n||"blue"in n)return[N(n.red),N(n.green),N(n.blue),y(n.alpha)];const e=S(n.cyan),r=S(n.magenta),o=S(n.yellow),i=S(n.black),a=y(n.alpha),c=S(n.tint,100)/100,s=1-i;return[Math.round(255*(1-e)*s*c),Math.round(255*(1-r)*s*c),Math.round(255*(1-o)*s*c),a]}function N(t){const n=Number(t);return d(isNaN(n)?0:n)}function S(t,n=0){const e=Number(t);return x((isNaN(e)?n:e)/100)}function y(t){return Math.round(255*S(t,100))}function d(t){return Math.max(0,Math.min(255,Math.round(t)))}function x(t){return Math.max(0,Math.min(1,t))}export{i as hasRichTextFormattingTags,a as parseRichTextRuns};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../request.js";import{bidiText as t}from"../../../../core/BidiText.js";import{getFullyQualifiedFontName as s}from"../../../../core/fontUtils.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{throwIfNotAbortError as a}from"../../../../core/promiseUtils.js";import{loadTextModule as r}from"../../../../libs/text/loadTextModule.js";import{parseRichTextRuns as h}from"../../../../symbols/cim/richTextUtils.js";import{sdfRadiusComplex as n,sdfBufferGlyphSDFCreator as o,sdfSizeComplex as c,sdfBufferServer as p,sdfRadiusSimple as l,sdfSizeSimple as f}from"./definitions.js";import{decorGlyphRect as g}from"./GlyphMosaic.js";import{GlyphSDFCreator as d}from"./GlyphSDFCreator.js";import _ from"./GlyphSource.js";import y from"./Rect.js";import u from"./RectangleBinPack.js";import{hashMosaic as m}from"./TextureManager.js";import{charCodes as w}from"./Utils.js";const S=.25,C="arial-unicode-ms-regular",G=/[\u0695\u0698\u06a9\u06af\u06b5\u06be\u06c6\u06cc\u06ce\u06d5\u06ca]|\p{Script=Thai}|\p{Script=Lao}|\p{Script=Tamil}|\p{Script=Khmer}/u,P=new Set(["Noto Sans Khmer","Noto Sans Lao","Noto Sans Myanmar","Noto Sans Thai"]),x=()=>i.getLogger("esri.views.MapView"),b=(e,t="")=>x().warnOnce(e,t);class R{constructor(){this._glyphSources=new Map,this._snapCoords=!0,this._currentPage=0,this._faces=new Map,this._facePromises=new Map,this._pbfRangePromises=new Map,this._glyphCache=new Map,this._pbfGlyphCache=new Map,this._invalidFonts=new Set,this._preloadCache={},this._glyphSDFCreator=new d({sdfSizePx:c,sdfBufferPx:o,radius:n,cutoff:S})}set remoteClient(e){this._client=e.createInvokeProxy();const t=this._client.getOptions();this._inited=this._init(t)}async rasterizeText(e,t,s){await this._inited;const i=t.symbol?h(t):null;if(i){return{type:"rich-glyphs",runs:(await Promise.all(i.map(async t=>({fontSize:t.fontSize,color:t.color,glyphs:await this._rasterizeTextRun(e,t.font,t.text,s)})))).filter(e=>null!=e.glyphs)}}return this._rasterizeTextRun(e,t.font,t.textString,s)}async _rasterizeTextRun(e,t,i,a){const r=s(t),h=this._invalidFonts.has(r),n=!!has("esri-2d-force-complex-shaping"),o=!!has("esri-2d-complex-shaping")&&G.test(i),c=P.has(t.family),p=n||o||c,l=h?C:r;let f=await this.getGlyphItems(i,p,e,l,!1,a);return f||(b(`Font ${r} is not available on the web, using "Arial Unicode MS Regular"`),this._invalidFonts.add(r),f=await this.getGlyphItems(i,p,e,C,!1,a)),f}async getGlyphItems(e,s,i,a,r,h){await this._inited;const g=this._getSource(i),d=s?c:f,_=s?n:l,y=s?o:p;let u,m,S;if(has("esri-2d-stabilize-glyphs")&&await this.preloadASCIIGlyphCache(g,a).catch(()=>{}),s){const t=await this._getFace(g,a);if(!t)return null;let s=this._glyphCache.get(a);s||(s=new Map,this._glyphCache.set(a,s));const{shaping:i,isRTL:r}=this._shape(t,e);S=r,u=i.map(e=>this._getShapedGlyph(t,s,e)),m={baseline:t.baseline()/d,midline:t.midline()/d}}else{let s=this._pbfGlyphCache.get(a);s||(s=new Map,this._pbfGlyphCache.set(a,s));const[i,n,o]=t(e),c=w(i);try{await this._fetchRanges(g,a,c,h)}catch{return null}S=n,u=c.map(e=>this._getPBFGlyph(s,g,a,e,r)).filter(e=>!!e)}const C=u.filter(e=>e.needsRecord);return C.length>0&&await this._client.recordGlyphs(C),{type:"glyphs",glyphs:u,faceInfo:m,isRightToLeft:S,sdfSize:d,sdfRadius:_,sdfPadding:y}}async _init(e){const{width:t,height:s,snapCoords:i}=await e;this._glyphCache=new Map,this._pbfGlyphCache=new Map,this._binPack=new u(t,s),this._snapCoords=i,this._currentPage=0,this._initDecorationGlyphs()}_getShapedGlyph(e,t,s){let i,a,r=t.get(s.glyphId);if(!r){i=this._glyphSDFCreator.draw(e,s.glyphId);const h=this._glyphSDFCreator.sdfBufferPx;r={mosaicItem:{rect:this._recordGlyph(i?.rect,h),page:this._currentPage,sdf:!0,textureBinding:m(1,this._currentPage,!0)},glyphRect:i?.rect??{width:0,height:0,top:0,left:0}},t.set(s.glyphId,r),a=!0}return{mosaicItem:r.mosaicItem,rect:r.glyphRect,shaping:{xAdvance:s.xAdvance,yAdvance:s.yAdvance,xOffset:s.xOffset,yOffset:s.yOffset},code:s.isNewline?10:s.isWhitespace?32:NaN,sdf:i,needsRecord:a}}_getPBFGlyph(e,t,s,i,a=!1){let r,h,n=e.get(i);if(!n){const c=t.getRange(s,i),p=c?.getRect(i),l=c?.getShaping(i),f=c?.getBitmap(i);if(a&&(!p||!l))return;if(!p||!l)return j(i);r=f&&{buffer:f,rect:p},n={mosaicItem:{rect:f?this._recordGlyph(p,o):new y(0,0,0,0),sdf:!0,page:this._currentPage,textureBinding:m(1,this._currentPage,!0)},rect:p,shaping:l,code:i},h=!0,e.set(i,n)}const{mosaicItem:c,rect:p,shaping:l}=n;return{mosaicItem:c,rect:p,shaping:l,code:i,sdf:r,needsRecord:h}}_shape(e,s){const i=this._glyphSDFCreator.sdfSizePx,[a,r,h]=t(s,!1),n=new Uint32Array(Array.from(a).map((e,t)=>h.levels[h.targetToSource[t]]));return{shaping:e.shape(a,n,i),isRTL:r}}async _getFace(t,s,i){if(this._faces.has(s))return this._faces.get(s);const a=t.woffURL(s);return await M(this._facePromises,s,async()=>{const t=await e(a,{responseType:"array-buffer",...i}),h=(await r()).Face.parseWoff2(new Uint8Array(t.data));this._faces.set(s,h)}),this._faces.get(s)}_getSource(e){return this._glyphSources.has(e)||this._glyphSources.set(e,new _(e)),this._glyphSources.get(e)}async _fetchRanges(e,t,s,i){const a=I(s),r=[];a.forEach(s=>{r.push(this._fetchRange(e,t,s,i))}),await Promise.all(r)}async _fetchRange(e,t,s,i){if(s>256)return;const a=t+s;return M(this._pbfRangePromises,a,()=>e.fetchRange(t,s,i))}_allocNewPage(){this._currentPage++,this._binPack=new u(this._binPack.width,this._binPack.height),this._initDecorationGlyphs()}_recordGlyph(e,t){const s=this._binPack;if(!e||0===e.width)return new y;const i=e.width+2*t,a=e.height+2*t;let r=i,h=a;if(this._snapCoords){r+=i%4?4-i%4:4,h+=a%4?4-a%4:4}const n=s.allocate(r,h);return n.isEmpty?(this._allocNewPage(),s.allocate(r,h)):n}_initDecorationGlyphs(){this._recordGlyph(g,p),this._recordGlyph(g,p)}preloadASCIIGlyphCache(e,t){const s=this._preloadCache[t];if(null!=s)return s;const i=e.preloadASCIIRange(t).then(async()=>{let s=this._pbfGlyphCache.get(t);s||(s=new Map,this._pbfGlyphCache.set(t,s));for(let a=0;a<256;a++)this._getPBFGlyph(s,e,t,a);const i=Array.from(this._pbfGlyphCache.get(t).values());await this._client.recordGlyphs(i)},e=>{throw delete this._preloadCache[t],e});return this._preloadCache[t]=i,i}}function I(e){const t=new Set;for(const s of e)t.add(Math.floor(s/256));return t}function M(e,t,s){return e.has(t)||e.set(t,s().finally(()=>{e.delete(t)}).catch(e=>{a(e)})),e.get(t)}const j=e=>({mosaicItem:{rect:new y(0,0,0,0),sdf:!0,page:0},rect:{left:0,width:0,height:0,top:0},shaping:{xAdvance:0,yAdvance:0,xOffset:0,yOffset:0},code:e});export{R as default};
2
+ import e from"../../../../request.js";import{bidiText as t}from"../../../../core/BidiText.js";import{getFullyQualifiedFontName as s}from"../../../../core/fontUtils.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{throwIfNotAbortError as a}from"../../../../core/promiseUtils.js";import{loadTextModule as r}from"../../../../libs/text/loadTextModule.js";import{parseRichTextRuns as h}from"../../../../symbols/cim/richTextUtils.js";import{sdfRadiusComplex as n,sdfBufferGlyphSDFCreator as o,sdfSizeComplex as c,sdfBufferServer as p,sdfRadiusSimple as l,sdfSizeSimple as f}from"./definitions.js";import{decorGlyphRect as g}from"./GlyphMosaic.js";import{GlyphSDFCreator as d}from"./GlyphSDFCreator.js";import _ from"./GlyphSource.js";import y from"./Rect.js";import u from"./RectangleBinPack.js";import{hashMosaic as m}from"./TextureManager.js";import{charCodes as w}from"./Utils.js";const S=.25,C="arial-unicode-ms-regular",G=/[\u0695\u0698\u06a9\u06af\u06b5\u06be\u06c6\u06cc\u06ce\u06d5\u06ca]|\p{Script=Thai}|\p{Script=Lao}|\p{Script=Tamil}|\p{Script=Khmer}/u,P=new Set(["Noto Sans Khmer","Noto Sans Lao","Noto Sans Myanmar","Noto Sans Thai"]),x=()=>i.getLogger("esri.views.MapView"),b=(e,t="")=>x().warnOnce(e,t);class R{constructor(){this._glyphSources=new Map,this._snapCoords=!0,this._currentPage=0,this._faces=new Map,this._facePromises=new Map,this._pbfRangePromises=new Map,this._glyphCache=new Map,this._pbfGlyphCache=new Map,this._invalidFonts=new Set,this._preloadCache={},this._glyphSDFCreator=new d({sdfSizePx:c,sdfBufferPx:o,radius:n,cutoff:S})}set remoteClient(e){this._client=e.createInvokeProxy();const t=this._client.getOptions();this._inited=this._init(t)}async rasterizeText(e,t,s){await this._inited;const i=t.symbol?h(t):null;if(i){return{type:"rich-glyphs",runs:(await Promise.all(i.map(async t=>({fontSize:t.fontSize,characterSpacing:t.characterSpacing,color:t.color,glyphs:await this._rasterizeTextRun(e,t.font,t.text,s)})))).filter(e=>null!=e.glyphs)}}return this._rasterizeTextRun(e,t.font,t.textString,s)}async _rasterizeTextRun(e,t,i,a){const r=s(t),h=this._invalidFonts.has(r),n=!!has("esri-2d-force-complex-shaping"),o=!!has("esri-2d-complex-shaping")&&G.test(i),c=P.has(t.family),p=n||o||c,l=h?C:r;let f=await this.getGlyphItems(i,p,e,l,!1,a);return f||(b(`Font ${r} is not available on the web, using "Arial Unicode MS Regular"`),this._invalidFonts.add(r),f=await this.getGlyphItems(i,p,e,C,!1,a)),f}async getGlyphItems(e,s,i,a,r,h){await this._inited;const g=this._getSource(i),d=s?c:f,_=s?n:l,y=s?o:p;let u,m,S;if(has("esri-2d-stabilize-glyphs")&&await this.preloadASCIIGlyphCache(g,a).catch(()=>{}),s){const t=await this._getFace(g,a);if(!t)return null;let s=this._glyphCache.get(a);s||(s=new Map,this._glyphCache.set(a,s));const{shaping:i,isRTL:r}=this._shape(t,e);S=r,u=i.map(e=>this._getShapedGlyph(t,s,e)),m={baseline:t.baseline()/d,midline:t.midline()/d}}else{let s=this._pbfGlyphCache.get(a);s||(s=new Map,this._pbfGlyphCache.set(a,s));const[i,n,o]=t(e),c=w(i);try{await this._fetchRanges(g,a,c,h)}catch{return null}S=n,u=c.map(e=>this._getPBFGlyph(s,g,a,e,r)).filter(e=>!!e)}const C=u.filter(e=>e.needsRecord);return C.length>0&&await this._client.recordGlyphs(C),{type:"glyphs",glyphs:u,faceInfo:m,isRightToLeft:S,sdfSize:d,sdfRadius:_,sdfPadding:y}}async _init(e){const{width:t,height:s,snapCoords:i}=await e;this._glyphCache=new Map,this._pbfGlyphCache=new Map,this._binPack=new u(t,s),this._snapCoords=i,this._currentPage=0,this._initDecorationGlyphs()}_getShapedGlyph(e,t,s){let i,a,r=t.get(s.glyphId);if(!r){i=this._glyphSDFCreator.draw(e,s.glyphId);const h=this._glyphSDFCreator.sdfBufferPx;r={mosaicItem:{rect:this._recordGlyph(i?.rect,h),page:this._currentPage,sdf:!0,textureBinding:m(1,this._currentPage,!0)},glyphRect:i?.rect??{width:0,height:0,top:0,left:0}},t.set(s.glyphId,r),a=!0}return{mosaicItem:r.mosaicItem,rect:r.glyphRect,shaping:{xAdvance:s.xAdvance,yAdvance:s.yAdvance,xOffset:s.xOffset,yOffset:s.yOffset},code:s.isNewline?10:s.isWhitespace?32:NaN,sdf:i,needsRecord:a}}_getPBFGlyph(e,t,s,i,a=!1){let r,h,n=e.get(i);if(!n){const c=t.getRange(s,i),p=c?.getRect(i),l=c?.getShaping(i),f=c?.getBitmap(i);if(a&&(!p||!l))return;if(!p||!l)return j(i);r=f&&{buffer:f,rect:p},n={mosaicItem:{rect:f?this._recordGlyph(p,o):new y(0,0,0,0),sdf:!0,page:this._currentPage,textureBinding:m(1,this._currentPage,!0)},rect:p,shaping:l,code:i},h=!0,e.set(i,n)}const{mosaicItem:c,rect:p,shaping:l}=n;return{mosaicItem:c,rect:p,shaping:l,code:i,sdf:r,needsRecord:h}}_shape(e,s){const i=this._glyphSDFCreator.sdfSizePx,[a,r,h]=t(s,!1),n=new Uint32Array(Array.from(a).map((e,t)=>h.levels[h.targetToSource[t]]));return{shaping:e.shape(a,n,i),isRTL:r}}async _getFace(t,s,i){if(this._faces.has(s))return this._faces.get(s);const a=t.woffURL(s);return await M(this._facePromises,s,async()=>{const t=await e(a,{responseType:"array-buffer",...i}),h=(await r()).Face.parseWoff2(new Uint8Array(t.data));this._faces.set(s,h)}),this._faces.get(s)}_getSource(e){return this._glyphSources.has(e)||this._glyphSources.set(e,new _(e)),this._glyphSources.get(e)}async _fetchRanges(e,t,s,i){const a=I(s),r=[];a.forEach(s=>{r.push(this._fetchRange(e,t,s,i))}),await Promise.all(r)}async _fetchRange(e,t,s,i){if(s>256)return;const a=t+s;return M(this._pbfRangePromises,a,()=>e.fetchRange(t,s,i))}_allocNewPage(){this._currentPage++,this._binPack=new u(this._binPack.width,this._binPack.height),this._initDecorationGlyphs()}_recordGlyph(e,t){const s=this._binPack;if(!e||0===e.width)return new y;const i=e.width+2*t,a=e.height+2*t;let r=i,h=a;if(this._snapCoords){r+=i%4?4-i%4:4,h+=a%4?4-a%4:4}const n=s.allocate(r,h);return n.isEmpty?(this._allocNewPage(),s.allocate(r,h)):n}_initDecorationGlyphs(){this._recordGlyph(g,p),this._recordGlyph(g,p)}preloadASCIIGlyphCache(e,t){const s=this._preloadCache[t];if(null!=s)return s;const i=e.preloadASCIIRange(t).then(async()=>{let s=this._pbfGlyphCache.get(t);s||(s=new Map,this._pbfGlyphCache.set(t,s));for(let a=0;a<256;a++)this._getPBFGlyph(s,e,t,a);const i=Array.from(this._pbfGlyphCache.get(t).values());await this._client.recordGlyphs(i)},e=>{throw delete this._preloadCache[t],e});return this._preloadCache[t]=i,i}}function I(e){const t=new Set;for(const s of e)t.add(Math.floor(s/256));return t}function M(e,t,s){return e.has(t)||e.set(t,s().finally(()=>{e.delete(t)}).catch(e=>{a(e)})),e.get(t)}const j=e=>({mosaicItem:{rect:new y(0,0,0,0),sdf:!0,page:0},rect:{left:0,width:0,height:0,top:0},shaping:{xAdvance:0,yAdvance:0,xOffset:0,yOffset:0},code:e});export{R as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{pt2px as t}from"../../../../../../core/screenUtils.js";import{fromRotation as e,multiply as n,translate as i,rotate 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 h,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 l,getYAnchorDirection as c}from"../../alignmentUtils.js";import{magicLabelLineHeight as f}from"../../definitions.js";import d from"../../Rect.js";import g from"../../collisions/BoundingBox.js";const m=22,u=4,p=m+u,y=m-6,x=Math.PI/180,w=8,b=1.5;class M{static fromGlyph(t,e,n,i,s){const{mosaicItem:o,rect:h,shaping:r,code:a}=n,l=o.rect;return new M({width:0===a?h.width:l.width*i,height:0===a?h.height:l.height*i,x:i*(t+r.xOffset+h.left),y:i*(e+r.yOffset-h.top),textureBinding:o.textureBinding,texcoords:{topLeft:[l.x,l.y],topRight:[l.x+l.width,l.y],bottomLeft:[l.x,l.y+l.height],bottomRight:[l.x+l.width,l.y+l.height]},fontSize:s?.fontSize,color:s?.color})}constructor(t){this._rotationT=o(),this._transform=o(),this._angle=0,this._bounds=null,this.width=t.width,this.height=t.height,this.x=t.x,this.y=t.y,this.textureBinding=t.textureBinding,this.texcoords=t.texcoords,this.fontSize=t.fontSize,this.color=t.color}set angle(t){this._angle=t,e(this._rotationT,-t),this._offsets=this._bounds=null}get angle(){return this._angle}get offsets(){if(!this._offsets){const{x:t,y:i,width:s,height:r}=this,a=e(o(),-this.angle),l=n(o(),a,this._transform);this._offsets={topLeft:h([0,0],[t,i],l),topRight:h([0,0],[t+s,i],l),bottomLeft:h([0,0],[t,i+r],l),bottomRight:h([0,0],[t+s,i+r],l)}}return this._offsets}get bounds(){if(this.width<=0)return null;if(!this._bounds){const t=this.offsets;let e=1/0,n=1/0,i=-1/0,s=-1/0;for(const[l,c]of[t.topLeft,t.topRight,t.bottomLeft,t.bottomRight])e=Math.min(e,l),n=Math.min(n,c),i=Math.max(i,l),s=Math.max(s,c);const o=i-e,h=s-n,r=e+o/2,a=n+h/2;this._bounds=new g(r,a,o,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const _=(t,e)=>({code:0,mosaicItem:{rect:new d(0,0,11,8),sdf:!0,page:0,textureBinding:e},rect:{height:4,width:t,left:0,top:0},shaping:{xOffset:0,yOffset:0,xAdvance:0,yAdvance:0}});function A(t,e){return t.forEach(t=>h(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class v{constructor(t,e,n,i){this._rotation=0,this._decorate(t,e,n,i),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==n.angle,this._transform=this._createGlyphTransform(this.bounds,n),this._borderLineSizePx=n.borderLineSizePx,(n.borderLineSizePx||n.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const s of t)s.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const i=this._transform,s=e(o(),t);n(i,s,i);for(const e of this.glyphs)e.setTransform(this._transform)}_decorate(t,e,n,i){if(!n.decoration||"none"===n.decoration||!t.length)return;const s=n.scale,o=t[0].textureBinding;for(const h of e){const e=h.scale??s,r="underline"===n.decoration?h.baseline??i?.baseline??p:h.midline??i?.midline??y,a=h.startX*e,l=h.startY*e,c=(h.width+h.glyphWidthEnd)*e;t.push(M.fromGlyph(a,l+r*e,_(c,o),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,n=(b+e)/2,i=this._borderLineSizePx?n:0,{xmin:s,ymin:o,xmax:h,ymax:r,x:a,y:l,width:c,height:f}=this.bounds,d=[s-w,o-w],m=[h+w,o-w],u=[s-w,r+w],p=[h+w,r+w],y=A([[d[0]-n,d[1]-n],[m[0]+n,m[1]-n],[d[0]+i,d[1]+i],[m[0]-i,m[1]+i]],t),x=A([[u[0]+i,u[1]-i],[p[0]-i,p[1]-i],[u[0]-n,u[1]+n],[p[0]+n,p[1]+n]],t),M=A([[d[0]-n,d[1]-n],[d[0]+i,d[1]+i],[u[0]-n,u[1]+n],[u[0]+i,u[1]-i]],t),_=A([[m[0]-i,m[1]+i],[m[0]+n,m[1]-n],[p[0]-i,p[1]-i],[p[0]+n,p[1]+n]],t),v={main:A([d,m,u,p],t),top:y,bot:x,left:M,right:_};return[new g(a,l,c+2*n,f+2*n),v]}get boundsT(){const t=this.bounds,e=r(a(),t.x,t.y);if(h(e,e,this._transform),this._hasRotation){const n=Math.max(t.width,t.height);return new g(e[0],e[1],n,n)}return new g(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,n=1/0,i=0,s=0;for(const r of t)e=Math.min(e,r.offsets.topLeft[0]),n=Math.min(n,r.offsets.topLeft[1]),i=Math.max(i,r.offsets.bottomRight[0]),s=Math.max(s,r.offsets.bottomRight[1]);const o=i-e,h=s-n;return new g(e+o/2,n+h/2,o,h)}_createGlyphTransform(t,e){const n=x*e.angle,h=o(),l=a();return i(h,h,r(l,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?s(h,h,n):(i(h,h,r(l,t.x,t.y)),s(h,h,n),i(h,h,r(l,-t.x,-t.y))),h}}class z{constructor(t,e,n,i,s,o){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,n)),this.end=Math.max(0,Math.max(e,n)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].rect.width),this.width=i,this.yMin=s,this.yMax=o}}const L=t=>10===t,R=t=>32===t;function S(t,e,n){const i=new Array,s=1/n.scale,o=n.maxLineWidth*s,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let l=h,c=0,f=0,d=l,g=d,m=0,u=1/0,p=0;for(;l!==r;){const{code:e,rect:n,shaping:s}=t[l],r=Math.abs(n.top);if(L(e)||R(e)||(u=Math.min(u,r),p=Math.max(p,r+n.height)),L(e))l!==h&&(i.push(new z(t,d,l-a,c,u===1/0?0:u,p)),u=1/0,p=0),c=0,d=l+a,g=l+a,f=0;else if(R(e))g=l+a,f=0,m=s.xAdvance,c+=s.xAdvance;else if(c>o){if(g!==d){const e=g-2*a;c-=m,i.push(new z(t,d,e,c-f,u,p)),u=1/0,p=0,d=g,c=f}else i.push(new z(t,d,l-a,c,u,p)),u=1/0,p=0,d=l,g=l,c=0;c+=s.xAdvance,f+=s.xAdvance}else c+=s.xAdvance,f+=s.xAdvance;l+=a}const y=new z(t,d,l-a,c,u,p);return y.start>=0&&y.end<t.length&&i.push(y),i}function B(t,e){let n=0;for(let o=0;o<t.length;o++){const{width:e}=t[o];n=Math.max(e,n)}const i="underline"===e.decoration?u:0,s=t[0].yMin;return{x:0,y:s,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-s,width:n}}function Y(t,e,n){let i=0;for(let s=e;s<n;s++)R(t[s].code)&&!L(t[s+1].code)&&i++;return i}function j(t,e){const n=e.scale,i=new Array,s=t.sdfPadding,{faceInfo:o,glyphs:h,isRightToLeft:r}=t,a="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,f=S(h,r,e),d=f.length?B(f,e):{y:0,height:0,width:0},g=a?r?1:-1:l(e.horizontalAlignment),u=c(e.verticalAlignment),p=2===u?1:0,y=p?0:u-1,x=o?.baseline??m,w=f.length>1,b=p?w?-d.y-d.height:-x:-d.y+y*(d.height/2);for(let l=0;l<f.length;l++){const{start:o,end:r,width:c}=f[l],m=a&&l<f.length-1?Y(h,o,r):0,u=m>0?(d.width-c)/m:0;let p=-1*(g+1)*((u>0?d.width:c)/2)-s;const y=(t.isRightToLeft?f.length-1-l:l)*e.lineHeight+b-s;f[l].startX=p,f[l].startY=y;for(let t=o;t<=r;t++){const e=h[t];if(L(e.code))continue;const s=M.fromGlyph(p,y,e,n);p+=e.shaping.xAdvance,u>0&&R(e.code)&&(p+=u),i.push(s)}}return new v(i,f,e,o)}function H(t,e){const n=e.scale,{faceInfo:i,glyphs:s}=t,o=s.reduce((t,e)=>Math.max(t,e.rect.height),0),h=s.map(t=>M.fromGlyph(-t.rect.width/2,-o,t,n));return new v(h,[],e,i)}function T(t,e){return"glyphs"===t.type?j(t,e):E(t,e)}function W(t,e){return"glyphs"===t.type?H(t,e):G(t,e)}function E(t,e){const n=I(t,e),i=X(n,e),s=i.length?O(i):{width:0},o=new Array,h="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,r=h?-1:l(e.horizontalAlignment),a=c(e.verticalAlignment),f=2===a,d=i.length?i[0].yMin:0,g=i.length?i[i.length-1].startY+i[i.length-1].yMax:0,m=g-d,u=f?i.length>1?-g:-(i[0]?.baseline??0):1===a?-d:-1===a?-g:-(d+m/2);for(let l=0;l<i.length;l++){const t=i[l],e=h&&l<i.length-1?k(n,t.start,t.end):0,a=e>0?(s.width-t.width)/e:0;let c=-1*(r+1)*((a>0?s.width:t.width)/2);const f=t.startY+u;t.startX=c,t.startY=f;for(let i=t.start;i<=t.end;i++){const e=n[i],{glyph:s,scale:h,fontSize:r}=e;if(L(s.code))continue;const l=f+t.baseline-e.baseline;o.push(M.fromGlyph(c/h,l/h,s,h,{fontSize:r,color:e.color})),c+=e.xAdvance,a>0&&R(s.code)&&(c+=a)}}return new v(o,i,e)}function G(t,e){const n=I(t,e),i=n.reduce((t,e)=>Math.max(t,e.glyph.rect.height*e.scale),0),s=n.filter(t=>!L(t.glyph.code)).map(t=>M.fromGlyph(-t.glyph.rect.width/2,-i/t.scale,t.glyph,t.scale,{fontSize:t.fontSize,color:t.color}));return new v(s,[],e)}function I(e,n){const i=n.lineHeightRatio??1,s=[];for(const o of e.runs){const e=t(o.fontSize),n=e/o.glyphs.sdfSize,h=e*(f/24)*i,r=(o.glyphs.faceInfo?.baseline??m)*n,a=(o.glyphs.faceInfo?.midline??y)*n;for(const t of o.glyphs.glyphs){const i=Math.abs(t.rect.top)*n,l=i+t.rect.height*n;s.push({glyph:t,scale:n,fontSize:e,color:o.color,xAdvance:t.shaping.xAdvance*n,top:i,bottom:l,lineHeight:h,baseline:r,midline:a})}}return s}function X(t,e){const n=[],i=e.maxLineWidth;let s=0,o=0,h=0,r=0,a=0,l=0;for(;s<t.length;){const e=t[s],{glyph:c}=e;if(L(c.code))0!==s&&n.push({width:o,start:r,end:s-1,glyphWidthEnd:t[s-1]?.glyph.rect.width*t[s-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),o=0,r=s+1,a=r,h=0,l=0;else if(R(c.code))a=s+1,h=0,l=e.xAdvance,o+=e.xAdvance;else if(o>i){if(a!==r){const e=a-2;o-=l,n.push({width:o-h,start:r,end:e,glyphWidthEnd:t[e]?.glyph.rect.width*t[e]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=a,o=h}else n.push({width:o,start:r,end:s-1,glyphWidthEnd:t[s-1]?.glyph.rect.width*t[s-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=s,a=s,o=0;o+=e.xAdvance,h+=e.xAdvance}else o+=e.xAdvance,h+=e.xAdvance;s++}if(r<t.length){const e=t.length-1;n.push({width:o,start:r,end:e,glyphWidthEnd:t[e]?.glyph.rect.width*t[e]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1})}return P(t,n)}function P(t,e){for(let n=0;n<e.length;n++){const i=e[n];let s=0,o=1/0,h=0;for(let e=i.start;e<=i.end;e++){const n=t[e];L(n.glyph.code)||R(n.glyph.code)||(s=Math.max(s,n.baseline),h=Math.max(h,n.lineHeight))}let r=1/0,a=-1/0;for(let e=i.start;e<=i.end;e++){const n=t[e];L(n.glyph.code)||R(n.glyph.code)||(r=Math.min(r,s-n.baseline+n.top),a=Math.max(a,s-n.baseline+n.bottom),o=Math.min(o,s-n.baseline+n.midline))}i.baseline=s,i.midline=o===1/0?s:o,i.lineHeight=h||Math.max(0,a-r),i.yMin=r===1/0?0:r,i.yMax=a===-1/0?0:a,i.startY=n>0?e[n-1].startY+e[n-1].lineHeight:0}return e}function O(t){let e=0;for(const s of t)e=Math.max(s.width+s.glyphWidthEnd,e);const n=t[0].yMin,i=t[t.length-1];return{x:0,y:n,height:i.startY+i.yMax-n,width:e}}function k(t,e,n){let i=0;for(let s=e;s<n;s++)R(t[s].glyph.code)&&!L(t[s+1].glyph.code)&&i++;return i}export{M as ShapedGlyph,v as ShapingInfo,j as shapeGlyphs,H as shapeGlyphsForMultipoint,E as shapeRichText,G as shapeRichTextForMultipoint,T as shapeTextResource,W as shapeTextResourceForMultipoint};
2
+ import{pt2px as t}from"../../../../../../core/screenUtils.js";import{fromRotation as e,multiply as n,translate as i,rotate 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 h,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 l,getYAnchorDirection as c}from"../../alignmentUtils.js";import{magicLabelLineHeight as f}from"../../definitions.js";import d from"../../Rect.js";import g from"../../collisions/BoundingBox.js";const m=22,u=4,p=m+u,y=m-6,x=Math.PI/180,w=8,b=1.5;class M{static fromGlyph(t,e,n,i,s){const{mosaicItem:o,rect:h,shaping:r,code:a}=n,l=o.rect;return new M({width:0===a?h.width:l.width*i,height:0===a?h.height:l.height*i,x:i*(t+r.xOffset+h.left),y:i*(e+r.yOffset-h.top),textureBinding:o.textureBinding,texcoords:{topLeft:[l.x,l.y],topRight:[l.x+l.width,l.y],bottomLeft:[l.x,l.y+l.height],bottomRight:[l.x+l.width,l.y+l.height]},fontSize:s?.fontSize,color:s?.color})}constructor(t){this._rotationT=o(),this._transform=o(),this._angle=0,this._bounds=null,this.width=t.width,this.height=t.height,this.x=t.x,this.y=t.y,this.textureBinding=t.textureBinding,this.texcoords=t.texcoords,this.fontSize=t.fontSize,this.color=t.color}set angle(t){this._angle=t,e(this._rotationT,-t),this._offsets=this._bounds=null}get angle(){return this._angle}get offsets(){if(!this._offsets){const{x:t,y:i,width:s,height:r}=this,a=e(o(),-this.angle),l=n(o(),a,this._transform);this._offsets={topLeft:h([0,0],[t,i],l),topRight:h([0,0],[t+s,i],l),bottomLeft:h([0,0],[t,i+r],l),bottomRight:h([0,0],[t+s,i+r],l)}}return this._offsets}get bounds(){if(this.width<=0)return null;if(!this._bounds){const t=this.offsets;let e=1/0,n=1/0,i=-1/0,s=-1/0;for(const[l,c]of[t.topLeft,t.topRight,t.bottomLeft,t.bottomRight])e=Math.min(e,l),n=Math.min(n,c),i=Math.max(i,l),s=Math.max(s,c);const o=i-e,h=s-n,r=e+o/2,a=n+h/2;this._bounds=new g(r,a,o,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const _=(t,e)=>({code:0,mosaicItem:{rect:new d(0,0,11,8),sdf:!0,page:0,textureBinding:e},rect:{height:4,width:t,left:0,top:0},shaping:{xOffset:0,yOffset:0,xAdvance:0,yAdvance:0}});function A(t,e){return t.forEach(t=>h(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class v{constructor(t,e,n,i){this._rotation=0,this._decorate(t,e,n,i),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==n.angle,this._transform=this._createGlyphTransform(this.bounds,n),this._borderLineSizePx=n.borderLineSizePx,(n.borderLineSizePx||n.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const s of t)s.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const i=this._transform,s=e(o(),t);n(i,s,i);for(const e of this.glyphs)e.setTransform(this._transform)}_decorate(t,e,n,i){if(!n.decoration||"none"===n.decoration||!t.length)return;const s=n.scale,o=t[0].textureBinding;for(const h of e){const e=h.scale??s,r="underline"===n.decoration?h.baseline??i?.baseline??p:h.midline??i?.midline??y,a=h.startX*e,l=h.startY*e,c=(h.width+h.glyphWidthEnd)*e;t.push(M.fromGlyph(a,l+r*e,_(c,o),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,n=(b+e)/2,i=this._borderLineSizePx?n:0,{xmin:s,ymin:o,xmax:h,ymax:r,x:a,y:l,width:c,height:f}=this.bounds,d=[s-w,o-w],m=[h+w,o-w],u=[s-w,r+w],p=[h+w,r+w],y=A([[d[0]-n,d[1]-n],[m[0]+n,m[1]-n],[d[0]+i,d[1]+i],[m[0]-i,m[1]+i]],t),x=A([[u[0]+i,u[1]-i],[p[0]-i,p[1]-i],[u[0]-n,u[1]+n],[p[0]+n,p[1]+n]],t),M=A([[d[0]-n,d[1]-n],[d[0]+i,d[1]+i],[u[0]-n,u[1]+n],[u[0]+i,u[1]-i]],t),_=A([[m[0]-i,m[1]+i],[m[0]+n,m[1]-n],[p[0]-i,p[1]-i],[p[0]+n,p[1]+n]],t),v={main:A([d,m,u,p],t),top:y,bot:x,left:M,right:_};return[new g(a,l,c+2*n,f+2*n),v]}get boundsT(){const t=this.bounds,e=r(a(),t.x,t.y);if(h(e,e,this._transform),this._hasRotation){const n=Math.max(t.width,t.height);return new g(e[0],e[1],n,n)}return new g(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,n=1/0,i=0,s=0;for(const r of t)e=Math.min(e,r.offsets.topLeft[0]),n=Math.min(n,r.offsets.topLeft[1]),i=Math.max(i,r.offsets.bottomRight[0]),s=Math.max(s,r.offsets.bottomRight[1]);const o=i-e,h=s-n;return new g(e+o/2,n+h/2,o,h)}_createGlyphTransform(t,e){const n=x*e.angle,h=o(),l=a();return i(h,h,r(l,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?s(h,h,n):(i(h,h,r(l,t.x,t.y)),s(h,h,n),i(h,h,r(l,-t.x,-t.y))),h}}class z{constructor(t,e,n,i,s,o){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,n)),this.end=Math.max(0,Math.max(e,n)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].rect.width),this.width=i,this.yMin=s,this.yMax=o}}const L=t=>10===t,R=t=>32===t;function S(t,e,n){const i=new Array,s=1/n.scale,o=n.maxLineWidth*s,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let l=h,c=0,f=0,d=l,g=d,m=0,u=1/0,p=0;for(;l!==r;){const{code:e,rect:n,shaping:s}=t[l],r=Math.abs(n.top);if(L(e)||R(e)||(u=Math.min(u,r),p=Math.max(p,r+n.height)),L(e))l!==h&&(i.push(new z(t,d,l-a,c,u===1/0?0:u,p)),u=1/0,p=0),c=0,d=l+a,g=l+a,f=0;else if(R(e))g=l+a,f=0,m=s.xAdvance,c+=s.xAdvance;else if(c>o){if(g!==d){const e=g-2*a;c-=m,i.push(new z(t,d,e,c-f,u,p)),u=1/0,p=0,d=g,c=f}else i.push(new z(t,d,l-a,c,u,p)),u=1/0,p=0,d=l,g=l,c=0;c+=s.xAdvance,f+=s.xAdvance}else c+=s.xAdvance,f+=s.xAdvance;l+=a}const y=new z(t,d,l-a,c,u,p);return y.start>=0&&y.end<t.length&&i.push(y),i}function B(t,e){let n=0;for(let o=0;o<t.length;o++){const{width:e}=t[o];n=Math.max(e,n)}const i="underline"===e.decoration?u:0,s=t[0].yMin;return{x:0,y:s,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-s,width:n}}function Y(t,e,n){let i=0;for(let s=e;s<n;s++)R(t[s].code)&&!L(t[s+1].code)&&i++;return i}function j(t,e){const n=e.scale,i=new Array,s=t.sdfPadding,{faceInfo:o,glyphs:h,isRightToLeft:r}=t,a="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,f=S(h,r,e),d=f.length?B(f,e):{y:0,height:0,width:0},g=a?r?1:-1:l(e.horizontalAlignment),u=c(e.verticalAlignment),p=2===u?1:0,y=p?0:u-1,x=o?.baseline??m,w=f.length>1,b=p?w?-d.y-d.height:-x:-d.y+y*(d.height/2);for(let l=0;l<f.length;l++){const{start:o,end:r,width:c}=f[l],m=a&&l<f.length-1?Y(h,o,r):0,u=m>0?(d.width-c)/m:0;let p=-1*(g+1)*((u>0?d.width:c)/2)-s;const y=(t.isRightToLeft?f.length-1-l:l)*e.lineHeight+b-s;f[l].startX=p,f[l].startY=y;for(let t=o;t<=r;t++){const e=h[t];if(L(e.code))continue;const s=M.fromGlyph(p,y,e,n);p+=e.shaping.xAdvance,u>0&&R(e.code)&&(p+=u),i.push(s)}}return new v(i,f,e,o)}function H(t,e){const n=e.scale,{faceInfo:i,glyphs:s}=t,o=s.reduce((t,e)=>Math.max(t,e.rect.height),0),h=s.map(t=>M.fromGlyph(-t.rect.width/2,-o,t,n));return new v(h,[],e,i)}function T(t,e){return"glyphs"===t.type?j(t,e):E(t,e)}function W(t,e){return"glyphs"===t.type?H(t,e):G(t,e)}function E(t,e){const n=I(t,e),i=X(n,e),s=i.length?O(i):{width:0},o=new Array,h="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,r=h?-1:l(e.horizontalAlignment),a=c(e.verticalAlignment),f=2===a,d=i.length?i[0].yMin:0,g=i.length?i[i.length-1].startY+i[i.length-1].yMax:0,m=g-d,u=f?i.length>1?-g:-(i[0]?.baseline??0):1===a?-d:-1===a?-g:-(d+m/2);for(let l=0;l<i.length;l++){const t=i[l],e=h&&l<i.length-1?k(n,t.start,t.end):0,a=e>0?(s.width-t.width)/e:0;let c=-1*(r+1)*((a>0?s.width:t.width)/2);const f=t.startY+u;t.startX=c,t.startY=f;for(let i=t.start;i<=t.end;i++){const e=n[i],{glyph:s,scale:h,fontSize:r}=e;if(L(s.code))continue;const l=f+t.baseline-e.baseline;o.push(M.fromGlyph(c/h,l/h,s,h,{fontSize:r,color:e.color})),c+=e.xAdvance,a>0&&R(s.code)&&(c+=a)}}return new v(o,i,e)}function G(t,e){const n=I(t,e),i=n.reduce((t,e)=>Math.max(t,e.glyph.rect.height*e.scale),0),s=n.filter(t=>!L(t.glyph.code)).map(t=>M.fromGlyph(-t.glyph.rect.width/2,-i/t.scale,t.glyph,t.scale,{fontSize:t.fontSize,color:t.color}));return new v(s,[],e)}function I(e,n){const i=n.lineHeightRatio??1,s=[];for(const o of e.runs){const e=t(o.fontSize),n=e/o.glyphs.sdfSize,h=e*(f/24)*i,r=(o.glyphs.faceInfo?.baseline??m)*n,a=(o.glyphs.faceInfo?.midline??y)*n,l=1+(o.characterSpacing??0);for(const t of o.glyphs.glyphs){const i=t.shaping.xAdvance*n,c=Math.abs(t.rect.top)*n,f=c+t.rect.height*n;s.push({glyph:t,scale:n,fontSize:e,color:o.color,xAdvance:L(t.code)||R(t.code)?i:i*l,top:c,bottom:f,lineHeight:h,baseline:r,midline:a})}}return s}function X(t,e){const n=[],i=e.maxLineWidth;let s=0,o=0,h=0,r=0,a=0,l=0;for(;s<t.length;){const e=t[s],{glyph:c}=e;if(L(c.code))0!==s&&n.push({width:o,start:r,end:s-1,glyphWidthEnd:t[s-1]?.glyph.rect.width*t[s-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),o=0,r=s+1,a=r,h=0,l=0;else if(R(c.code))a=s+1,h=0,l=e.xAdvance,o+=e.xAdvance;else if(o>i){if(a!==r){const e=a-2;o-=l,n.push({width:o-h,start:r,end:e,glyphWidthEnd:t[e]?.glyph.rect.width*t[e]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=a,o=h}else n.push({width:o,start:r,end:s-1,glyphWidthEnd:t[s-1]?.glyph.rect.width*t[s-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=s,a=s,o=0;o+=e.xAdvance,h+=e.xAdvance}else o+=e.xAdvance,h+=e.xAdvance;s++}if(r<t.length){const e=t.length-1;n.push({width:o,start:r,end:e,glyphWidthEnd:t[e]?.glyph.rect.width*t[e]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1})}return P(t,n)}function P(t,e){for(let n=0;n<e.length;n++){const i=e[n];let s=0,o=1/0,h=0;for(let e=i.start;e<=i.end;e++){const n=t[e];L(n.glyph.code)||R(n.glyph.code)||(s=Math.max(s,n.baseline),h=Math.max(h,n.lineHeight))}let r=1/0,a=-1/0;for(let e=i.start;e<=i.end;e++){const n=t[e];L(n.glyph.code)||R(n.glyph.code)||(r=Math.min(r,s-n.baseline+n.top),a=Math.max(a,s-n.baseline+n.bottom),o=Math.min(o,s-n.baseline+n.midline))}i.baseline=s,i.midline=o===1/0?s:o,i.lineHeight=h||Math.max(0,a-r),i.yMin=r===1/0?0:r,i.yMax=a===-1/0?0:a,i.startY=n>0?e[n-1].startY+e[n-1].lineHeight:0}return e}function O(t){let e=0;for(const s of t)e=Math.max(s.width+s.glyphWidthEnd,e);const n=t[0].yMin,i=t[t.length-1];return{x:0,y:n,height:i.startY+i.yMax-n,width:e}}function k(t,e,n){let i=0;for(let s=e;s<n;s++)R(t[s].glyph.code)&&!L(t[s+1].glyph.code)&&i++;return i}export{M as ShapedGlyph,v as ShapingInfo,j as shapeGlyphs,H as shapeGlyphsForMultipoint,E as shapeRichText,G as shapeRichTextForMultipoint,T as shapeTextResource,W as shapeTextResourceForMultipoint};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{EventEmitter as e}from"../../../core/Evented.js";import{makeHandle as t}from"../../../core/handleUtils.js";import"../../../core/has.js";import{deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{createRenderScreenPointArray3 as o,createScreenPointArray as r,screenPointObjectToArray as n,castRenderScreenPointArray as a}from"../../../core/screenUtils.js";import{fromMat4 as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as l}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as h,set as d,multiply as _,identity as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{squaredDistance as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{add as f,transformMat3 as p,transformMat4 as b,scale as v,copy as y,squaredDistance as j,set as L,subtract as S}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as O,ZEROS as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as w}from"../../../geometry/ellipsoidUtils.js";import T from"../../../geometry/Point.js";import{canProjectWithoutEngine as A,projectPoint as E}from"../../../geometry/projectionUtils.js";import{computeENUToPCPFLocalRotation as D}from"../../../geometry/projection/localRotationUtils.js";import{sphericalPCPFtoLonLatElevation as F}from"../../../geometry/projection/projectors.js";import{containsPointObject as z}from"../../../geometry/support/aaBoundingRect.js";import{distance2 as P,fromPoints as x,closestRayDistance2 as C,create as M}from"../../../geometry/support/lineSegment.js";import{fromPositionAndNormal as k,intersectRay as I,create as U}from"../../../geometry/support/plane.js";import{create as W}from"../../../geometry/support/ray.js";import{sv3d as B}from"../../../geometry/support/vectorStacks.js";import{clonePoint as H,hydratedSpatialReference as q}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationOffset as G}from"../../../support/elevationInfoUtils.js";import{getElevationAtPoint as V}from"../support/ElevationProvider.js";import{fromScreen as J}from"../support/geometryUtils/ray.js";import K from"../webgl/RenderCamera.js";import{Object3D as N}from"../webgl-engine/lib/Object3D.js";import{WebGLLayer as Q}from"../webgl-engine/lib/WebGLLayer.js";class X{constructor(t){this.metadata=void 0,this._camera=new K,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=g(),this._worldFrame=null,this._renderLocation=O(),this._renderLocationDirty=!0,this._location=new T({x:0,y:0,z:0}),this._elevationAlignedLocation=new T,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.consumesClicks=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=0,this._focused=!1,this.events=new e,this._screenLocation={screenPointArray:r(),renderScreenPointArray:o(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=t.view.spatialReference,Object.assign(this,t);const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._applyObjectTransform=ue,this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?.stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),t(()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()})}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){Y(e)&&(this._screenLocationDirty=!0),h(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=g()),Z(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){H(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){H(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=null!=this._elevation.override?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=q(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(Y(this._modelTransform)){const t=this._calculateModelTransformOffset(de);e=f(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(e,t){if(!this.available)return null;const i=n(e,$),s=this._getCollisionRadius(t),o=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(m(this.screenLocation.screenPointArray,i)<s*s)return this.screenLocation.renderScreenPointArray[2]+o;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),r=this._calculateObjectTransform(t,oe),n=s*this.screenLocation.pixelSize,c=J(this._camera,i,te);if(null==c)return null;for(const i of e){if(0===i.length)continue;const e=b(ne,i[0],r);for(let t=1;t<i.length;t++){const s=b(ae,i[t],r),l=C(x(e,s,ee),c);if(null!=l&&l<n*n){const t=f(B.get(),e,s);v(t,t,.5);const i=a(B.get());if(this._camera.projectToRenderScreen(t,i))return i[2]+o}y(e,s)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??R,r=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(r,oe),a=s*this.screenLocation.pixelSize,l=J(this._camera,i,te);if(null==l)return null;const h=c(ie,n),d=p(le,e,h),_=b(he,t,n);k(_,d,re);const u=ce;if(I(re,l,u)&&j(u,_)<a*a)return this.screenLocation.renderScreenPointArray[2]+o;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,r=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(r,oe),l=s*this._camera.computeScreenPixelSizeAt(this.renderLocation),h=J(this._camera,i,te);if(null==h)return null;const d=c(ie,n),_=p(le,t,d),u=this._calculateModelTransformPosition(he);k(u,_,re);const g=ce;if(!I(re,h,g))break;for(const i of e){if(0===i.length)continue;const e=b(ne,i[0],n);for(let t=1;t<i.length;t++){const s=b(ae,i[t],n),r=P(x(e,s,ee),g);if(null!=r&&r<l*l){const t=f(B.get(),e,s);v(t,t,.5);const i=a(B.get());if(this._camera.projectToRenderScreen(t,i))return i[2]+o}y(e,s)}}break}default:this.collisionType}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;null==i.engineLayerId?(this._engineLayer=new Q(t,{pickable:!1,updatePolicy:1}),i.engineLayerId=this._engineLayer.id):t?.getLayer&&(this._engineLayer=t.getLayer(i.engineLayerId)),i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),A(this._location.spatialReference,this.view.spatialReference)||(this.location=new T({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;this._removeResourcesFromStage(),i&&(t.engineLayerId=null,s(this._engineLayer)),this._engineResources=null,this._engineLayer=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){E(this.location,_e,e.spatialReference)&&z(e.extent,_e)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(null==this.elevationInfo)return;let e=null,t=0;const i=G(this.elevationInfo,this.location.spatialReference??this.view.elevationProvider.spatialReference);switch(this.elevationInfo.mode){case"on-the-ground":e=V(this.view.elevationProvider,this.location,"ground")??0;break;case"relative-to-ground":t=(V(this.view.elevationProvider,this.location,"ground")??0)+i;break;case"relative-to-scene":t=(V(this.view.elevationProvider,this.location,"scene")??0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=oe;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?2:1)|(this.selected?8:4),o=this._noDisplayCount>0;for(const{stateMask:r,objects:n}of i){if(o){for(const e of n)e.visible=!1;continue}const e=!!!(15&r)||(s&r)===(15&r),i=!!!(65520&r)||(this.state&r)===(65520&r);if(e&&i)for(const s of n)s.visible=!0,s.transformation=t;else for(const t of n)t.visible=!1}}_ensureEngineResources(){if(null==this._engineResources){const e=this._engineLayer,t=[],i=new Set;this.renderObjects.forEach(({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))});const s=new Map;this._renderObjects.forEach(e=>{const t=new N({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)});const o=[];s.forEach((e,t)=>o.push({stateMask:t,objects:e})),this._engineResources={objectsByState:o,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.addMany(e)),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(){const e=this._stage;if(!this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.removeMany(e)),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,se);return L(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return S(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return d(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&_(t,t,this._worldFrame),_(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,null!=this._applyObjectTransform&&this._applyObjectTransform(t),t}get test(){}}function Y(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function Z(e,t,s){switch(e.viewingMode){case"local":return u(s),!0;case"global":{const o=w(e.renderCoordsHelper.spatialReference);return F(t,0,ne,0,o.radius),D(i(ne[0]),i(ne[1]),s),!0}}}const $=r(),ee=M(),te=W(),ie=l(),se=g(),oe=g(),re=U(),ne=O(),ae=O(),ce=O(),le=O(),he=O(),de=O(),_e=new T({x:0,y:0,z:0,spatialReference:null}),ue=()=>{};export{X as Manipulator3D};
2
+ import{EventEmitter as e}from"../../../core/Evented.js";import{makeHandle as t}from"../../../core/handleUtils.js";import"../../../core/has.js";import{deg2rad as i}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{createRenderScreenPointArray3 as o,createScreenPointArray as r,screenPointObjectToArray as n,castRenderScreenPointArray as a}from"../../../core/screenUtils.js";import{generateUID as c}from"../../../core/uid.js";import{fromMat4 as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as d,getTranslation as _,set as u,multiply as g,identity as m}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{squaredDistance as p}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{add as b,transformMat3 as v,transformMat4 as y,scale as j,copy as L,squaredDistance as S,set as O,subtract as w}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as R,ZEROS as T}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as A}from"../../../geometry/ellipsoidUtils.js";import E from"../../../geometry/Point.js";import{canProjectWithoutEngine as D,projectPoint as F}from"../../../geometry/projectionUtils.js";import{computeENUToPCPFLocalRotation as P}from"../../../geometry/projection/localRotationUtils.js";import{sphericalPCPFtoLonLatElevation as z}from"../../../geometry/projection/projectors.js";import{containsPointObject as x}from"../../../geometry/support/aaBoundingRect.js";import{distance2 as C,fromPoints as M,closestRayDistance2 as k,create as I}from"../../../geometry/support/lineSegment.js";import{fromPositionAndNormal as U,intersectRay as W,create as B}from"../../../geometry/support/plane.js";import{create as H}from"../../../geometry/support/ray.js";import{sv3d as q}from"../../../geometry/support/vectorStacks.js";import{clonePoint as G,hydratedSpatialReference as V}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationOffset as $}from"../../../support/elevationInfoUtils.js";import{getElevationAtPoint as J}from"../support/ElevationProvider.js";import{fromScreen as K}from"../support/geometryUtils/ray.js";import N from"../webgl/RenderCamera.js";import{fromValues as Q}from"../webgl-engine/lib/LocalOriginFactory.js";import{Object3D as X}from"../webgl-engine/lib/Object3D.js";import{WebGLLayer as Y}from"../webgl-engine/lib/WebGLLayer.js";class Z{constructor(t){this.metadata=void 0,this._camera=new N,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this.usePreciseLocalOrigin=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=f(),this._worldFrame=null,this._renderLocation=R(),this._renderLocationDirty=!0,this._location=new E({x:0,y:0,z:0}),this._elevationAlignedLocation=new E,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.consumesClicks=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=0,this._focused=!1,this.events=new e,this._screenLocation={screenPointArray:r(),renderScreenPointArray:o(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=t.view.spatialReference,Object.assign(this,t);const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._applyObjectTransform=fe,this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?.stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),t(()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()})}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){ee(e)&&(this._screenLocationDirty=!0),d(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=f()),te(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){G(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){G(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=null!=this._elevation.override?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=V(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(ee(this._modelTransform)){const t=this._calculateModelTransformOffset(ge);e=b(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(e,t){if(!this.available)return null;const i=n(e,ie),s=this._getCollisionRadius(t),o=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(p(this.screenLocation.screenPointArray,i)<s*s)return this.screenLocation.renderScreenPointArray[2]+o;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),r=this._calculateObjectTransform(t,ae),n=s*this.screenLocation.pixelSize,c=K(this._camera,i,oe);if(null==c)return null;for(const i of e){if(0===i.length)continue;const e=y(le,i[0],r);for(let t=1;t<i.length;t++){const s=y(he,i[t],r),l=k(M(e,s,se),c);if(null!=l&&l<n*n){const t=b(q.get(),e,s);j(t,t,.5);const i=a(q.get());if(this._camera.projectToRenderScreen(t,i))return i[2]+o}L(e,s)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??T,r=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(r,ae),a=s*this.screenLocation.pixelSize,c=K(this._camera,i,oe);if(null==c)return null;const h=l(re,n),d=v(_e,e,h),_=y(ue,t,n);U(_,d,ce);const u=de;if(W(ce,c,u)&&S(u,_)<a*a)return this.screenLocation.renderScreenPointArray[2]+o;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,r=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(r,ae),c=s*this._camera.computeScreenPixelSizeAt(this.renderLocation),h=K(this._camera,i,oe);if(null==h)return null;const d=l(re,n),_=v(_e,t,d),u=this._calculateModelTransformPosition(ue);U(u,_,ce);const g=de;if(!W(ce,h,g))break;for(const i of e){if(0===i.length)continue;const e=y(le,i[0],n);for(let t=1;t<i.length;t++){const s=y(he,i[t],n),r=C(M(e,s,se),g);if(null!=r&&r<c*c){const t=b(q.get(),e,s);j(t,t,.5);const i=a(q.get());if(this._camera.projectToRenderScreen(t,i))return i[2]+o}L(e,s)}}break}default:this.collisionType}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;null==i.engineLayerId?(this._engineLayer=new Y(t,{pickable:!1,updatePolicy:1}),i.engineLayerId=this._engineLayer.id):t?.getLayer&&(this._engineLayer=t.getLayer(i.engineLayerId)),i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),D(this._location.spatialReference,this.view.spatialReference)||(this.location=new E({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;this._removeResourcesFromStage(),i&&(t.engineLayerId=null,s(this._engineLayer)),this._engineResources=null,this._engineLayer=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){F(this.location,me,e.spatialReference)&&x(e.extent,me)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(null==this.elevationInfo)return;let e=null,t=0;const i=$(this.elevationInfo,this.location.spatialReference??this.view.elevationProvider.spatialReference);switch(this.elevationInfo.mode){case"on-the-ground":e=J(this.view.elevationProvider,this.location,"ground")??0;break;case"relative-to-ground":t=(J(this.view.elevationProvider,this.location,"ground")??0)+i;break;case"relative-to-scene":t=(J(this.view.elevationProvider,this.location,"scene")??0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=ae;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?2:1)|(this.selected?8:4),o=this._noDisplayCount>0;for(const{stateMask:r,objects:n}of i){if(o){for(const e of n)e.visible=!1;continue}const e=!!!(15&r)||(s&r)===(15&r),i=!!!(65520&r)||(this.state&r)===(65520&r);if(e&&i)for(const s of n)s.visible=!0,this.usePreciseLocalOrigin?this._updateObjectTransformAndLocalOrigin(s,t):s.transformation=t;else for(const t of n)t.visible=!1}}_updateObjectTransformAndLocalOrigin(e,t){const i=_(ue,t),s=Q(i[0],i[1],i[2],`manipulator-${c()}`);for(const o of e.geometries)o.localOrigin=s;e.transformation=t}_ensureEngineResources(){if(null==this._engineResources){const e=this._engineLayer,t=[],i=new Set;this.renderObjects.forEach(({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))});const s=new Map;this._renderObjects.forEach(e=>{const t=new X({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)});const o=[];s.forEach((e,t)=>o.push({stateMask:t,objects:e})),this._engineResources={objectsByState:o,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.addMany(e)),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(){const e=this._stage;if(!this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.removeMany(e)),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,ne);return O(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return w(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return u(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&g(t,t,this._worldFrame),g(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,null!=this._applyObjectTransform&&this._applyObjectTransform(t),t}get test(){}}function ee(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function te(e,t,s){switch(e.viewingMode){case"local":return m(s),!0;case"global":{const o=A(e.renderCoordsHelper.spatialReference);return z(t,0,le,0,o.radius),P(i(le[0]),i(le[1]),s),!0}}}const ie=r(),se=I(),oe=H(),re=h(),ne=f(),ae=f(),ce=B(),le=R(),he=R(),de=R(),_e=R(),ue=R(),ge=R(),me=new E({x:0,y:0,z:0,spatialReference:null}),fe=()=>{};export{Z as Manipulator3D};