16 lines
71 KiB
JavaScript
16 lines
71 KiB
JavaScript
import{A as u,B as c,C as S,K as ee,bk as ne,Y as g,a8 as $e,E as te,f as Ae,ku as Oe,kv as Pe,$ as Be,J as L,jK as Le,aj as Ce,v as k,eL as Me,kw as De,kx as ze,ky as x,eq as Ne,eP as He,kz as F,au as Fe,eJ as Je,x as oe,ks as Ge,z as V,kA as je,Z as Ie,bj as Qe,D,fQ as Ve,T as le,a_ as ue,hH as he,aV as N,f2 as Ke,kB as de,kC as Ye,kD as ce,kE as Ze,kF as Xe,iH as J,kG as G,s as q,kH as We,eM as et,bZ as j,V as tt,L as it,u as fe,ab as rt,P as st,bb as nt,kI as at,kJ as ot,jU as lt,jN as ut,kK as ht,jO as dt,eH as ct,eI as ft}from"./index-b5c8f851.js";import{a as pe}from"./Container-f991c035.js";import{V as pt}from"./definitions-1467ba4a.js";import{m as yt,u as gt}from"./LayerView-c5a0067c.js";import{a as _t,r as ye,n as mt,m as vt,b as bt,w as wt,h as xt}from"./AttributeStoreView-b12ba31a.js";import{n as Rt}from"./BitmapTileContainer-1ba3b7ae.js";import{t as ge}from"./CircularArray-ef508845.js";import{t as _e,E as Et,T as Q}from"./color-0916c686.js";import{r as St}from"./BufferPool-f0e47fc2.js";import{h as K}from"./FramebufferObject-4be671ef.js";import{F as me}from"./enums-bdecffa2.js";import{f as Ct}from"./ProgramTemplate-a9187eb2.js";import{j as Ft}from"./visualVariablesUtils-f4ae79f2.js";import{w as _}from"./WGLContainer-21aabd6b.js";import{o as It}from"./FeatureContainer-090d46c9.js";import{o as ve}from"./floorFilterUtils-080a7cd2.js";import{p as Y,n as Vt}from"./popupUtils-8fdcef26.js";import{a as qt}from"./RefreshableLayerView-4421c564.js";import"./Texture-507d5ea8.js";import"./scaleUtils-7ebacf58.js";import"./TiledDisplayObject-a2315f25.js";import"./ExpandedCIM-0020ab0e.js";import"./BidiEngine-9a40f2f4.js";import"./GeometryUtils-984e8446.js";import"./enums-f1a6a48a.js";import"./utils-ebbcf3da.js";import"./GeometryUtils-7a7937c3.js";import"./Rect-ea14f53a.js";import"./quantizationUtils-50e37a76.js";import"./floatRGBA-ba8d5dad.js";import"./util-a6af6461.js";import"./Bitmap-e9c1dde3.js";import"./TileContainer-1c596b67.js";import"./VertexElementDescriptor-2925c6af.js";import"./OptimizedGeometry-d94e541f.js";import"./StyleDefinition-29c49b98.js";import"./config-1337d16e.js";import"./earcut-d423749e.js";import"./featureConversionUtils-6aca8295.js";import"./OptimizedFeatureSet-1d1ac4b9.js";let z=class extends ee{constructor(){super(...arguments),this.isAggregate=!0}getEffectivePopupTemplate(e=!1){var i;if(this.popupTemplate)return this.popupTemplate;const t=(i=this.sourceLayer)==null?void 0:i.featureReduction;return t&&"popupTemplate"in t&&t.popupEnabled?t.popupTemplate:null}getObjectId(){return this.attributes.aggregateId}};u([c({type:Boolean})],z.prototype,"isAggregate",void 0),z=u([S("esri.AggregateGraphic")],z);const ae=z;let w=class extends ne{constructor(e){super(e),this._filter=null,this.duration=g("mapview-transitions-duration"),this._excludedEffectView=new pe(e),this._includedEffectView=new pe(e)}get excludedEffects(){return this._excludedEffectView.effects}set featureEffect(e){this._get("featureEffect")!==e&&this._transitionTo(e)}get filter(){var e;return this._filter||((e=this.featureEffect)==null?void 0:e.filter)||null}get hasEffects(){return this._excludedEffectView.hasEffects||this._includedEffectView.hasEffects}get includedEffects(){return this._includedEffectView.effects}set scale(e){this._set("scale",e),this._excludedEffectView.scale=e,this._includedEffectView.scale=e}get transitioning(){return this._excludedEffectView.transitioning||this._includedEffectView.transitioning}transitionStep(e,t){this._set("scale",t),this.transitioning?(this._includedEffectView.transitionStep(e,t),this._excludedEffectView.transitionStep(e,t),this.transitioning||(this._filter=null)):(this._excludedEffectView.scale=t,this._includedEffectView.scale=t)}endTransitions(){this._includedEffectView.endTransitions(),this._excludedEffectView.endTransitions(),this._filter=null}_transitionTo(e){const t=this._get("featureEffect"),i=e,s=i==null?void 0:i.includedEffect,n=i==null?void 0:i.excludedEffect,a=this._includedEffectView.canTransitionTo(s)&&this._excludedEffectView.canTransitionTo(n);this._includedEffectView.effect=s,this._excludedEffectView.effect=n,this._set("featureEffect",i),this._filter=(i==null?void 0:i.filter)||(t==null?void 0:t.filter)||null,a||this.endTransitions()}};u([c()],w.prototype,"_filter",void 0),u([c()],w.prototype,"_excludedEffectView",void 0),u([c()],w.prototype,"_includedEffectView",void 0),u([c()],w.prototype,"duration",void 0),u([c()],w.prototype,"excludedEffects",null),u([c()],w.prototype,"featureEffect",null),u([c()],w.prototype,"filter",null),u([c()],w.prototype,"hasEffects",null),u([c()],w.prototype,"includedEffects",null),u([c({value:0})],w.prototype,"scale",null),u([c()],w.prototype,"transitioning",null),w=u([S("esri.layers.effects.FeatureEffectView")],w);const Tt=w;let P=class extends te{constructor(){super(...arguments),this.features=[]}readFeatures(e,t){var n;const i=Ae.fromJSON(t.spatialReference),s=[];for(let a=0;a<e.length;a++){const l=e[a],o=ae.fromJSON(l),h=(n=l.geometry)==null?void 0:n.spatialReference;o.geometry==null||h||(o.geometry.spatialReference=i);const d=l.aggregateGeometries,p=o.aggregateGeometries;if(d&&p!=null)for(const f in p){const y=p[f],m=d[f],b=m==null?void 0:m.spatialReference;y==null||b||(y.spatialReference=i)}s.push(o)}return s}};u([c({type:[ae],json:{write:!0}})],P.prototype,"features",void 0),u([$e("features")],P.prototype,"readFeatures",null),P=u([S("esri.rest.support.AggregateFeatureSet")],P);const kt=P;let I=class extends ne{constructor(e){super(e),this.tiles=new Map}destroy(){this.tiles.clear(),this.layer=this.layerView=this.tileInfoView=this.tiles=null}get updating(){return this.isUpdating()}acquireTile(e){const t=this.createTile(e);return t.once("isReady",()=>this.notifyChange("updating")),this.tiles.set(e.id,t),this.notifyChange("updating"),t}forceAttributeTextureUpload(){}forEachTile(e){this.tiles.forEach(e)}releaseTile(e){this.tiles.delete(e.key.id),this.notifyChange("updating"),this.disposeTile(e)}isUpdating(){let e=!0;this.tiles.forEach(i=>{e=e&&i.isReady});const t=!e;if(g("esri-2d-log-updating")){let i="";this.tiles.forEach(s=>{const n=s.updateStatus;i+=`-> ${s.key.id}: isReady: ${s.isReady} status: ${n}
|
|
`,e=e&&s.isReady}),console.log(`Updating BaseTileRenderer ${t}
|
|
${i}`)}return t}setHighlight(){}invalidateLabels(){}requestUpdate(){this.layerView.requestUpdate()}};u([c()],I.prototype,"layer",void 0),u([c()],I.prototype,"layerView",void 0),u([c()],I.prototype,"tileInfoView",void 0),u([c()],I.prototype,"updating",null),I=u([S("esri.views.2d.layers.features.tileRenderers.BaseTileRenderer")],I);const qe=I;let Ut=class{constructor(){this.gradient=null,this.height=512,this.intensities=null,this.width=512}render(e){Oe(e,512,this.intensities,this.gradient,this.minDensity,this.maxDensity)}},ie=class extends qe{constructor(e){super(e),this._intensityInfo={minDensity:0,maxDensity:0},this.type="heatmap",this.featuresView={attributeView:{initialize:()=>{},requestUpdate:()=>{}},requestRender:()=>{}},this._container=new Rt(e.tileInfoView)}createTile(e){const t=this._container.createTile(e);return this.tileInfoView.getTileCoords(t.bitmap,e),t.bitmap.resolution=this.tileInfoView.getTileResolution(e),t}onConfigUpdate(){const e=this.layer.renderer;if(e.type==="heatmap"){const{minDensity:t,maxDensity:i,colorStops:s}=e;this._intensityInfo.minDensity=t,this._intensityInfo.maxDensity=i,this._gradient=Pe(s),this.tiles.forEach(n=>{const a=n.bitmap.source;a&&(a.minDensity=t,a.maxDensity=i,a.gradient=this._gradient,n.bitmap.invalidateTexture(),n.bitmap.requestRender())})}}hitTest(){return Promise.resolve([])}install(e){e.addChild(this._container)}uninstall(e){this._container.removeAllChildren(),e.removeChild(this._container)}disposeTile(e){this._container.removeChild(e),e.destroy()}supportsRenderer(e){return e&&e.type==="heatmap"}onTileData(e){const t=this.tiles.get(e.tileKey);if(!t)return;const i=e.intensityInfo,{minDensity:s,maxDensity:n}=this._intensityInfo,a=t.bitmap.source||new Ut;a.intensities=(i==null?void 0:i.matrix)||null,a.minDensity=s,a.maxDensity=n,a.gradient=this._gradient,t.bitmap.source=a,this._container.addChild(t),this._container.requestRender(),this.requestUpdate()}onTileError(e){console.error(e)}lockGPUUploads(){}unlockGPUUploads(){}fetchResource(e,t){return console.error(e),Promise.reject()}};ie=u([S("esri.views.2d.layers.features.tileRenderers.HeatmapTileRenderer")],ie);const E=6,Z=4294967296;class H{constructor(e){this._savedCursor=null,this._savedOffset=null,this._head=e,this._cursor=e}static from(e){const t=$t.from(new Float32Array(e));return new H(t)}get id(){return this._cursor.id}get baseZoom(){return this._cursor.baseZoom}get anchorX(){return this._cursor.anchorX}get anchorY(){return this._cursor.anchorY}get directionX(){return this._cursor.directionX}get directionY(){return this._cursor.directionY}get size(){return this._cursor.size}get materialKey(){return this._cursor.materialKey}get boundsCount(){return this._cursor.boundsCount}computedMinZoom(){return this._cursor.computedMinZoom()}setComputedMinZoom(e){return this._cursor.setComputedMinZoom(e)}boundsComputedAnchorX(e){return this._cursor.boundsComputedAnchorX(e)}boundsComputedAnchorY(e){return this._cursor.boundsComputedAnchorY(e)}setBoundsComputedAnchorX(e,t){return this._cursor.setBoundsComputedAnchorX(e,t)}setBoundsComputedAnchorY(e,t){return this._cursor.setBoundsComputedAnchorY(e,t)}boundsX(e){return this._cursor.boundsX(e)}boundsY(e){return this._cursor.boundsY(e)}boundsWidth(e){return this._cursor.boundsWidth(e)}boundsHeight(e){return this._cursor.boundsHeight(e)}link(e){if(e._head!=null)return this._cursor.link(e._head)}getCursor(){return this.copy()}copy(){var s;const e=new H((s=this._head)==null?void 0:s.copy());if(!e._head)return e;let t=e._head,i=e._head._link;for(;i;)t._link=i.copy(),t=i,i=t._link;return e}peekId(){return this._cursor.peekId()??this._cursor._link.peekId()}nextId(){const e=this.id;for(;e===this.id;)if(!this.next())return!1;return!0}save(){this._savedCursor=this._cursor,this._savedOffset=this._cursor._offset}restore(){this._savedCursor&&(this._cursor=this._savedCursor),this._savedOffset!=null&&(this._cursor._offset=this._savedOffset)}next(){if(!this._cursor)return!1;if(!this._cursor.next()){if(!this._cursor._link)return!1;this._cursor=this._cursor._link,this._cursor._offset=0}return!0}lookup(e){for(this._cursor=this._head;this._cursor&&!this._cursor.lookup(e);){if(!this._cursor._link)return!1;this._cursor=this._cursor._link}return!!this._cursor}delete(e){let t=this._head,i=null;for(;t;){if(t.delete(e))return t.isEmpty()&&i!=null&&(i._link=t._link),!0;i=t,t=t._link}return!1}}let $t=class re{constructor(e){this._offset=-1,this._link=null,this._count=0,this._deletedCount=0,this._offsets={instance:null},this._buffer=e}static from(e){return new re(new Float32Array(e))}isEmpty(){return this._deletedCount===this.count}get count(){return this._count||(this._count=this._computeCount()),this._count}get id(){return this._buffer[this._offset]}set id(e){this._buffer[this._offset]=e}get baseZoom(){return this._buffer[this._offset+1]}get anchorX(){return this._buffer[this._offset+2]}get anchorY(){return this._buffer[this._offset+3]}get directionX(){return this._buffer[this._offset+4]}get directionY(){return this._buffer[this._offset+5]}get size(){return this._buffer[this._offset+6]}get materialKey(){return this._buffer[this._offset+7]}computedMinZoom(){return this._buffer[this._offset+8]}setComputedMinZoom(e){this._buffer[this._offset+8]=e}get boundsCount(){return this._buffer[this._offset+9]}boundsComputedAnchorX(e){return this._buffer[this._offset+10+e*E]}boundsComputedAnchorY(e){return this._buffer[this._offset+10+e*E+1]}setBoundsComputedAnchorX(e,t){this._buffer[this._offset+10+e*E]=t}setBoundsComputedAnchorY(e,t){this._buffer[this._offset+10+e*E+1]=t}boundsX(e){return this._buffer[this._offset+10+e*E+2]}boundsY(e){return this._buffer[this._offset+10+e*E+3]}boundsWidth(e){return this._buffer[this._offset+10+e*E+4]}boundsHeight(e){return this._buffer[this._offset+10+e*E+5]}link(e){let t=this;for(;t._link;)t=t._link;t._link=e}getCursor(){return this.copy()}copy(){const e=new re(this._buffer);return e._link=this._link,e._offset=this._offset,e._deletedCount=this._deletedCount,e._offsets=this._offsets,e._count=this._count,e}peekId(){const e=this._offset+10+this.boundsCount*E+0;return e>=this._buffer.length?0:this._buffer[e]}next(){let e=0;for(;this._offset<this._buffer.length&&e++<100&&(this._offset===-1?this._offset=0:this._offset+=10+this.boundsCount*E,this.id===Z););return this.id!==Z&&this._offset<this._buffer.length}delete(e){const t=this._offset,i=this.lookup(e);if(i)for(this.id=4294967295,++this._deletedCount;this.next()&&this.id===e;)this.id=4294967295,++this._deletedCount;return this._offset=t,i}lookup(e){const t=this._offset;if(this._offsets.instance==null){this._offsets.instance=new Map;const i=this.copy();i._offset=-1;let s=0;for(;i.next();)i.id!==s&&(this._offsets.instance.set(i.id,i._offset),s=i.id)}return!!this._offsets.instance.has(e)&&(this._offset=this._offsets.instance.get(e),this.id!==Z||(this._offset=t,!1))}_computeCount(){const e=this._offset;let t=0;for(this._offset=-1;this.next();)t++;return this._offset=e,t}};const At=1.25,be=32767,Ot=be<<16|be;let we=class{constructor(e,t,i,s){const n=St.create(t*i*Uint32Array.BYTES_PER_ELEMENT,s);this.size=t,this.strideInt=i,this.bufferType=e,this.dirty={start:1/0,end:0},this._gpu=null,this._cpu=n,this.clear()}get elementSize(){return this._cpu.length/this.strideInt}get invalidated(){return this.bufferSize>0&&!this._gpu}get invalidatedComputeBuffer(){return this.bufferSize>0&&!this._gpuComputeTriangles}invalidate(){var e;this._invalidateTriangleBuffer(),(e=this._gpu)==null||e.dispose(),this._gpu=null}_invalidateTriangleBuffer(){var e;(e=this._gpuComputeTriangles)==null||e.dispose(),this._gpuComputeTriangles=null}destroy(){var e,t,i,s;(e=this._gpu)==null||e.dispose(),(t=this._gpuComputeTriangles)==null||t.dispose(),(i=this._cpu)==null||i.destroy(),(s=this._cpu2)==null||s.destroy()}clear(){this.dirty.start=1/0,this.dirty.end=0,this.freeList=new _t({start:0,end:this._cpu.length/this.strideInt}),this.fillPointer=0}ensure(e){if(!(this.maxAvailableSpace()>=e)&&e*this.strideInt>this._cpu.length-this.fillPointer){this.invalidate();const t=this._cpu.length/this.strideInt,i=Math.round((t+e)*At),s=i*this.strideInt;this._cpu.expand(s*Uint32Array.BYTES_PER_ELEMENT),this.freeList.free(t,i-t)}}set(e,t){this._cpu.array[e]!==t&&(this._cpu.array[e]=t,this.dirty.start=Math.min(e,this.dirty.start),this.dirty.end=Math.max(e,this.dirty.end))}getGPUBuffer(e,t=!1){if(!this.bufferSize)return null;if(t){if(this.bufferType!=="index")throw new Error("Tired to get triangle buffer, but target is not an index buffer");return this._gpuComputeTriangles==null&&(this._gpuComputeTriangles=this._createComputeBuffer(e)),this._gpuComputeTriangles}return this._gpu==null&&(this._gpu=this._createBuffer(e)),this._gpu}getCPUBuffer(){if(!this._cpu2){const e=this._cpu.slice();this._cpu2=e}return this._cpu2.length!==this._cpu.length&&this._cpu2.expand(this._cpu.length*this._cpu.array.BYTES_PER_ELEMENT),this._cpu2.set(this._cpu),this._cpu2}get bufferSize(){return this._cpu.length/this.strideInt}maxAvailableSpace(){return this.freeList.maxAvailableSpace()}insert(e,t,i,s){const n=i*this.strideInt;if(!n)return 0;const a=t*this.strideInt*Uint32Array.BYTES_PER_ELEMENT,l=new Uint32Array(e,a,n),o=this.freeList.firstFit(i);Be(o,"First fit region must be defined");const h=o*this.strideInt,d=n,p=h/this.strideInt-t;if(s!==0)for(let f=0;f<l.length;f++)l[f]+=s;return this._cpu.array.set(l,h),this.dirty.start=Math.min(this.dirty.start,h),this.dirty.end=Math.max(this.dirty.end,h+d),this.fillPointer=Math.max(this.fillPointer,h+d),p}free(e,t,i){const s=e*this.strideInt,n=(e+t)*this.strideInt;if(i===!0)for(let a=e;a!==e+t;a++)this._cpu.array[a*this.strideInt]=Ot;this.dirty.start=Math.min(this.dirty.start,s),this.dirty.end=Math.max(this.dirty.end,n),this.freeList.free(e,t)}upload(){if(this.dirty.end){if(this._invalidateTriangleBuffer(),this._gpu==null)return this.dirty.start=1/0,void(this.dirty.end=0);this._gpu.setSubData(this._cpu.array,this.dirty.start,this.dirty.start,this.dirty.end),this.dirty.start=1/0,this.dirty.end=0}}_createBuffer(e){const t=me.DYNAMIC_DRAW;return this.bufferType==="index"?K.createIndex(e,t,this._cpu.array):K.createVertex(e,t,this._cpu.array)}_createComputeBuffer(e){const t=me.DYNAMIC_DRAW,i=new Uint32Array(this.fillPointer/3);for(let s=0;s<this.fillPointer;s+=3)i[s/3]=this._cpu.array[s];return K.createIndex(e,t,i)}};const Pt=0,Bt=1;let Lt=class{constructor(e,t){this._vaos=new Map,this._indicesInvalid=!1,this.geometryType=e,this._stage=t}destroy(){for(const[e,t]of this._vaos)t==null||t.disposeVAOOnly();this._indexBuffer=L(this._indexBuffer),this._vertexBuffer=L(this._vertexBuffer)}get records(){return this._records}insert(e,t,i){if(!e.records.byteLength)return;const s=e.stride;if(this._vertexBuffer&&this._indexBuffer){const n=e.indices.byteLength/4,a=e.vertices.byteLength/s;this._indexBuffer.ensure(n),this._vertexBuffer.ensure(a);const{vertices:l,indices:o}=e,h=ye.from(e.records),d=this._vertexBuffer.insert(l,0,l.byteLength/s,0),p=this._indexBuffer.insert(o,0,o.byteLength/4,d);if(h.forEach(f=>{f.indexFrom+=p,f.vertexFrom+=d}),this._records.link(h),t)this._indicesInvalid=!0;else if(this._displayList){const f=h.getCursor();for(;f.next();)this._displayList.addRecord(f)}}else{const n=e.indices.byteLength/4,a=e.vertices.byteLength/s,l=s/Uint32Array.BYTES_PER_ELEMENT,o=this._stage.bufferPool;this._records=ye.from(e.records),this._indexBuffer=new we("index",n,1,o),this._vertexBuffer=new we("vertex",a,l,o),this._indexBuffer.insert(e.indices,0,e.indices.byteLength/4,0),this._vertexBuffer.insert(e.vertices,0,e.vertices.byteLength/s,0),t&&(this._indicesInvalid=!0)}}remove(e){if(this._records!=null)for(const t of e){const i=this._records.getCursor();if(!i.lookup(t))continue;const s=i.indexFrom,n=i.vertexFrom;let a=i.indexCount,l=i.vertexCount;for(;i.next()&&i.id===t;)a+=i.indexCount,l+=i.vertexCount;this._indexBuffer.free(s,a),this._vertexBuffer.free(n,l,!0),this._records.delete(t)}}getVAO(e,t,i,s){if(!this._vertexBuffer||!this._indexBuffer||this._records==null||!this._vertexBuffer.bufferSize)return null;const n=s?Bt:Pt;let a=this._vaos.get(n);(this._vertexBuffer.invalidated||this._indexBuffer.invalidated||s&&this._indexBuffer.invalidatedComputeBuffer)&&(a==null||a.disposeVAOOnly(),a=null),this._vertexBuffer.upload(),this._indexBuffer.upload();const l=this._indexBuffer.getGPUBuffer(e,n===1),o=this._vertexBuffer.getGPUBuffer(e);return a||(a=new Ct(e,i,t,{geometry:o},l),this._vaos.set(n,a)),a}forEachCommand(e){if(this._records!=null){if(this._sortIndices(this._records),!this._displayList){const t=this._cursorIndexOrder;this._displayList=mt.from(this,this.geometryType,this._records.getCursor(),t)}this._displayList.forEach(e)}}_sortIndices(e){const t=!!this._indexBuffer.bufferSize;if(!this._indicesInvalid)return;this._indicesInvalid=!1;let i=0;const s=e.getCursor(),n=[],a=[],l=[];for(;s.next();)a.push(s.index),l.push(s.sortKey),n.push(s.id);a.sort((d,p)=>{const f=l[p],y=l[d];return y===f?n[p]-n[d]:f-y});const o=e.getCursor(),h=t?this._indexBuffer.getCPUBuffer():this._vertexBuffer.getCPUBuffer();for(const d of a){if(!o.seekIndex(d))throw new Error("Expected to find index");if(t){const{indexFrom:p,indexCount:f}=o;o.indexFrom=i;for(let y=0;y<f;y++)this._indexBuffer.set(i++,h.array[p+y])}else{const{vertexFrom:p,vertexCount:f}=o,y=this._vertexBuffer.strideInt,m=p*y,b=m+f*y;o.vertexFrom=i/y;for(let C=m;C<b;C++)this._vertexBuffer.set(i++,h.array[C])}}this._cursorIndexOrder=a,this._displayList=null}};const Mt=50,Dt=4,xe=100;let zt=0,Nt=class extends vt{constructor(e,t,i,s,n,a){super(e,t,i,s),this.instanceId=zt++,this.patchCount=0,this._renderState={current:{geometry:new Map,metrics:null},next:null,swap:!1,swapFrames:0,locked:!1},this._patches=new ge(xe),this._bufferPatches=new ge(xe),this._lastCommitTime=0,this.transforms.labelMat2d=Le(),this._store=n,this._requestLabelUpdate=a}destroy(){super.destroy(),this._renderState.current.geometry.forEach(e=>e.destroy()),this._renderState.next!=null&&this._renderState.next.geometry.forEach(e=>e.destroy()),this._renderState.current=null,this._renderState.next=null}get labelMetrics(){return this._renderState.current.metrics}get hasData(){return!!this._renderState.current.geometry.size}get updateStatus(){return`renderState:${!!this._renderState.current}, ${!!this._renderState.next}, hasData:${this.hasData}, queue:${this._patches.size}`}getGeometry(e){return this._renderState.current.geometry.get(e)}patch(e,t){this.patchCount++,e.clear&&this._patches.size>=Mt&&this._dropPatches();const i=e,s=i.addOrUpdate&&this.key.id!==i.addOrUpdate.tileKeyOrigin;t&&s?this._bufferPatches.enqueue(i):(i.sort=i.sort&&!t,this._patches.enqueue(i)),this.requestRender()}commit(e){if(this._lastCommitTime!==e.time){this._lastCommitTime=e.time;for(let t=0;t<Dt;t++)this._updateMesh(),this.isReady&&this._updateBufferMesh();this._renderState.swap&&(this._swapRenderStates(),this.requestRender())}}lock(){this._renderState.locked=!0}unlock(){this._renderState.locked=!1,this._flushUpdates(),this._swap()}_swapRenderStates(){if(this._renderState.next){if(this._renderState.locked)return this._renderState.swap=!0,void this.requestRender();this._renderState.swap=!0,this._swap()}}_swap(){this._renderState.swap&&(this._renderState.swap=!1,this._renderState.next!=null&&(this._renderState.current.geometry.forEach(e=>e.destroy()),this._renderState.current=this._renderState.next,this._renderState.next=null,this._requestLabelUpdate()))}_flushUpdates(){let e=this._patches.maxSize;for(;this._patches.size&&e--;)this._updateMesh(),this._swap()}_updateBufferMesh(){const e=this._bufferPatches.peek();if(e==null||!e.clear||this._renderState.next===null)for(;this._bufferPatches.size;){const t=this._bufferPatches.dequeue();t!=null&&this._patchBuffer(t)}}_updateMesh(){var t,i,s,n;const e=this._patches.dequeue();if(e!=null){if(g("esri-2d-update-debug")){const a=e,l=(t=a.addOrUpdate)==null?void 0:t.tileKeyOrigin,o=this.key.id===l?"SELF":l;let h="";for(let d=0;d<5;d++)h+=(n=(s=(i=a.addOrUpdate)==null?void 0:i.data[d])==null?void 0:s.records)!=null&&n.byteLength?1:0;console.debug(this.key.id,"FeatureTile:patch",`[clear: ${a.clear} origin: ${o}, end:${a.end} data:${h}]`)}e.clear===!0&&(this._renderState.next!=null&&(this._renderState.next.geometry.forEach(a=>a.destroy()),this._renderState.next=null),this._renderState.next={geometry:new Map,metrics:null},g("esri-2d-update-debug")&&console.debug(this.key.id,"FeatureTile:_updateMesh - Creating new renderState")),this.requestRender(),this._patch(e),e.end&&(g("esri-2d-update-debug")&&console.debug(this.key.id,"FeatureTile:_updateMesh - Encountered end message"),this.ready(),this._swapRenderStates())}}_patch(e){_e(t=>{this._remove(t,e.remove),this._insert(t,e,!1)})}_patchBuffer(e){_e(t=>{this._insert(t,e,!0)})}_insert(e,t,i){var s,n;try{const a=this._renderState.next??this._renderState.current,l=(s=t.addOrUpdate)==null?void 0:s.data[e],o=a.geometry;if(l==null)return;o.has(e)||(g("esri-2d-update-debug")&&console.debug(this.key.id,`FeatureTile:_insert - Creating geometry buffer ${e}`),o.set(e,new Lt(e,this.stage))),g("esri-2d-update-debug")&&console.debug(this.key.id,`FeatureTile:_insert - Inserting into ${e}, version=${(n=t.addOrUpdate)==null?void 0:n.version} stride=${l.stride}`),o.get(e).insert(l,t.sort,i),e===Et.LABEL&&this._insertLabelMetrics(t.type,l.metrics,t.clear)}catch{}}_insertLabelMetrics(e,t,i){const s=this._renderState.next??this._renderState.current;if(t==null)return;const n=H.from(t);if(s.metrics!=null){if(e==="update"){const a=n.getCursor();for(;a.next();)s.metrics.delete(a.id)}s.metrics.link(n)}else s.metrics=n}_remove(e,t){const i=(this._renderState.next??this._renderState.current).geometry.get(e);t&&t.length&&i&&(i.remove(t),this._removeLabelMetrics(t))}_removeLabelMetrics(e){const{metrics:t}=this._renderState.next??this._renderState.current;if(t!=null&&e.length)for(const i of e)for(;t.delete(i););}_dropPatches(){const e=new Array;let t=!1;for(;this._patches.size;){const i=this._patches.dequeue();if(i==null)break;if(i.clear){if(t)break;t=!0}e.push(i)}this._patches.clear(),e.forEach(i=>this._patches.enqueue(i))}};const Ht=g("featurelayer-order-by-server-enabled");let Jt=class extends It{constructor(e,t,i,s){super(e),this._hitTestsRequests=[],this._layer=i,this._layerView=t,this._onUpdate=s}renderChildren(e){this.attributeView.update(),this.hasAnimation&&e.painter.effects.integrate.draw(e,e.attributeView),super.renderChildren(e)}hasEmptyAttributeView(){return this.attributeView.isEmpty()}isUpdating(){return this.attributeView.isUpdating()}hitTest(e){let t=this._hitTestsRequests.find(({x:s,y:n})=>s===e.x&&n===e.y);const i=Ce();return t?t.resolvers.push(i):(t={x:e.x,y:e.y,resolvers:[i]},this._hitTestsRequests.push(t)),this.requestRender(),i.promise}onTileData(e,t){const i=Ht&&"orderBy"in this._layer&&this._layer.orderBy,s=i&&(i==null?void 0:i.length)&&!i[0].valueExpression&&i[0].field,n=!!i&&this._layerView.orderByFields===s;e.patch(t,n),this.contains(e)||this.addChild(e),this.requestRender()}onTileError(e){this.contains(e)||this.addChild(e)}updateTransitionProperties(e,t){super.updateTransitionProperties(e,t),this._layerView.featureEffectView.transitionStep(e,t),this._layerView.featureEffectView.transitioning&&this.requestRender()}doRender(e){const{minScale:t,maxScale:i}=this._layer.effectiveScaleRange,s=e.state.scale;s<=(t||1/0)&&s>=i&&super.doRender(e)}afterRender(e){super.afterRender(e),this._hitTestsRequests.length&&this.requestRender()}onAttributeStoreUpdate(){this.hasLabels&&this._layerView.view.labelManager.requestUpdate(),this._onUpdate()}get hasAnimation(){return this.hasLabels}setStencilReference(e){const{rendererSchema:t}=e.rendererInfo;if((t==null?void 0:t.type)==="dot-density"&&(t==null?void 0:t.dotSize)>1||(t==null?void 0:t.type)==="heatmap")for(const s of this.children)s.stencilRef=s.key.level+1;else super.setStencilReference(e)}get hasHighlight(){return this._layerView.hasHighlight()}get hasLabels(){var i;if("sublayers"in this._layer)return this._layer.sublayers.some(s=>{var n;return!!((n=s.labelingInfo)!=null&&n.length)&&s.labelsVisible});const e=this._layer.featureReduction,t=e&&"labelingInfo"in e&&e.labelsVisible&&e.labelingInfo&&e.labelingInfo.length;return((i=this._layer.labelingInfo)==null?void 0:i.length)&&this._layer.labelsVisible||!!t}prepareRenderPasses(e){const t=super.prepareRenderPasses(e),i=e.registerRenderPass({name:"label",brushes:[_.label],target:()=>this.hasLabels?this.children:null,drawPhase:Q.LABEL|Q.LABEL_ALPHA});if(g("featurelayer-force-marker-text-draw-order")){const n=e.registerRenderPass({name:"geometry",brushes:[_.fill,_.dotDensity,_.line,_.heatmap,_.pieChart],target:()=>this.children,forceDrawByDisplayOrder:!0,enableDefaultDraw:()=>!this._layerView.featureEffectView.hasEffects,effects:[{apply:e.effects.outsideEffect,enable:()=>this._layerView.featureEffectView.hasEffects,args:()=>this._layerView.featureEffectView.excludedEffects},{apply:e.effects.insideEffect,enable:()=>this._layerView.featureEffectView.hasEffects,args:()=>this._layerView.featureEffectView.includedEffects},{apply:e.effects.hittest,enable:()=>!!this._hitTestsRequests.length,args:()=>this._hitTestsRequests}]});t.push(n)}else{const n=e.registerRenderPass({name:"geometry",brushes:[_.fill,_.dotDensity,_.line,_.marker,_.heatmap,_.pieChart,_.text],target:()=>this.children,enableDefaultDraw:()=>!this._layerView.featureEffectView.hasEffects,effects:[{apply:e.effects.outsideEffect,enable:()=>this._layerView.featureEffectView.hasEffects,args:()=>this._layerView.featureEffectView.excludedEffects},{apply:e.effects.insideEffect,enable:()=>this._layerView.featureEffectView.hasEffects,args:()=>this._layerView.featureEffectView.includedEffects},{apply:e.effects.hittest,enable:()=>!!this._hitTestsRequests.length,args:()=>this._hitTestsRequests}]});t.push(n)}const s=e.registerRenderPass({name:"highlight",brushes:[_.fill,_.dotDensity,_.line,_.marker,_.pieChart,_.text],target:()=>this.children,drawPhase:Q.HIGHLIGHT,enableDefaultDraw:()=>!1,effects:[{apply:e.effects.highlight,enable:()=>!!this._layerView.hasHighlight()}]});return t.push(s),t.push(i),t}},se=class extends qe{constructor(){super(...arguments),this.type="symbol"}install(e){const t=()=>this.notifyChange("updating"),i=new Jt(this.tileInfoView,this.layerView,this.layer,t);this.featuresView=i,e.addChild(i)}uninstall(e){e.removeChild(this.featuresView),this.featuresView=L(this.featuresView)}fetchResource(e,t){const{url:i}=e,s=this.featuresView.stage;try{return s.resourceManager.fetchResource(i,{signal:t.signal})}catch(n){return k(n)?Promise.resolve({width:0,height:0}):Promise.reject(n)}}isUpdating(){var n;const e=super.isUpdating(),t=!this.featuresView||this.featuresView.isUpdating(),i=(n=this.featuresView)==null?void 0:n.hasEmptyAttributeView(),s=e||t||e&&i;return g("esri-2d-log-updating")&&console.log(`Updating SymbolTileRenderer ${s}
|
|
-> updatingTiles ${e}
|
|
-> hasFeaturesView ${!!this.featuresView}
|
|
-> updatingFeaturesView ${t}`),s}hitTest(e){return this.featuresView.hitTest(e)}supportsRenderer(e){return e!=null&&["simple","class-breaks","unique-value","dot-density","dictionary","heatmap","pie-chart"].includes(e.type)}onConfigUpdate(e){let t=null;if(e&&"visualVariables"in e){const i=(bt(e).visualVariables||[]).map(s=>{const n=s.clone();return"normalizationField"in s&&(n.normalizationField=null),s.valueExpression&&s.valueExpression!=="$view.scale"&&(n.valueExpression=null,n.field="nop"),n});t=Ft(i)}this.featuresView.setRendererInfo(e,t,this.layerView.featureEffect)}onTileData(e){const t=this.tiles.get(e.tileKey);t&&e.data&&this.featuresView.onTileData(t,e.data),this.layerView.view.labelManager.requestUpdate()}onTileError(e){const t=this.tiles.get(e.tileKey);t&&this.featuresView.onTileError(t)}forceAttributeTextureUpload(){this.featuresView.attributeView.forceTextureUpload()}lockGPUUploads(){this.featuresView.attributeView.lockTextureUpload(),this.tiles.forEach(e=>e.lock())}unlockGPUUploads(){this.featuresView.attributeView.unlockTextureUpload(),this.tiles.forEach(e=>e.unlock())}async getMaterialItems(e){return this.featuresView.getMaterialItems(e)}invalidateLabels(){this.featuresView.hasLabels&&this.layerView.view.labelManager.requestUpdate()}createTile(e){const t=this.tileInfoView.getTileBounds(Me(),e),i=()=>this.layerView.view.labelManager.requestUpdate(),s=this.tileInfoView.getTileResolution(e.level),n=this.featuresView.attributeView;return new Nt(e,s,t[0],t[3],n,i)}disposeTile(e){this.featuresView.removeChild(e),e.destroy(),this.layerView.view.labelManager.requestUpdate()}};se=u([S("esri.views.2d.layers.features.tileRenderers.SymbolTileRenderer")],se);function Gt(r,e){if(!r)return null;switch(r.type){case"symbol":return new se(e);case"heatmap":return new ie(e)}}function X(r){return r.some(e=>e.globalId)}function O(r){return r.filter(e=>!e.error).map(e=>e.objectId??e.globalId).filter(e=>e!=null)}function Re(r,e){const t=new Set(r);for(const i of e.values())t.add(i);return t}function Ee(r,e){const t=new Set(r);for(const i of e.values())t.delete(i);return t}let B=class extends ne{constructor(e){super(e),this._hasGlobalIds=!1,this._notifyUpdating=()=>{this.notifyChange("updating")}}normalizeCtorArgs(e){return this._queueProcessor=new De({concurrency:1,process:e.process}),{}}destroy(){this.clear()}get updating(){return this._queueProcessor.length>0}clear(){this._queueProcessor.clear()}push(e){const t=this._queueProcessor,i=t.last();switch(e.type){case"update":case"refresh":if((i==null?void 0:i.type)===e.type)return;t.push(e).then(this._notifyUpdating,this._notifyUpdating);break;case"edit":{const s=(i==null?void 0:i.type)==="processed-edit"?i:null;s&&t.popLast();const n=this._mergeEdits(s,e);for(const a of n)a&&t.push(a).then(this._notifyUpdating,this._notifyUpdating);break}}this.notifyChange("updating")}_mergeEdits(e,t){const{addedFeatures:i,deletedFeatures:s,updatedFeatures:n}=t.edits;if(this._hasGlobalIds=this._hasGlobalIds||X(i)||X(n)||X(s),this._hasGlobalIds)return[e,{type:"processed-edit",edits:{addOrModified:[...i,...n],removed:s}}];const a=new Set(O((e==null?void 0:e.edits.addOrModified)??[])),l=new Set(O((e==null?void 0:e.edits.removed)??[])),o=new Set([...O(i),...O(n)]),h=new Set(O(s));return[{type:"processed-edit",edits:{addOrModified:Array.from(Re(Ee(a,h),o)).map(d=>({objectId:d})),removed:Array.from(Re(Ee(l,o),h)).map(d=>({objectId:d}))}}]}};u([c({readOnly:!0})],B.prototype,"updating",null),u([c()],B.prototype,"process",void 0),B=u([S("esri.views.2d.layers.support.FeatureCommandQueue")],B);const jt=B;function Qt(r){return Array.isArray(r)}let U=class extends ze{constructor(e){super(e),this._startupResolver=Ce(),this.isReady=!1}initialize(){this._controller=new AbortController,this.addResolvingPromise(this._startWorker(this._controller.signal))}destroy(){this._controller.abort(),this._connection&&this._connection.close()}set tileRenderer(e){this.client.tileRenderer=e}get closed(){return this._connection.closed}async startup(e,t,i,s){await this.when();const n=this._controller.signal,a=Qt(i.source)?{transferList:i.source,signal:n}:void 0,l={service:i,config:t,tileInfo:e.tileInfo.toJSON(),tiles:s};await this._connection.invoke("startup",l,a),this._startupResolver.resolve(),this._set("isReady",!0)}async updateTiles(e){return await this._startupResolver.promise,x(this._connection.invoke("updateTiles",e))}async update(e){const t={config:e};return await this._startupResolver.promise,this._connection.invoke("update",t)}async applyUpdate(e){return await this._startupResolver.promise,this._connection.invoke("applyUpdate",e)}async setHighlight(e){return await this._startupResolver.promise,x(this._connection.invoke("controller.setHighlight",e))}async stop(){if(await this._startupResolver.promise,!this.closed)return x(this._connection.invoke("stop"))}async refresh(e){return await this._startupResolver.promise,x(this._connection.invoke("controller.refresh",e))}async querySummaryStatistics(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.querySummaryStatistics",{query:e.toJSON(),params:t},i)}async queryAggregateSummaryStatistics(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateSummaryStatistics",{query:e.toJSON(),params:t},i)}async queryUniqueValues(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryUniqueValues",{query:e.toJSON(),params:t},i)}async queryAggregateUniqueValues(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateUniqueValues",{query:e.toJSON(),params:t},i)}async queryClassBreaks(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryClassBreaks",{query:e.toJSON(),params:t},i)}async queryAggregateClassBreaks(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateClassBreaks",{query:e.toJSON(),params:t},i)}async queryHistogram(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryHistogram",{query:e.toJSON(),params:t},i)}async queryAggregateHistogram(e,t,i){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateHistogram",{query:e.toJSON(),params:t},i)}async queryFeatures(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryFeatures",e==null?void 0:e.toJSON(),t)}async queryVisibleFeatures(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryVisibleFeatures",e==null?void 0:e.toJSON(),t)}async queryObjectIds(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryObjectIds",e==null?void 0:e.toJSON(),t)}async queryFeatureCount(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryFeatureCount",e==null?void 0:e.toJSON(),t)}async queryExtent(e,t){return this._connection.invoke("controller.queryExtent",e.toJSON(),t)}async queryLatestObservations(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryLatestObservations",e.toJSON(),t)}async queryStatistics(e){return await this._startupResolver.promise,this._connection.invoke("controller.queryStatistics",e)}async queryAggregates(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregates",e==null?void 0:e.toJSON(),t)}async queryAggregateCount(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateCount",e==null?void 0:e.toJSON(),t)}async queryAggregateIds(e,t){return await this._startupResolver.promise,this._connection.invoke("controller.queryAggregateIds",e==null?void 0:e.toJSON(),t)}async getObjectId(e){return await this._startupResolver.promise,this._connection.invoke("controller.getObjectId",e)}async getDisplayId(e){return await this._startupResolver.promise,this._connection.invoke("controller.getDisplayId",e)}async getFeatures(e){return await this._startupResolver.promise,this._connection.invoke("controller.getFeatures",e)}async getAggregates(){return await this._startupResolver.promise,this._connection.invoke("controller.getAggregates")}async getAggregateValueRanges(){return await this._startupResolver.promise,this._connection.invoke("controller.getAggregateValueRanges")}async mapValidDisplayIds(e){return await this._startupResolver.promise,this._connection.invoke("controller.mapValidDisplayIds",e)}async onEdits(e){return await this._startupResolver.promise,x(this._connection.invoke("controller.onEdits",e))}async enableEvent(e,t){return await this._startupResolver.promise,x(this._connection.invoke("controller.enableEvent",{name:e,value:t}))}async pauseStream(){return await this._startupResolver.promise,x(this._connection.invoke("controller.pauseStream"))}async resumeStream(){return await this._startupResolver.promise,x(this._connection.invoke("controller.resumeStream"))}async sendMessageToSocket(e){return await this._startupResolver.promise,x(this._connection.invoke("controller.sendMessageToSocket",e))}async sendMessageToClient(e){return await this._startupResolver.promise,x(this._connection.invoke("controller.sendMessageToClient",e))}async updateCustomParameters(e){return await this._startupResolver.promise,x(this._connection.invoke("controller.updateCustomParameters",e))}async _startWorker(e){try{this._connection=await Ne("Pipeline",{client:this.client,strategy:"dedicated",signal:e})}catch(t){He(t)}}};u([c()],U.prototype,"isReady",void 0),u([c({constructOnly:!0})],U.prototype,"client",void 0),u([c()],U.prototype,"tileRenderer",null),U=u([S("esri.views.2d.layers.support.FeatureLayerProxy")],U);const Kt=U,Yt=Math.PI;function Te(r,e){switch(e.transformationType){case F.Additive:return Zt(r,e);case F.Constant:return Xt(e,r);case F.ClampedLinear:return Wt(r,e);case F.Proportional:return ei(r,e);case F.Stops:return ti(r,e);case F.RealWorldSize:return ii(r,e);case F.Identity:return r;case F.Unknown:return null}}function R(r,e){return typeof r=="number"?r:Te(e,r)}function Zt(r,e){return r+(R(e.minSize,r)||e.minDataValue)}function Xt(r,e){const t=r.stops;let i=(t==null?void 0:t.length)&&t[0].size;return i==null&&(i=r.minSize),R(i,e)}function Wt(r,e){const t=e.minDataValue,i=e.maxDataValue,s=(r-t)/(i-t),n=R(e.minSize,r),a=R(e.maxSize,r);return r<=t?n:r>=i?a:n+s*(a-n)}function ei(r,e){const t=r/e.minDataValue,i=R(e.minSize,r),s=R(e.maxSize,r);let n=null;return n=t*i,Fe(n,i,s)}function ti(r,e){const[t,i,s]=ri(r,e.cache.ipData);if(t===i)return R(e.stops[t].size,r);{const n=R(e.stops[t].size,r);return n+(R(e.stops[i].size,r)-n)*s}}function ii(r,e){const t=Je[e.valueUnit],i=R(e.minSize,r),s=R(e.maxSize,r),{valueRepresentation:n}=e;let a=null;return a=n==="area"?2*Math.sqrt(r/Yt)/t:n==="radius"||n==="distance"?2*r/t:r/t,Fe(a,i,s)}function ri(r,e){if(!e)return;let t=0,i=e.length-1;return e.some((s,n)=>r<s?(i=n,!0):(t=n,!1)),[t,i,(r-e[t])/(e[i]-e[t])]}const si=1e-6;class ni{constructor(e){this._tiles=new Map,this.buffer=0,this.acquireTile=e.acquireTile,this.releaseTile=e.releaseTile,this.tileInfoView=e.tileInfoView,this.buffer=e.buffer}destroy(){}clear(){this._tiles.forEach(e=>this._releaseTile(e))}tileKeys(){const e=[];return this._tiles.forEach((t,i)=>e.push(i)),e}update(e){const t=this.tileInfoView.getTileCoverage(e.state,this.buffer,!0,"closest"),{spans:i,lodInfo:s}=t,{level:n}=s,a=[],l=[],o=new Set,h=new Set;for(const{row:d,colFrom:p,colTo:f}of i)for(let y=p;y<=f;y++){const m=oe.getId(n,d,s.normalizeCol(y),s.getWorldForColumn(y)),b=this._getOrAcquireTile(a,m);o.add(m),b.isReady?b.visible=!0:h.add(b.key)}return h.forEach(d=>this._addPlaceholders(o,d)),this._tiles.forEach(d=>{o.has(d.key.id)||(l.push(d.key.id),this._releaseTile(d))}),Ge.pool.release(t),{hasMissingTiles:h.size>0,added:a,removed:l}}_getOrAcquireTile(e,t){if(!this._tiles.has(t)){const i=this.acquireTile(new oe(t));e.push(t),this._tiles.set(t,i),i.visible=!1}return this._tiles.get(t)}_getTile(e){return this._tiles.get(e)}_releaseTile(e){this._tiles.delete(e.key.id),this.releaseTile(e)}_addPlaceholders(e,t){const i=this._addPlaceholderChildren(e,t);Math.abs(1-i)<si||this._addPlaceholderParent(e,t)||(this._getTile(t.id).visible=!0)}_addPlaceholderChildren(e,t){let i=0;return this._tiles.forEach(s=>{i+=this._addPlaceholderChild(e,s,t)}),i}_addPlaceholderChild(e,t,i){return t.key.level<=i.level||!t.hasData||!i.contains(t.key)?0:(t.visible=!0,e.add(t.key.id),1/(1<<2*(t.key.level-i.level)))}_addPlaceholderParent(e,t){let i=t.getParentKey(),s=0,n=null;for(;i!=null;){if(e.has(i.id))return!0;const a=this._getTile(i.id);if(a!=null&&a.isReady){for(const l of e){const o=this._getTile(l);o&&i.contains(o.key)&&(o.visible=!1)}return a.visible=!0,e.add(a.key.id),!0}a!=null&&a.hasData&&a.patchCount>s&&(s=a.patchCount,n=a),i=i.getParentKey()}return!!n&&(n.visible=!0,e.add(n.key.id),!0)}}const ke="esri.views.layers.FeatureLayerView",W=V.getLogger(ke),ai=r=>{let e=class extends r{constructor(...t){super(...t),this._updatingRequiredFieldsPromise=null,this.dataUpdating=!1,this.filter=null,this.timeExtent=null,this.layer=null,this.requiredFields=[],this.view=null}initialize(){this.addHandles([D(()=>{var i;const t=this.layer;return[(i=t==null?void 0:t.elevationInfo)==null?void 0:i.featureExpressionInfo,t&&"displayField"in t?t.displayField:null,t&&"timeInfo"in t&&t.timeInfo,t&&"renderer"in t&&t.renderer,t&&"labelingInfo"in t&&t.labelingInfo,t&&"floorInfo"in t&&t.floorInfo,this.filter,this.featureEffect,this.timeExtent]},()=>this._handleRequiredFieldsChange(),Ve),le(()=>{var t;return(t=this.view)==null?void 0:t.floors},"change",()=>this._handleRequiredFieldsChange()),le(()=>{const t=this.layer;return t&&"sublayers"in t?t.sublayers:null},"change",()=>this._handleRequiredFieldsChange())])}get availableFields(){const{layer:t,layer:{fieldsIndex:i},requiredFields:s}=this;return"outFields"in t&&t.outFields?ue(i,[...he(i,t.outFields),...s]):ue(i,s)}get featureEffect(){return this.layer&&"featureEffect"in this.layer?this.layer.featureEffect:null}set featureEffect(t){this._override("featureEffect",t)}get maximumNumberOfFeatures(){return 0}set maximumNumberOfFeatures(t){W.error("#maximumNumberOfFeatures=","Setting maximum number of features is not supported")}get maximumNumberOfFeaturesExceeded(){return!1}highlight(t){throw new Error("missing implementation")}createQuery(){const t={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference},i=this.filter!=null?this.filter.createQuery(t):new N(t);if(this.layer.type==="feature"){const s=ve(this);s!=null&&(i.where=i.where?`(${i.where}) AND (${s})`:s)}return this.timeExtent!=null&&(i.timeExtent=i.timeExtent!=null?i.timeExtent.intersection(this.timeExtent):this.timeExtent.clone()),i}createAggregateQuery(){const t={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return new N(t)}queryFeatures(t,i){throw new Error("missing implementation")}queryObjectIds(t,i){throw new Error("missing implementation")}queryFeatureCount(t,i){throw new Error("missing implementation")}queryExtent(t,i){throw new Error("missing implementation")}async fetchPopupFeatures(t,i){const s=this.validateFetchPopupFeatures(i);if(s)throw s;return this.fetchClientPopupFeatures(i)}_loadArcadeModules(t){var i;return(i=t.expressionInfos)!=null&&i.length||Array.isArray(t.content)&&t.content.some(s=>s.type==="expression")?Ke():Promise.resolve()}_handleRequiredFieldsChange(){const t=this._updateRequiredFields();this._set("_updatingRequiredFieldsPromise",t),t.then(()=>{this._updatingRequiredFieldsPromise===t&&this._set("_updatingRequiredFieldsPromise",null)})}async _updateRequiredFields(){if(!this.layer||!this.view)return;const t=this.view.type==="3d",{layer:i,layer:{fieldsIndex:s,objectIdField:n}}=this,a="renderer"in i&&i.renderer,l="orderBy"in i&&i.orderBy,o="featureReduction"in i?i.featureReduction:null,h=new Set,d=await Promise.allSettled([a?a.collectRequiredFields(h,s):null,de(h,i),t?Ye(h,i):null,this.filter!=null?ce(h,i,this.filter):null,this.featureEffect!=null?ce(h,i,this.featureEffect.filter):null,o?Ze(h,i,o):null,l?Xe(h,i,l):null]);if("timeInfo"in i&&i.timeInfo&&this.timeExtent&&J(h,i.fieldsIndex,[i.timeInfo.startField,i.timeInfo.endField]),i.type==="feature"&&(i.floorInfo&&J(h,i.fieldsIndex,[i.floorInfo.floorField]),t&&i.infoFor3D!=null&&(i.globalIdField==null&&W.error("globalIdField missing on 3DObjectFeatureLayer"),J(h,i.fieldsIndex,[i.globalIdField]))),i.type==="subtype-group"){G(h,s,i.subtypeField);const f=i.sublayers.map(y=>{var m;return Promise.all([(m=y.renderer)==null?void 0:m.collectRequiredFields(h,s),de(h,y)])});await Promise.allSettled(f)}for(const f of d)f.status==="rejected"&&W.error(f.reason);G(h,s,n),t&&"displayField"in i&&i.displayField&&G(h,s,i.displayField);const p=Array.from(h).sort();this._set("requiredFields",p)}validateFetchPopupFeatures(t){if(t==null)return null;for(const i of t.clientGraphics??[]){const s=i.layer;if("popupEnabled"in s&&!s.popupEnabled)return new q("featurelayerview:fetchPopupFeatures","Popups are disabled",{layer:s});if(i.isAggregate){const n="featureReduction"in s?s.featureReduction:null;if(!(n&&"popupTemplate"in n&&n.popupEnabled&&n.popupTemplate))return new q("featurelayerview:fetchPopupFeatures","Popups are disabled",{layer:s})}else if("popupTemplate"in s&&!Y(s,t))return new q("featurelayerview:fetchPopupFeatures","Layer does not define a popup template",{layer:s})}}async fetchClientPopupFeatures(t){const i=t!=null?t.clientGraphics:null;if(!i||i.length===0)return[];const s=new Array(i.length),n=new Map,a=await this.createPopupQuery(t);for(let l=0;l<i.length;l++){const o=i[l];if(o.isAggregate){s[l]=o;continue}const h=o.layer;if(!("popupEnabled"in h))continue;const d=he(this.layer.fieldsIndex,a.outFields),p=Y(h,t);if(p==null)continue;const f=await this._loadArcadeModules(p);f&&f.arcadeUtils.hasGeometryOperations(p)||!We(d,o)?n.set(o.getObjectId(),{graphic:o,index:l}):s[l]=o}if(this.layer.type==="stream"||n.size===0)return s.filter(Boolean);a.objectIds=Array.from(n.keys());try{const l=await this.layer.queryFeatures(a);for(const o of l.features){const{graphic:{geometry:h},index:d}=n.get(o.getObjectId());o.geometry||(o.geometry=h),s[d]=o}}catch{}return s.filter(Boolean)}async createPopupQuery(t){const i=this.layer.createQuery(),s=new Set;let n=!1;const a=t!=null&&t.clientGraphics?t.clientGraphics.map(l=>l.layer):[this.layer];for(const l of a){if(!("popupEnabled"in l))continue;const o=Y(l,t);if(o==null)continue;const h=await this._loadArcadeModules(o),d=h&&h.arcadeUtils.hasGeometryOperations(o);n=!(this.layer.geometryType!=="point"&&!d);const p=await Vt(this.layer,o);for(const f of p)s.add(f)}if(i.returnGeometry=n,i.returnZ=n,i.returnM=n,i.outFields=Array.from(s),i.outSpatialReference=this.view.spatialReference,this.layer.type==="feature"){const l=ve(this);l!=null&&(i.where=i.where?`(${i.where}) AND (${l})`:l)}return i}canResume(){return!!super.canResume()&&(this.timeExtent==null||!this.timeExtent.isEmpty)}};return u([c()],e.prototype,"_updatingRequiredFieldsPromise",void 0),u([c({readOnly:!0})],e.prototype,"availableFields",null),u([c({readOnly:!0})],e.prototype,"dataUpdating",void 0),u([c({type:je})],e.prototype,"featureEffect",null),u([c({type:Ie})],e.prototype,"filter",void 0),u([c(Qe)],e.prototype,"timeExtent",void 0),u([c()],e.prototype,"layer",void 0),u([c({type:Number})],e.prototype,"maximumNumberOfFeatures",null),u([c({readOnly:!0,type:Boolean})],e.prototype,"maximumNumberOfFeaturesExceeded",null),u([c({readOnly:!0})],e.prototype,"requiredFields",void 0),u([c()],e.prototype,"suspended",void 0),u([c()],e.prototype,"view",void 0),e=u([S(ke)],e),e};function Se(r){return r&&"openPorts"in r}function oi(r){for(const e of r){const t="featureReduction"in e&&e.featureReduction&&"labelingInfo"in e.featureReduction?e.featureReduction:void 0,i=[...e.labelingInfo||[],...(t==null?void 0:t.labelingInfo)||[]];if(!(!e.labelsVisible||!i.length)&&i.some(s=>s.deconflictionStrategy==="none"))return!0}return!1}function li(r){return e=>ft(Te(e,r))}function ui(r){const e=r!=null&&"visualVariables"in r&&r.visualVariables;if(!e)return null;for(const t of e)if(t.type==="size")return li(t);return null}const Ue="esri.views.2d.layers.FeatureLayerView2D";function hi(r){switch(r.geometryType){case"point":return"esriGeometryPoint";case"polyline":return"esriGeometryPolyline";case"polygon":case"multipatch":return"esriGeometryPolygon";case"multipoint":return"esriGeometryMultipoint";default:return V.getLogger(Ue).error(new q("unsupported-geometry-type",`Geometry type of ${r.geometryType} is not supported`)),null}}let v=class extends ai(qt(yt(gt))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new jt({process:r=>{switch(r.type){case"processed-edit":return this._doEdit(r);case"refresh":return this._doRefresh(r.dataChanged);case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._highlightIds=new Map,this._updateHighlight=et(async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys()))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.featureEffectView=new Tt,this._lastDefinitionExpression=null}destroy(){var r,e;(r=this._updateClusterSizeTask)==null||r.remove(),(e=this._proxy)==null||e.destroy(),this._commandsQueue.destroy()}initialize(){this.addResolvingPromise(Promise.all([this._initProxy(),this._initServiceOptions()])),this.addHandles([this.on("valueRangesChanged",r=>{this._set("_aggregateValueRanges",r.valueRanges)}),D(()=>this.featureEffect,r=>{this.featureEffectView.featureEffect=r},Ve)],"constructor"),this.featureEffectView.endTransitions()}async _initProxy(){var t;const r=this.layer;if("isTable"in r&&r.isTable)throw new q("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});if((r.type==="feature"||r.type==="subtype-group")&&!((t=j(r))!=null&&t.operations.supportsQuery))throw new q("featurelayerview:query-not-supported","layer view requires a layer with query capability",{layer:r});this._proxy&&this._proxy.destroy();const e=this._createClientOptions();return this._set("_proxy",new Kt({client:e})),this._proxy.when()}async _initServiceOptions(){return this._set("_serviceOptions",await this._createServiceOptions()),this._serviceOptions}get _effectiveFeatureReduction(){if(!("featureReduction"in this.layer))return null;const r=this.layer.featureReduction;return r&&(!("maxScale"in r)||!r.maxScale||r.maxScale<this.view.scale)?r:null}get orderByFields(){var r,e;return((r=this._serviceOptions)==null?void 0:r.type)!=="stream"?(e=this._serviceOptions)==null?void 0:e.orderByFields:void 0}get labelsVisible(){const r=this.layer.type==="subtype-group"?this.layer.sublayers.items:[this.layer];return!this.suspended&&r.some(e=>e.labelingInfo&&e.labelsVisible)}get labelingCollisionInfos(){const{tileRenderer:r,layer:e}=this;if(r==null)return null;const t=this.layer.type==="subtype-group"?this.layer.sublayers.items:[this.layer],i=e.geometryType,s=!oi(t),n={};if(e.type!=="subtype-group"){if((r==null?void 0:r.type)==="heatmap")return null;const a=ui(e.renderer);n[0]=a}return[{tileRenderer:r,vvEvaluators:n,deconflictionEnabled:s,geometryType:i,visible:!this.suspended}]}get queryMode(){var r;return(r=this._serviceOptions)==null?void 0:r.type}get renderingConfigHash(){var $,A;if(!this.layer)return null;const r=this.availableFields,e=this.layer,t=this.view.floors,{definitionExpression:i}=e,s=this.layer.type!=="subtype-group"&&this.layer.labelsVisible&&this.layer.labelingInfo,n="renderer"in e&&e.renderer,a="gdbVersion"in e?e.gdbVersion:void 0,l="historicMoment"in e?($=e.historicMoment)==null?void 0:$.getTime():void 0,{timeExtent:o}=this,h="customParameters"in e?JSON.stringify(e.customParameters):void 0,d="apiKey"in e?e.apiKey:void 0,p=e.type==="stream"?`${JSON.stringify(e.geometryDefinition)}${e.definitionExpression}`:null,f=JSON.stringify(this.clips),y=(A=this._effectiveFeatureReduction)==null?void 0:A.toJSON(),m="orderBy"in this.layer&&JSON.stringify(this.layer.orderBy),b="sublayers"in this.layer&&this.layer.sublayers.items.reduce((T,M)=>T+`${M.visible?1:0}.${JSON.stringify(M.renderer)}.${M.labelsVisible}
|
|
.${JSON.stringify(M.labelingInfo)}`,""),C="subtypeCode"in this.layer&&this.layer.subtypeCode;return JSON.stringify({orderBy:m,sublayerHash:b,subtypeCode:C,filterHash:this.filter!=null&&this.filter.toJSON(),effectHash:this.featureEffect!=null&&this.featureEffect.toJSON(),streamFilter:p,gdbVersion:a,definitionExpression:i,historicMoment:l,availableFields:r,renderer:n,labelingInfo:s,timeExtent:o,floors:t,clipsHash:f,featureReduction:y,customParameters:h,apiKey:d,timeZone:this.view.timeZone})}highlight(r){let e;r instanceof ee?e=[r.getObjectId()]:typeof r=="number"||typeof r=="string"?e=[r]:tt.isCollection(r)&&r.length>0?e=r.map(i=>i==null?void 0:i.getObjectId()).toArray():Array.isArray(r)&&r.length>0&&(e=typeof r[0]=="number"||typeof r[0]=="string"?r:r.map(i=>i==null?void 0:i.getObjectId()));const t=e==null?void 0:e.filter(it);return t!=null&&t.length?(this._addHighlight(t),fe(()=>this._removeHighlight(t))):fe()}hasHighlight(){return!!this._highlightIds.size}async hitTest(r,e){if(!this.tileRenderer)return null;const t=await this.tileRenderer.hitTest(e);if(t.length===0)return null;g("featurelayer-force-marker-text-draw-order")&&t.sort((n,a)=>n-a);const{features:i,aggregates:s}=await this._proxy.getFeatures(t);return[...s.map(n=>this._createGraphicHit(r,ae.fromJSON(n))),...i.map(n=>this._createGraphicHit(r,ee.fromJSON(n)))]}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.querySummaryStatistics(this._cleanUpQuery(r),i,t)}async queryAggregateSummaryStatistics(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryAggregateSummaryStatistics(this._cleanUpAggregateQuery(r),i,t)}async queryUniqueValues(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryUniqueValues(this._cleanUpQuery(r),i,t)}async queryAggregateUniqueValues(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryAggregateUniqueValues(this._cleanUpAggregateQuery(r),i,t)}async queryClassBreaks(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryClassBreaks(this._cleanUpQuery(r),i,t)}async queryAggregateClassBreaks(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryAggregateClassBreaks(this._cleanUpAggregateQuery(r),i,t)}async queryHistogram(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryHistogram(this._cleanUpQuery(r),i,t)}async queryAggregateHistogram(r,e,t){const i={...e,scale:this.view.scale};return this._proxy.queryAggregateHistogram(this._cleanUpAggregateQuery(r),i,t)}queryFeatures(r,e){return this.queryFeaturesJSON(r,e).then(t=>{const i=te.fromJSON(t);return i.features.forEach(s=>this._setLayersForFeature(s)),i})}queryVisibleFeatures(r,e){return this._proxy.queryVisibleFeatures(this._cleanUpQuery(r),e).then(t=>{const i=te.fromJSON(t);return i.features.forEach(s=>this._setLayersForFeature(s)),i})}async queryAggregates(r,e){const t=await this._proxy.queryAggregates(this._cleanUpAggregateQuery(r),e),i=kt.fromJSON(t);return i.features.forEach(s=>this._setLayersForFeature(s)),i}queryAggregateIds(r,e){return this._proxy.queryAggregateIds(this._cleanUpAggregateQuery(r),e)}queryAggregateCount(r,e){return this._proxy.queryAggregateCount(this._cleanUpAggregateQuery(r),e)}queryAggregateJSON(r,e){return this._proxy.queryAggregates(this._cleanUpAggregateQuery(r),e)}queryFeaturesJSON(r,e){return this._proxy.queryFeatures(this._cleanUpQuery(r),e)}queryObjectIds(r,e){return this._proxy.queryObjectIds(this._cleanUpQuery(r),e)}queryFeatureCount(r,e){return this._proxy.queryFeatureCount(this._cleanUpQuery(r),e)}queryExtent(r,e){return this._proxy.queryExtent(this._cleanUpQuery(r),e).then(t=>({count:t.count,extent:rt.fromJSON(t.extent)}))}setVisibility(r,e){e?this._visibilityOverrides.delete(r):this._visibilityOverrides.add(r),this._update()}update(r){if(!this._tileStrategy||!this.tileRenderer)return;const{hasMissingTiles:e,added:t,removed:i}=this._tileStrategy.update(r);(t.length||i.length)&&this._proxy.updateTiles({added:t,removed:i}),e&&this.requestUpdate(),this.notifyChange("updating")}attach(){this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._tileStrategy=new ni({acquireTile:r=>this._acquireTile(r),releaseTile:r=>this._releaseTile(r),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.addAttachHandles(D(()=>this.renderingConfigHash,()=>this._update(),st)),this.layer.type!=="stream"&&this.addAttachHandles(this.layer.on("edits",r=>this._edit(r)))}detach(){var r,e;this._commandsQueue.clear(),(r=this._proxy)==null||r.stop(),this.container.removeAllChildren(),(e=this.tileRenderer)==null||e.uninstall(this.container),this.tileRenderer=null,this._tileStrategy=L(this._tileStrategy),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}isUpdating(){var l;const r="renderer"in this.layer&&this.layer.renderer!=null,e=this._commandsQueue.updating,t=this._updatingRequiredFieldsPromise!=null,i=!this._proxy||!this._proxy.isReady,s=this._pipelineIsUpdating,n=this.tileRenderer==null||((l=this.tileRenderer)==null?void 0:l.updating),a=r&&(e||t||i||s||this.dataUpdating||n);return g("esri-2d-log-updating")&&console.log(`Updating FLV2D (${this.layer.id}): ${a}
|
|
-> hasRenderer ${r}
|
|
-> hasPendingCommand ${e}
|
|
-> updatingRequiredFields ${t}
|
|
-> updatingProxy ${i}
|
|
-> updatingPipeline ${s}
|
|
-> updatingData: ${this.dataUpdating}
|
|
-> updatingTileRenderer ${n}
|
|
`),a}_createClientOptions(){return{setUpdating:r=>{this._set("_pipelineIsUpdating",r)},setDataUpdating:r=>{this._set("dataUpdating",r)},emitEvent:r=>{this.emit(r.name,r.event)}}}async _detectQueryMode(r){var l;const e="path"in r,{layer:t}=this,i="editingInfo"in t&&((l=t.editingInfo)==null?void 0:l.lastEditDate),s="refreshInterval"in t&&!!t.refreshInterval,n=!i&&s,a=j(t);if(e&&(t.type==="feature"||t.type==="subtype-group")&&t.geometryType==="point"&&(a!=null&&a.query.supportsPagination)&&!(a!=null&&a.operations.supportsEditing)&&!n&&g("featurelayer-snapshot-enabled"))try{const o=await t.queryFeatureCount();if(o<=g("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:o};const h=g("featurelayer-snapshot-point-max-threshold"),d=g("featurelayer-snapshot-point-coverage"),p=this.view.extent,f=t.fullExtent,y=f==null?void 0:f.clone().intersection(p),m=y!=null?y.width*y.height:0,b=(f==null?void 0:f.width)*(f==null?void 0:f.height);if(o<=h&&(b===0?0:m/b)>=d)return{mode:"snapshot",featureCount:o}}catch(o){V.getLogger(this).warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:o})}return{mode:"on-demand"}}async _createServiceOptions(){var $,A;const r=this.layer;if(r.type==="stream")return null;const e=j(r),{capabilities:t,objectIdField:i}=r,s=r.fieldsIndex.toJSON(),n=s.fields,a=r.fullExtent!=null?r.fullExtent.toJSON():null,l=hi(r),o="timeInfo"in r&&(($=r.timeInfo)==null?void 0:$.toJSON())||null,h=r.spatialReference?r.spatialReference.toJSON():null,d=r.type==="feature"?r.globalIdField:null;let p;r.type==="ogc-feature"?p=r.source.getSource():Se(r.source)?p=await r.source.openPorts():r.parsedUrl&&(p=nt(r.parsedUrl),"dynamicDataSource"in r&&r.dynamicDataSource&&(p.query={layer:JSON.stringify({source:r.dynamicDataSource})}));const f="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,y=("subtypeField"in this.layer?this.layer.subtypeField:null)??null,{mode:m,featureCount:b}=await this._detectQueryMode(p);let C=this.layer.objectIdField;if(this.layer.type==="feature"&&this.layer.orderBy!=null&&this.layer.orderBy.length){const T=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;T&&(C=T)}return{type:m,typeIdField:"typeIdField"in r&&r.typeIdField||void 0,types:"types"in r&&((A=r.types)==null?void 0:A.map(T=>T.toJSON()))||void 0,timeReferenceUnknownClient:f,subtypeField:y,featureCount:b,globalIdField:d,maxRecordCount:t.query.maxRecordCount,tileMaxRecordCount:t.query.tileMaxRecordCount,capabilities:t,effectiveCapabilities:e,fields:n,fieldsIndex:s,fullExtent:a,geometryType:l,objectIdField:i,source:p,timeInfo:o,spatialReference:h,orderByFields:C}}async _createMemoryServiceOptions(r){const e=await r.openPorts();return{...this._createServiceOptions(),type:"memory",source:e}}_cleanUpQuery(r){const e=N.from(r)||this.createQuery();return e.outSpatialReference||(e.outSpatialReference=this.view.spatialReference),e}_cleanUpAggregateQuery(r){const e=N.from(r)||this.createAggregateQuery();return e.outSpatialReference||(e.outSpatialReference=this.view.spatialReference),e}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(r){return this.suspended?void this._clearTiles():this._validateEdit(r)?this._commandsQueue.push({type:"edit",edits:r}):void 0}async doRefresh(r){if(this.attached&&this._tileStrategy.tileKeys().length)return this.suspended&&r?void this._clearTiles():this._commandsQueue.push({type:"refresh",dataChanged:r})}_clearTiles(){this._tileStrategy.tileKeys().length&&(this._proxy.updateTiles({added:[],removed:this._tileStrategy.tileKeys()}),this._tileStrategy.clear(),this.requestUpdate(),this._commandsQueue.clear(),this._update())}_validateEdit(r){const e="globalIdField"in this.layer&&this.layer.globalIdField,t=r.deletedFeatures.some(s=>s.objectId===-1||!s.objectId),i=e&&this.availableFields.includes(e);return t&&!i?(V.getLogger(this).error(new q("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${e} to be included the layer's outFields for updates to be reflected on the map`)),null):r}async _doUpdate(){var r,e;try{if(this.destroyed||!this._hasRequiredSupport(this.layer)||!this._tileStrategy)return;const{featureEffectView:t,filter:i}=this;if(await this._updateRequiredFields(),this.destroyed)return;const{renderer:s}=this._getEffectiveRenderer();this._set("_effectiveRenderer",s);const n=this._createSchemaConfig(),a=this._createConfiguration(n,i,t.filter),l=this._lastDefinitionExpression!==a.schema.source.definitionExpression;this._lastDefinitionExpression=a.schema.source.definitionExpression;const o=a.schema.tileRenderer,h=this._createTileRendererHash(o);if(this._serviceOptions.type==="snapshot"&&(a.schema.source.initialFeatureCount=this._serviceOptions.featureCount),h!==this._tileRendererHash){this._initTileRenderer(o,s);const d=this.layer,p=d.type==="stream"?await this._initServiceOptions():this._serviceOptions;this.tileRenderer.onConfigUpdate(s),d.type!=="stream"&&Se(d.source)&&(p.source=await d.source.openPorts());const f={added:this._tileStrategy.tileKeys(),removed:[]};g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Proxy startup"),await this._proxy.startup(this.view.featuresTilingScheme,a,p,f),g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Finished proxy startup"),this.hasHighlight()&&(g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Updating highlight"),await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Finished highlight update")),g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: onConfigUpdate start"),this.tileRenderer.onConfigUpdate(s),g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: onConfigUpdate end")}else{this._serviceOptions.type==="snapshot"&&l&&(a.schema.source.changedFeatureCount=await this.layer.queryFeatureCount()),g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Updating proxy");const d=await this._proxy.update(a);g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Finished proxy update"),(d.mesh||(r=d.targets)!=null&&r.aggregate)&&(g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Locking GPU Uploads"),this._lockGPUUploads());try{g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Applying update to proxy"),await this._proxy.applyUpdate(d),g("esri-2d-update-debug")&&console.debug("FeatureLayerView2D: Finished applying update to proxy")}catch(p){k(p)||V.getLogger(this).error(p)}(d.mesh||(e=d.targets)!=null&&e.aggregate)&&this._unlockGPUUploads(),this.tileRenderer.onConfigUpdate(s),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=h,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch{}}async _doEdit(r){try{await this._proxy.onEdits(r)}catch(e){k(e)}}async _doRefresh(r){this._lockGPUUploads();try{let e;r&&this.queryMode==="snapshot"&&"queryFeatureCount"in this.layer&&(e=await this.layer.queryFeatureCount()),await this._proxy.refresh({dataChanged:r,featureCount:e})}catch(e){k(e)}this._unlockGPUUploads(),this._effectiveFeatureReduction&&this._updateClusterSizeVariable()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(r,e){return D(()=>this._aggregateValueRanges,t=>{this._updateClusterEffectiveRendererSizeVariable(r,e,t),this._needsClusterSizeUpdate=!0,this._uploadsLocked||this._updateClusterSizeVariable()})}async _updateClusterEffectiveRendererSizeVariable(r,e,t){if(r.dynamicClusterSize&&"visualVariables"in r&&r.visualVariables){const i=at(r.visualVariables);if(i!=null&&i.field==="cluster_count"){const s=r.visualVariables.indexOf(i);r.visualVariables[s]=ot(e,t);const n=r.clone();n.dynamicClusterSize=!0,this._set("_effectiveRenderer",n)}}}_getEffectiveRenderer(){var i;const r=this.layer,e="renderer"in r?r.renderer:null,t=this._effectiveFeatureReduction;if(this._updateClusterSizeTask=lt(this._updateClusterSizeTask),t&&"renderer"in t&&t.renderer&&!((i=t.renderer.authoringInfo)!=null&&i.isAutoGenerated)){const s=t.fields;if(t.type==="cluster"){const{renderer:n,didInject:a}=ut(t.renderer,t,this._aggregateValueRanges);return a&&(this._updateClusterSizeTask=this._createUpdateClusterSizeTask(n,t)),{renderer:n,aggregateFields:s,featureReduction:t}}return{renderer:t.renderer,aggregateFields:s,featureReduction:t}}if(t&&t.type==="cluster"&&e&&ht(e)){const s=t,n=[],a=dt(n,e,s,this._aggregateValueRanges,!0);return this._updateClusterSizeTask=this._createUpdateClusterSizeTask(a,s),{renderer:a,aggregateFields:n,featureReduction:t}}return{renderer:e,aggregateFields:[],featureReduction:null}}_acquireTile(r){const e=this.tileRenderer.acquireTile(r);return e.once("attach",()=>{this.requestUpdate()}),e}_releaseTile(r){this.tileRenderer.releaseTile(r)}_initTileRenderer(r,e){const t=Gt(r,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer=L(this.tileRenderer)),this.destroyed?null:(this._proxy.tileRenderer=t,this._set("tileRenderer",t),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(e),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(r){return`${r.type}`}get hasFilter(){const r=!!("floorInfo"in this.layer&&this.layer.floorInfo&&this.view.floors&&this.view.floors.length);return!!this.filter||r||!!this._visibilityOverrides.size||!!this.timeExtent}_injectOverrides(r){const e=r!=null?r.timeExtent:null,t=this.timeExtent!=null&&e!=null?this.timeExtent.intersection(e):this.timeExtent||e;let i=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const a=r!=null?r.where:null;i=this._addFloorFilterClause(a)}if(!this._visibilityOverrides.size&&!t&&!s)return r!=null?r.toJSON():null;(r=r!=null&&r.clone()||new Ie).timeExtent=t,i&&(r.where=i);const n=r.toJSON();return n.hiddenIds=Array.from(this._visibilityOverrides),n}_addFloorFilterClause(r){var i;const e=this.layer;let t=r||"";if("floorInfo"in e&&e.floorInfo){let s=this.view.floors;if(!(s!=null&&s.length))return t;(i=e.floorInfo.viewAllLevelIds)!=null&&i.length&&(s=e.floorInfo.viewAllLevelIds);const n=s.filter(o=>o!=="").map(o=>"'"+o+"'");n.push("''");const a=e.floorInfo.floorField;let l="("+a+" IN ({ids}) OR "+a+" IS NULL)";if(l=l.replace("{ids}",n.join(", ")),t!=null&&t.includes(a)){let o=new RegExp("AND \\("+a+".*NULL\\)","g");t=t.replace(o,""),o=new RegExp("\\("+a+".*NULL\\)","g"),t=t.replace(o,""),t=t.replaceAll(/\s+/g," ").trim()}t=t!==""?"("+t+") AND "+l:l}return t!==""?t:null}_createConfiguration(r,e,t){const i=this.layer.type==="feature"&&this.layer.historicMoment?this.layer.historicMoment.getTime():void 0,s=this.layer.type==="feature"?this.layer.gdbVersion??void 0:void 0,n=new Array(pt),a=this._injectOverrides(e);n[0]=a,n[1]=t!=null?t.toJSON():null;const l=wt(r);if(l==null)return null;const o=ct("2d");return{availableFields:this.availableFields,gdbVersion:s,historicMoment:i,devicePixelRatio:window.devicePixelRatio||1,filters:n,schema:l,supportsTextureFloat:o.supportsTextureFloat,maxTextureSize:o.maxTextureSize,timeZone:this.view.timeZone}}_hasRequiredSupport(r){return!("renderer"in r)||xt(r.renderer)}_lockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!0,this.tileRenderer.lockGPUUploads())}_unlockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!1,this.tileRenderer.unlockGPUUploads())}_forceAttributeTextureUpload(){this.tileRenderer&&this.tileRenderer.forceAttributeTextureUpload()}_createSchemaConfig(){const r=this.layer;return{renderer:"renderer"in r?r.renderer:null,spatialReference:r.spatialReference,timeExtent:"timeExtent"in r?r.timeExtent:null,definitionExpression:r.definitionExpression,featureReduction:this._effectiveFeatureReduction,fields:r.fields,geometryType:r.geometryType,historicMoment:"historicMoment"in r?r.historicMoment:null,labelsVisible:"labelsVisible"in r&&r.labelsVisible,labelingInfo:"labelingInfo"in r?r.labelingInfo:null,availableFields:this.availableFields,featureEffect:this.featureEffect,filter:this.filter,gdbVersion:"gdbVersion"in r?r.gdbVersion:null,pixelBuffer:0,orderBy:"orderBy"in r&&r.orderBy?r.orderBy:null,customParameters:{..."customParameters"in r?r.customParameters:void 0,token:"apiKey"in r?r.apiKey??void 0:void 0},subtypeCode:"subtypeCode"in r?r.subtypeCode:void 0,subtypeField:"subtypeField"in r?r.subtypeField:void 0}}_addHighlight(r){for(const e of r)if(this._highlightIds.has(e)){const t=this._highlightIds.get(e);this._highlightIds.set(e,t+1)}else this._highlightIds.set(e,1);this._updateHighlight().catch(e=>{k(e)||V.getLogger(this).error(e)})}_removeHighlight(r){for(const e of r)if(this._highlightIds.has(e)){const t=this._highlightIds.get(e)-1;t===0?this._highlightIds.delete(e):this._highlightIds.set(e,t)}this._updateHighlight().catch(e=>{k(e)||V.getLogger(this).error(e)})}_setLayersForFeature(r){const e=this.layer;r.layer=e,r.sourceLayer=e}_createGraphicHit(r,e){return this._setLayersForFeature(e),e.geometry!=null&&(e.geometry.spatialReference=this.view.spatialReference),{type:"graphic",graphic:e,layer:this.layer,mapPoint:r}}};u([c()],v.prototype,"_serviceOptions",void 0),u([c()],v.prototype,"_proxy",void 0),u([c()],v.prototype,"_pipelineIsUpdating",void 0),u([c()],v.prototype,"_effectiveRenderer",void 0),u([c()],v.prototype,"_effectiveFeatureReduction",null),u([c()],v.prototype,"_aggregateValueRanges",void 0),u([c()],v.prototype,"_commandsQueue",void 0),u([c()],v.prototype,"featureEffectView",void 0),u([c()],v.prototype,"labelsVisible",null),u([c()],v.prototype,"labelingCollisionInfos",null),u([c({readOnly:!0})],v.prototype,"queryMode",null),u([c()],v.prototype,"renderingConfigHash",null),u([c()],v.prototype,"tileRenderer",void 0),u([c()],v.prototype,"updating",void 0),v=u([S(Ue)],v);const hr=v;export{hr as default};
|