@arcgis/core 5.2.0-next.104 → 5.2.0-next.105

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/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{ec5542d6ecc0622f7705.js → 1ec01fd6330d011c76d6.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{c91905b5808b8049f96d.js → 2168ee64fd32f160dcf1.js} +3 -3
  4. package/assets/esri/core/workers/chunks/{ffca0b2333e760b66d3a.js → 262052dfaec3af8a58b9.js} +1 -1
  5. package/assets/esri/core/workers/chunks/33e583166ab3943ecf0e.js +1 -0
  6. package/assets/esri/core/workers/chunks/{2350f1eb70819cc06bb6.js → 4c00a46bf0345f99a9bb.js} +1 -1
  7. package/assets/esri/core/workers/chunks/91e545745706111f5f62.js +1 -0
  8. package/assets/esri/core/workers/chunks/c7b762bae945f383c723.js +1 -0
  9. package/assets/esri/core/workers/chunks/d0eb609a214d85d21ed5.js +1 -0
  10. package/assets/esri/core/workers/chunks/{23c4ec0bcbc83179013e.js → dc1b38f490142f7273ef.js} +1 -1
  11. package/chunks/GlobalIllumination.glsl.js +4 -4
  12. package/config.js +1 -1
  13. package/kernel.js +1 -1
  14. package/package.json +5 -5
  15. package/support/revision.js +1 -1
  16. package/symbols/TextSymbol3DLayer.js +1 -1
  17. package/symbols/cim/TextRasterizer.js +1 -1
  18. package/symbols/cim/richTextUtils.js +1 -1
  19. package/symbols/support/Symbol3DTextBorder.js +2 -0
  20. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  21. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  22. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  23. package/views/2d/layers/support/annodime/MatcherGeometryOverride.js +1 -1
  24. package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
  25. package/views/3d/support/QualityProfile.js +1 -1
  26. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  27. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  28. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  29. package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
  30. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  31. package/assets/esri/core/workers/chunks/3a8f6010a9f06a2457ae.js +0 -1
  32. package/assets/esri/core/workers/chunks/a191ddb3b59ec1a7d818.js +0 -1
  33. package/assets/esri/core/workers/chunks/b24e1c901f7fda2a62ca.js +0 -1
  34. package/assets/esri/core/workers/chunks/fbbc5f551115787363d2.js +0 -1
@@ -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/librust-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"]),b=()=>i.getLogger("esri.views.MapView"),x=(e,t="")=>b().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||(x(`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 t from"../../../../request.js";import{bidiText as e}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/librust-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"]),b=()=>i.getLogger("esri.views.MapView"),x=(t,e="")=>b().warnOnce(t,e);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(t){this._client=t.createInvokeProxy();const e=this._client.getOptions();this._inited=this._init(e)}async rasterizeText(t,e,s){await this._inited;const i=e.symbol?h(e):null;if(i){return{type:"rich-glyphs",runs:(await Promise.all(i.map(async e=>({fontSize:e.fontSize,characterSpacing:e.characterSpacing,decoration:e.font.decoration,color:e.color,glyphs:await this._rasterizeTextRun(t,e.font,e.text,s)})))).filter(t=>null!=t.glyphs)}}return this._rasterizeTextRun(t,e.font,e.textString,s)}async _rasterizeTextRun(t,e,i,a){const r=s(e),h=this._invalidFonts.has(r),n=!!has("esri-2d-force-complex-shaping"),o=!!has("esri-2d-complex-shaping")&&G.test(i),c=P.has(e.family),p=n||o||c,l=h?C:r;let f=await this.getGlyphItems(i,p,t,l,!1,a);return f||(x(`Font ${r} is not available on the web, using "Arial Unicode MS Regular"`),this._invalidFonts.add(r),f=await this.getGlyphItems(i,p,t,C,!1,a)),f}async getGlyphItems(t,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 e=await this._getFace(g,a);if(!e)return null;let s=this._glyphCache.get(a);s||(s=new Map,this._glyphCache.set(a,s));const{shaping:i,isRTL:r}=this._shape(e,t);S=r,u=i.map(t=>this._getShapedGlyph(e,s,t)),m={baseline:e.baseline()/d,midline:e.midline()/d}}else{let s=this._pbfGlyphCache.get(a);s||(s=new Map,this._pbfGlyphCache.set(a,s));const[i,n,o]=e(t),c=w(i);try{await this._fetchRanges(g,a,c,h)}catch{return null}S=n,u=c.map(t=>this._getPBFGlyph(s,g,a,t,r)).filter(t=>!!t)}const C=u.filter(t=>t.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(t){const{width:e,height:s,snapCoords:i}=await t;this._glyphCache=new Map,this._pbfGlyphCache=new Map,this._binPack=new u(e,s),this._snapCoords=i,this._currentPage=0,this._initDecorationGlyphs()}_getShapedGlyph(t,e,s){let i,a,r=e.get(s.glyphId);if(!r){i=this._glyphSDFCreator.draw(t,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}},e.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(t,e,s,i,a=!1){let r,h,n=t.get(i);if(!n){const c=e.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,t.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(t,s){const i=this._glyphSDFCreator.sdfSizePx,[a,r,h]=e(s,!1),n=new Uint32Array(Array.from(a).map((t,e)=>h.levels[h.targetToSource[e]]));return{shaping:t.shape(a,n,i),isRTL:r}}async _getFace(e,s,i){if(this._faces.has(s))return this._faces.get(s);const a=e.woffURL(s);return await M(this._facePromises,s,async()=>{const e=await t(a,{responseType:"array-buffer",...i}),h=(await r()).Face.parseWoff2(new Uint8Array(e.data));this._faces.set(s,h)}),this._faces.get(s)}_getSource(t){return this._glyphSources.has(t)||this._glyphSources.set(t,new _(t)),this._glyphSources.get(t)}async _fetchRanges(t,e,s,i){const a=I(s),r=[];a.forEach(s=>{r.push(this._fetchRange(t,e,s,i))}),await Promise.all(r)}async _fetchRange(t,e,s,i){if(s>256)return;const a=e+s;return M(this._pbfRangePromises,a,()=>t.fetchRange(e,s,i))}_allocNewPage(){this._currentPage++,this._binPack=new u(this._binPack.width,this._binPack.height),this._initDecorationGlyphs()}_recordGlyph(t,e){const s=this._binPack;if(!t||0===t.width)return new y;const i=t.width+2*e,a=t.height+2*e;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(t,e){const s=this._preloadCache[e];if(null!=s)return s;const i=t.preloadASCIIRange(e).then(async()=>{let s=this._pbfGlyphCache.get(e);s||(s=new Map,this._pbfGlyphCache.set(e,s));for(let a=0;a<256;a++)this._getPBFGlyph(s,t,e,a);const i=Array.from(this._pbfGlyphCache.get(e).values());await this._client.recordGlyphs(i)},t=>{throw delete this._preloadCache[e],t});return this._preloadCache[e]=i,i}}function I(t){const e=new Set;for(const s of t)e.add(Math.floor(s/256));return e}function M(t,e,s){return t.has(e)||t.set(e,s().finally(()=>{t.delete(e)}).catch(t=>{a(t)})),t.get(e)}const j=t=>({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:t});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,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};
2
+ import{pt2px as t}from"../../../../../../core/screenUtils.js";import{fromRotation as e,multiply as n,translate as i,rotate as o}from"../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as s}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 d}from"../../definitions.js";import f from"../../Rect.js";import g from"../../collisions/BoundingBox.js";const u=22,m=4,p=2,y=u-6,x=Math.PI/180,w=8,b=1.5;class M{static fromGlyph(t,e,n,i,o){const{mosaicItem:s,rect:h,shaping:r,code:a}=n,l=s.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:s.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:o?.fontSize,color:o?.color})}constructor(t){this._rotationT=s(),this._transform=s(),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:o,height:r}=this,a=e(s(),-this.angle),l=n(s(),a,this._transform);this._offsets={topLeft:h([0,0],[t,i],l),topRight:h([0,0],[t+o,i],l),bottomLeft:h([0,0],[t,i+r],l),bottomRight:h([0,0],[t+o,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,o=-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),o=Math.max(o,c);const s=i-e,h=o-n,r=e+s/2,a=n+h/2;this._bounds=new g(r,a,s,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const _=(t,e)=>({code:0,mosaicItem:{rect:new f(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(e){return"underline"===e?t(p):0}function v(t,e,n,i,o){switch(t){case"underline":return(n??o?.baseline??u)+m+A(t)/e;case"line-through":return i??o?.midline??y;default:return 0}}function z(t,e){return t.forEach(t=>h(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class B{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 o of t)o.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const i=this._transform,o=e(s(),t);n(i,o,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 o=n.scale,s=t[0].textureBinding;for(const h of e){const e=h.scale??o,r=v(n.decoration,e,h.baseline,h.midline,i),a=h.startX*e,l=h.startY*e,c=(h.width+h.glyphWidthEnd)*e;t.push(M.fromGlyph(a,l+r*e,_(c,s),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,n=(b+e)/2,i=this._borderLineSizePx?n:0,{xmin:o,ymin:s,xmax:h,ymax:r,x:a,y:l,width:c,height:d}=this.bounds,f=[o-w,s-w],u=[h+w,s-w],m=[o-w,r+w],p=[h+w,r+w],y=z([[f[0]-n,f[1]-n],[u[0]+n,u[1]-n],[f[0]+i,f[1]+i],[u[0]-i,u[1]+i]],t),x=z([[m[0]+i,m[1]-i],[p[0]-i,p[1]-i],[m[0]-n,m[1]+n],[p[0]+n,p[1]+n]],t),M=z([[f[0]-n,f[1]-n],[f[0]+i,f[1]+i],[m[0]-n,m[1]+n],[m[0]+i,m[1]-i]],t),_=z([[u[0]-i,u[1]+i],[u[0]+n,u[1]-n],[p[0]-i,p[1]-i],[p[0]+n,p[1]+n]],t),A={main:z([f,u,m,p],t),top:y,bot:x,left:M,right:_};return[new g(a,l,c+2*n,d+2*n),A]}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,o=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]),o=Math.max(o,r.offsets.bottomRight[1]);const s=i-e,h=o-n;return new g(e+s/2,n+h/2,s,h)}_createGlyphTransform(t,e){const n=x*e.angle,h=s(),l=a();return i(h,h,r(l,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?o(h,h,n):(i(h,h,r(l,t.x,t.y)),o(h,h,n),i(h,h,r(l,-t.x,-t.y))),h}}class L{constructor(t,e,n,i,o,s){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=o,this.yMax=s}}const R=t=>10===t,S=t=>32===t;function X(t,e,n){const i=new Array,o=1/n.scale,s=n.maxLineWidth*o,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let l=h,c=0,d=0,f=l,g=f,u=0,m=1/0,p=0;for(;l!==r;){const{code:e,rect:n,shaping:o}=t[l],r=Math.abs(n.top);if(R(e)||S(e)||(m=Math.min(m,r),p=Math.max(p,r+n.height)),R(e))l!==h&&(i.push(new L(t,f,l-a,c,m===1/0?0:m,p)),m=1/0,p=0),c=0,f=l+a,g=l+a,d=0;else if(S(e))g=l+a,d=0,u=o.xAdvance,c+=o.xAdvance;else if(c>s){if(g!==f){const e=g-2*a;c-=u,i.push(new L(t,f,e,c-d,m,p)),m=1/0,p=0,f=g,c=d}else i.push(new L(t,f,l-a,c,m,p)),m=1/0,p=0,f=l,g=l,c=0;c+=o.xAdvance,d+=o.xAdvance}else c+=o.xAdvance,d+=o.xAdvance;l+=a}const y=new L(t,f,l-a,c,m,p);return y.start>=0&&y.end<t.length&&i.push(y),i}function O(t,e){let n=0;for(let s=0;s<t.length;s++){const{width:e}=t[s];n=Math.max(e,n)}const i="underline"===e.decoration?m:0,o=t[0].yMin;return{x:0,y:o,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-o,width:n}}function W(t,e,n){let i=0;for(let o=e;o<n;o++)S(t[o].code)&&!R(t[o+1].code)&&i++;return i}function E(t,e){const n=e.scale,i=new Array,o=t.sdfPadding,{faceInfo:s,glyphs:h,isRightToLeft:r}=t,a="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,d=X(h,r,e),f=d.length?O(d,e):{y:0,height:0,width:0},g=a?r?1:-1:l(e.horizontalAlignment),m=c(e.verticalAlignment),p=2===m?1:0,y=p?0:m-1,x=s?.baseline??u,w=d.length>1,b=p?w?-f.y-f.height:-x:-f.y+y*(f.height/2);for(let l=0;l<d.length;l++){const{start:s,end:r,width:c}=d[l],u=a&&l<d.length-1?W(h,s,r):0,m=u>0?(f.width-c)/u:0;let p=-1*(g+1)*((m>0?f.width:c)/2)-o;const y=(t.isRightToLeft?d.length-1-l:l)*e.lineHeight+b-o;d[l].startX=p,d[l].startY=y;for(let t=s;t<=r;t++){const e=h[t];if(R(e.code))continue;const o=M.fromGlyph(p,y,e,n);p+=e.shaping.xAdvance,m>0&&S(e.code)&&(p+=m),i.push(o)}}return new B(i,d,e,s)}function H(t,e){const n=e.scale,{faceInfo:i,glyphs:o}=t,s=o.reduce((t,e)=>Math.max(t,e.rect.height),0),h=o.map(t=>M.fromGlyph(-t.rect.width/2,-s,t,n));return new B(h,[],e,i)}function Y(t,e){return"glyphs"===t.type?E(t,e):I(t,e)}function j(t,e){return"glyphs"===t.type?H(t,e):T(t,e)}function I(t,e){const n=G(t,e),i=P(n,e),o=i.length?J(i):{width:0},s=new Array,h="underline"===e.decoration?"none":e.decoration,r="justify"===e.horizontalAlignment||"Justify"===e.horizontalAlignment,a=r?-1:l(e.horizontalAlignment),d=c(e.verticalAlignment),f=2===d,g=i.length?i[0].yMin:0,u=i.length?U(i[i.length-1]):0,m=u-g,p=f?i.length>1?-u:-(i[0]?.baseline??0):1===d?-g:-1===d?-u:-(g+m/2);for(let l=0;l<i.length;l++){const t=i[l],e=r&&l<i.length-1?C(n,t.start,t.end):0,h=e>0?(o.width-t.width)/e:0;let c=-1*(a+1)*((h>0?o.width:t.width)/2);const d=t.startY+p;let f=null;t.startX=c,t.startY=d;for(let i=t.start;i<=t.end;i++){const e=n[i],{glyph:o,scale:r,fontSize:a}=e,l=c;if(R(o.code)){f=q(s,f,d,t.baseline);continue}("underline"!==e.decoration||f&&f.underlineOffset!==e.underlineOffset||f&&!D(f.color,e.color))&&(f=q(s,f,d,t.baseline));const g=d+t.baseline-e.baseline;s.push(M.fromGlyph(c/r,g/r,o,r,{fontSize:a,color:e.color})),c+=e.xAdvance,"underline"===e.decoration&&(f??={startX:l,endX:c,glyphWidthEnd:o.rect.width*r,textureBinding:o.mosaicItem.textureBinding,underlineOffset:e.underlineOffset,color:e.color},f.endX=c,f.glyphWidthEnd=o.rect.width*r,f.textureBinding=f.textureBinding??o.mosaicItem.textureBinding),h>0&&S(o.code)&&(c+=h,f&&(f.endX=c))}q(s,f,d,t.baseline)}return new B(s,i,{...e,decoration:h})}function T(t,e){const n=G(t,e),i=n.reduce((t,e)=>Math.max(t,e.glyph.rect.height*e.scale),0),o=n.filter(t=>!R(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 B(o,[],e)}function G(e,n){const i=n.lineHeightRatio??1,o=[];for(const s of e.runs){const e=t(s.fontSize),n=e/s.glyphs.sdfSize,h=e*(d/24)*i,r=(s.glyphs.faceInfo?.baseline??u)*n,a=(s.glyphs.faceInfo?.midline??y)*n,l=m*n+A(s.decoration),c=1+(s.characterSpacing??0);for(const t of s.glyphs.glyphs){const i=t.shaping.xAdvance*n,d=Math.abs(t.rect.top)*n,f=d+t.rect.height*n;o.push({glyph:t,scale:n,fontSize:e,decoration:s.decoration,underlineOffset:l,color:s.color,xAdvance:R(t.code)||S(t.code)?i:i*c,top:d,bottom:f,lineHeight:h,baseline:r,midline:a})}}return o}function P(t,e){const n=[],i=e.maxLineWidth;let o=0,s=0,h=0,r=0,a=0,l=0;for(;o<t.length;){const e=t[o],{glyph:c}=e;if(R(c.code))0!==o&&n.push({width:s,start:r,end:o-1,glyphWidthEnd:t[o-1]?.glyph.rect.width*t[o-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),s=0,r=o+1,a=r,h=0,l=0;else if(S(c.code))a=o+1,h=0,l=e.xAdvance,s+=e.xAdvance;else if(s>i){if(a!==r){const e=a-2;s-=l,n.push({width:s-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,s=h}else n.push({width:s,start:r,end:o-1,glyphWidthEnd:t[o-1]?.glyph.rect.width*t[o-1]?.scale||0,yMin:0,yMax:0,lineHeight:0,baseline:0,midline:0,startX:0,startY:0,scale:1}),r=o,a=o,s=0;s+=e.xAdvance,h+=e.xAdvance}else s+=e.xAdvance,h+=e.xAdvance;o++}if(r<t.length){const e=t.length-1;n.push({width:s,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 k(t,n)}function k(t,e){for(let n=0;n<e.length;n++){const i=e[n];let o=0,s=1/0,h=0,r=0;for(let e=i.start;e<=i.end;e++){const n=t[e];"underline"===n.decoration&&(r=Math.max(r,n.underlineOffset)),R(n.glyph.code)||S(n.glyph.code)||(o=Math.max(o,n.baseline),h=Math.max(h,n.lineHeight))}let a=1/0,l=-1/0;for(let e=i.start;e<=i.end;e++){const n=t[e];R(n.glyph.code)||S(n.glyph.code)||(a=Math.min(a,o-n.baseline+n.top),l=Math.max(l,o-n.baseline+n.bottom),s=Math.min(s,o-n.baseline+n.midline))}r>0&&(l=Math.max(l,o+r)),i.baseline=o,i.midline=s===1/0?o:s,i.lineHeight=Math.max(h,l),i.yMin=a===1/0?0:a,i.yMax=l===-1/0?0:l,i.startY=n>0?e[n-1].startY+e[n-1].lineHeight:0}return e}function J(t){let e=0;for(const i of t)e=Math.max(i.width+i.glyphWidthEnd,e);const n=t[0].yMin;return{x:0,y:n,height:U(t[t.length-1])-n,width:e}}function U(t){return t.startY+t.lineHeight}function C(t,e,n){let i=0;for(let o=e;o<n;o++)S(t[o].glyph.code)&&!R(t[o+1].glyph.code)&&i++;return i}function q(t,e,n,i){return e?(t.push(M.fromGlyph(e.startX,n+i+e.underlineOffset,_(e.endX-e.startX+e.glyphWidthEnd,e.textureBinding),1,{color:e.color})),null):null}function D(t,e){return t===e||!!t&&!!e&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}export{M as ShapedGlyph,B as ShapingInfo,E as shapeGlyphs,H as shapeGlyphsForMultipoint,I as shapeRichText,T as shapeRichTextForMultipoint,Y as shapeTextResource,j as shapeTextResourceForMultipoint};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import i from"../../../../../core/Error.js";import e from"../../../../../core/Logger.js";import{deg2rad as n,rad2deg as t}from"../../../../../core/mathUtils.js";import{dist as s,set as o,equals as r,subtract as h,len as l,scale as m}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as _,create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as a}from"../../../../../geometry/support/jsonTypeUtils.js";import u from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as g}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as c,fromCIMVerticalAlignment as x,fromCIMFontDecoration as P}from"../../../../../symbols/cim/utils.js";import p from"../../../arcade/callExpressionWithFeature.js";import{magicLabelLineHeight as b}from"../../../engine/webgl/definitions.js";import f from"../../../engine/webgl/Rect.js";import{shapeTextResource as y}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as D,getLineWidth as L}from"../../graphics/graphicsUtils.js";import{initializeDimensionStyleDefaults as R}from"./dimensionStyleDefaults.js";import{DimensionRealFieldName as S,rectsOverlap as M,queryPointOnLine as T,angleFromXAxis as w,intersectLinesByPointsAndAngles as E,measureMarkerSymbolSize as k,translateRect as N,scaleRect as v,rotatePoint as A,rectsOverlapOnAxis as B}from"./dimensionUtils.js";import{getAttributeValue as F}from"./utils.js";class j{static async create(i,e,n){const t=new j(i);return await t.initialize(e,n),t}constructor(i){if(this._dimensionStyle=i,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._compiledExpression=null,this._fieldsIndex=null,this._textResource=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!");R(i)}async initialize(n,t){if(!this._dimensionStyle)return;const{attributes:s}=n;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:s,expressionParserName:o}=this._dimensionStyle;s&&o&&"arcade"===o.toLowerCase()?(this._compiledExpression=await g(s,t),this._fieldsIndex=I(n)):e.getLogger("esri.layers.DimensionFeatureLayer").warn(new i("dimension-layer:unsupported-expression","Only Arcade expressions are supported",{expressionType:o,expression:s}))}const o=Number(F(S.extAngle,s));this._extAngleRad=isNaN(o)?Math.PI/2:o,this._systemLength=Number(F("__SYSTEM_LENGTH__",s));const{geometry:r}=n;if(r&&!a(r))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const h=r?.rings[0];if(!h||h.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=0!==h[3][0]&&0!==h[3][1]&&void 0!==h[3][0]&&void 0!==h[3][1],this._hasTextPoint&&(this._textPoint=h[3]);const l=this._dimensionStyle.textSymbol;s.__DIMENSION_ANGLE__+=l?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}setTextResource(i){this._textResource=i??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,e){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,e),this._evaluateDefaultPlacement(e),this._updateExtensionLines(e),this._updateTextPoint(e),this._offsetTextPoint(e),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:e}=this._dimensionStyle;let n=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===e||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(n=!0);if((M(this._beginMarkerRect,this._textRect)||M(this._endMarkerRect,this._textRect))&&(n=!1),!n){const i=this._textRect.width/2,n=this._beginMarkerRect.width/2,t=this._endMarkerRect.width/2;"MoveBegin"===e?(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,-(i+n)),this._extendDimensionLineForMovedText("begin",n+this._textRect.width)):"MoveEnd"===e&&(this._textPoint=T(this._endDimensionPoint,this._beginDimensionPoint,-(i+t)),this._extendDimensionLineForMovedText("end",t+this._textRect.width))}}}_extendDimensionLineForMovedText(i,e){if(this._dimensionPolyline?.length)if("begin"===i){const i=T(this._beginDimensionPoint,this._endDimensionPoint,-e);this._dimensionPolyline[0]=[i,this._beginDimensionPoint]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+e);this._dimensionPolyline[1]=[i,this._endDimensionPoint]}}_offsetTextPoint(i){if(this._hasTextPoint)return;const e=this._textPoint;if(!e)return;const n=.5*this._textSize*i,t=-n*this._dimensionDirection[1],s=n*this._dimensionDirection[0];e[0]+=t,e[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:e,extensionLineOffset:n}=this._dimensionStyle;let t=this._dimensionLinePoint,o=this._endDimensionPoint;null==e||isNaN(e)||0===e||(t=T(this._dimensionLinePoint,this._beginBaselinePoint,-e*i),o=T(this._endDimensionPoint,this._endBaselinePoint,-e*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=n&&!isNaN(n)&&0!==n){const i=s(t,this._beginBaselinePoint),e=s(o,this._endBaselinePoint);r=T(t,this._beginBaselinePoint,i-n),h=T(o,this._endBaselinePoint,e-n)}this._dimensionExtensionLines=[[t,r],[o,h]]}_computeDimensionLineInfo(e,s){if(!e||!a(e)||e.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const u=e.rings[0],g=_(u[0][0],u[0][1]),c=_(u[1][0],u[1][1]),x=_(u[2][0],u[2][1]);this._beginBaselinePoint=o(d(),g[0],g[1]),this._endBaselinePoint=o(d(),c[0],c[1]),this._dimensionLinePoint=x;let P=this._extAngleRad;if(r(g,x))this._beginDimensionPoint=o(d(),g[0],g[1]),this._endDimensionPoint=o(d(),c[0],c[1]),this._displayExtLines=!1;else{const e=w([c[0]-g[0],c[1]-g[1]]),s=t(P);s>=-1&&s<=1?P+=n(1):s>=179&&s<=181&&(P-=n(1));const r=E(x,e,c,e+P);if(!r)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=o(d(),x[0],x[1]),this._endDimensionPoint=o(d(),r[0],r[1])}this._dimensionDirection=h(d(),this._endDimensionPoint,this._beginDimensionPoint),this._dimensionAngleRad=w(this._dimensionDirection),this._dimensionLength=l(this._dimensionDirection),this._dimensionDirection=m(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2))}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:e,endMarkerSymbol:n}=this._dimensionStyle,t=k(e,this._dimensionAngleRad),s=k(n,this._dimensionAngleRad+Math.PI),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const r=i*((t?.width??0)/2),h=i*((s?.width??0)/2),l=t&&this._beginDimensionPoint?N(v(t,i),this._beginDimensionPoint[0],this._beginDimensionPoint[1]):null,m=s&&this._endDimensionPoint?N(v(s,i),this._endDimensionPoint[0],this._endDimensionPoint[1]):null;if(this._beginMarkerRect=l,this._endMarkerRect=m,this._doMarkersFit=this._checkMarkerFit(l,m,o,i),this._doMarkersFit){const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,-4*r),e=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*h);this._dimensionPolyline=[[i,this._beginDimensionPoint],[e,this._endDimensionPoint]]}}_checkMarkerFit(i,e,n,t){if(!i||!e)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;const l=(i,e)=>M(i,e)||B(i,e,this._dimensionDirection);if("Tolerance"===s)r*t>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?l(i,e)&&(h=!1):(l(i,e)&&(h=!1),h&&n&&(l(n,i)||l(n,e))&&(h=!1))}return h}_measureDimensionText(i,e,n){if(null==this._textString||null==e||null==this._textResource)return null;const t=this._dimensionStyle.textSymbol;if(!t)return null;const s=c(t.horizontalAlignment),o=x(t.verticalAlignment),r=P(t),h=D(t.height||10);this._textSize="glyphs"===this._textResource.type?h:Math.max(h,...this._textResource.runs.map(i=>D(i.fontSize||0)));const l=!0,m=t.angle||0,_="glyphs"===this._textResource.type?this._textResource.sdfSize:this._textResource.runs[0]?.glyphs.sdfSize;if(!_)return null;const d=h/_,a=L(t.lineWidth),u=Math.max(.25,Math.min(h||1,4)),g=b*u,p=y(this._textResource,{scale:d,angle:m,xOffset:0,yOffset:0,horizontalAlignment:s,verticalAlignment:o,decoration:r,lineHeight:g,lineHeightRatio:u,useCIMAngleBehavior:l,maxLineWidth:a,hasBackground:!1}),R=e;if(!R)return null;const S=n,M=[p.bounds.blX,p.bounds.trY],T=[p.bounds.trX,p.bounds.trY],w=[p.bounds.blX,p.bounds.blY],E=[p.bounds.trX,p.bounds.blY];M[0]-=p.bounds.x,M[1]-=p.bounds.y,T[0]-=p.bounds.x,T[1]-=p.bounds.y,w[0]-=p.bounds.x,w[1]-=p.bounds.y,E[0]-=p.bounds.x,E[1]-=p.bounds.y,M[0]*=S,M[1]*=S,T[0]*=S,T[1]*=S,w[0]*=S,w[1]*=S,E[0]*=S,E[1]*=S,this._dimensionAngleRad&&(A(M,this._dimensionAngleRad),A(T,this._dimensionAngleRad),A(w,this._dimensionAngleRad),A(E,this._dimensionAngleRad)),M[0]+=R[0],M[1]+=R[1],T[0]+=R[0],T[1]+=R[1],w[0]+=R[0],w[1]+=R[1],E[0]+=R[0],E[1]+=R[1];const k=Math.min(M[0],T[0],w[0],E[0]),N=Math.min(M[1],T[1],w[1],E[1]),v=Math.max(M[0],T[0],w[0],E[0]),B=Math.max(M[1],T[1],w[1],E[1]);return new f(k,N,1.1*(v-k),1.1*(B-N))}_getDimensionText(i){const{attributes:e}=i;let n=null;const t=1===Number(F(S.useCustomLength,e));n=Number(F(t?S.customLength:S.dimLength,e)),(0===n||isNaN(n)||null==n)&&(n=this._systemLength);let s=this._getDimensionString(n,i);return"number"==typeof s&&(s=s.toString()),e.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,e){const{convertUnits:n,displayUnits:t,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&e)return p(this._compiledExpression,e,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function I(i){const{attributes:e}=i,n=Object.keys(S).map(i=>({name:i,alias:i,type:"string"==typeof e[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new u(n)}export{j as default};
2
+ import i from"../../../../../core/Error.js";import n from"../../../../../core/Logger.js";import{dist as e,set as t,subtract as s,len as o,scale as r,equals as h}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{isPolygon as _}from"../../../../../geometry/support/jsonTypeUtils.js";import d from"../../../../../layers/support/FieldsIndex.js";import{createRendererExpression as a}from"../../../../../support/ArcadeExpression.js";import{fromCIMHorizontalAlignment as u,fromCIMVerticalAlignment as g,fromCIMFontDecoration as c}from"../../../../../symbols/cim/utils.js";import x from"../../../arcade/callExpressionWithFeature.js";import{magicLabelLineHeight as P}from"../../../engine/webgl/definitions.js";import p from"../../../engine/webgl/Rect.js";import{shapeTextResource as b}from"../../../engine/webgl/mesh/templates/shapingUtils.js";import{roundPtToWholePixel as y,getLineWidth as D}from"../../graphics/graphicsUtils.js";import{initializeDimensionStyleDefaults as f}from"./dimensionStyleDefaults.js";import{normalizeExtensionAngle as L,DimensionRealFieldName as R,rectsOverlap as S,queryPointOnLine as T,angleFromXAxis as M,capDimensionExtensionAngle as w,intersectLinesByPointsAndAngles as E,projectLinearDimensionPoints as k,measureMarkerSymbolSize as v,translateRect as A,scaleRect as F,rotatePoint as N,rectsOverlapOnAxis as B}from"./dimensionUtils.js";import{getAttributeValue as j}from"./utils.js";class I{static async create(i,n,e){const t=new I(i);return await t.initialize(n,e),t}constructor(i){if(this._dimensionStyle=i,this._textString=null,this._displayExtLines=!0,this._systemLength=0,this._dimensionAngleRad=0,this._dimensionLength=0,this._dimensionDirection=null,this._textSize=null,this._extAngleRad=Math.PI/2,this._dimensionType=0,this._compiledExpression=null,this._fieldsIndex=null,this._textResource=null,this._beginBaselinePoint=null,this._endBaselinePoint=null,this._dimensionLinePoint=null,this._beginDimensionPoint=null,this._endDimensionPoint=null,this._beginMarkerRect=null,this._endMarkerRect=null,this._textRect=null,this._textPoint=null,this._dimensionPolyline=null,this._dimensionExtensionLines=null,this._hasTextPoint=!1,this._doMarkersFit=!0,this._dimensionIsEvaluated=!1,null==i)throw new Error("dimension syle must be defined!");f(i)}async initialize(e,t){if(!this._dimensionStyle)return;const{attributes:s}=e;if("Expression"===(this._dimensionStyle.textOption??"None")){const{expression:s,expressionParserName:o}=this._dimensionStyle;s&&o&&"arcade"===o.toLowerCase()?(this._compiledExpression=await a(s,t),this._fieldsIndex=O(e)):n.getLogger("esri.layers.DimensionFeatureLayer").warn(new i("dimension-layer:unsupported-expression","Only Arcade expressions are supported",{expressionType:o,expression:s}))}this._extAngleRad=L(j(R.extAngle,s)),this._dimensionType=1===Number(j(R.dimType,s))?1:0,this._systemLength=Number(j("__SYSTEM_LENGTH__",s));const{geometry:o}=e;if(o&&!_(o))throw new i("dimension-layer","processed geometry must be a valid 'polygon'.");const r=o?.rings[0];if(!r||r.length<3)throw new i("dimension-layer","processed geometry must have at least 3 points.");this._hasTextPoint=null!=r[3]&&0!==r[3][0]&&0!==r[3][1]&&void 0!==r[3][0]&&void 0!==r[3][1],this._hasTextPoint&&(this._textPoint=r[3]);const h=this._dimensionStyle.textSymbol;s.__DIMENSION_ANGLE__+=h?.angle??0}getTextString(i){return null==this._textString&&(this._textString=this._getDimensionText(i)),this._textString}get textSymbol(){return this._dimensionStyle.textSymbol??null}setTextResource(i){this._textResource=i??null}get beginBaselinePoint(){return this._beginBaselinePoint}get endBaselinePoint(){return this._endBaselinePoint}get beginDimensionPoint(){return this._beginDimensionPoint}get endDimensionPoint(){return this._endDimensionPoint}get textPoint(){return this._textPoint}get dimensionLine(){return this._dimensionPolyline}get extensionLines(){return this._displayExtLines?this._dimensionExtensionLines:null}evaluateWithGeometry(i,n){this._dimensionIsEvaluated||(this._computeDimensionLineInfo(i,n),this._evaluateDefaultPlacement(n),this._updateExtensionLines(n),this._updateTextPoint(n),this._offsetTextPoint(n),this._dimensionIsEvaluated=!0)}_updateTextPoint(i){if(this._hasTextPoint)return;const{textFit:n}=this._dimensionStyle;let e=!0;if(!this._doMarkersFit){if(this._hasTextPoint)return;if("None"===n||!this._beginMarkerRect||!this._endMarkerRect||!this._textRect)return void(e=!0);if((S(this._beginMarkerRect,this._textRect)||S(this._endMarkerRect,this._textRect))&&(e=!1),!e){const i=this._textRect.width/2,e=this._beginMarkerRect.width/2,t=this._endMarkerRect.width/2;"MoveBegin"===n?(this._textPoint=T(this._beginDimensionPoint,this._endDimensionPoint,-(i+e)),this._extendDimensionLineForMovedText("begin",e+this._textRect.width)):"MoveEnd"===n&&(this._textPoint=T(this._endDimensionPoint,this._beginDimensionPoint,-(i+t)),this._extendDimensionLineForMovedText("end",t+this._textRect.width))}}}_extendDimensionLineForMovedText(i,n){if(this._dimensionPolyline?.length)if("begin"===i){const i=T(this._beginDimensionPoint,this._endDimensionPoint,-n);this._dimensionPolyline[0]=[i,this._beginDimensionPoint]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+n);this._dimensionPolyline[1]=[i,this._endDimensionPoint]}}_offsetTextPoint(i){if(this._hasTextPoint)return;const n=this._textPoint;if(!n)return;const e=.5*this._textSize*i,t=-e*this._dimensionDirection[1],s=e*this._dimensionDirection[0];n[0]+=t,n[1]+=s}_updateExtensionLines(i){if(!(this._displayExtLines&&this._beginDimensionPoint&&this._dimensionLinePoint&&this._endDimensionPoint))return;const{extensionLineOvershot:n,extensionLineOffset:t}=this._dimensionStyle;let s=this._dimensionLinePoint,o=this._endDimensionPoint;null==n||isNaN(n)||0===n||(s=T(this._dimensionLinePoint,this._beginBaselinePoint,-n*i),o=T(this._endDimensionPoint,this._endBaselinePoint,-n*i));let r=this._beginBaselinePoint,h=this._endBaselinePoint;if(null!=t&&!isNaN(t)&&0!==t){const i=e(s,this._beginBaselinePoint),n=e(o,this._endBaselinePoint);r=T(s,this._beginBaselinePoint,i-t),h=T(o,this._endBaselinePoint,n-t)}this._dimensionExtensionLines=[[s,r],[o,h]]}_computeDimensionLineInfo(n,e){if(!n||!_(n)||n.rings[0].length<3)throw new i("DimensionLayerView: bad geometry","Dimension cann't be applied to an empty geometry!");const h=n.rings[0],d=l(h[0][0],h[0][1]),a=l(h[1][0],h[1][1]),u=l(h[2][0],h[2][1]);this._beginBaselinePoint=t(m(),d[0],d[1]),this._endBaselinePoint=t(m(),a[0],a[1]),this._dimensionLinePoint=u,1===this._dimensionType?this._computeLinearDimensionPoints(d,a,u):this._computeAlignedDimensionPoints(d,a,u);const g=this._beginDimensionPoint,c=this._endDimensionPoint;if(!g||!c)throw new i("DimensionLayerView: bad geometry","Failed to construct the dimension line!");this._dimensionDirection=s(m(),c,g),this._dimensionAngleRad=M(this._dimensionDirection),this._dimensionLength=o(this._dimensionDirection),this._dimensionDirection=r(this._dimensionDirection,this._dimensionDirection,1/this._dimensionLength),this._hasTextPoint||(this._textPoint=T(g,c,this._dimensionLength/2))}_computeAlignedDimensionPoints(n,e,s){const o=w(this._extAngleRad);if(h(n,s))return this._beginDimensionPoint=t(m(),n[0],n[1]),this._endDimensionPoint=t(m(),e[0],e[1]),void(this._displayExtLines=!1);const r=M([e[0]-n[0],e[1]-n[1]]),l=E(s,r,e,r+o);if(!l)throw new i("DimensionLayerView: bad geometry","Failed to construct dimension extension lines!");this._beginDimensionPoint=t(m(),s[0],s[1]),this._endDimensionPoint=t(m(),l[0],l[1])}_computeLinearDimensionPoints(i,n,e){const s=k(i,n,e,this._extAngleRad);if(!s)return this._beginDimensionPoint=t(m(),i[0],i[1]),this._endDimensionPoint=t(m(),n[0],n[1]),void(this._displayExtLines=!1);this._beginDimensionPoint=s.beginDimensionPoint,this._endDimensionPoint=s.endDimensionPoint}_evaluateDefaultPlacement(i){const{beginMarkerSymbol:n,endMarkerSymbol:e}=this._dimensionStyle,t=v(n,this._dimensionAngleRad),s=v(e,this._dimensionAngleRad+Math.PI),o=this._measureDimensionText(this._textString||"",this._textPoint,i);this._textRect=o;const r=i*((t?.width??0)/2),h=i*((s?.width??0)/2),l=t&&this._beginDimensionPoint?A(F(t,i),this._beginDimensionPoint[0],this._beginDimensionPoint[1]):null,m=s&&this._endDimensionPoint?A(F(s,i),this._endDimensionPoint[0],this._endDimensionPoint[1]):null;if(this._beginMarkerRect=l,this._endMarkerRect=m,this._doMarkersFit=this._checkMarkerFit(l,m,o,i),this._doMarkersFit){const i=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength/2);this._dimensionPolyline=[[i,this._beginDimensionPoint],[i,this._endDimensionPoint]]}else{const i=T(this._beginDimensionPoint,this._endDimensionPoint,-4*r),n=T(this._beginDimensionPoint,this._endDimensionPoint,this._dimensionLength+4*h);this._dimensionPolyline=[[i,this._beginDimensionPoint],[n,this._endDimensionPoint]]}}_checkMarkerFit(i,n,e,t){if(!i||!n)return!1;const{markerFit:s,markerOption:o,markerFitTolerance:r}=this._dimensionStyle;if("None"===s)return!0;let h=!0;const l=(i,n)=>S(i,n)||B(i,n,this._dimensionDirection);if("Tolerance"===s)r*t>=this._dimensionLength&&(h=!1);else{if(this._hasTextPoint&&"Both"!==o)return!0;this._hasTextPoint&&"Both"===o?l(i,n)&&(h=!1):(l(i,n)&&(h=!1),h&&e&&(l(e,i)||l(e,n))&&(h=!1))}return h}_measureDimensionText(i,n,e){if(null==this._textString||null==n||null==this._textResource)return null;const t=this._dimensionStyle.textSymbol;if(!t)return null;const s=u(t.horizontalAlignment),o=g(t.verticalAlignment),r=c(t),h=y(t.height||10);this._textSize="glyphs"===this._textResource.type?h:Math.max(h,...this._textResource.runs.map(i=>y(i.fontSize||0)));const l=!0,m=t.angle||0,_="glyphs"===this._textResource.type?this._textResource.sdfSize:this._textResource.runs[0]?.glyphs.sdfSize;if(!_)return null;const d=h/_,a=D(t.lineWidth),x=Math.max(.25,Math.min(h||1,4)),f=P*x,L=b(this._textResource,{scale:d,angle:m,xOffset:0,yOffset:0,horizontalAlignment:s,verticalAlignment:o,decoration:r,lineHeight:f,lineHeightRatio:x,useCIMAngleBehavior:l,maxLineWidth:a,hasBackground:!1}),R=n;if(!R)return null;const S=e,T=[L.bounds.blX,L.bounds.trY],M=[L.bounds.trX,L.bounds.trY],w=[L.bounds.blX,L.bounds.blY],E=[L.bounds.trX,L.bounds.blY];T[0]-=L.bounds.x,T[1]-=L.bounds.y,M[0]-=L.bounds.x,M[1]-=L.bounds.y,w[0]-=L.bounds.x,w[1]-=L.bounds.y,E[0]-=L.bounds.x,E[1]-=L.bounds.y,T[0]*=S,T[1]*=S,M[0]*=S,M[1]*=S,w[0]*=S,w[1]*=S,E[0]*=S,E[1]*=S,this._dimensionAngleRad&&(N(T,this._dimensionAngleRad),N(M,this._dimensionAngleRad),N(w,this._dimensionAngleRad),N(E,this._dimensionAngleRad)),T[0]+=R[0],T[1]+=R[1],M[0]+=R[0],M[1]+=R[1],w[0]+=R[0],w[1]+=R[1],E[0]+=R[0],E[1]+=R[1];const k=Math.min(T[0],M[0],w[0],E[0]),v=Math.min(T[1],M[1],w[1],E[1]),A=Math.max(T[0],M[0],w[0],E[0]),F=Math.max(T[1],M[1],w[1],E[1]);return new p(k,v,1.1*(A-k),1.1*(F-v))}_getDimensionText(i){const{attributes:n}=i;let e=null;const t=1===Number(j(R.useCustomLength,n));e=Number(j(t?R.customLength:R.dimLength,n)),(0===e||isNaN(e)||null==e)&&(e=this._systemLength);let s=this._getDimensionString(e,i);return"number"==typeof s&&(s=s.toString()),n.__COMPUTED_TEXT_STRING__=s,s||""}_getDimensionString(i,n){const{convertUnits:e,displayUnits:t,displayPrecision:s,prefix:o,suffix:r,textOption:h}=this._dimensionStyle;if("None"===h)return null;if("Expression"===h&&this._compiledExpression&&n)return x(this._compiledExpression,n,{},"esriGeometryPolyline",this._fieldsIndex);let l=(i=null==s||isNaN(s)?parseFloat(i.toString()):parseFloat(i.toFixed(s))).toString();return"Suffix"===h&&(o&&(l=`${o} ${l}`),r&&(l=`${l} ${r}`)),l}}function O(i){const{attributes:n}=i,e=Object.keys(R).map(i=>({name:i,alias:i,type:"string"==typeof n[i]?"esriFieldTypeString":"esriFieldTypeDouble"}));return new d(e)}export{I as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{rad2deg as e}from"../../../../../core/mathUtils.js";import t from"../../../../../geometry/Point.js";import{normalizeTransform as r,quantizeY as o,quantizeX as n}from"../../../../../geometry/support/quantizationUtils.js";import{convertToGeometry as i}from"../../../../../layers/graphics/featureConversionUtils.js";import a from"../../../../../layers/graphics/OptimizedGeometry.js";import{project as m}from"../../../../../layers/graphics/data/projectionSupport.js";import{DimensionRealFieldName as s}from"./dimensionUtils.js";import{getAttributeValue as u,parseElement as y,reprojectAndQuantize as p}from"./utils.js";import{featureFields as l}from"./virtualFields.js";function f(e){const t=e.readAttribute("element");if(!t)return null;const o=e.getInTransform()??e.getDisplayTransform();if(!o)throw new Error("Quantization transform is required to read annotation features.");const n=e.geometryType;if(!n)return null;const i=e.metadata.outSpatialReference,a=e.metadata.attributeSpatialReference??e.metadata.spatialReference??i,m=r(o),s=y(t),{geometry:u}=s;if(!u)return null;const f=p(u,a,i,m);if(!f)return null;const c={},g={annotationGeometryType:d(s),annotationGraphic:s,attributes:c,geometryOverride:{geometry:f,geometryType:n}};for(const r of l)r.setOnFeature(g,s);return g}function c(i){const y=i.getInTransform()??i.getDisplayTransform();if(!y)throw new Error("Quantization transform is required to read dimension features.");const p=i.geometryType;if(!p)return null;const l={...i.readAttributes()},f=i.metadata.outSpatialReference,c=i.metadata.attributeSpatialReference??i.metadata.spatialReference??f,g=r(y),d={x:Number(u(s.beginX,l)),y:Number(u(s.beginY,l)),spatialReference:c},b={x:Number(u(s.endX,l)),y:Number(u(s.endY,l)),spatialReference:c},N={x:Number(u(s.dimX,l)),y:Number(u(s.dimY,l)),spatialReference:c};if(isNaN(d.x)||isNaN(d.y)||isNaN(b.x)||isNaN(b.y))return console.error(`Feature with ${s.objectId}=${u(s.objectId,l)} is missing valid begin, end, or dimension points and will be skipped.`),null;(isNaN(N.x)||isNaN(N.y))&&(N.x=d.x,N.y=d.y);const x=m(new t(d),c,f),h=m(new t(b),c,f),w=[x,h,m(new t(N),c,f)],j=Math.sqrt((h.x-x.x)*(h.x-x.x)+(h.y-x.y)*(h.y-x.y)),T=h.x-x.x,R=h.y-x.y;let _=Math.PI/2;0!==T?_=Math.atan2(R,T):R<0&&(_=-Math.PI/2);const E=u(s.textX,l),I=u(s.textY,l);if(null!=E&&null!=I){const e=new t({x:Number(E),y:Number(I),spatialReference:c}),r=m(e,c,f);w.push(r)}const S=w.map(e=>({x:n(g,e.x),y:o(g,e.y)})).flatMap(e=>[e.x,e.y]);return l.__SYSTEM_LENGTH__=j,l.__DIMENSION_ANGLE__=360-e(_),{attributes:l,geometryOverride:{geometry:new a([S.length],S),geometryType:p}}}function g(e,t){const{geometry:r,geometryType:o}=t.geometryOverride,n=i(r,o,!1,!1);return n?{attributes:{...e.readAttributes(),...t.attributes},centroid:null,geometry:n}:null}function d(e){if(e.geometry){if("custom-two-point"===e.geometry.type)return"line";if("custom-multipoint"===e.geometry.type)return"multipoint";if("geometry-bag"===e.geometry.type){if("custom-multipoint"===e.geometry.geometries[0].type)return"multipoint";throw new Error("Unable to determine geometry type from annotation graphic")}if("custom-point"===e.geometry.type)return"point";if("polyline"===e.geometry.type)return"line";if("point"===e.geometry.type)return"point";throw new Error("Unable to determine geometry type from annotation graphic")}throw new Error("Unable to determine geometry type from annotation graphic")}export{f as createAnnotationMatcherFeatureInfo,c as createDimensionMatcherFeatureInfo,d as getAnnotationGeometryType,g as mixFeature};
2
+ import{rad2deg as e}from"../../../../../core/mathUtils.js";import t from"../../../../../geometry/Point.js";import{normalizeTransform as r,quantizeY as n,quantizeX as o}from"../../../../../geometry/support/quantizationUtils.js";import{convertToGeometry as i}from"../../../../../layers/graphics/featureConversionUtils.js";import a from"../../../../../layers/graphics/OptimizedGeometry.js";import{project as m}from"../../../../../layers/graphics/data/projectionSupport.js";import{DimensionRealFieldName as s,projectLinearDimensionPoints as u,normalizeExtensionAngle as y,angleFromXAxis as p}from"./dimensionUtils.js";import{getAttributeValue as l,parseElement as f,reprojectAndQuantize as c}from"./utils.js";import{featureFields as g}from"./virtualFields.js";function d(e){const t=e.readAttribute("element");if(!t)return null;const n=e.getInTransform()??e.getDisplayTransform();if(!n)throw new Error("Quantization transform is required to read annotation features.");const o=e.geometryType;if(!o)return null;const i=e.metadata.outSpatialReference,a=e.metadata.attributeSpatialReference??e.metadata.spatialReference??i,m=r(n),s=f(t),{geometry:u}=s;if(!u)return null;const y=c(u,a,i,m);if(!y)return null;const p={},l={annotationGeometryType:h(s),annotationGraphic:s,attributes:p,geometryOverride:{geometry:y,geometryType:o}};for(const r of g)r.setOnFeature(l,s);return l}function b(i){const f=i.getInTransform()??i.getDisplayTransform();if(!f)throw new Error("Quantization transform is required to read dimension features.");const c=i.geometryType;if(!c)return null;const g={...i.readAttributes()},d=i.metadata.outSpatialReference,b=i.metadata.attributeSpatialReference??i.metadata.spatialReference??d,N=r(f),h={x:Number(l(s.beginX,g)),y:Number(l(s.beginY,g)),spatialReference:b},x={x:Number(l(s.endX,g)),y:Number(l(s.endY,g)),spatialReference:b},w={x:Number(l(s.dimX,g)),y:Number(l(s.dimY,g)),spatialReference:b};if(isNaN(h.x)||isNaN(h.y)||isNaN(x.x)||isNaN(x.y))return console.error(`Feature with ${s.objectId}=${l(s.objectId,g)} is missing valid begin, end, or dimension points and will be skipped.`),null;(isNaN(w.x)||isNaN(w.y))&&(w.x=h.x,w.y=h.y);const T=m(new t(h),b,d),j=m(new t(x),b,d),R=m(new t(w),b,d),_=[T,j,R],E=j.x-T.x,I=j.y-T.y;let M=Math.PI/2;0!==E?M=Math.atan2(I,E):I<0&&(M=-Math.PI/2);let S=Math.sqrt(E*E+I*I);if(1===Number(l(s.dimType,g))){const e=u([T.x,T.y],[j.x,j.y],[R.x,R.y],y(l(s.extAngle,g)));if(e){const t=e.endDimensionPoint[0]-e.beginDimensionPoint[0],r=e.endDimensionPoint[1]-e.beginDimensionPoint[1];S=Math.sqrt(t*t+r*r),M=p([t,r])}}const D=l(s.textX,g),P=l(s.textY,g);if(null!=D&&null!=P){const e=new t({x:Number(D),y:Number(P),spatialReference:b}),r=m(e,b,d);_.push(r)}const U=_.map(e=>({x:o(N,e.x),y:n(N,e.y)})).flatMap(e=>[e.x,e.y]);return g.__SYSTEM_LENGTH__=S,g.__DIMENSION_ANGLE__=360-e(M),{attributes:g,geometryOverride:{geometry:new a([U.length],U),geometryType:c}}}function N(e,t){const{geometry:r,geometryType:n}=t.geometryOverride,o=i(r,n,!1,!1);return o?{attributes:{...e.readAttributes(),...t.attributes},centroid:null,geometry:o}:null}function h(e){if(e.geometry){if("custom-two-point"===e.geometry.type)return"line";if("custom-multipoint"===e.geometry.type)return"multipoint";if("geometry-bag"===e.geometry.type){if("custom-multipoint"===e.geometry.geometries[0].type)return"multipoint";throw new Error("Unable to determine geometry type from annotation graphic")}if("custom-point"===e.geometry.type)return"point";if("polyline"===e.geometry.type)return"line";if("point"===e.geometry.type)return"point";throw new Error("Unable to determine geometry type from annotation graphic")}throw new Error("Unable to determine geometry type from annotation graphic")}export{d as createAnnotationMatcherFeatureInfo,b as createDimensionMatcherFeatureInfo,h as getAnnotationGeometryType,N as mixFeature};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{getFontFamily as t}from"../../../../../core/fontUtils.js";import{set as n,len as o,scaleAndAdd as e,dot as i}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as a}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as c}from"../../../../../geometry/support/boundsUtils.js";import{fromCIMFontDecoration as s,fromCIMFontStyle as u}from"../../../../../symbols/cim/utils.js";import f from"../../../engine/webgl/Rect.js";function m(n){const o=s(n),{style:e,weight:i}=u(n.fontStyleName);return{family:t(n.fontFamilyName),decoration:o,style:e,weight:i}}function h(t){const n=(t.symbolLayers||[]).map(t=>{if("CIMVectorMarker"===t.type){const n=t.frame.xmax-t.frame.xmin;return{...t,frame:{xmin:t.frame.xmin,ymin:t.frame.ymin,xmax:t.frame.xmax+n,ymax:t.frame.ymax}}}return t});return{...t,symbolLayers:n}}function l(t,n,o){if(!t?.symbolLayers?.length)return null;const e=h(t);let i=null;for(const a of e.symbolLayers||[]){const t=x(a,n);t&&(i=i?L(i,t):t)}const r=new f(-16,-16,32,32);return i?L(i,r):r}function x(t,n){switch(t.type){case"CIMVectorMarker":return y(t,n);case"CIMPictureMarker":return M(t,n);default:return g(t,n)}}function y(t,n){const o=p(t.markerGraphics),e=t.frame,i=e?new f(e.xmin,e.ymin,e.xmax-e.xmin,e.ymax-e.ymin):null,r=o??i??w(t.size);if(!r)return null;const a=P(r),c=null!=e?.xmax&&null!=e?.xmin?e.xmax-e.xmin:r.width,s=null!=e?.ymax&&null!=e?.ymin?e.ymax-e.ymin:r.height,u=t.size&&s?t.size/s:1;if(i&&E(a,.5*-(e.xmax+e.xmin),.5*-(e.ymax+e.ymin)),t.anchorPoint){let n=t.anchorPoint.x,o=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits?(n*=c,o*=s):0!==u&&(n/=u,o/=u),E(a,-n,-o)}return 1!==u&&b(a,u,u),d(a,t,n),I(a)}function M(t,n){const o=t.size;if(!o)return null;const e=o*(t.scaleX??1),i=P(new f(-e/2,-o/2,e,o));if(t.anchorPoint){let n=t.anchorPoint.x,r=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits&&(n*=e,r*=o),E(i,-n,-r)}return d(i,t,n),I(i)}function g(t,n){const o=w(t.size);if(!o)return null;const e=P(o);if(t.anchorPoint){let n=t.anchorPoint.x,i=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits&&(n*=o.width,i*=o.height),E(e,-n,-i)}return d(e,t,n),I(e)}function p(t){let n=null;for(const o of t||[]){if(!o.geometry)continue;const t=c(a(),o.geometry),e=new f(t[0],t[1],t[2]-t[0],t[3]-t[1]);n=n?L(n,e):e}return n}function w(t){return t?new f(-t/2,-t/2,t,t):null}function d(t,n,o){const e=n.rotation??0,i=(n.rotateClockwise?-e:e)*(Math.PI/180);i&&T(t,i),(n.offsetX||n.offsetY)&&E(t,n.offsetX??0,n.offsetY??0),o&&T(t,o)}function P(t){return[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]]}function I(t){let n=1/0,o=1/0,e=-1/0,i=-1/0;for(const[r,a]of t)n=Math.min(n,r),o=Math.min(o,a),e=Math.max(e,r),i=Math.max(i,a);return new f(n,o,e-n,i-o)}function E(t,n,o){for(const e of t)e[0]+=n,e[1]+=o}function b(t,n,o){for(const e of t)e[0]*=n,e[1]*=o}function T(t,n){for(const o of t)G(o,n)}function L(t,n){const o=Math.min(t.x,n.x),e=Math.min(t.y,n.y),i=Math.max(t.x+t.width,n.x+n.width),r=Math.max(t.y+t.height,n.y+n.height);return new f(o,e,i-o,r-e)}var X;function D(t,i,a){const c=n(r(),i[0]-t[0],i[1]-t[1]),s=o(c);return 0===s?[t[0],t[1]]:e(r(),t,c,a/s)}function Y(t){return{left:t.x,right:t.x+t.width,top:t.y+t.height,bottom:t.y}}function A(t,n){const o=Y(t),e=Y(n),i=o.left<=e.right&&e.left<=o.right,r=o.bottom<=e.top&&e.bottom<=o.top;return i&&r}function N(t,n,o){const e=S(t,o),i=S(n,o);return e[0]<=i[1]&&i[0]<=e[1]}function S(t,n){const o=[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]];let e=1/0,r=-1/0;for(const[a,c]of o){const t=i([a,c],n);e=Math.min(e,t),r=Math.max(r,t)}return[e,r]}function j(t,n){return new f(t.x*n,t.y*n,t.width*n,t.height*n)}function C(t,n,o){return new f(t.x+n,t.y+o,t.width,t.height)}function G(t,n){const o=t[0],e=t[1];t[0]=o*Math.cos(n)-e*Math.sin(n),t[1]=o*Math.sin(n)+e*Math.cos(n)}!function(t){t.objectId="OBJECTID",t.shape="SHAPE",t.dimLength="DIMLENGTH",t.beginX="BEGINX",t.beginY="BEGINY",t.endX="ENDX",t.endY="ENDY",t.textX="TEXTX",t.textY="TEXTY",t.styleId="STYLEID",t.dimX="DIMX",t.dimY="DIMY",t.customLength="CUSTOMLENGTH",t.useCustomLength="USECUSTOMLENGTH",t.dimDisplay="DIMDISPLAY",t.extDisplay="EXTDISPLAY",t.markerDisplay="MARKERDISPLAY",t.extAngle="EXTANGLE",t.dimType="DIMTYPE",t.textAngle="TEXTANGLE"}(X||(X={}));const U=1e-9;function k(t,n){return t[0]*n[1]-t[1]*n[0]}function z(t,n,o,e){return B(t,n,o,e)?.point??null}function B(t,o,i,a){const c=n(r(),Math.cos(o),Math.sin(o)),s=n(r(),Math.cos(a),Math.sin(a)),u=n(r(),i[0]-t[0],i[1]-t[1]),f=k(c,s);if(Math.abs(f)<=U)return null;const m=k(u,s)/f,h=k(u,c)/f;return{point:e(r(),t,c,m),t1:m,t2:h}}function H(t){const n=t[0],o=t[1];if(0===n&&0===o)return 0;if(0===n&&o>0)return Math.PI/2;if(0===n&&o<0)return 3*Math.PI/2;if(n<0&&0===o)return Math.PI;if(n>0&&0===o)return 0;let e=Math.atan2(o,n);return e<0&&(e+=2*Math.PI),e}export{X as DimensionRealFieldName,H as angleFromXAxis,m as getFontForCIMTextSymbol,z as intersectLinesByPointsAndAngles,l as measureMarkerSymbolSize,S as projectRectToAxis,D as queryPointOnLine,A as rectsOverlap,N as rectsOverlapOnAxis,h as repositionMarkerSymbol,G as rotatePoint,j as scaleRect,Y as toBounds,C as translateRect};
2
+ import{getFontFamily as t}from"../../../../../core/fontUtils.js";import{deg2rad as n,rad2deg as o}from"../../../../../core/mathUtils.js";import{set as i,len as e,scaleAndAdd as r,dot as c}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as a}from"../../../../../geometry/support/boundsUtils.js";import{fromCIMFontDecoration as f,fromCIMFontStyle as h}from"../../../../../symbols/cim/utils.js";import m from"../../../engine/webgl/Rect.js";function l(n){const o=f(n),{style:i,weight:e}=h(n.fontStyleName);return{family:t(n.fontFamilyName),decoration:o,style:i,weight:e}}function y(t){const n=(t.symbolLayers||[]).map(t=>"CIMVectorMarker"!==t.type||t.anchorPoint||!t.frame?t:{...t,anchorPointUnits:"Absolute",anchorPoint:{x:-t.frame.xmin,y:0}});return{...t,symbolLayers:n}}function x(t,n,o){if(!t?.symbolLayers?.length)return null;const i=y(t);let e=null;for(const c of i.symbolLayers||[]){const t=M(c,n);t&&(e=e?N(e,t):t)}const r=new m(-16,-16,32,32);return e?N(e,r):r}function M(t,n){switch(t.type){case"CIMVectorMarker":return g(t,n);case"CIMPictureMarker":return P(t,n);default:return p(t,n)}}function g(t,n){const o=d(t.markerGraphics),i=t.frame,e=i?new m(i.xmin,i.ymin,i.xmax-i.xmin,i.ymax-i.ymin):null,r=o??e??w(t.size);if(!r)return null;const c=b(r),s=null!=i?.xmax&&null!=i?.xmin?i.xmax-i.xmin:r.width,u=null!=i?.ymax&&null!=i?.ymin?i.ymax-i.ymin:r.height,a=t.size&&u?t.size/u:1;if(e&&D(c,.5*-(i.xmax+i.xmin),.5*-(i.ymax+i.ymin)),t.anchorPoint){let n=t.anchorPoint.x,o=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits?(n*=s,o*=u):0!==a&&(n/=a,o/=a),D(c,-n,-o)}return 1!==a&&T(c,a,a),I(c,t,n),E(c)}function P(t,n){const o=t.size;if(!o)return null;const i=o*(t.scaleX??1),e=b(new m(-i/2,-o/2,i,o));if(t.anchorPoint){let n=t.anchorPoint.x,r=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits&&(n*=i,r*=o),D(e,-n,-r)}return I(e,t,n),E(e)}function p(t,n){const o=w(t.size);if(!o)return null;const i=b(o);if(t.anchorPoint){let n=t.anchorPoint.x,e=t.anchorPoint.y;"Absolute"!==t.anchorPointUnits&&(n*=o.width,e*=o.height),D(i,-n,-e)}return I(i,t,n),E(i)}function d(t){let n=null;for(const o of t||[]){if(!o.geometry)continue;const t=a(u(),o.geometry),i=new m(t[0],t[1],t[2]-t[0],t[3]-t[1]);n=n?N(n,i):i}return n}function w(t){return t?new m(-t/2,-t/2,t,t):null}function I(t,n,o){const i=n.rotation??0,e=(n.rotateClockwise?-i:i)*(Math.PI/180);e&&L(t,e),(n.offsetX||n.offsetY)&&D(t,n.offsetX??0,n.offsetY??0),o&&L(t,o)}function b(t){return[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]]}function E(t){let n=1/0,o=1/0,i=-1/0,e=-1/0;for(const[r,c]of t)n=Math.min(n,r),o=Math.min(o,c),i=Math.max(i,r),e=Math.max(e,c);return new m(n,o,i-n,e-o)}function D(t,n,o){for(const i of t)i[0]+=n,i[1]+=o}function T(t,n,o){for(const i of t)i[0]*=n,i[1]*=o}function L(t,n){for(const o of t)H(o,n)}function N(t,n){const o=Math.min(t.x,n.x),i=Math.min(t.y,n.y),e=Math.max(t.x+t.width,n.x+n.width),r=Math.max(t.y+t.height,n.y+n.height);return new m(o,i,e-o,r-i)}var X;function Y(t){const n=null==t?NaN:Number(t);return isNaN(n)?Math.PI/2:n}function A(t,n,o,r){const c=i(s(),o[0]-t[0],o[1]-t[1]);if(0===e(c))return null;const u=F(c),a=O(o,u-U(r),n,u);return a?{beginDimensionPoint:i(s(),o[0],o[1]),endDimensionPoint:a}:null}function U(t){const i=o(t);return i>=-1&&i<=1?t+n(1):i>=179&&i<=181?t-n(1):t}function j(t,n,o){const c=i(s(),n[0]-t[0],n[1]-t[1]),u=e(c);return 0===u?[t[0],t[1]]:r(s(),t,c,o/u)}function S(t){return{left:t.x,right:t.x+t.width,top:t.y+t.height,bottom:t.y}}function C(t,n){const o=S(t),i=S(n),e=o.left<=i.right&&i.left<=o.right,r=o.bottom<=i.top&&i.bottom<=o.top;return e&&r}function G(t,n,o){const i=k(t,o),e=k(n,o);return i[0]<=e[1]&&e[0]<=i[1]}function k(t,n){const o=[[t.x,t.y],[t.x+t.width,t.y],[t.x+t.width,t.y+t.height],[t.x,t.y+t.height]];let i=1/0,e=-1/0;for(const[r,s]of o){const t=c([r,s],n);i=Math.min(i,t),e=Math.max(e,t)}return[i,e]}function z(t,n){return new m(t.x*n,t.y*n,t.width*n,t.height*n)}function B(t,n,o){return new m(t.x+n,t.y+o,t.width,t.height)}function H(t,n){const o=t[0],i=t[1];t[0]=o*Math.cos(n)-i*Math.sin(n),t[1]=o*Math.sin(n)+i*Math.cos(n)}!function(t){t.objectId="OBJECTID",t.shape="SHAPE",t.dimLength="DIMLENGTH",t.beginX="BEGINX",t.beginY="BEGINY",t.endX="ENDX",t.endY="ENDY",t.textX="TEXTX",t.textY="TEXTY",t.styleId="STYLEID",t.dimX="DIMX",t.dimY="DIMY",t.customLength="CUSTOMLENGTH",t.useCustomLength="USECUSTOMLENGTH",t.dimDisplay="DIMDISPLAY",t.extDisplay="EXTDISPLAY",t.markerDisplay="MARKERDISPLAY",t.extAngle="EXTANGLE",t.dimType="DIMTYPE",t.textAngle="TEXTANGLE"}(X||(X={}));const R=1e-9;function v(t,n){return t[0]*n[1]-t[1]*n[0]}function O(t,n,o,i){return V(t,n,o,i)?.point??null}function V(t,n,o,e){const c=i(s(),Math.cos(n),Math.sin(n)),u=i(s(),Math.cos(e),Math.sin(e)),a=i(s(),o[0]-t[0],o[1]-t[1]),f=v(c,u);if(Math.abs(f)<=R)return null;const h=v(a,u)/f,m=v(a,c)/f;return{point:r(s(),t,c,h),t1:h,t2:m}}function F(t){const n=t[0],o=t[1];if(0===n&&0===o)return 0;if(0===n&&o>0)return Math.PI/2;if(0===n&&o<0)return 3*Math.PI/2;if(n<0&&0===o)return Math.PI;if(n>0&&0===o)return 0;let i=Math.atan2(o,n);return i<0&&(i+=2*Math.PI),i}export{X as DimensionRealFieldName,F as angleFromXAxis,U as capDimensionExtensionAngle,l as getFontForCIMTextSymbol,O as intersectLinesByPointsAndAngles,x as measureMarkerSymbolSize,Y as normalizeExtensionAngle,A as projectLinearDimensionPoints,k as projectRectToAxis,j as queryPointOnLine,C as rectsOverlap,G as rectsOverlapOnAxis,y as repositionMarkerSymbol,H as rotatePoint,z as scaleRect,S as toBounds,B as translateRect};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"../../../core/has.js";import{Milliseconds as e}from"../../../core/time.js";function a(e){return l[e]}function i(){return has("esri-iPhone")?"low":"medium"}const o={reset(){const e=m();for(const a of Object.keys(e))l[a]=e[a]}},t={IPhone12Pro:120,GalaxyS20:200,FullHD:240,SurfacePro7:300,FullHDRetina:430},l=m();function m(){const a=!!has("esri-mobile"),i=!!has("ios"),o=e(400);return{low:{graphics3D:{maxTotalNumberOfFeatures:5e4,maxNumberOfDrawCalls:8e3,maxTotalNumberOfVertices:255e4,polygonLodFactor:.5,polylineLodFactor:1,snapshotAvailable:!1,skipHighSymbolLods:!0},heatmap:{pixelRatio:.125},sceneService:{objectLoDFactor:.2,pointLoDFactor:1,meshLoDFactor:.6,pointCloudLoDFactor:.5},gaussianSplat:{minimumPixelRadius:2,minimumOpacity:0,maximumNumberOfGaussians:1e6},flow:{maxTotalNumberOfStreamlines:5e3,maxTracingResolution:1024,transitionEnabled:!1},tiledSurface:{lodBias:-1,angledSplitBias:.5,vtlContentZoom:.75,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:e(0),physicallyBasedRenderingEnabled:!1,maxTexturePixels:a?1048576:4194304,memoryLimit:200+t.IPhone12Pro,additionalCacheMemory:0,frameRate:0,maximumPixelRatio:1},medium:{graphics3D:{maxTotalNumberOfFeatures:15e4,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:625e4,polygonLodFactor:a?.8:1,polylineLodFactor:a?1.2:1.5,snapshotAvailable:!i,skipHighSymbolLods:!1},heatmap:{pixelRatio:.25},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumPixelRadius:1,minimumOpacity:1,maximumNumberOfGaussians:2e6},flow:{maxTotalNumberOfStreamlines:2e4,maxTracingResolution:2048,transitionEnabled:!0},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:o,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4194304:4096**2,memoryLimit:a?600+t.GalaxyS20:750+t.FullHD,additionalCacheMemory:a?-100:150,frameRate:0,maximumPixelRatio:1},high:{graphics3D:{maxTotalNumberOfFeatures:3e5,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:125e5,polygonLodFactor:a?1.2:2,polylineLodFactor:a?1.2:2,snapshotAvailable:!i,skipHighSymbolLods:!1},heatmap:{pixelRatio:.5},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumPixelRadius:.5,minimumOpacity:2,maximumNumberOfGaussians:4e6},flow:{maxTotalNumberOfStreamlines:2e4,maxTracingResolution:2048,transitionEnabled:!0},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:2,reduceTileLevelDifferences:!0},fadeDuration:o,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4096**2:1/0,memoryLimit:a?900+t.SurfacePro7:1500+t.FullHDRetina,additionalCacheMemory:a?-150:0,frameRate:0,maximumPixelRatio:a?1:1/0}}}export{o as QualityProfileTest,i as getDefaultQualityProfileName,a as getQualityProfileSettings};
2
+ import has from"../../../core/has.js";import{Milliseconds as e}from"../../../core/time.js";function a(e){return l[e]}function i(){return has("esri-iPhone")?"low":"medium"}const o={reset(){const e=m();for(const a of Object.keys(e))l[a]=e[a]}},t={IPhone12Pro:120,GalaxyS20:200,FullHD:240,SurfacePro7:300,FullHDRetina:430},l=m();function m(){const a=!!has("esri-mobile"),i=!!has("ios"),o=e(400);return{low:{graphics3D:{maxTotalNumberOfFeatures:5e4,maxNumberOfDrawCalls:8e3,maxTotalNumberOfVertices:255e4,polygonLodFactor:.5,polylineLodFactor:1,snapshotAvailable:!1,skipHighSymbolLods:!0},heatmap:{pixelRatio:.125},sceneService:{objectLoDFactor:.2,pointLoDFactor:1,meshLoDFactor:.6,pointCloudLoDFactor:.5},gaussianSplat:{minimumPixelRadius:2,minimumOpacity:0,maximumNumberOfGaussians:2e6},flow:{maxTotalNumberOfStreamlines:5e3,maxTracingResolution:1024,transitionEnabled:!1},tiledSurface:{lodBias:-1,angledSplitBias:.5,vtlContentZoom:.75,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:e(0),physicallyBasedRenderingEnabled:!1,maxTexturePixels:a?1048576:4194304,memoryLimit:200+t.IPhone12Pro,additionalCacheMemory:0,frameRate:0,maximumPixelRatio:1},medium:{graphics3D:{maxTotalNumberOfFeatures:15e4,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:625e4,polygonLodFactor:a?.8:1,polylineLodFactor:a?1.2:1.5,snapshotAvailable:!i,skipHighSymbolLods:!1},heatmap:{pixelRatio:.25},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumPixelRadius:1,minimumOpacity:1,maximumNumberOfGaussians:4e6},flow:{maxTotalNumberOfStreamlines:2e4,maxTracingResolution:2048,transitionEnabled:!0},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:o,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4194304:4096**2,memoryLimit:a?600+t.GalaxyS20:750+t.FullHD,additionalCacheMemory:a?-100:150,frameRate:0,maximumPixelRatio:1},high:{graphics3D:{maxTotalNumberOfFeatures:3e5,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:125e5,polygonLodFactor:a?1.2:2,polylineLodFactor:a?1.2:2,snapshotAvailable:!i,skipHighSymbolLods:!1},heatmap:{pixelRatio:.5},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumPixelRadius:.5,minimumOpacity:2,maximumNumberOfGaussians:8e6},flow:{maxTotalNumberOfStreamlines:2e4,maxTracingResolution:2048,transitionEnabled:!0},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:2,reduceTileLevelDifferences:!0},fadeDuration:o,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4096**2:1/0,memoryLimit:a?900+t.SurfacePro7:1500+t.FullHDRetina,additionalCacheMemory:a?-150:0,frameRate:0,maximumPixelRatio:a?1:1/0}}}export{o as QualityProfileTest,i as getDefaultQualityProfileName,a as getQualityProfileSettings};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{generateUID as i}from"../../../../core/uid.js";import{add as t}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{getContinuousIndexArray as e}from"../../../../geometry/support/Indices.js";import{NullSphere as n,Sphere as h}from"../../../../geometry/support/sphere.js";import{BoundingInfo as s}from"./BoundingInfo.js";import{Object3DHighlightStateID as o}from"./Object3DStateID.js";import{assert as r}from"./Util.js";class g{constructor(t,e,n,h={}){this.material=t,this._buffers=e,this.localOrigin=n,this.id=i(),this.type=1,this.baseGeometry=null,this.layerViewUid=null,this.graphicUid=null,this._readPrimitivePosition=null,this._boundingInfo=null,this._boundingSphere=null,this._highlights=null,this._highlightOptionsCounts=null,this.occludees=void 0,this.visible=!0;const s=t?.useIndexing??!1,o=null!=e.index;r(s===o,"Material index requirement and BufferGeometry.buffers.index must match"),this.castShadow=h.castShadow??!1}get buffers(){return this._buffers}get indexCount(){return this._buffers.index?.length??this._buffers.vertex.count??0}get readPrimitivePosition(){return this._readPrimitivePosition??=this.material.createPrimitivePositionReader(this.buffers),this._readPrimitivePosition}get boundingInfo(){return this._boundingInfo??=this._calculateBoundingInfo(),this._boundingInfo}get boundingSphere(){const i=this.boundingInfo?.sphere;if(null==i)return n;if(null==this._boundingSphere){const e=new h;e.copyFrom(i),t(e.center,e.center,this.localOrigin.vec3),this._boundingSphere=e}return this._boundingSphere}_calculateBoundingInfo(){const i=this.indexCount;if(0===i)return null;const t=this.material.primitiveVertexCount;r(i%t===0,"Indexing error: "+i+" not divisible by "+t);const n=e(i/t);return new s(n,t,this.readPrimitivePosition)}invalidateBoundingInfo(){this._boundingInfo=null,this._boundingSphere=null}computeAttachmentOrigin(i){return!!this.material.computeAttachmentOrigin(i,this.readPrimitivePosition,this.indexCount)&&(t(i,i,this.localOrigin.vec3),!0)}get highlights(){return this._highlights||l}get hasHighlights(){return(this._highlightOptionsCounts?.size??0)>0}forEachHighlightOption(i){this._highlightOptionsCounts?.forEach((t,e)=>i(e))}allocateIdAndHighlight(i){const t=new o(i);return this.addHighlight(t)}addHighlight(i){this._ensureHighlights().add(i);const{highlightName:t}=i,e=(this._highlightOptionsCounts?.get(t)??0)+1;return this._ensureHighlightOptionsCounts().set(t,e),i}_ensureHighlights(){let i=this._highlights;return i||(i=new Set,this._highlights=i),i}_ensureHighlightOptionsCounts(){let i=this._highlightOptionsCounts;return i||(i=new Map,this._highlightOptionsCounts=i),i}removeHighlight(i){if(this._highlights?.delete(i)){const{highlightName:t}=i,e=this._highlightOptionsCounts?.get(t)??0;e<=1?this._highlightOptionsCounts?.delete(t):this._ensureHighlightOptionsCounts().set(t,e-1)}}}const l=new Set;export{g as BufferGeometry};
2
+ import{generateUID as i}from"../../../../core/uid.js";import{add as t}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{getContinuousIndexArray as e}from"../../../../geometry/support/Indices.js";import{NullSphere as n,Sphere as h}from"../../../../geometry/support/sphere.js";import{BoundingInfo as s}from"./BoundingInfo.js";import{Object3DHighlightStateID as o}from"./Object3DStateID.js";import{assert as r}from"./Util.js";class g{constructor(t,e,n,h={}){this.material=t,this._buffers=e,this.localOrigin=n,this.id=i(),this.type=1,this.baseGeometry=null,this.layerViewUid=null,this.graphicUid=null,this._readPrimitivePosition=null,this._boundingInfo=null,this._boundingSphere=null,this._highlights=null,this._highlightOptionsCounts=null,this.occludees=void 0,this.visible=!0;const s=t?.useIndexing??!1,o=null!=e.index;r(s===o,"Material index requirement and BufferGeometry.buffers.index must match"),this.castShadow=h.castShadow??!1}get buffers(){return this._buffers}get indexCount(){return this._buffers.index?.length??this._buffers.vertex.count??0}get faceCount(){return this.indexCount/3}get readPrimitivePosition(){return this._readPrimitivePosition??=this.material.createPrimitivePositionReader(this.buffers),this._readPrimitivePosition}get boundingInfo(){return this._boundingInfo??=this._calculateBoundingInfo(),this._boundingInfo}get boundingSphere(){const i=this.boundingInfo?.sphere;if(null==i)return n;if(null==this._boundingSphere){const e=new h;e.copyFrom(i),t(e.center,e.center,this.localOrigin.vec3),this._boundingSphere=e}return this._boundingSphere}_calculateBoundingInfo(){const i=this.indexCount;if(0===i)return null;const t=this.material.primitiveVertexCount;r(i%t===0,"Indexing error: "+i+" not divisible by "+t);const n=e(i/t);return new s(n,t,this.readPrimitivePosition)}invalidateBoundingInfo(){this._boundingInfo=null,this._boundingSphere=null}computeAttachmentOrigin(i){return!!this.material.computeAttachmentOrigin(i,this.readPrimitivePosition,this.indexCount)&&(t(i,i,this.localOrigin.vec3),!0)}get highlights(){return this._highlights||u}get hasHighlights(){return(this._highlightOptionsCounts?.size??0)>0}forEachHighlightOption(i){this._highlightOptionsCounts?.forEach((t,e)=>i(e))}allocateIdAndHighlight(i){const t=new o(i);return this.addHighlight(t)}addHighlight(i){this._ensureHighlights().add(i);const{highlightName:t}=i,e=(this._highlightOptionsCounts?.get(t)??0)+1;return this._ensureHighlightOptionsCounts().set(t,e),i}_ensureHighlights(){let i=this._highlights;return i||(i=new Set,this._highlights=i),i}_ensureHighlightOptionsCounts(){let i=this._highlightOptionsCounts;return i||(i=new Map,this._highlightOptionsCounts=i),i}removeHighlight(i){if(this._highlights?.delete(i)){const{highlightName:t}=i,e=this._highlightOptionsCounts?.get(t)??0;e<=1?this._highlightOptionsCounts?.delete(t):this._ensureHighlightOptionsCounts().set(t,e-1)}}}const u=new Set;export{g as BufferGeometry};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{generateUID as e}from"../../../../core/uid.js";import{identity as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i,IDENTITY as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{copy as o,offset as s}from"../../../../geometry/support/aaBoundingBox.js";import{BoundingVolume as n}from"./BoundingVolume.js";import{Object3DOccludeeStateID as l,Object3DHighlightStateID as h}from"./Object3DStateID.js";import{assert as m}from"./Util.js";import{addObject3DStateID as g,removeObject3DStateID as u}from"../materials/renderers/utils.js";class a{constructor(t){this.id=e(),this.type=1,this.lastValidElevationBB=void 0,this._layer=null,this._boundingVolume=null,this._geometries=[t]}dispose(){this._geometries.length=0}get layerViewUid(){return this.geometry.layerViewUid}get graphicUid(){return this.geometry.graphicUid}get geometries(){return this._geometries}get geometry(){return this._geometries[0]}get layer(){return this._layer}set layer(e){m(null==this._layer||null==e,"BufferObject3D can only be added to a single Layer"),this._layer=e}get visible(){return this.geometry.visible}set visible(e){this.visible!==e&&(this.geometry.visible=e,this._emit("visibilityChanged",this))}_emit(e,t){this.layer?.events.emit(e,t)}maskOccludee(){const e=new l;return this.geometry.occludees=g(this.geometry.occludees,e),this._emit("occlusionChanged",this),e}removeOcclude(e){this.geometry.occludees=u(this.geometry.occludees,e),this._emit("occlusionChanged",this)}highlight(e){const t=new h(e);return this.geometry.addHighlight(t),this._emit("highlightChanged",this),t}removeHighlight(e){this.geometry.removeHighlight(e),this._emit("highlightChanged",this)}removeStateID(e){0===e.channel?this.removeHighlight(e):this.removeOcclude(e)}getCombinedStaticTransformation(e,i){return t(i)}getCombinedShaderTransformation(e,r=i()){return t(r)}get boundingVolumeWorldSpace(){return this._boundingVolume||(this._boundingVolume=new n,this._validateBoundingVolume(this._boundingVolume)),this._boundingVolume}get boundingVolumeObjectSpace(){return this.boundingVolumeWorldSpace}_validateBoundingVolume(e){const{boundingInfo:t,localOrigin:i,boundingSphere:r}=this.geometry;if(null==t)return;const{box:n,sphere:l}=e,[h,m,g]=i.vec3;o(n,t.box),s(n,h,m,g),l.copyFrom(r)}get transformation(){return r}get shaderTransformation(){return null}}export{a as BufferObject3D};
2
+ import{generateUID as e}from"../../../../core/uid.js";import{identity as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i,IDENTITY as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{empty as o,copy as s,offset as n}from"../../../../geometry/support/aaBoundingBox.js";import{BoundingVolume as l}from"./BoundingVolume.js";import{Object3DOccludeeStateID as h,Object3DHighlightStateID as m}from"./Object3DStateID.js";import{assert as g}from"./Util.js";import{addObject3DStateID as a,removeObject3DStateID as u}from"../materials/renderers/utils.js";class d{constructor(t){this.id=e(),this.type=1,this.lastValidElevationBB=void 0,this._layer=null,this._boundingVolume=null,this._geometries=[t.geometry],t.isElevationSource&&(this.lastValidElevationBB=o())}dispose(){this._geometries.length=0}get layerViewUid(){return this.geometry.layerViewUid}get graphicUid(){return this.geometry.graphicUid}get geometries(){return this._geometries}get geometry(){return this._geometries[0]}get layer(){return this._layer}set layer(e){g(null==this._layer||null==e,"BufferObject3D can only be added to a single Layer"),this._layer=e}get visible(){return this.geometry.visible}set visible(e){this.visible!==e&&(this.geometry.visible=e,this._emit("visibilityChanged",this))}_emit(e,t){this.layer?.events.emit(e,t)}maskOccludee(){const e=new h;return this.geometry.occludees=a(this.geometry.occludees,e),this._emit("occlusionChanged",this),e}removeOcclude(e){this.geometry.occludees=u(this.geometry.occludees,e),this._emit("occlusionChanged",this)}highlight(e){const t=new m(e);return this.geometry.addHighlight(t),this._emit("highlightChanged",this),t}removeHighlight(e){this.geometry.removeHighlight(e),this._emit("highlightChanged",this)}removeStateID(e){0===e.channel?this.removeHighlight(e):this.removeOcclude(e)}getCombinedStaticTransformation(e,i){return t(i)}getCombinedShaderTransformation(e,r=i()){return t(r)}get boundingVolumeWorldSpace(){return this._boundingVolume||(this._boundingVolume=new l,this._validateBoundingVolume(this._boundingVolume)),this._boundingVolume}get boundingVolumeObjectSpace(){return this.boundingVolumeWorldSpace}_validateBoundingVolume(e){const{boundingInfo:t,localOrigin:i,boundingSphere:r}=this.geometry;if(null==t)return;const{box:o,sphere:l}=e,[h,m,g]=i.vec3;s(o,t.box),n(o,h,m,g),l.copyFrom(r)}get transformation(){return r}get shaderTransformation(){return null}get effectiveTransformation(){return r}}export{d as BufferObject3D};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{add as t,transformMat4 as e,copy as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as r}from"../../../../geometry/support/frustumPlanes.js";import{create as n,fromPoints as o,copy as a}from"../../../../geometry/support/ray.js";import l from"../../webgl/RenderCamera.js";import{HUDTarget as c,HUDIntersectorResult as h}from"./HUDIntersectorResult.js";import{IntersectorOptions as f}from"./IntersectorInterfaces.js";import{IntersectorResultRay as m,compareOrderedIntersectionHits as u}from"./IntersectorResult.js";import{ObjectTarget as y}from"./ObjectTarget.js";import{PolygonIntersectionResults as d}from"./PolygonIntersectionResults.js";import{IntersectorTransform as g,getVerticalOffsetObject3D as p}from"./verticalOffsetUtils.js";const _=1e-5;class v{constructor(t){this.options=new f,this._results=new b,this.polygonResults=new d,this.transform=new g,this.camera=new l,this.screenPolygonPrimitiveProcessor=j,this.tolerance=_,this.verticalOffset=null,this._ray=n(),this._rayEnd=i(),this._rayBeginTransformed=i(),this._rayEndTransformed=i(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(o(t,e,this._ray),s)}resetWithRay(e,s){this.camera=s,e!==this._ray&&a(e,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,t(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??_;const n=p(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e){if(this.verticalOffset=null,t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const i of s.objects.values())i.visible&&r(e.broadPhaseFrustum,i.boundingVolumeWorldSpace.sphere)&&(yield*this._intersectScreenPolygonObject(i,e))}}*intersectHUDScreenPolygon(t=null,e){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.(),i=t?.degenerateObjectValues()??s.objects.values();for(const s of i)yield*this._intersectScreenPolygonObject(s,e)}}*_intersectScreenPolygonObject(t,e){if(0!==t.type)return;const s=t.geometries;if(!t.visible||!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;if(!s.visible||!s.intersectScreenPolygon)continue;this.transform.setAndInvalidateLazyTransforms(i,r.transformation);const o=s.intersectScreenPolygon(r,this.transform.transform,this,e);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new y(t,n,o.primitiveIndex),o.distance,o.point),yield}}intersectObject(t){if(0!==t.type)return;const s=t.geometries;if(!s)return;const i=t.effectiveTransformation,r=p(this.verticalOffset);for(const n of s){if(!n.visible)continue;const{material:s,id:o}=n;if(!s.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),s.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r,n)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:r},e,s,i,a,n))}}handleObjectIntersection(t,e,s,i,r,n){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,s))return;const o=n?this._results.hud:this._results;t=n?new c(t,n):t;const a=n?r=>r.set(1,t,e,s,i):n=>n.set(4,t,e,s,i,r);if((null==o.min.renderDistance||s<o.min.renderDistance)&&a(o.min),0!==this.options.store&&(null==o.max.renderDistance||s>o.max.renderDistance)&&a(o.max),2===this.options.store)if(n){const t=new h(this._ray);a(t),this._results.hud.all.push(t)}else{const t=new m(this._ray);a(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){s<0||(null==this.filterPredicate||null!=i&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(t,1===t&&i?new c(e,i):e,s)}sortResults(t=this._results.all){t.sort(u)}}class b{constructor(){this.min=new m(n()),this.max=new m(n()),this.hud={min:new h(n()),max:new h(n()),all:new Array},this.ground=new m(n()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}const j={*processTriangle(t){yield t},*processLineSegment(t,e,i){s(t[0],e),s(t[1],i),yield t},validatePoint:()=>!0};export{v as Intersector,j as defaultScreenPolygonPrimitiveProcessor,_ as defaultTolerance};
2
+ import{fromTranslation as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{add as s,transformMat4 as i,copy as r}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as o}from"../../../../geometry/support/frustumPlanes.js";import{create as a,fromPoints as l,copy as c}from"../../../../geometry/support/ray.js";import h from"../../webgl/RenderCamera.js";import{HUDTarget as f,HUDIntersectorResult as m}from"./HUDIntersectorResult.js";import{IntersectorOptions as u}from"./IntersectorInterfaces.js";import{IntersectorResultRay as y,compareOrderedIntersectionHits as d}from"./IntersectorResult.js";import{ObjectTarget as g}from"./ObjectTarget.js";import{PolygonIntersectionResults as p}from"./PolygonIntersectionResults.js";import{IntersectorTransform as _,getVerticalOffsetObject3D as v}from"./verticalOffsetUtils.js";const b=1e-5,j=e();class O{constructor(t){this.options=new u,this._results=new P,this.polygonResults=new p,this.transform=new _,this.camera=new h,this.screenPolygonPrimitiveProcessor=w,this.tolerance=b,this.verticalOffset=null,this._ray=a(),this._rayEnd=n(),this._rayBeginTransformed=n(),this._rayEndTransformed=n(),this.viewingMode=t??1}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,e,s){this.resetWithRay(l(t,e,this._ray),s)}resetWithRay(t,e){this.camera=e,t!==this._ray&&c(t,this._ray),0!==this.options.verticalOffset?2===this.viewingMode?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,s(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray),this.polygonResults.init()}intersect(t=null,e,s,i,r){this.point=e,this.filterPredicate=i,this.tolerance=s??b;const n=v(this.verticalOffset);if(t&&t.length>0){const e=r?t=>{r(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const s of t){const t=s.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,e,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,e),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(e)):s.objects.forEach(t=>e(t))}}this.sortResults()}*intersectScreenPolygon(t=null,e){if(this.verticalOffset=null,t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.();if(null!=t)for(const s of t.intersectingFrustumValues(e.broadPhaseFrustum,t=>t.visible))yield*this._intersectScreenPolygonObject(s,e);else for(const i of s.objects.values())i.visible&&o(e.broadPhaseFrustum,i.boundingVolumeWorldSpace.sphere)&&(yield*this._intersectScreenPolygonObject(i,e))}}*intersectHUDScreenPolygon(t=null,e){if(this.verticalOffset=null,this.options.selectionMode&&this.options.hud&&t?.length)for(const s of t){const t=s.getSpatialQueryAccelerator?.(),i=t?.degenerateObjectValues()??s.objects.values();for(const s of i)yield*this._intersectScreenPolygonObject(s,e)}}*_intersectScreenPolygonObject(t,e){const s=t.geometries;if(!t.visible||!s)return;const i=t.effectiveTransformation;for(const r of s){if(!r.visible)continue;const{material:s,id:n}=r;if(!s.visible||!s.intersectScreenPolygon)continue;this._setGeometryTransform(i,r);const o=s.intersectScreenPolygon(r,this.transform.transform,this,e);o?.valid&&this._handleObjectScreenPolygonIntersection(o.type,new g(t,n,o.primitiveIndex),o.distance,o.point),yield}}intersectObject(t){const e=t.geometries;if(!e)return;const s=t.effectiveTransformation,r=v(this.verticalOffset);for(const n of e){if(!n.visible)continue;const{material:e,id:o}=n;if(!e.visible)continue;this._setGeometryTransform(s,n),i(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),i(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const a=this.transform.transform;null!=r&&(r.objectTransform=this.transform),e.intersectRay(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,(e,s,i,r,n)=>this.handleObjectIntersection({object:t,geometryId:o,primitiveIndex:r},e,s,i,a,n))}}_setGeometryTransform(e,s){const i=1===s.type?t(j,s.localOrigin.vec3):s.transformation;this.transform.setAndInvalidateLazyTransforms(e,i)}handleObjectIntersection(t,e,s,i,r,n){if(e<0||null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,s))return;const o=n?this._results.hud:this._results;t=n?new f(t,n):t;const a=n?r=>r.set(1,t,e,s,i):n=>n.set(4,t,e,s,i,r);if((null==o.min.renderDistance||s<o.min.renderDistance)&&a(o.min),0!==this.options.store&&(null==o.max.renderDistance||s>o.max.renderDistance)&&a(o.max),2===this.options.store)if(n){const t=new m(this._ray);a(t),this._results.hud.all.push(t)}else{const t=new y(this._ray);a(t),this._results.all.push(t)}}_handleObjectScreenPolygonIntersection(t,e,s,i){s<0||(null==this.filterPredicate||null!=i&&this.filterPredicate(this.camera.eye,i,1))&&this.polygonResults.add(t,1===t&&i?new f(e,i):e,s)}sortResults(t=this._results.all){t.sort(d)}}class P{constructor(){this.min=new y(a()),this.max=new y(a()),this.hud={min:new m(a()),max:new m(a()),all:new Array},this.ground=new y(a()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}const w={*processTriangle(t){yield t},*processLineSegment(t,e,s){r(t[0],e),r(t[1],s),yield t},validatePoint:()=>!0};export{O as Intersector,w as defaultScreenPolygonPrimitiveProcessor,b as defaultTolerance};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{isCachedFontFace as o,loadFont as t}from"../../../../core/fontUtils.js";import e from"../../../../core/Logger.js";import{pt2px as i}from"../../../../core/screenUtils.js";import{ZEROS as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";class n{constructor(o){this.definition=o,this.key=JSON.stringify(o),this.haloSize=Math.round(o.halo.size),this.textStyle=l(o.color),this.haloStyle=s(o.halo.color),this.backgroundStyle=0!==o.background.color[3]?l(o.background.color):null}fontString(o){const t=this.definition.font,e="sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji";return`${t.style} ${t.weight} ${o}px ${t.family}, ${e}`}setFontProperties(o,t){o.font=this.fontString(t),o.textAlign="left",o.textBaseline="alphabetic"}static async fromSymbol(s,l){const c=s?.material?.color?.toUnitRGBA()??r,f=null!=s.size?i(s.size):12,m=s.lineHeight,g=s.background?.color?.toUnitRGBA()??r,u={family:s.font?.family??"sans-serif",decoration:s.font?.decoration??"none",weight:s.font?.weight??"normal",style:s.font?.style??"normal"},d=s.halo,h=null!=d?.color&&d.size>0?{size:i(d.size),color:d.color.toUnitRGBA()}:{size:0,color:r},y=new n({color:c,size:f,background:{color:g,padding:null!=s.background?[.65*f,.5*f]:[0,0],borderRadius:null!=s.background?f*(6/16):0},lineSpacingFactor:m,font:u,halo:h,pixelRatio:l});if(s.font){let i=!1;const r=y.fontString(f);try{i=(await document.fonts.load(r)).some(t=>!o(t))}catch(b){e.getLogger("esri.views.3d.webgl-engine.lib.TextRenderParameters").warnOnce(`Failed to preload font '${r}'. Some text symbology may be rendered using the default browser font.`)}if(!i&&!a.has(s.font.family))try{await t(s.font)}catch(b){}}return y}}function s(o){return`rgb(${o.slice(0,3).map(o=>Math.floor(255*o)).toString()})`}function l(o){return`rgba(${o.slice(0,3).map(o=>Math.floor(255*o)).toString()},${o[3]})`}const a=new Set(["Arial","Times New Roman","Courier New","serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);export{n as TextRenderParameters};
2
+ import{isCachedFontFace as o,loadFont as e}from"../../../../core/fontUtils.js";import t from"../../../../core/Logger.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";class n{constructor(o){this.definition=o,this.key=JSON.stringify(o),this.haloSize=Math.round(o.halo.size),this.textStyle=l(o.color),this.haloStyle=s(o.halo.color),this.backgroundStyle=a(o.background.color),this.borderSize=o.background.border.size,this.borderStyle=a(o.background.border.color)}fontString(o){const e=this.definition.font,t="sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji";return`${e.style} ${e.weight} ${o}px ${e.family}, ${t}`}setFontProperties(o,e){o.font=this.fontString(e),o.textAlign="left",o.textBaseline="alphabetic"}static async fromSymbol(s,l){const a=f(s?.material?.color),m=null!=s.size?r(s.size):12,u=s.lineHeight,g=f(s.background?.color),d=s.border,h=f(d?.color),b=null!=d&&d.size>0&&h!==i?{size:r(d.size),color:h}:{size:0,color:i},y=null!=s.background||b.size>0,S={family:s.font?.family??"sans-serif",decoration:s.font?.decoration??"none",weight:s.font?.weight??"normal",style:s.font?.style??"normal"},p=s.halo,z=null!=p?.color&&p.size>0?{size:r(p.size),color:p.color.toUnitRGBA()}:{size:0,color:i},w=new n({color:a,size:m,background:{color:g,border:b,padding:y?[.65*m,.5*m]:[0,0],borderRadius:y?m*(6/16):0},lineSpacingFactor:u,font:S,halo:z,pixelRatio:l});if(s.font){let r=!1;const i=w.fontString(m);try{r=(await document.fonts.load(i)).some(e=>!o(e))}catch(x){t.getLogger("esri.views.3d.webgl-engine.lib.TextRenderParameters").warnOnce(`Failed to preload font '${i}'. Some text symbology may be rendered using the default browser font.`)}if(!r&&!c.has(s.font.family))try{await e(s.font)}catch(x){}}return w}}function s(o){return`rgb(${o.slice(0,3).map(o=>Math.floor(255*o)).toString()})`}function l(o){return`rgba(${o.slice(0,3).map(o=>Math.floor(255*o)).toString()},${o[3]})`}function a(o){return 0!==o[3]?l(o):null}const c=new Set(["Arial","Times New Roman","Courier New","serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);function f(o){return null!=o&&0!==o.a?o.toUnitRGBA():i}export{n as TextRenderParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{clamp as t}from"../../../../core/mathUtils.js";import{debugFlags as e}from"../../support/debugFlags.js";import{getFontMetrics as i}from"./FontMetrics.js";import{getTextHelperCanvas as s}from"./TextHelperCanvas.js";const n=1;class r{constructor(t,e,i,s){this.text=t,this._alignment=e,this._parameters=i,this._maxSize=s,this._textWidths=[],this._lineWidths=[],this._renderPixelRatio=null,this._metricsCached=null,this.key=`${t}--${this._parameters.key}-${this._alignment}`,this._lines=t.replaceAll(" "," ").split(/\r?\n/)}get displayWidth(){return Math.ceil(this._displayWidth+2*this._horizontalPadding)}get displayHeight(){let t=this._metrics.firstLineAscent;for(let e=0;e<this._lines.length-1;e++)t+=this._lineSpacing;return t+=this._metrics.lastLineDescent,Math.ceil(t+2*this._haloSize+2*this._verticalPadding)}get renderedWidth(){return this._toRoundedRenderUnit(this.displayWidth)}get renderedHeight(){return this._toRoundedRenderUnit(this.displayHeight)}get firstRenderedBaselinePosition(){return this._toRenderUnit(this._firstLineYOffset+this._metrics.firstLineAscent)}get _firstLineYOffset(){return this._verticalPadding+this._haloSize}get _metrics(){if(null==this._metricsCached){const t=s(o,d,d).getContext("2d"),e=this._parameters.definition.pixelRatio,n=this._fontSize*e;this._parameters.setFontProperties(t,n);let r=2*this._haloSize;const h=this._parameters.definition.font;"italic"!==h.style&&"oblique"!==h.style&&"bold"!==h.weight&&"bolder"!==h.weight||(r+=.3*t.measureText("A").width),this._textWidths.length=0,this._lineWidths.length=0;let a=0,l=0,c=0,g=0,m=0;this._lines.forEach((i,s)=>{const n=t.measureText(i),h=n.width/e,o=h+r;this._textWidths.push(h),this._lineWidths.push(o),a=Math.max(a,o),g=Math.max(g,n.actualBoundingBoxAscent/e),m=Math.max(m,n.actualBoundingBoxDescent/e),0===s&&(l=n.actualBoundingBoxAscent/e),s===this._lines.length-1&&(c=n.actualBoundingBoxDescent/e)});const f=i(this._parameters),u=Math.max(g,f.maxAscent),p=Math.max(m,f.maxDescent),x=l,R="underline"===this._parameters.definition.font.decoration?p:c,S=a;this._metricsCached=new _(x,R,u,p,S)}return this._metricsCached}get _lineSpacing(){return(this._midLineHeight+this._linePadding)*this._parameters.definition.lineSpacingFactor}get _midLineHeight(){return this._metrics.midLineHeight}get _linePadding(){return this._midLineHeight*a}get _midLineAscent(){return this._metrics.maxLineAscent}get _renderedFontSize(){return this._toRenderUnit(this._fontSize)}get _fontSize(){return this._parameters.definition.size}get _renderedHaloSize(){return this._toRenderUnit(this._haloSize)}get _haloSize(){return this._parameters.haloSize}get _horizontalPadding(){return this._hasBackground?this._parameters.definition.background.padding[0]:0}get _verticalPadding(){return Math.max(this._hasBackground?this._parameters.definition.background.padding[1]:0,n)}get _hasBackground(){return!!this._parameters.backgroundStyle}get renderPixelRatio(){if(null==this._renderPixelRatio){const t=this._parameters.definition.pixelRatio;this._renderPixelRatio=Math.min(t,Math.min(this._maxSize[0]/this.displayWidth,this._maxSize[1]/this.displayHeight))}return this._renderPixelRatio}_getLineXOffset(t){switch(this._alignment){case 0:return this._horizontalPadding;case 1:return(this.displayWidth-this._lineWidths[t])/2;case 2:return this.displayWidth-this._horizontalPadding-this._lineWidths[t]}}render(t,i,s){t.save();const n=i/=this.renderPixelRatio,r=s/=this.renderPixelRatio,h=this._haloSize,o=this._firstLineYOffset+this._metrics.firstLineAscent;i+=h,s+=o;const a=this._haloSize>0;a&&this._renderHalo(t,n,r,h,o),this._parameters.setFontProperties(t,this._renderedFontSize);for(let e=0;e<this._lines.length;++e){const n=this._lines[e],r=this._getLineXOffset(e);a&&(t.globalCompositeOperation="destination-out",t.fillStyle="rgb(0, 0, 0)",this._fillText(t,n,i+r,s),this._renderLineDecoration(t,i+r,s,this._textWidths[e])),t.globalCompositeOperation="source-over",t.fillStyle=this._parameters.textStyle,this._fillText(t,n,i+this._getLineXOffset(e),s),this._renderLineDecoration(t,i+r,s,this._textWidths[e]),s+=this._lineSpacing}if(e.TEXT_SHOW_BASELINE){t.strokeStyle=l,t.setLineDash([2,2]),t.lineWidth=1;let e=r+o;for(let i=0;i<this._lines.length;++i)this._drawLine(t,[n,e],[n+this.displayWidth,e]),e+=this._lineSpacing}if(e.TEXT_SHOW_BORDER&&(t.strokeStyle=l,t.setLineDash([]),t.lineWidth=1,this._drawBox(t,[n,r],[this.displayWidth,this.displayHeight])),this._hasBackground){const e=this._parameters.definition.background.borderRadius*this.renderPixelRatio;this._roundedRect(t,n,r,e),t.globalCompositeOperation="destination-over",t.fillStyle=this._parameters.backgroundStyle,t.fill()}t.restore()}_renderLineDecoration(t,e,i,s,n=!1){if("none"===this._parameters.definition.font.decoration||0===s)return;const r=1,h=Math.max(this._parameters.definition.size/16,r);switch(this._parameters.definition.font.decoration){case"underline":i+=2*h;break;case"line-through":i-=.33*this._midLineAscent}const o=n?this._haloSize:0;t.strokeStyle=n?this._parameters.haloStyle:this._parameters.textStyle,t.lineWidth=this._toRenderUnit(h+2*o),t.beginPath(),t.moveTo(this._toRenderUnit(e-o),this._toRenderUnit(i)),t.lineTo(this._toRenderUnit(e+s+o),this._toRenderUnit(i)),t.stroke()}_roundedRect(e,i,s,n){i=this._toRenderUnit(i),s=this._toRenderUnit(s);const r=this.renderedWidth,h=this.renderedHeight;0!==n?(n=t(n,0,Math.floor(h/2)),e.beginPath(),e.moveTo(i,s+n),e.arcTo(i,s,i+n,s,n),e.lineTo(i+r-n,s),e.arcTo(i+r,s,i+r,s+n,n),e.lineTo(i+r,s+h-n),e.arcTo(i+r,s+h,i+r-n,s+h,n),e.lineTo(i+n,s+h),e.arcTo(i,s+h,i,s+h-n,n),e.closePath()):e.rect(i,s,r,h)}_renderHalo(t,e,i,n,r){const h=this.renderedWidth,a=this.renderedHeight,l=s(o,Math.max(h,d),Math.max(a,d)),_=l.getContext("2d");_.clearRect(0,0,h,a),this._parameters.setFontProperties(_,this._renderedFontSize),_.fillStyle=this._parameters.haloStyle,_.strokeStyle=this._parameters.haloStyle;const c=this._renderedHaloSize<3;_.lineJoin=c?"miter":"round",c?this._renderHaloEmulated(_,n,r):this._renderHaloNative(_,n,r);let g=r;for(let s=0;s<this._lines.length;++s){const t=this._getLineXOffset(s);this._renderLineDecoration(_,n+t,g,this._textWidths[s],!0),g+=this._lineSpacing}t.globalAlpha=this._parameters.definition.halo.color[3],t.drawImage(l,0,0,h,a,this._toRenderUnit(e),this._toRenderUnit(i),h,a),t.globalAlpha=1}_renderHaloEmulated(t,e,i){for(let s=0;s<this._lines.length;++s){const n=this._lines[s],r=this._getLineXOffset(s);for(const[s,o]of h)this._fillText(t,n,e+r+this._haloSize*s,i+this._haloSize*o);i+=this._lineSpacing}}_renderHaloNative(t,e,i){const s=2*this._haloSize;for(let n=0;n<this._lines.length;++n){const r=this._lines[n],h=this._getLineXOffset(n),o=5,a=.1;for(let n=0;n<o;n++){const d=1-(o-1)*a+n*a;t.lineWidth=this._toRenderUnit(d*s),this._strokeText(t,r,e+h,i)}i+=this._lineSpacing}}get _displayWidth(){return this._metrics.displayWidth}_toRenderUnit(t){return t*this.renderPixelRatio}_toRoundedRenderUnit(t){return Math.round(t*this.renderPixelRatio)}_fillText(t,e,i,s){t.fillText(e,this._toRenderUnit(i),this._toRenderUnit(s))}_strokeText(t,e,i,s){t.strokeText(e,this._toRenderUnit(i),this._toRenderUnit(s))}_drawLine(t,e,i){t.beginPath(),t.moveTo(this._toRoundedRenderUnit(e[0])+.5,this._toRoundedRenderUnit(e[1])+.5),t.lineTo(this._toRoundedRenderUnit(i[0])+.5,this._toRoundedRenderUnit(i[1])+.5),t.stroke()}_drawBox(t,e,i){const s=this._toRenderUnit(e[0]),n=this._toRenderUnit(e[1]),r=this._toRenderUnit(i[0]),h=this._toRenderUnit(i[1]),o=Math.floor(s)+.5,a=Math.ceil(s+r)-.5,d=Math.floor(n)+.5,l=Math.ceil(n+h)-.5;t.beginPath(),t.moveTo(o,d),t.lineTo(a,d),t.lineTo(a,l),t.lineTo(o,l),t.lineTo(o,d),t.stroke()}}const h=[];{const t=16;for(let e=0;e<360;e+=360/t)h.push([Math.cos(Math.PI*e/180),Math.sin(Math.PI*e/180)])}const o={canvas:null},a=.2,d=512,l="rgb(255, 0, 255, 0.5)";class _{get firstLineHeight(){return this.firstLineAscent+this.maxLineDescent}get midLineHeight(){return this.maxLineAscent+this.maxLineDescent}get lastLineHeight(){return this.maxLineAscent+this.lastLineDescent}constructor(t,e,i,s,n){this.firstLineAscent=t,this.lastLineDescent=e,this.maxLineAscent=i,this.maxLineDescent=s,this.displayWidth=n}}export{r as TextRenderer,n as textVerticalPaddingPx};
2
+ import{clamp as t}from"../../../../core/mathUtils.js";import{debugFlags as e}from"../../support/debugFlags.js";import{getFontMetrics as i}from"./FontMetrics.js";import{getTextHelperCanvas as s}from"./TextHelperCanvas.js";const n=1;class r{constructor(t,e,i,s){this.text=t,this._alignment=e,this._parameters=i,this._maxSize=s,this._textWidths=[],this._lineWidths=[],this._renderPixelRatio=null,this._metricsCached=null,this.key=`${t}--${this._parameters.key}-${this._alignment}`,this._lines=t.replaceAll(" "," ").split(/\r?\n/)}get displayWidth(){return Math.ceil(this._displayWidth+2*this._horizontalPadding)}get displayHeight(){let t=this._metrics.firstLineAscent;for(let e=0;e<this._lines.length-1;e++)t+=this._lineSpacing;return t+=this._metrics.lastLineDescent,Math.ceil(t+2*this._haloSize+2*this._verticalPadding)}get renderedWidth(){return this._toRoundedRenderUnit(this.displayWidth)}get renderedHeight(){return this._toRoundedRenderUnit(this.displayHeight)}get firstRenderedBaselinePosition(){return this._toRenderUnit(this._firstLineYOffset+this._metrics.firstLineAscent)}get _firstLineYOffset(){return this._verticalPadding+this._haloSize}get _metrics(){if(null==this._metricsCached){const t=s(o,d,d).getContext("2d"),e=this._parameters.definition.pixelRatio,n=this._fontSize*e;this._parameters.setFontProperties(t,n);let r=2*this._haloSize;const h=this._parameters.definition.font;"italic"!==h.style&&"oblique"!==h.style&&"bold"!==h.weight&&"bolder"!==h.weight||(r+=.3*t.measureText("A").width),this._textWidths.length=0,this._lineWidths.length=0;let a=0,l=0,c=0,g=0,m=0;this._lines.forEach((i,s)=>{const n=t.measureText(i),h=n.width/e,o=h+r;this._textWidths.push(h),this._lineWidths.push(o),a=Math.max(a,o),g=Math.max(g,n.actualBoundingBoxAscent/e),m=Math.max(m,n.actualBoundingBoxDescent/e),0===s&&(l=n.actualBoundingBoxAscent/e),s===this._lines.length-1&&(c=n.actualBoundingBoxDescent/e)});const u=i(this._parameters),f=Math.max(g,u.maxAscent),p=Math.max(m,u.maxDescent),x=l,S="underline"===this._parameters.definition.font.decoration?p:c,R=a;this._metricsCached=new _(x,S,f,p,R)}return this._metricsCached}get _lineSpacing(){return(this._midLineHeight+this._linePadding)*this._parameters.definition.lineSpacingFactor}get _midLineHeight(){return this._metrics.midLineHeight}get _linePadding(){return this._midLineHeight*a}get _midLineAscent(){return this._metrics.maxLineAscent}get _renderedFontSize(){return this._toRenderUnit(this._fontSize)}get _fontSize(){return this._parameters.definition.size}get _renderedHaloSize(){return this._toRenderUnit(this._haloSize)}get _haloSize(){return this._parameters.haloSize}get _horizontalPadding(){return this._hasBackgroundOrBorder?this._parameters.definition.background.padding[0]+this._borderSize:0}get _verticalPadding(){return Math.max(this._hasBackgroundOrBorder?this._parameters.definition.background.padding[1]:0,n)+this._borderSize}get _hasBackground(){return null!=this._parameters.backgroundStyle}get _hasBackgroundOrBorder(){return this._hasBackground||this._hasBorder}get _hasBorder(){return null!=this._parameters.borderStyle&&this._parameters.borderSize>0}get _borderSize(){return this._hasBorder?this._parameters.borderSize:0}get _rendererBorderSize(){return this._toRenderUnit(this._borderSize)}get renderPixelRatio(){if(null==this._renderPixelRatio){const t=this._parameters.definition.pixelRatio;this._renderPixelRatio=Math.min(t,Math.min(this._maxSize[0]/this.displayWidth,this._maxSize[1]/this.displayHeight))}return this._renderPixelRatio}_getLineXOffset(t){switch(this._alignment){case 0:return this._horizontalPadding;case 1:return(this.displayWidth-this._lineWidths[t])/2;case 2:return this.displayWidth-this._horizontalPadding-this._lineWidths[t]}}render(i,s,n){i.save();const r=s/=this.renderPixelRatio,h=n/=this.renderPixelRatio,o=this._haloSize,a=this._firstLineYOffset+this._metrics.firstLineAscent;s+=o,n+=a;const d=this._haloSize>0;d&&this._renderHalo(i,r,h,o,a),this._parameters.setFontProperties(i,this._renderedFontSize);for(let t=0;t<this._lines.length;++t){const e=this._lines[t],r=this._getLineXOffset(t);d&&(i.globalCompositeOperation="destination-out",i.fillStyle="rgb(0, 0, 0)",this._fillText(i,e,s+r,n),this._renderLineDecoration(i,s+r,n,this._textWidths[t])),i.globalCompositeOperation="source-over",i.fillStyle=this._parameters.textStyle,this._fillText(i,e,s+this._getLineXOffset(t),n),this._renderLineDecoration(i,s+r,n,this._textWidths[t]),n+=this._lineSpacing}if(e.TEXT_SHOW_BASELINE){i.strokeStyle=l,i.setLineDash([2,2]),i.lineWidth=1;let t=h+a;for(let e=0;e<this._lines.length;++e)this._drawLine(i,[r,t],[r+this.displayWidth,t]),t+=this._lineSpacing}if(e.TEXT_SHOW_BORDER&&(i.strokeStyle=l,i.setLineDash([]),i.lineWidth=1,this._drawBox(i,[r,h],[this.displayWidth,this.displayHeight])),this._hasBackgroundOrBorder){const e=this._rendererBorderSize,s=t(this._parameters.definition.background.borderRadius*this.renderPixelRatio,0,Math.floor(Math.min(this.renderedWidth-e,this.renderedHeight-e)/2)),n=Math.max(s-e/2,0);i.globalCompositeOperation="destination-over",this._hasBackground&&(this._roundedRect(i,r,h,n,e),i.fillStyle=this._parameters.backgroundStyle,i.fill()),this._hasBorder&&(this._roundedRect(i,r,h,s,e/2),i.strokeStyle=this._parameters.borderStyle,i.lineWidth=e,i.lineJoin="round",i.stroke())}i.restore()}_renderLineDecoration(t,e,i,s,n=!1){if("none"===this._parameters.definition.font.decoration||0===s)return;const r=1,h=Math.max(this._parameters.definition.size/16,r);switch(this._parameters.definition.font.decoration){case"underline":i+=2*h;break;case"line-through":i-=.33*this._midLineAscent}const o=n?this._haloSize:0;t.strokeStyle=n?this._parameters.haloStyle:this._parameters.textStyle,t.lineWidth=this._toRenderUnit(h+2*o),t.beginPath(),t.moveTo(this._toRenderUnit(e-o),this._toRenderUnit(i)),t.lineTo(this._toRenderUnit(e+s+o),this._toRenderUnit(i)),t.stroke()}_roundedRect(t,e,i,s,n){e=this._toRenderUnit(e)+n,i=this._toRenderUnit(i)+n;const r=this.renderedWidth-2*n,h=this.renderedHeight-2*n;if(!(r<=0||h<=0)){if(t.beginPath(),0===s)return t.moveTo(e,i),t.lineTo(e+r,i),t.lineTo(e+r,i+h),t.lineTo(e,i+h),void t.closePath();t.moveTo(e,i+s),t.arcTo(e,i,e+s,i,s),t.lineTo(e+r-s,i),t.arcTo(e+r,i,e+r,i+s,s),t.lineTo(e+r,i+h-s),t.arcTo(e+r,i+h,e+r-s,i+h,s),t.lineTo(e+s,i+h),t.arcTo(e,i+h,e,i+h-s,s),t.closePath()}}_renderHalo(t,e,i,n,r){const h=this.renderedWidth,a=this.renderedHeight,l=s(o,Math.max(h,d),Math.max(a,d)),_=l.getContext("2d");_.clearRect(0,0,h,a),this._parameters.setFontProperties(_,this._renderedFontSize),_.fillStyle=this._parameters.haloStyle,_.strokeStyle=this._parameters.haloStyle;const c=this._renderedHaloSize<3;_.lineJoin=c?"miter":"round",c?this._renderHaloEmulated(_,n,r):this._renderHaloNative(_,n,r);let g=r;for(let s=0;s<this._lines.length;++s){const t=this._getLineXOffset(s);this._renderLineDecoration(_,n+t,g,this._textWidths[s],!0),g+=this._lineSpacing}t.globalAlpha=this._parameters.definition.halo.color[3],t.drawImage(l,0,0,h,a,this._toRenderUnit(e),this._toRenderUnit(i),h,a),t.globalAlpha=1}_renderHaloEmulated(t,e,i){for(let s=0;s<this._lines.length;++s){const n=this._lines[s],r=this._getLineXOffset(s);for(const[s,o]of h)this._fillText(t,n,e+r+this._haloSize*s,i+this._haloSize*o);i+=this._lineSpacing}}_renderHaloNative(t,e,i){const s=2*this._haloSize;for(let n=0;n<this._lines.length;++n){const r=this._lines[n],h=this._getLineXOffset(n),o=5,a=.1;for(let n=0;n<o;n++){const d=1-(o-1)*a+n*a;t.lineWidth=this._toRenderUnit(d*s),this._strokeText(t,r,e+h,i)}i+=this._lineSpacing}}get _displayWidth(){return this._metrics.displayWidth}_toRenderUnit(t){return t*this.renderPixelRatio}_toRoundedRenderUnit(t){return Math.round(t*this.renderPixelRatio)}_fillText(t,e,i,s){t.fillText(e,this._toRenderUnit(i),this._toRenderUnit(s))}_strokeText(t,e,i,s){t.strokeText(e,this._toRenderUnit(i),this._toRenderUnit(s))}_drawLine(t,e,i){t.beginPath(),t.moveTo(this._toRoundedRenderUnit(e[0])+.5,this._toRoundedRenderUnit(e[1])+.5),t.lineTo(this._toRoundedRenderUnit(i[0])+.5,this._toRoundedRenderUnit(i[1])+.5),t.stroke()}_drawBox(t,e,i){const s=this._toRenderUnit(e[0]),n=this._toRenderUnit(e[1]),r=this._toRenderUnit(i[0]),h=this._toRenderUnit(i[1]),o=Math.floor(s)+.5,a=Math.ceil(s+r)-.5,d=Math.floor(n)+.5,l=Math.ceil(n+h)-.5;t.beginPath(),t.moveTo(o,d),t.lineTo(a,d),t.lineTo(a,l),t.lineTo(o,l),t.lineTo(o,d),t.stroke()}}const h=[];{const t=16;for(let e=0;e<360;e+=360/t)h.push([Math.cos(Math.PI*e/180),Math.sin(Math.PI*e/180)])}const o={canvas:null},a=.2,d=512,l="rgb(255, 0, 255, 0.5)";class _{get firstLineHeight(){return this.firstLineAscent+this.maxLineDescent}get midLineHeight(){return this.maxLineAscent+this.maxLineDescent}get lastLineHeight(){return this.maxLineAscent+this.lastLineDescent}constructor(t,e,i,s,n){this.firstLineAscent=t,this.lastLineDescent=e,this.maxLineAscent=i,this.maxLineDescent=s,this.displayWidth=n}}export{r as TextRenderer,n as textVerticalPaddingPx};