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

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 (78) hide show
  1. package/WebScene.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/0630e650abdfea1792e4.js +1 -0
  4. package/assets/esri/core/workers/chunks/{9a084a12afd6f0bbabce.js → 082069f80eee0407b828.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{ec5542d6ecc0622f7705.js → 1ec01fd6330d011c76d6.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{4b0e3f83a5f2d3b0478a.js → 20a9d39673d95ed401cc.js} +1 -1
  7. package/assets/esri/core/workers/chunks/24673aac70d6c949b6fa.js +1 -0
  8. package/assets/esri/core/workers/chunks/{bba3eb07a2a0065759f9.js → 25bb07d3c32b16a08813.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{ffca0b2333e760b66d3a.js → 262052dfaec3af8a58b9.js} +1 -1
  10. package/assets/esri/core/workers/chunks/33e583166ab3943ecf0e.js +1 -0
  11. package/assets/esri/core/workers/chunks/{98414a10f6de21107a03.js → 3dc5b97408b54daa9a8d.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{2350f1eb70819cc06bb6.js → 4c00a46bf0345f99a9bb.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{2165493d36c85b7c9a04.js → 5c8f423812a23c02c1fd.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{c2d19bb097d074a1ef21.js → 753d1ff177ecee8e2377.js} +1 -1
  15. package/assets/esri/core/workers/chunks/777fc163530448eea13e.js +1 -0
  16. package/assets/esri/core/workers/chunks/{09a40fd0e462144c4640.js → 842f993fa60b410cb613.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{6cf881f793fd0ec93981.js → 8c521caf050a486b6548.js} +1 -1
  18. package/assets/esri/core/workers/chunks/91e545745706111f5f62.js +1 -0
  19. package/assets/esri/core/workers/chunks/{c582441200ee1cdf51a7.js → 925a0b29d3ed7165b8dd.js} +1 -1
  20. package/assets/esri/core/workers/chunks/b013b70e40dfb6ce013e.js +1 -0
  21. package/assets/esri/core/workers/chunks/{34e04b24942da2b9b87c.js → b56c5883a5468b18b122.js} +1 -1
  22. package/assets/esri/core/workers/chunks/c7b762bae945f383c723.js +1 -0
  23. package/assets/esri/core/workers/chunks/d0eb609a214d85d21ed5.js +1 -0
  24. package/assets/esri/core/workers/chunks/d9b63cf111035b05cd2e.js +1 -0
  25. package/assets/esri/core/workers/chunks/{23c4ec0bcbc83179013e.js → dc1b38f490142f7273ef.js} +1 -1
  26. package/assets/esri/core/workers/chunks/f05622413cadfd14553e.js +1 -0
  27. package/assets/esri/core/workers/chunks/{c91905b5808b8049f96d.js → f3a547f179fe7e655af9.js} +10 -9
  28. package/chunks/GlobalIllumination.glsl.js +4 -4
  29. package/config.js +1 -1
  30. package/kernel.js +1 -1
  31. package/layers/AnnotationFeatureLayer.d.ts +22 -0
  32. package/layers/AnnotationFeatureLayer.js +1 -1
  33. package/layers/DimensionFeatureLayer.js +1 -1
  34. package/layers/list/Item.d.ts +11 -28
  35. package/layers/list/Item.js +1 -1
  36. package/layers/list/LayerItemCollection.js +1 -1
  37. package/layers/list/types.d.ts +30 -0
  38. package/layers/save/featureLayerUtils.js +1 -1
  39. package/layers/support/AnnotationFeatureSublayer.d.ts +24 -3
  40. package/layers/support/AnnotationFeatureSublayer.js +1 -1
  41. package/layers/support/layerUtils.js +1 -1
  42. package/layers/support/layersMapping.js +1 -1
  43. package/layers/support/telemetryDisplayUtils.js +2 -0
  44. package/package.json +5 -5
  45. package/support/revision.js +1 -1
  46. package/symbols/TextSymbol3DLayer.js +1 -1
  47. package/symbols/cim/TextRasterizer.js +1 -1
  48. package/symbols/cim/richTextUtils.js +1 -1
  49. package/symbols/support/Symbol3DTextBorder.js +2 -0
  50. package/views/2d/engine/webgl/GlyphWorker.js +1 -1
  51. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  52. package/views/2d/layers/MediaLayerView2D.js +1 -1
  53. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  54. package/views/2d/layers/support/annodime/MatcherGeometryOverride.js +1 -1
  55. package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
  56. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  57. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  58. package/views/3d/support/QualityProfile.js +1 -1
  59. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceRayMarching.glsl.js +7 -6
  60. package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
  61. package/views/3d/webgl-engine/lib/BufferGeometryBaseInstance.js +2 -0
  62. package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
  63. package/views/3d/webgl-engine/lib/Buffers.js +2 -0
  64. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  65. package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
  66. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  67. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  68. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  69. package/assets/esri/core/workers/chunks/0d69a18146722f792b5b.js +0 -1
  70. package/assets/esri/core/workers/chunks/3a8f6010a9f06a2457ae.js +0 -1
  71. package/assets/esri/core/workers/chunks/546213fb53fa921a3928.js +0 -1
  72. package/assets/esri/core/workers/chunks/5ed56ade84a0bea4a0c8.js +0 -1
  73. package/assets/esri/core/workers/chunks/93375f5f5bb754eca35f.js +0 -1
  74. package/assets/esri/core/workers/chunks/9e514a58b1165e273202.js +0 -1
  75. package/assets/esri/core/workers/chunks/a191ddb3b59ec1a7d818.js +0 -1
  76. package/assets/esri/core/workers/chunks/b24e1c901f7fda2a62ca.js +0 -1
  77. package/assets/esri/core/workers/chunks/da77257b517119578088.js +0 -1
  78. 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 t from"../../Color.js";import{fromCIMFontStyle as n}from"./utils.js";const e=/([A-Za-z_][\w-]*)\s*=\s*(['"])(.*?)\2/g,r=/&(amp|lt|gt|quot|apos);/g,o=/<\s*\/?\s*(?:CLR|BOL|_BOL|ITA|_ITA|FNT|CHR)\b/i;function i(t){return o.test(t)}function a(t){if(!t.supportsRichText||!t.textString.includes("<"))return null;const n=c(t),e=[],r=[];let o=s(n),i="",a=!1;const l=t.textString,g=()=>{if(!i)return;const t=f(i);if(!t)return void(i="");const n=r[r.length-1];n&&u(n,o)?n.text+=t:r.push({text:t,font:{...o.font},fontSize:o.fontSize,characterSpacing:o.characterSpacing,color:o.color}),i=""};let p=0;for(;p<l.length;){const t=l[p];if("<"!==t){i+=t,p++;continue}const n=l.indexOf(">",p+1);if(-1===n)return null;const r=h(l.slice(p+1,n));if(!r)return null;if(a=!0,g(),r.isEnd){const t=e.pop();if(!t||t.name!==r.name)return null;o=t.previous}else{const t=s(o);o=m(o,r),e.push({name:r.name,previous:t})}p=n+1}return e.length?null:(g(),a?r.filter(t=>t.text.length>0):null)}function c(t){return{font:{...t.font},fontSize:t.symbol?.height&&!isNaN(t.symbol.height)?t.symbol.height:10,characterSpacing:0}}function s(t){return{font:{...t.font},fontSize:t.fontSize,characterSpacing:t.characterSpacing,color:t.color}}function u(t,n){return t.fontSize===n.fontSize&&t.characterSpacing===n.characterSpacing&&t.font.family===n.font.family&&t.font.style===n.font.style&&t.font.weight===n.font.weight&&l(t.color,n.color)}function l(t,n){return t===n||!!t&&!!n&&t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function f(t){return t.replaceAll(r,(t,n)=>{switch(n){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";default:return t}})}function h(t){const n=t.trim();if(!n)return null;const r=n.startsWith("/"),o=r?n.slice(1).trim():n,i=/^([A-Za-z_][\w-]*)/.exec(o);if(!i)return null;const a=i[1],c=o.slice(a.length),s={};let u;for(e.lastIndex=0;u=e.exec(c);)s[u[1]]=u[3];return{isEnd:r,name:a,attributes:s}}function m(t,n){const e=s(t);switch(n.name.toUpperCase()){case"BOL":e.font.weight="bold";break;case"_BOL":e.font.weight="normal";break;case"ITA":e.font.style="italic";break;case"_ITA":e.font.style="normal";break;case"FNT":p(e,n.attributes);break;case"CLR":e.color=b(n.attributes);break;case"CHR":g(e,n.attributes)}return e}function g(t,n){const e=Number(n.spacing);!isNaN(e)&&e>=0&&(t.characterSpacing=e/100)}function p(t,e){const{name:r,style:o,size:i,scale:a,wght:c,ital:s}=e;if(r&&(t.font.family=r),o){const e=n(o);t.font.style=e.style,t.font.weight=e.weight}if(c){const n=Number(c);t.font.weight=n>=600?"bold":"normal"}if(s){const n=Number(s);isNaN(n)||(t.font.style=0!==n?"italic":"normal")}if(i){const n=Number(i);!isNaN(n)&&n>0&&(t.fontSize=n)}if(a){const n=Number(a);!isNaN(n)&&n>0&&(t.fontSize*=n/100)}}function b(n){if(n.hex){const e=t.fromHex(n.hex)?.toArray();if(e){const t="alpha"in n?y(n.alpha):e[3];return[e[0],e[1],e[2],t]}}if("red"in n||"green"in n||"blue"in n)return[N(n.red),N(n.green),N(n.blue),y(n.alpha)];const e=S(n.cyan),r=S(n.magenta),o=S(n.yellow),i=S(n.black),a=y(n.alpha),c=S(n.tint,100)/100,s=1-i;return[Math.round(255*(1-e)*s*c),Math.round(255*(1-r)*s*c),Math.round(255*(1-o)*s*c),a]}function N(t){const n=Number(t);return d(isNaN(n)?0:n)}function S(t,n=0){const e=Number(t);return x((isNaN(e)?n:e)/100)}function y(t){return Math.round(255*S(t,100))}function d(t){return Math.max(0,Math.min(255,Math.round(t)))}function x(t){return Math.max(0,Math.min(1,t))}export{i as hasRichTextFormattingTags,a as parseRichTextRuns};
2
+ import t from"../../Color.js";import{fromCIMFontStyle as n}from"./utils.js";const e=/([A-Za-z_][\w-]*)\s*=\s*(['"])(.*?)\2/g,r=/&(amp|lt|gt|quot|apos);/g,o=/<\s*\/?\s*(?:CLR|BOL|_BOL|ITA|_ITA|UND|_UND|FNT|CHR)\b/i;function i(t){return o.test(t)}function a(t){if(!t.supportsRichText||!t.textString.includes("<"))return null;const n=c(t),e=[],r=[];let o=s(n),i="",a=!1;const f=t.textString,g=()=>{if(!i)return;const t=l(i);if(!t)return void(i="");const n=r[r.length-1];n&&u(n,o)?n.text+=t:r.push({text:t,font:{...o.font},fontSize:o.fontSize,characterSpacing:o.characterSpacing,color:o.color}),i=""};let p=0;for(;p<f.length;){const t=f[p];if("<"!==t){i+=t,p++;continue}const n=f.indexOf(">",p+1);if(-1===n)return null;const r=h(f.slice(p+1,n));if(!r)return null;if(a=!0,g(),r.isEnd){const t=e.pop();if(!t||t.name!==r.name)return null;o=t.previous}else{const t=s(o);o=m(o,r),e.push({name:r.name,previous:t})}p=n+1}return e.length?null:(g(),a?r.filter(t=>t.text.length>0):null)}function c(t){return{font:{...t.font},fontSize:t.symbol?.height&&!isNaN(t.symbol.height)?t.symbol.height:10,characterSpacing:0}}function s(t){return{font:{...t.font},fontSize:t.fontSize,characterSpacing:t.characterSpacing,color:t.color}}function u(t,n){return t.fontSize===n.fontSize&&t.characterSpacing===n.characterSpacing&&t.font.family===n.font.family&&t.font.style===n.font.style&&t.font.weight===n.font.weight&&t.font.decoration===n.font.decoration&&f(t.color,n.color)}function f(t,n){return t===n||!!t&&!!n&&t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function l(t){return t.replaceAll(r,(t,n)=>{switch(n){case"amp":return"&";case"lt":return"<";case"gt":return">";case"quot":return'"';case"apos":return"'";default:return t}})}function h(t){const n=t.trim();if(!n)return null;const r=n.startsWith("/"),o=r?n.slice(1).trim():n,i=/^([A-Za-z_][\w-]*)/.exec(o);if(!i)return null;const a=i[1],c=o.slice(a.length),s={};let u;for(e.lastIndex=0;u=e.exec(c);)s[u[1]]=u[3];return{isEnd:r,name:a,attributes:s}}function m(t,n){const e=s(t);switch(n.name.toUpperCase()){case"BOL":e.font.weight="bold";break;case"_BOL":e.font.weight="normal";break;case"ITA":e.font.style="italic";break;case"_ITA":e.font.style="normal";break;case"UND":e.font.decoration="underline";break;case"_UND":e.font.decoration="none";break;case"FNT":p(e,n.attributes);break;case"CLR":e.color=b(n.attributes);break;case"CHR":g(e,n.attributes)}return e}function g(t,n){const e=Number(n.spacing);!isNaN(e)&&e>=0&&(t.characterSpacing=e/100)}function p(t,e){const{name:r,style:o,size:i,scale:a,wght:c,ital:s}=e;if(r&&(t.font.family=r),o){const e=n(o);t.font.style=e.style,t.font.weight=e.weight}if(c){const n=Number(c);t.font.weight=n>=600?"bold":"normal"}if(s){const n=Number(s);isNaN(n)||(t.font.style=0!==n?"italic":"normal")}if(i){const n=Number(i);!isNaN(n)&&n>0&&(t.fontSize=n)}if(a){const n=Number(a);!isNaN(n)&&n>0&&(t.fontSize*=n/100)}}function b(n){if(n.hex){const e=t.fromHex(n.hex)?.toArray();if(e){const t="alpha"in n?S(n.alpha):e[3];return[e[0],e[1],e[2],t]}}if("red"in n||"green"in n||"blue"in n)return[N(n.red),N(n.green),N(n.blue),S(n.alpha)];const e=d(n.cyan),r=d(n.magenta),o=d(n.yellow),i=d(n.black),a=S(n.alpha),c=d(n.tint,100)/100,s=1-i;return[Math.round(255*(1-e)*s*c),Math.round(255*(1-r)*s*c),Math.round(255*(1-o)*s*c),a]}function N(t){const n=Number(t);return y(isNaN(n)?0:n)}function d(t,n=0){const e=Number(t);return x((isNaN(e)?n:e)/100)}function S(t){return Math.round(255*d(t,100))}function y(t){return Math.max(0,Math.min(255,Math.round(t)))}function x(t){return Math.max(0,Math.min(1,t))}export{i as hasRichTextFormattingTags,a as parseRichTextRuns};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{__decorate as o}from"tslib";import r from"../../Color.js";import{ClonableMixin as e}from"../../core/Clonable.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{px2pt as t}from"../../core/screenUtils.js";import{property as i,subclass as p}from"../../core/accessorSupport/decorators.js";import{colorAndTransparencyProperty as l,screenSizeProperty as m}from"./materialUtils.js";let c=class extends(e(s)){constructor(o){super(o),this.color=new r([0,0,0,1])}get size(){return this._get("size")??t(1)}set size(o){this._set("size",o)}};o([i({...l({colorRequiredOnWrite:!0}),json:void 0})],c.prototype,"color",void 0),o([i({...m,json:void 0})],c.prototype,"size",null),c=o([p("esri.symbols.support.Symbol3DTextBorder")],c);export{c as default};
@@ -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{__decorate as e}from"tslib";import"../../../Graphic.js";import t from"../../../core/Collection.js";import i from"../../../core/Error.js";import"../../../core/has.js";import{some as r}from"../../../core/iteratorUtils.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as n}from"../../../core/MapUtils.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import l from"../../../core/ReactiveMap.js";import{watch as a,syncAndInitial as m,on as c}from"../../../core/reactiveUtils.js";import{isScreenRect as h}from"../../../core/screenUtils.js";import{property as p,subclass as u}from"../../../core/accessorSupport/decorators.js";import d from"../../../geometry/Extent.js";import{create as f}from"../../../geometry/support/aaBoundingRect.js";import{ringsContainsCoords as g}from"../../../geometry/support/contains.js";import{targetIntersectsPolygon as y,extentIntersectsPolygon as j}from"../../../geometry/support/intersectsBase.js";import{MediaElementView as _}from"../../../layers/support/MediaElementView.js";import"../../../renderers/SimpleRenderer.js";import"../../../symbols/SimpleFillSymbol.js";import"../engine/Stage.js";import"../../../Color.js";import"../../../core/libs/gl-matrix-2/factories/vec4f32.js";import"../../../geometry/Point.js";import"../../../chunks/pe.js";import"../../../core/units.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../core/RandomLCG.js";import"../../../core/Accessor.js";import"../engine/transitions/FadeTransition.js";import"../../webgl/BufferObject.js";import"../../webgl/FramebufferObject.js";import"../../webgl/Program.js";import"../../webgl/Renderbuffer.js";import"../../webgl/Texture.js";import"../../webgl/enums.js";import"../../webgl/Util.js";import"../engine/webgl/meshing/definitions.js";import"../engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"../LabelManager.js";import"./graphics/GraphicsView2D.js";import"../../../layers/effects/EffectView.js";import"../engine/webgl/shaderGraph/techniques/clip/ClipTechnique.js";import"../engine/webgl/AFeatureTile.js";import"../engine/webgl/DisplayEntity.js";import"../../../core/libs/gl-matrix-2/factories/vec2f32.js";import"../engine/webgl/number.js";import"../engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"../engine/webgl/cpuMapped/GpuMeshState.js";import"../engine/webgl/shaderGraph/techniques/shaders/Tile.js";import"../engine/webgl/shaderGraph/techniques/shaders/TileDebugInfoShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/TileInfo.js";import"../engine/webgl/shaderGraph/techniques/shaders/ViewInfo.js";import"../engine/webgl/shaderGraph/techniques/shaders/TileStencilShader.js";import"../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"./support/util.js";import"../navigation/MapViewNavigation.js";import"../../../request.js";import"../../../core/asyncUtils.js";import"../../../core/support/UpdatingHandles.js";import"../../../core/mathUtils.js";import"../../../core/urlUtils.js";import"../engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../geometry/SpatialReference.js";import"../../../geometry/spatialReferenceEllipsoidUtils.js";import"../../../geometry/operators/support/GeographicTransformation.js";import"../../../geometry/projection/projectors.js";import"../engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../../../geometry/support/geodesicConstants.js";import"../../../geometry/support/Ellipsoid.js";import"../tiling/TileInfoView.js";import"../tiling/TileKey.js";import w from"../tiling/TileQueue.js";import v from"../tiling/TileStrategy.js";import b from"../engine/webgl/Overlay.js";import E from"../engine/webgl/OverlayContainer.js";import{LayerView2D as S}from"./LayerView2D.js";import{getMapPointsFromScreen as R}from"../support/hitTestUtils.js";import T from"../../layers/MediaLayerView.js";import{TaskPriority as G}from"../../support/Scheduler.js";let U=class extends(S(T)){constructor(){super(...arguments),this._overlayContainer=null,this._fetchQueue=null,this._tileStrategy=null,this._elementReferences=new l,this._debugGraphicsView=null,this._interaction=null,this.elements=new t}initialize(){this.addHandles([a(()=>[this.interactive,this.suspended],async()=>{if(this.interactive&&!this._interaction){const{MediaLayerInteraction:e}=await this._updatingHandles.addPromise(import("./support/MediaLayerInteraction.js"));if(this.destroyed)return;this._interaction=new e({view:this.view,layer:this.layer}),this.selectedElement!==this._interaction.selectedElement&&(this._interaction.selectedElement=this.selectedElement),this.interactionOptions!==this._interaction.options&&(this._interaction.options=this.interactionOptions)}this._interaction&&(this._interaction.enabled=!this.suspended&&this.interactive)},m),a(()=>this.interactionOptions,e=>{this._interaction&&(this._interaction.options=e)},m),a(()=>this.selectedElement,e=>{this._interaction&&(this._interaction.selectedElement=e)},m)])}isUpdating(){return!0===this._interaction?.updating||r(this._elementReferences.values(),({overlay:e})=>!e.isReady)}attach(){this.addAttachHandles([c(()=>this.layer.effectiveSource,"refresh",()=>{const e=this.layer.effectiveSource;if(e)for(const{elementView:{element:t}}of this._elementReferences.values())e.hasElement(t)||this._removeElementReference(t);this._tileStrategy.refresh(e=>this._updateTile(e)),this.requestUpdate()}),c(()=>this.layer.effectiveSource,"change",({element:e})=>this._elementUpdateHandler(e))]),this._overlayContainer=new E,this.container.addChild(this._overlayContainer),this._fetchQueue=new w({tileInfoView:this.view.featuresTilingScheme,concurrency:10,process:(e,t)=>this._queryElements(e,t),scheduler:this.scheduler,priority:G.MAPVIEW_FETCH_QUEUE}),this._tileStrategy=new v({cachePolicy:"purge",resampling:!0,acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme}),this.requestUpdate()}detach(){this.elements.removeAll(),this._tileStrategy.destroy(),this._fetchQueue.destroy(),this._overlayContainer.removeAllChildren(),this.container.removeAllChildren(),this._elementReferences.clear(),this._debugGraphicsView?.destroy()}supportsSpatialReference(e){return!0}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}update(e){this._tileStrategy.update(e),this._debugGraphicsView?.update(e)}async hitTest(e,t){const i=[],r=e.normalize(),s=[r.x,r.y],n=h(t);for(const{elementView:{normalizedCoords:o,element:l}}of this._elementReferences.values())if(n){const r=R(this.view,t).map(e=>[e.x,e.y]);null!=o&&y(r,o.rings)&&i.push({type:"media",element:l,layer:this.layer,mapPoint:null,sourcePoint:l.toSource(e)})}else null!=o&&g(o.rings,s)&&i.push({type:"media",element:l,layer:this.layer,mapPoint:e,sourcePoint:l.toSource(e)});return i.reverse()}canResume(){return null!=this.layer.source&&super.canResume()}async doRefresh(){this._fetchQueue.reset(),this._tileStrategy.refresh(e=>this._updateTile(e))}_acquireTile(e){const t=new x(e.clone());return this._updateTile(t),t}_updateTile(e){this._updatingHandles.consumePromise(this._fetchQueue.push(e.key).then(t=>{const[i,r]=e.setElements(t);this._referenceElements(e,i),this._dereferenceElements(e,r),this.requestUpdate()},e=>{o(e)||s.getLogger(this).error(e)}))}_releaseTile(e){this._fetchQueue.abort(e.key.id),e.elements&&this._dereferenceElements(e,e.elements),this.requestUpdate()}async _queryElements(e,t){const i=this.layer.effectiveSource;if(null==i)return[];this.view.featuresTilingScheme.getTileBounds(q,e,!0);const r=new d({xmin:q[0],ymin:q[1],xmax:q[2],ymax:q[3],spatialReference:this.view.spatialReference});return i.queryElements(r,t)}_referenceElements(e,t){if(null!=this.layer.source)for(const i of t)this._referenceElement(e,i)}_referenceElement(e,t){n(this._elementReferences,t.uid,()=>{const e=new _({element:t,spatialReference:this.view.spatialReference}),r=new b(e);return this._overlayContainer.addChild(r),this.elements.add(t),this._updatingHandles.consumePromise(t.load().catch(e=>{s.getLogger("esri.views.2d.layers.MediaLayerView2D").error(new i("element-load-error","Element cannot be displayed",{element:t,error:e}))})),{debugGraphic:null,elementView:e,overlay:r,tiles:new Set}}).tiles.add(e)}_dereferenceElements(e,t){for(const i of t)this._dereferenceElement(e,i)}_dereferenceElement(e,t){const i=this._elementReferences.get(t.uid);i&&(i.tiles.delete(e),i.tiles.size||this._removeElementReference(t))}_removeElementReference(e){const t=this._elementReferences.get(e.uid);t&&(this._overlayContainer.removeChild(t.overlay),t.overlay.destroy(),t.elementView.destroy(),this._elementReferences.delete(e.uid),this.elements.remove(e),this._debugGraphicsView?.graphics.remove(t.debugGraphic))}_elementUpdateHandler(e){if(!this.layer.effectiveSource?.hasElement(e))return;let t=this._elementReferences.get(e.uid);if(t){const i=t.elementView.normalizedCoords;if(null==i)return void this._removeElementReference(e);const r=[],s=[];for(const e of this._tileStrategy.tiles){const n=C(this.view.featuresTilingScheme,e,i);t.tiles.has(e)?n||s.push(e):n&&r.push(e)}for(const t of r)this._referenceElement(t,e);for(const t of s)this._dereferenceElement(t,e);return t=this._elementReferences.get(e.uid),void(t?.debugGraphic&&(t.debugGraphic.geometry=t.elementView.normalizedCoords,this._debugGraphicsView.graphicUpdateHandler({graphic:t.debugGraphic,property:"geometry"})))}const i=new _({element:e,spatialReference:this.view.spatialReference}).normalizedCoords;if(null!=i)for(const r of this._tileStrategy.tiles){C(this.view.featuresTilingScheme,r,i)&&this._referenceElement(r,e)}}};e([p({readOnly:!0})],U.prototype,"elements",void 0),U=e([u("esri.views.2d.layers.MediaLayerView2D")],U);const q=f(),V={xmin:0,ymin:0,xmax:0,ymax:0};function C(e,t,i){return e.getTileBounds(q,t.key,!0),V.xmin=q[0],V.ymin=q[1],V.xmax=q[2],V.ymax=q[3],j(V,i)}class x{constructor(e){this.key=e,this.elements=null,this.isReady=!1,this.visible=!0}setElements(e){const t=[],i=new Set(this.elements);this.elements=e;for(const r of e)i.has(r)?i.delete(r):t.push(r);return this.isReady=!0,[t,Array.from(i)]}destroy(){}}const M=U;export{M as default};
2
+ import{__decorate as e}from"tslib";import"../../../Graphic.js";import t from"../../../core/Collection.js";import i from"../../../core/Error.js";import"../../../core/has.js";import{some as r}from"../../../core/iteratorUtils.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as n}from"../../../core/MapUtils.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import l from"../../../core/ReactiveMap.js";import{watch as a,syncAndInitial as m,on as c}from"../../../core/reactiveUtils.js";import{isScreenRect as h,isScreenPolygon as p}from"../../../core/screenUtils.js";import{property as u,subclass as d}from"../../../core/accessorSupport/decorators.js";import f from"../../../geometry/Extent.js";import{create as g}from"../../../geometry/support/aaBoundingRect.js";import{ringsContainsCoords as y}from"../../../geometry/support/contains.js";import{targetIntersectsPolygon as j,extentIntersectsPolygon as _}from"../../../geometry/support/intersectsBase.js";import{MediaElementView as w}from"../../../layers/support/MediaElementView.js";import"../../../renderers/SimpleRenderer.js";import"../../../symbols/SimpleFillSymbol.js";import"../engine/Stage.js";import"../../../Color.js";import"../../../core/libs/gl-matrix-2/factories/vec4f32.js";import"../../../geometry/Point.js";import"../../../chunks/pe.js";import"../../../core/units.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../core/RandomLCG.js";import"../../../core/Accessor.js";import"../engine/transitions/FadeTransition.js";import"../../webgl/BufferObject.js";import"../../webgl/FramebufferObject.js";import"../../webgl/Program.js";import"../../webgl/Renderbuffer.js";import"../../webgl/Texture.js";import"../../webgl/enums.js";import"../../webgl/Util.js";import"../engine/webgl/meshing/definitions.js";import"../engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"../LabelManager.js";import"./graphics/GraphicsView2D.js";import"../../../layers/effects/EffectView.js";import"../engine/webgl/shaderGraph/techniques/clip/ClipTechnique.js";import"../engine/webgl/AFeatureTile.js";import"../engine/webgl/DisplayEntity.js";import"../../../core/libs/gl-matrix-2/factories/vec2f32.js";import"../engine/webgl/number.js";import"../engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"../engine/webgl/cpuMapped/GpuMeshState.js";import"../engine/webgl/shaderGraph/techniques/shaders/Tile.js";import"../engine/webgl/shaderGraph/techniques/shaders/TileDebugInfoShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/TileInfo.js";import"../engine/webgl/shaderGraph/techniques/shaders/ViewInfo.js";import"../engine/webgl/shaderGraph/techniques/shaders/TileStencilShader.js";import"../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"./support/util.js";import"../navigation/MapViewNavigation.js";import"../../../request.js";import"../../../core/asyncUtils.js";import"../../../core/support/UpdatingHandles.js";import"../../../core/mathUtils.js";import"../../../core/urlUtils.js";import"../engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../geometry/SpatialReference.js";import"../../../geometry/spatialReferenceEllipsoidUtils.js";import"../../../geometry/operators/support/GeographicTransformation.js";import"../../../geometry/projection/projectors.js";import"../engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../../../geometry/support/geodesicConstants.js";import"../../../geometry/support/Ellipsoid.js";import"../tiling/TileInfoView.js";import"../tiling/TileKey.js";import v from"../tiling/TileQueue.js";import b from"../tiling/TileStrategy.js";import E from"../engine/webgl/Overlay.js";import S from"../engine/webgl/OverlayContainer.js";import{LayerView2D as R}from"./LayerView2D.js";import{getMapPointsFromScreen as T}from"../support/hitTestUtils.js";import G from"../../layers/MediaLayerView.js";import{TaskPriority as U}from"../../support/Scheduler.js";let q=class extends(R(G)){constructor(){super(...arguments),this._overlayContainer=null,this._fetchQueue=null,this._tileStrategy=null,this._elementReferences=new l,this._debugGraphicsView=null,this._interaction=null,this.elements=new t}initialize(){this.addHandles([a(()=>[this.interactive,this.suspended],async()=>{if(this.interactive&&!this._interaction){const{MediaLayerInteraction:e}=await this._updatingHandles.addPromise(import("./support/MediaLayerInteraction.js"));if(this.destroyed)return;this._interaction=new e({view:this.view,layer:this.layer}),this.selectedElement!==this._interaction.selectedElement&&(this._interaction.selectedElement=this.selectedElement),this.interactionOptions!==this._interaction.options&&(this._interaction.options=this.interactionOptions)}this._interaction&&(this._interaction.enabled=!this.suspended&&this.interactive)},m),a(()=>this.interactionOptions,e=>{this._interaction&&(this._interaction.options=e)},m),a(()=>this.selectedElement,e=>{this._interaction&&(this._interaction.selectedElement=e)},m)])}isUpdating(){return!0===this._interaction?.updating||r(this._elementReferences.values(),({overlay:e})=>!e.isReady)}attach(){this.addAttachHandles([c(()=>this.layer.effectiveSource,"refresh",()=>{const e=this.layer.effectiveSource;if(e)for(const{elementView:{element:t}}of this._elementReferences.values())e.hasElement(t)||this._removeElementReference(t);this._tileStrategy.refresh(e=>this._updateTile(e)),this.requestUpdate()}),c(()=>this.layer.effectiveSource,"change",({element:e})=>this._elementUpdateHandler(e))]),this._overlayContainer=new S,this.container.addChild(this._overlayContainer),this._fetchQueue=new v({tileInfoView:this.view.featuresTilingScheme,concurrency:10,process:(e,t)=>this._queryElements(e,t),scheduler:this.scheduler,priority:U.MAPVIEW_FETCH_QUEUE}),this._tileStrategy=new b({cachePolicy:"purge",resampling:!0,acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme}),this.requestUpdate()}detach(){this.elements.removeAll(),this._tileStrategy.destroy(),this._fetchQueue.destroy(),this._overlayContainer.removeAllChildren(),this.container.removeAllChildren(),this._elementReferences.clear(),this._debugGraphicsView?.destroy()}supportsSpatialReference(e){return!0}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}update(e){this._tileStrategy.update(e),this._debugGraphicsView?.update(e)}async hitTest(e,t){const i=[],r=e.normalize(),s=[r.x,r.y],n=h(t),o=p(t),l=n||o;for(const{elementView:{normalizedCoords:a,element:m}}of this._elementReferences.values())if(l){const r=T(this.view,t).map(e=>[e.x,e.y]);null!=a&&j(r,a.rings)&&i.push({type:"media",element:m,layer:this.layer,mapPoint:null,sourcePoint:m.toSource(e)})}else null!=a&&y(a.rings,s)&&i.push({type:"media",element:m,layer:this.layer,mapPoint:e,sourcePoint:m.toSource(e)});return i.reverse()}canResume(){return null!=this.layer.source&&super.canResume()}async doRefresh(){this._fetchQueue.reset(),this._tileStrategy.refresh(e=>this._updateTile(e))}_acquireTile(e){const t=new M(e.clone());return this._updateTile(t),t}_updateTile(e){this._updatingHandles.consumePromise(this._fetchQueue.push(e.key).then(t=>{const[i,r]=e.setElements(t);this._referenceElements(e,i),this._dereferenceElements(e,r),this.requestUpdate()},e=>{o(e)||s.getLogger(this).error(e)}))}_releaseTile(e){this._fetchQueue.abort(e.key.id),e.elements&&this._dereferenceElements(e,e.elements),this.requestUpdate()}async _queryElements(e,t){const i=this.layer.effectiveSource;if(null==i)return[];this.view.featuresTilingScheme.getTileBounds(V,e,!0);const r=new f({xmin:V[0],ymin:V[1],xmax:V[2],ymax:V[3],spatialReference:this.view.spatialReference});return i.queryElements(r,t)}_referenceElements(e,t){if(null!=this.layer.source)for(const i of t)this._referenceElement(e,i)}_referenceElement(e,t){n(this._elementReferences,t.uid,()=>{const e=new w({element:t,spatialReference:this.view.spatialReference}),r=new E(e);return this._overlayContainer.addChild(r),this.elements.add(t),this._updatingHandles.consumePromise(t.load().catch(e=>{s.getLogger("esri.views.2d.layers.MediaLayerView2D").error(new i("element-load-error","Element cannot be displayed",{element:t,error:e}))})),{debugGraphic:null,elementView:e,overlay:r,tiles:new Set}}).tiles.add(e)}_dereferenceElements(e,t){for(const i of t)this._dereferenceElement(e,i)}_dereferenceElement(e,t){const i=this._elementReferences.get(t.uid);i&&(i.tiles.delete(e),i.tiles.size||this._removeElementReference(t))}_removeElementReference(e){const t=this._elementReferences.get(e.uid);t&&(this._overlayContainer.removeChild(t.overlay),t.overlay.destroy(),t.elementView.destroy(),this._elementReferences.delete(e.uid),this.elements.remove(e),this._debugGraphicsView?.graphics.remove(t.debugGraphic))}_elementUpdateHandler(e){if(!this.layer.effectiveSource?.hasElement(e))return;let t=this._elementReferences.get(e.uid);if(t){const i=t.elementView.normalizedCoords;if(null==i)return void this._removeElementReference(e);const r=[],s=[];for(const e of this._tileStrategy.tiles){const n=x(this.view.featuresTilingScheme,e,i);t.tiles.has(e)?n||s.push(e):n&&r.push(e)}for(const t of r)this._referenceElement(t,e);for(const t of s)this._dereferenceElement(t,e);return t=this._elementReferences.get(e.uid),void(t?.debugGraphic&&(t.debugGraphic.geometry=t.elementView.normalizedCoords,this._debugGraphicsView.graphicUpdateHandler({graphic:t.debugGraphic,property:"geometry"})))}const i=new w({element:e,spatialReference:this.view.spatialReference}).normalizedCoords;if(null!=i)for(const r of this._tileStrategy.tiles){x(this.view.featuresTilingScheme,r,i)&&this._referenceElement(r,e)}}};e([u({readOnly:!0})],q.prototype,"elements",void 0),q=e([d("esri.views.2d.layers.MediaLayerView2D")],q);const V=g(),C={xmin:0,ymin:0,xmax:0,ymax:0};function x(e,t,i){return e.getTileBounds(V,t.key,!0),C.xmin=V[0],C.ymin=V[1],C.xmax=V[2],C.ymax=V[3],_(C,i)}class M{constructor(e){this.key=e,this.elements=null,this.isReady=!1,this.visible=!0}setElements(e){const t=[],i=new Set(this.elements);this.elements=e;for(const r of e)i.has(r)?i.delete(r):t.push(r);return this.isReady=!0,[t,Array.from(i)]}destroy(){}}const P=q;export{P as default};
@@ -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{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,removeMaybe as s,destroyMaybe as a}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{watch as n,initial as l}from"../../../core/reactiveUtils.js";import{isUint32Array as o}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as h,convertUnit as d}from"../../../core/units.js";import{property as u,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromValues as p}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import f from"../../../geometry/HeightModelInfo.js";import{create as g}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as _}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as y,isWebMercator as w,equals as v,isGeographic as b}from"../../../geometry/support/spatialReferenceUtils.js";import S from"../../../geometry/support/WKIDUnitConversion.js";import{validateEntity3D as C,makeCacheKey as M,getHeightModelInfoFromVCS as x}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as T}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as I}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as H}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as A}from"./LayerView3D.js";import{addLayerViewToWasm as F,getLyr3DWasm as P,removeLayerViewFromWasm as R}from"./Lyr3DWasm.js";import{LayerElevationProvider as V}from"./i3s/LayerElevationProvider.js";import{ElevationRange as j}from"../support/ElevationRange.js";import{projectToBoundingBox as E}from"../support/extentUtils.js";import{Obb as G}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as O,gaussiansPerPage as U,packedGaussianSizeInU32 as D,splatAtlasTextureWidth as z}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as B}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as L}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as k}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as q}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatDepthRenderer as W}from"../webgl-engine/lib/GaussianSplatDepthRenderer.js";import{GaussianSplatRenderer as N}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as $}from"../webgl-engine/lib/GaussianSplatShadows.js";import X from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Z,isInEffectiveScaleRange as K}from"../../support/layerViewUtils.js";import{TaskPriority as Y}from"../../support/Scheduler.js";var J;const Q=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D"),ee=3,te=ee*ee,ie=255,se=(()=>{const e=new Int16Array(ie+1);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/ie));return e})();let ae=class extends(A(X)){static{J=this}static{this.createRenderableBatchSize=64}constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(O),this._tmpTilesWithChangedVisibility=new Array,this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(Y.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=g();return E(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw Z("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);this._initializationController=new AbortController;const e=F(this,this._initializationController.signal).then(e=>{r(this._initializationController.signal),this._wasmLayerId=e,this._renderer=new N({view:this.view,layerView:this}),this.data=new B(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new $({view:this.view,layerView:this}),this.fadeHelper=new L(this),this._depthRenderer=new W({view:this.view,layerView:this}),this._intersectionHandler=new k(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new V({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),n(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),l)]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),l),this.addHandles([n(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},l)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians),this._initializationController=null});this.addHandles([n(()=>this.view.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())}),n(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),n(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return P(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return T(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new j(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return K(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{entity3d:t}=e;if(!C(t))throw new Error("entity3D not valid");const i=t.desc.geometry.prims[t.validPrimitiveIndices[0]].atrbs[0],s=t.assets[i.assetId];if(!s)throw new Error("entity3D not valid");const a=s.count;if(0===a)return Q().warnOnce("encountered tile with zero Gaussians"),()=>({memUsageBytes:0,numGaussians:0});let r=null;if("U32"!==s.dataType||!o(s.data))throw new Error("unexpected GaussianSplat Entity3D asset.data format");r=s.data;const n=this.extractHeader(r),l=2.048,h=n.tileOrigin.x*l,d=n.tileOrigin.y*l,u=n.tileOrigin.z*l,c=t.desc,f=c.obb.quaternion,g=new G(c.obb.center,c.obb.halfSize,p(...f)),_=this.view.state.isGlobal,y=_?m(this.view.spatialReference).radius:0,w={handle:e.handle,bufferView:r,totalGaussians:a,packedHeader:n.packedHeader,tileOrigin:{x:h,y:d,z:u},invPosScale:n.invPosScale,obb:g,origin:{x:g.centerX,y:g.centerY,z:g.centerZ},isGlobal:_,ellipsoidRadius:y};let v;this._renderablesBeingCreated.add(e.handle);try{v=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(w,e),this._createRenderableAbortController.signal)}catch(b){throw this._renderablesBeingCreated.delete(e.handle),b}return this._renderablesBeingCreated.delete(e.handle),()=>v}*_createRenderableTask(e,t){const{handle:i,bufferView:s,totalGaussians:a,packedHeader:r,tileOrigin:n,invPosScale:l,obb:o,origin:h,isGlobal:d,ellipsoidRadius:u}=e,c=n.x,p=n.y,m=n.z,f=h.x,g=h.y,_=h.z,y=new Float32Array(3*a),w=new Uint32Array(a),v=new Uint32Array(a),b=new Array,S=Math.ceil(a/U);let C=1/0,M=-1/0,x=1/0,T=-1/0,I=0,H=-1,A=0,F=0;for(let j=0;j<a;j++){const e=j*D,i=s[e],a=s[e+1],r=s[e+2],n=s[e+3],o=16383&a,h=a>>>14&16383,u=a>>>28&15|(1023&r)<<4,b=n>>>24,S=se[b],P=(r>>>10&255)+S,R=(r>>>18&255)+S,V=(r>>>26&63|(3&n)<<6)+S,E=P>0?P:0,G=R>0?R:0,O=V>0?V:0,U=E|G<<8|O<<16,z=Math.max(E,G,O),B=o*l+c,L=h*l+p,k=u*l+m;if(y[I]=B-f,y[I+1]=L-g,y[I+2]=k-_,d){const e=B*B+L*L+k*k;x=Math.min(x,e),T=Math.max(T,e)}else C=Math.min(C,k),M=Math.max(M,k);w[j]=i,v[j]=U,z>H&&(H=z),b>A&&(A=b),I+=3,F++,F===J.createRenderableBatchSize&&(F=0,t.madeProgress()&&(t=yield))}F>0&&t.madeProgress(),d&&(C=Math.sqrt(x)-u,M=Math.sqrt(T)-u);const P=this._extractGaussianSplatMbsRadiusSquared(H),{fullExtent:R}=this.layer;R?.hasZ&&R.zmax&&R.zmin&&(C=Math.max(C,R.zmin),M=Math.min(M,R.zmax));const V=new j(C,M);try{for(let e=0;e<S;e++){let t=this.data.textureAtlas.allocatePage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.allocatePage()),null===t)throw new Error("ran out of gaussian splat memory");b.push(t);const i=a-e*U,n=Math.min(i,U),l=t*U,o=e*O,h=n*D;this._pageBuffer.set(s.subarray(o,o+h));const d=l%z,u=Math.floor(l/z);this.data.textureAtlas.update(d,u,this._pageBuffer),this.data.headerTexture.update(t,r)}}catch(G){throw this.data.textureAtlas.freePages(b),G}const E=new q(i,o,b,y,w,v,a,P,A/ie,V);return this._tileHandles.set(i,E),this._cacheTileMemory+=E.usedMemory,this._memCache.put(`${E.handle}`,E),{memUsageBytes:E.usedMemory,numGaussians:a}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*te}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);const t=this.data?.textureAtlas;let i=!1;const s=this._tileHandles.get(e);if(s){0!==s.lifecycleState?(i=!0,this.fadeHelper.onTileDiscarded(s),this._usedTileMemory-=s.usedMemory,this._intersectionHandler.removeTile(s)):this._cacheTileMemory-=s.usedMemory,t&&s.pageIds.forEach(e=>t.freePage(e)),this.freeObject(s),this._tileHandles.delete(e)}i&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(const{obb:i}of e)if(!t(i))break})}setRenderableVisibility(e,t,i){const s=this._currentLyr3dVisibilityChange+1,a=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(s,a);let r=!1;for(let n=0;n<i;n++){const i=this._tileHandles.get(e[n]);if(!i)continue;const l=t[n]?this._prepareTileFadeIn(i,s,a):this._prepareTileFadeOut(i,s);r||=l}r?(this._currentLyr3dVisibilityChange=s,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(s)}_prepareTileFadeIn(e,t,i){const s=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return 2===e.lifecycleState?(this.fadeHelper.fadeTile(e,0,i),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)!==t?(0===e.lifecycleState&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0):s}_prepareTileFadeOut(e,t){const i=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return i&&1===e.lifecycleState&&(this.moveTileToCache(e),e.lifecycleState=0),2!==e.lifecycleState?i:this._tileFadeOutsAwaitingInitialSort.get(e.handle)!==t?(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):i}_onSortComplete(e,t){const i=this._tmpTilesWithChangedVisibility;i.length=0;const s=this._tmpSortedTileHandles;s.clear();for(let r=0;r<e.length;r++){const t=e[r];s.add(t.handle)}this._triggerFadeIns(t,s,i);const a=this._triggerFadeOuts(t,i);s.clear(),i.length>0&&this.notifyTileObbsChanged(i),a&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,i){for(const[s,a]of this._tileFadeInsAwaitingInitialSort){if(a>e||!t.has(s))continue;const r=this._tileHandles.get(s);if(!r){this._tileFadeInsAwaitingInitialSort.delete(s);continue}const n=this._getFadeDurationForPendingVisibilityChange(a),l=0===r.lifecycleState;2!==r.lifecycleState&&(r.lifecycleState=2,l&&this._popTileFromCache(r),i.push(r)),this.fadeHelper.fadeTile(r,0,n),this._tileFadeInsAwaitingInitialSort.delete(s)}}_triggerFadeOuts(e,t){let i=!1;for(const[s,a]of this._tileFadeOutsAwaitingInitialSort){if(a>e)continue;const r=this._tileHandles.get(s);if(r){const e=2===r.lifecycleState,s=this._getFadeDurationForPendingVisibilityChange(a);this.fadeHelper.fadeTile(r,1,s),e&&0===r.lifecycleState&&(t.push(r),i=!0)}this._tileFadeOutsAwaitingInitialSort.delete(s)}return i}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(0!==this._fadeDurationPerVisibilityChange.size)for(const t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(M(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(M(e.handle),e)}destroy(){this._initializationController=i(this._initializationController),this._createRenderableAbortController.abort(),R(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(const{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=a(this._shadows),this._depthRenderer=a(this._depthRenderer),this._renderer=a(this._renderer),this._memCache.destroy(),this.data=a(this.data)}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(y(this.view.renderSpatialReference)||w(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&v(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=x(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!b(t)&&t.wkid&&-1!==t.wkid&&(i=h(S.units[S[t.wkid]])),i&&(e=new f({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===_(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=d(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=I(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,T(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())0!==t.lifecycleState&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange("updating")}setMaximumGaussianCount(e){const t=Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians);this._wasm?.setMaximumGaussianSplatCount(t)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())0!==e.lifecycleState||this._renderablesBeingCreated.has(e.handle)||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),a=this.reinterpretU32AsFloat(e[t+2]),r=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:a},invPosScale:r}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(i=>{0===i.lifecycleState?t++:e++});const i=this.data?.textureAtlasMemory??0,s=this.data?.headerTextureMemory??0,a=this.data?.orderTextureMemory??0,r=this.data?.fadingTextureMemory??0,n=this.data?.sortBufferMemory??0;return new H(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,i,s,a,r,n)}get test(){}};e([u()],ae.prototype,"layer",void 0),e([u({readOnly:!0})],ae.prototype,"_clippingBox",null),e([u()],ae.prototype,"elevationOffset",null),e([u({readOnly:!0})],ae.prototype,"visibleAtCurrentScale",null),e([u()],ae.prototype,"fullExtentInLocalViewSpatialReference",void 0),ae=J=e([c("esri.views.3d.layers.GaussianSplatLayerView3D")],ae);const re=ae;export{re as default};
2
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{abortMaybe as i,removeMaybe as s,destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as n,whenOnce as l,initial as o}from"../../../core/reactiveUtils.js";import{isUint32Array as h}from"../../../core/typedArrayUtil.js";import{unitFromRESTJSON as d,convertUnit as u}from"../../../core/units.js";import{property as c,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromValues as m}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import g from"../../../geometry/HeightModelInfo.js";import{create as _}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as y}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as w,isWebMercator as b,equals as v,isGeographic as S}from"../../../geometry/support/spatialReferenceUtils.js";import C from"../../../geometry/support/WKIDUnitConversion.js";import{validateEntity3D as x,makeCacheKey as M,getHeightModelInfoFromVCS as T}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as I}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as A}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as H}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as F}from"./LayerView3D.js";import{addLayerViewToWasm as P,getLyr3DWasm as R,removeLayerViewFromWasm as V}from"./Lyr3DWasm.js";import{LayerElevationProvider as j}from"./i3s/LayerElevationProvider.js";import{ElevationRange as E}from"../support/ElevationRange.js";import{projectToBoundingBox as G}from"../support/extentUtils.js";import{Obb as U}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as O,gaussiansPerPage as D,packedGaussianSizeInU32 as z,splatAtlasTextureWidth as B}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as L}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as k}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as q}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as W}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatDepthRenderer as $}from"../webgl-engine/lib/GaussianSplatDepthRenderer.js";import{GaussianSplatRenderer as N}from"../webgl-engine/lib/GaussianSplatRenderer.js";import{GaussianSplatShadows as X}from"../webgl-engine/lib/GaussianSplatShadows.js";import Z from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as K,isInEffectiveScaleRange as Y}from"../../support/layerViewUtils.js";import{TaskPriority as J}from"../../support/Scheduler.js";var Q;const ee=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D"),te=3,ie=te*te,se=255,re=(()=>{const e=new Int16Array(se+1);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/se));return e})();let ae=class extends(F(Z)){static{Q=this}static{this.createRenderableBatchSize=64}constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(O),this._tmpTilesWithChangedVisibility=new Array,this._renderablesBeingCreated=new Set,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this._initializationController=null,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask(J.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=_();return G(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderer?.clippingBox??null}initialize(){const{view:e}=this;this.addHandles([n(()=>e.qualitySettings.fadeDuration,e=>{this.data&&(this.fadeHelper.onFadeDurationChanged(e),this.updateFadingTexture())})]),this.addResolvingPromise(this._initializeAsync(e))}async _initializeAsync(e){this._initializationController=new AbortController;const{signal:t}=this._initializationController;if(await l(()=>e?.defaultsFromMap.heightModelInfoReady,t),a(t),!this._canProjectWithoutEngine())throw K("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);this._wasmLayerId=await P(this,t),a(t),this._renderer=new N({view:e,layerView:this}),this.data=new L(this._renderer,(e,t)=>this._onSortComplete(e,t),()=>this._freeInvisibleTiles()),this._shadows=new X({view:e,layerView:this}),this.fadeHelper=new k(this),this._depthRenderer=new $({view:e,layerView:this});const i=new q(this);this._intersectionHandler=i,e.sceneIntersectionHelper.addIntersectionHandler(i),this._elevationProvider=new j({view:e,layerElevationSource:this,intersectionHandler:i}),e.elevationProvider.register(2,this._elevationProvider),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),n(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),o)]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o),this.addHandles([n(()=>this._clippingBox,e=>{this._renderer&&(this._renderer.clippingBox=e)},o),n(()=>this.maximumGaussianCount,e=>this._wasm?.setMaximumGaussianSplatCount(Math.min(e,this.data.textureAtlas.maximumSupportedVisibleGaussians)),o)]),this._initializationController=null}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}updateFadingTexture(){this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}get _wasm(){return R(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return I(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new E(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return Y(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");const{entity3d:t}=e;if(!x(t))throw new Error("entity3D not valid");const i=t.desc.geometry.prims[t.validPrimitiveIndices[0]].atrbs[0],s=t.assets[i.assetId];if(!s)throw new Error("entity3D not valid");const r=s.count;if(0===r)return ee().warnOnce("encountered tile with zero Gaussians"),()=>({memUsageBytes:0,numGaussians:0});let a=null;if("U32"!==s.dataType||!h(s.data))throw new Error("unexpected GaussianSplat Entity3D asset.data format");a=s.data;const n=this.extractHeader(a),l=2.048,o=n.tileOrigin.x*l,d=n.tileOrigin.y*l,u=n.tileOrigin.z*l,c=t.desc,p=c.obb.quaternion,g=new U(c.obb.center,c.obb.halfSize,m(...p)),_=this.view.state.isGlobal,y=_?f(this.view.spatialReference).radius:0,w={handle:e.handle,bufferView:a,totalGaussians:r,packedHeader:n.packedHeader,tileOrigin:{x:o,y:d,z:u},invPosScale:n.invPosScale,obb:g,origin:{x:g.centerX,y:g.centerY,z:g.centerZ},isGlobal:_,ellipsoidRadius:y};let b;this._renderablesBeingCreated.add(e.handle);try{b=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(w,e),this._createRenderableAbortController.signal)}catch(v){throw this._renderablesBeingCreated.delete(e.handle),v}return this._renderablesBeingCreated.delete(e.handle),()=>b}*_createRenderableTask(e,t){const{handle:i,bufferView:s,totalGaussians:r,packedHeader:a,tileOrigin:n,invPosScale:l,obb:o,origin:h,isGlobal:d,ellipsoidRadius:u}=e,c=n.x,p=n.y,m=n.z,f=h.x,g=h.y,_=h.z,y=new Float32Array(3*r),w=new Uint32Array(r),b=new Uint32Array(r),v=new Array,S=Math.ceil(r/D);let C=1/0,x=-1/0,M=1/0,T=-1/0,I=0,A=-1,H=0,F=0;for(let E=0;E<r;E++){const e=E*z,i=s[e],r=s[e+1],a=s[e+2],n=s[e+3],o=16383&r,h=r>>>14&16383,u=r>>>28&15|(1023&a)<<4,v=n>>>24,S=re[v],P=(a>>>10&255)+S,R=(a>>>18&255)+S,V=(a>>>26&63|(3&n)<<6)+S,j=P>0?P:0,G=R>0?R:0,U=V>0?V:0,O=j|G<<8|U<<16,D=Math.max(j,G,U),B=o*l+c,L=h*l+p,k=u*l+m;if(y[I]=B-f,y[I+1]=L-g,y[I+2]=k-_,d){const e=B*B+L*L+k*k;M=Math.min(M,e),T=Math.max(T,e)}else C=Math.min(C,k),x=Math.max(x,k);w[E]=i,b[E]=O,D>A&&(A=D),v>H&&(H=v),I+=3,F++,F===Q.createRenderableBatchSize&&(F=0,t.madeProgress()&&(t=yield))}F>0&&t.madeProgress(),d&&(C=Math.sqrt(M)-u,x=Math.sqrt(T)-u);const P=this._extractGaussianSplatMbsRadiusSquared(A),{fullExtent:R}=this.layer;R?.hasZ&&R.zmax&&R.zmin&&(C=Math.max(C,R.zmin),x=Math.min(x,R.zmax));const V=new E(C,x);try{for(let e=0;e<S;e++){let t=this.data.textureAtlas.allocatePage();if(null===t&&(this._freeInvisibleTiles(),t=this.data.textureAtlas.allocatePage()),null===t)throw new Error("ran out of gaussian splat memory");v.push(t);const i=r-e*D,n=Math.min(i,D),l=t*D,o=e*O,h=n*z;this._pageBuffer.set(s.subarray(o,o+h));const d=l%B,u=Math.floor(l/B);this.data.textureAtlas.update(d,u,this._pageBuffer),this.data.headerTexture.update(t,a)}}catch(G){throw this.data.textureAtlas.freePages(v),G}const j=new W(i,o,v,y,w,b,r,P,H/se,V);return this._tileHandles.set(i,j),this._cacheTileMemory+=j.usedMemory,this._memCache.put(`${j.handle}`,j),{memUsageBytes:j.usedMemory,numGaussians:r}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*ie}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);const t=this.data?.textureAtlas;let i=!1;const s=this._tileHandles.get(e);if(s){0!==s.lifecycleState?(i=!0,this.fadeHelper.onTileDiscarded(s),this._usedTileMemory-=s.usedMemory,this._intersectionHandler.removeTile(s)):this._cacheTileMemory-=s.usedMemory,t&&s.pageIds.forEach(e=>t.freePage(e)),this.freeObject(s),this._tileHandles.delete(e)}i&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(e.length,t=>{for(const{obb:i}of e)if(!t(i))break})}setRenderableVisibility(e,t,i){const s=this._currentLyr3dVisibilityChange+1,r=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(s,r);let a=!1;for(let n=0;n<i;n++){const i=this._tileHandles.get(e[n]);if(!i)continue;const l=t[n]?this._prepareTileFadeIn(i,s,r):this._prepareTileFadeOut(i,s);a||=l}a?(this._currentLyr3dVisibilityChange=s,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(s)}_prepareTileFadeIn(e,t,i){const s=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return 2===e.lifecycleState?(this.fadeHelper.fadeTile(e,0,i),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)!==t?(0===e.lifecycleState&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0):s}_prepareTileFadeOut(e,t){const i=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return i&&1===e.lifecycleState&&(this.moveTileToCache(e),e.lifecycleState=0),2!==e.lifecycleState?i:this._tileFadeOutsAwaitingInitialSort.get(e.handle)!==t?(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):i}_onSortComplete(e,t){const i=this._tmpTilesWithChangedVisibility;i.length=0;const s=this._tmpSortedTileHandles;s.clear();for(let a=0;a<e.length;a++){const t=e[a];s.add(t.handle)}this._triggerFadeIns(t,s,i);const r=this._triggerFadeOuts(t,i);s.clear(),i.length>0&&this.notifyTileObbsChanged(i),r&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,i){for(const[s,r]of this._tileFadeInsAwaitingInitialSort){if(r>e||!t.has(s))continue;const a=this._tileHandles.get(s);if(!a){this._tileFadeInsAwaitingInitialSort.delete(s);continue}const n=this._getFadeDurationForPendingVisibilityChange(r),l=0===a.lifecycleState;2!==a.lifecycleState&&(a.lifecycleState=2,l&&this._popTileFromCache(a),i.push(a)),this.fadeHelper.fadeTile(a,0,n),this._tileFadeInsAwaitingInitialSort.delete(s)}}_triggerFadeOuts(e,t){let i=!1;for(const[s,r]of this._tileFadeOutsAwaitingInitialSort){if(r>e)continue;const a=this._tileHandles.get(s);if(a){const e=2===a.lifecycleState,s=this._getFadeDurationForPendingVisibilityChange(r);this.fadeHelper.fadeTile(a,1,s),e&&0===a.lifecycleState&&(t.push(a),i=!0)}this._tileFadeOutsAwaitingInitialSort.delete(s)}return i}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(0!==this._fadeDurationPerVisibilityChange.size)for(const t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(M(e.handle))}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(M(e.handle),e)}destroy(){this._initializationController=i(this._initializationController),this._createRenderableAbortController.abort(),V(this),this._suspendedHandle&&(this._suspendedHandle=s(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(this._tileHandles.size,e=>{for(const{obb:t}of this._tileHandles.values())if(!e(t))break}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadows=r(this._shadows),this._depthRenderer=r(this._depthRenderer),this._renderer=r(this._renderer),this._memCache.destroy(),this.data=r(this.data)}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(w(this.view.renderSpatialReference)||b(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&v(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=T(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!S(t)&&t.wkid&&-1!==t.wkid&&(i=d(C.units[C[t.wkid]])),i&&(e=new g({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===y(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=u(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=A(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,I(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderer&&(this._renderer.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())0!==t.lifecycleState&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange("updating")}get maximumGaussianCount(){return this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*this.view.quality}set maximumGaussianCount(e){this._set("maximumGaussianCount",e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())0!==e.lifecycleState||this._renderablesBeingCreated.has(e.handle)||this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),r=this.reinterpretU32AsFloat(e[t+2]),a=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:r},invPosScale:a}}_deleteTile(e){this._renderablesBeingCreated.has(e.handle)||this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(i=>{0===i.lifecycleState?t++:e++});const i=this.data?.textureAtlasMemory??0,s=this.data?.headerTextureMemory??0,r=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,n=this.data?.sortBufferMemory??0;return new H(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,i,s,r,a,n)}get test(){}};e([c()],ae.prototype,"layer",void 0),e([c({readOnly:!0})],ae.prototype,"_clippingBox",null),e([c()],ae.prototype,"elevationOffset",null),e([c({readOnly:!0})],ae.prototype,"visibleAtCurrentScale",null),e([c()],ae.prototype,"fullExtentInLocalViewSpatialReference",void 0),e([c()],ae.prototype,"maximumGaussianCount",null),ae=Q=e([p("esri.views.3d.layers.GaussianSplatLayerView3D")],ae);const ne=ae;export{ne as default};