1"use strict";(self.webpackChunkbirn_project=self.webpackChunkbirn_project||[]).push([[6407],{64288:(et,pe,T)=>{T.d(pe,{mR:()=>qe,C$:()=>dt,e2:()=>gt,Jq:()=>Wt,wO:()=>st,Mk:()=>We,cM:()=>Zt,Z_:()=>ot,ws:()=>Et,xV:()=>Lt,Ub:()=>qt,UK:()=>it,Yw:()=>Ut,$_:()=>rt,Gr:()=>Qe,nU:()=>Rt,Ll:()=>at,$K:()=>ft,DQ:()=>Dt,HX:()=>yt,yP:()=>Qt,hj:()=>pt,iw:()=>mt,TB:()=>Kt,sG:()=>Se,Gg:()=>Jt,js:()=>Pt,Y8:()=>ze});var A=T(26584),Q=T(63290),G=(T(21286),T(7547)),U=(T(81295),T(39406)),q=T(27899);class xe{constructor(){this.color=[0,0,0,0],this.haloColor=[0,0,0,0],this.haloSize=0,this.size=12,this.angle=0,this.offsetX=0,this.offsetY=0,this.hAnchor=0,this.vAnchor=0}acquire(k,W,$,me,le,Ee,Vt,Fe,Oe){this.color=k,this.haloColor=W,this.haloSize=$,this.size=me,this.angle=le,this.offsetX=Ee,this.offsetY=Vt,this.hAnchor=Fe,this.vAnchor=Oe}release(){this.color[0]=this.color[1]=this.color[2]=this.color[3]=0,this.haloColor[0]=this.haloColor[1]=this.haloColor[2]=this.haloColor[3]=0,this.haloSize=0,this.size=0,this.angle=0,this.offsetX=0,this.offsetY=0,this.hAnchor=0,this.vAnchor=0}}xe.pool=new q.Z(xe);var C=T(67969),Ge=(T(55086),T(40852));const N=Q.Z.getLogger("esri.views.2d.engine.webgl.Utils"),b="geometry",tt=[{name:b,strideInBytes:12}],z=[{name:b,strideInBytes:36}],ve=[{name:b,strideInBytes:24}],Ae=[{name:b,strideInBytes:12}],K=[{name:b,strideInBytes:40}],Me=[{name:b,strideInBytes:36}],bt=[{name:b,strideInBytes:36}];function Ce(S){const k={};for(const W of S)k[W.name]=W.strideInBytes;return k}const ct=Ce([{name:b,strideInBytes:36}]),ke=Ce(tt),ye=Ce(z),xt=Ce(ve),Be=Ce(Ae),_e=Ce(K),ht=Ce(Me),lt=Ce(bt);function rt(S,k){switch(S){case U.LW.MARKER:return k===U.mD.HEATMAP?ke:ct;case U.LW.FILL:switch(k){case U.mD.DOT_DENSITY:return Be;case U.mD.SIMPLE:case U.mD.OUTLINE_FILL_SIMPLE:return xt;default:return ye}case U.LW.LINE:return _e;case U.LW.TEXT:return ht;case U.LW.LABEL:return lt}}const Ct=[b],Ft=[b],Tt=[b],wt=[b],At=[b];function Mt(S){switch(S){case U.LW.MARKER:return Ct;case U.LW.FILL:return Ft;case U.LW.LINE:return Tt;case U.LW.TEXT:return wt;case U.LW.LABEL:return At}}function ze(S){switch(S%4){case 0:case 2:return 4;case 1:case 3:return 1}}function dt(S,k){switch(k%4){case 0:case 2:return new Uint32Array(Math.floor(S*k/4));case 1:case 3:return new Uint8Array(S*k)}}function gt(S,k){switch(k%4){case 0:case 2:return new Uint32Array(S);case 1:case 3:return new Uint8Array(S)}}function ft(S){return null!=S}function pt(S){return"number"==typeof S}function Et(S){switch(S){case"butt":return G.RL.BUTT;case"round":return G.RL.ROUND;case"square":return G.RL.SQUARE;default:return N.error(new A.Z("mapview-invalid-type",`Cap type ${S} is not a valid option. Defaulting to round`)),G.RL.ROUND}}function Lt(S){switch(S){case"miter":return G.AH.MITER;case"bevel":return G.AH.BEVEL;case"round":return G.AH.ROUND;default:return N.error(new A.Z("mapview-invalid-type",`Join type ${S} is not a valid option. Defaulting to round`)),G.AH.ROUND}}function Rt(S){switch(S){case"opacity":return U.pc.OPACITY;case"color":return U.pc.COLOR;case"rotation":return U.pc.ROTATION;case"size":return U.pc.SIZE;default:return N.error(`Cannot interpret unknown vv: ${S}`),null}}function st(S,k,W,$,me,le,Ee){for(const Fe in le){const Oe=le[Fe].stride,Nt=ze(Oe),Te=le[Fe].data,Ve=W[Fe].data,He=Oe*me.vertexCount/Nt,tr=Oe*S/Nt,Le=Oe*me.vertexFrom/Nt;for(let Ie=0;Ie<He;++Ie)Ve[Ie+tr]=Te[Ie+Le]}const Vt=me.indexCount;for(let Fe=0;Fe<Vt;++Fe)$[Fe+k]=Ee[Fe+me.indexFrom]-me.vertexFrom+S}const qe={[b]:C.l1.STATIC_DRAW};function We(S,k){const W=[];for(let $=0;$<5;++$){const me=Mt($),le={};for(const Ee of me)le[Ee]={data:k($,Ee)};W.push({data:S($),buffers:le})}return W}function Bt(S){switch(S){case C.g.BYTE:case C.g.UNSIGNED_BYTE:return 1;case C.g.SHORT:case C.g.UNSIGNED_SHORT:return 2;case C.g.FLOAT:case C.g.INT:case C.g.UNSIGNED_INT:return 4}}function Ut(S){switch(S){case C.Br.UNSIGNED_BYTE:return 1;case C.Br.UNSIGNED_SHORT_4_4_4_4:return 2;case C.Br.FLOAT:return 4;default:return void N.error(new A.Z("webgl-utils",`Unable to handle type ${S}`))}}function it(S){switch(S){case C.Br.UNSIGNED_BYTE:return Uint8Array;case C.Br.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case C.Br.FLOAT:return Float32Array;default:return void N.error(new A.Z("webgl-utils",`Unable to handle type ${S}`))}}const zt=S=>{const k=new Map;for(const W in S)for(const $ of S[W])k.set($.name,$.location);return k},jt=S=>{const k={};for(const W in S){const $=S[W];k[W]=$.length?$[0].stride:0}return k},nt=new Map,Zt=(S,k)=>{if(!nt.has(S)){const W=function Ot(S){const k={};for(const W in S){let me=0;k[W]=S[W].map(le=>{const Ee=new Ge.G(le.name,le.count,le.type,me,0,le.normalized||!1);return me+=le.count*Bt(le.type),Ee}),k[W].forEach(le=>le.stride=me)}return k}(k),$={strides:jt(W),bufferLayouts:W,attributes:zt(k)};nt.set(S,$)}return nt.get(S)};function ot(S){S(U.LW.FILL),S(U.LW.LINE),S(U.LW.MARKER),S(U.LW.TEXT),S(U.LW.LABEL)}const Se=S=>"path"in S&&er(S.path),yt=S=>"url"in S&&S.url||"imageData"in S&&S.imageData,Qe=S=>"imageData"in S&&S.imageData&&"contentType"in S&&S.contentType?`data:${S.contentType};base64,${S.imageData}`:"url"in S?S.url:null,ie=S=>S.startsWith("data:image/gif"),Dt=S=>"url"in S&&S.url&&(S.url.includes(".gif")||ie(S.url))||"contentType"in S&&"image/gif"===S.contentType||"imageData"in S&&ie(S.imageData),_t=S=>S.startsWith("data:image/png"),mt=S=>"url"in S&&S.url&&(S.url.includes(".png")||_t(S.url))||"contentType"in S&&"image/png"===S.contentType||"imageData"in S&&_t(S.imageData),at=S=>S.type&&S.type.toLowerCase().includes("3d");function Jt(S){switch(S.type){case"line":{const k=S;return"CIMSolidStroke"===k.cim.type&&!k.dashTemplate}case"fill":return"CIMSolidFill"===S.cim.type;case"esriSFS":return"esriSFSSolid"===S.style||"esriSFSNull"===S.style;case"esriSLS":return"esriSLSSolid"===S.style||"esriSLSNull"===S.style;default:return!1}}const Kt=S=>S.includes("data:image/svg+xml");function Pt(S){switch("cim"in S?S.cim.type:S.type){case"esriSMS":case"esriPMS":case"CIMPointSymbol":return!1;case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":return Qt(S);default:return!0}}function qt(S){return"maxVVSize"in S&&S.maxVVSize||"width"in S&&S.width||"size"in S&&S.size||0}function Wt(S){const k=[];for(let W=0;W<S.length;W++)k.push(S.charCodeAt(W));return k}const er=S=>!!S&&(S=S.trim(),!!(/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(S)&&/[\dz]$/i.test(S)&&S.length>4)),Qt=S=>"fill"===S.type&&"CIMMarkerPlacementInsidePolygon"===S?.cim?.markerPlacement?.type},81295:(et,pe,T)=>{T.d(pe,{Vs:()=>Ge,aH:()=>Ne,pr:()=>U,t2:()=>C});var A=T(62208),Q=T(5254);function U(N,b=0,D=!1){const X=N[b+3];return N[b+0]*=X,N[b+1]*=X,N[b+2]*=X,D||(N[b+3]*=255),N}function C(N){if(!N)return 0;const{r:b,g:D,b:X,a:fe}=N;return(0,Q.Jz)(b*fe,D*fe,X*fe,255*fe)}function Ne(N){if(!N)return 0;const[b,D,X,fe]=N;return(0,Q.Jz)(b*(fe/255),D*(fe/255),X*(fe/255),fe)}function Ge(N,b,D=0){if((0,A.Wi)(b))return N[D+0]=0,N[D+1]=0,N[D+2]=0,void(N[D+3]=0);const{r:X,g:fe,b:tt,a:z}=b;N[D+0]=X*z/255,N[D+1]=fe*z/255,N[D+2]=tt*z/255,N[D+3]=z}},39351:(et,pe,T)=>{T.d(pe,{$0:()=>Ge,AI:()=>te,Al:()=>ke,By:()=>lt,C1:()=>Zt,CQ:()=>Se,CU:()=>kt,D3:()=>ct,Ex:()=>K,I_:()=>U,Ic:()=>ye,Ij:()=>_e,Ip:()=>Ot,Iv:()=>Dt,Iw:()=>Me,Jw:()=>Tt,MI:()=>nt,QU:()=>Ft,SD:()=>mt,Tz:()=>yt,Uh:()=>ot,V4:()=>We,XJ:()=>it,Xj:()=>Ct,Zd:()=>Lt,_5:()=>Mt,_6:()=>_t,a:()=>Gt,aK:()=>gt,dn:()=>qe,e0:()=>ie,eF:()=>bt,eV:()=>N,f2:()=>ht,fL:()=>Ut,iJ:()=>xt,iV:()=>Rt,jk:()=>at,kF:()=>wt,lK:()=>ft,m4:()=>pt,mx:()=>rt,nM:()=>Be,oK:()=>Qe,pU:()=>dt,ru:()=>se,tQ:()=>st,uG:()=>Et,xl:()=>ze,xm:()=>b,yP:()=>At});const te=1e-30,se=4294967295,U=512,Ge=8,N=10,b=29,K=24,Me=8,bt={metrics:{width:15,height:17,left
1:0,top:-7,advance:14}},ct=0,ke=0,ye=0,xt=1,Be=2,_e=3,ht=4,lt=5,rt=6,Ct=12,Ft=5,Tt=6,wt=5,At=6,Mt=0,ze=1,dt=2,gt=3,ft=4,pt=2,Et=1,Lt=2,Rt=4,st=1.05,qe=3,We=5,kt=6,Gt=1.15,Ut=2,it=8,Ot=500,nt=10,Zt=1024,ot=2,Se=0,yt=1,Qe=4,ie=8,Dt=16,_t=4,mt=1,at=4},39406:(et,pe,T)=>{var A,Q,te,G,se,U,q,xe,C;T.d(pe,{LW:()=>A,Un:()=>q,X:()=>se,jx:()=>te,mD:()=>xe,mf:()=>U,pc:()=>G}),(C=A||(A={}))[C.FILL=0]="FILL",C[C.LINE=1]="LINE",C[C.MARKER=2]="MARKER",C[C.TEXT=3]="TEXT",C[C.LABEL=4]="LABEL",function(C){C[C.SUCCEEDED=0]="SUCCEEDED",C[C.FAILED_OUT_OF_MEMORY=1]="FAILED_OUT_OF_MEMORY"}(Q||(Q={})),function(C){C[C.NONE=0]="NONE",C[C.MAP=1]="MAP",C[C.LABEL=2]="LABEL",C[C.LABEL_ALPHA=4]="LABEL_ALPHA",C[C.HITTEST=8]="HITTEST",C[C.HIGHLIGHT=16]="HIGHLIGHT",C[C.CLIP=32]="CLIP",C[C.DEBUG=64]="DEBUG",C[C.NUM_DRAW_PHASES=9]="NUM_DRAW_PHASES"}(te||(te={})),function(C){C[C.SIZE=0]="SIZE",C[C.COLOR=1]="COLOR",C[C.OPACITY=2]="OPACITY",C[C.ROTATION=3]="ROTATION"}(G||(G={})),function(C){C[C.NONE=0]="NONE",C[C.OPACITY=1]="OPACITY",C[C.COLOR=2]="COLOR",C[C.ROTATION=4]="ROTATION",C[C.SIZE_MINMAX_VALUE=8]="SIZE_MINMAX_VALUE",C[C.SIZE_SCALE_STOPS=16]="SIZE_SCALE_STOPS",C[C.SIZE_FIELD_STOPS=32]="SIZE_FIELD_STOPS",C[C.SIZE_UNIT_VALUE=64]="SIZE_UNIT_VALUE"}(se||(se={})),function(C){C[C.MINMAX_TARGETS_OUTLINE=128]="MINMAX_TARGETS_OUTLINE",C[C.SCALE_TARGETS_OUTLINE=256]="SCALE_TARGETS_OUTLINE",C[C.FIELD_TARGETS_OUTLINE=512]="FIELD_TARGETS_OUTLINE",C[C.UNIT_TARGETS_OUTLINE=1024]="UNIT_TARGETS_OUTLINE"}(U||(U={})),function(C){C[C.SPRITE=0]="SPRITE",C[C.GLYPH=1]="GLYPH"}(q||(q={})),function(C){C[C.DEFAULT=0]="DEFAULT",C[C.SIMPLE=1]="SIMPLE",C[C.DOT_DENSITY=2]="DOT_DENSITY",C[C.OUTLINE_FILL=3]="OUTLINE_FILL",C[C.OUTLINE_FILL_SIMPLE=4]="OUTLINE_FILL_SIMPLE",C[C.HEATMAP=5]="HEATMAP",C[C.PIE_CHART=6]="PIE_CHART"}(xe||(xe={}))},5254:(et,pe,T)=>{T.d(pe,{Au:()=>N,Jz:()=>X,UJ:()=>D});const A=new Float32Array(1);function N(z){return[255&z,(65280&z)>>>8,(16711680&z)>>>16,(4278190080&z)>>>24]}function D(z,ve){return 65535&z|ve<<16}function X(z,ve,Ae,K){return 255&z|(255&ve)<<8|(255&Ae)<<16|K<<24}new Uint32Array(A.buffer)},25310:(et,pe,T)=>{T.d(pe,{a:()=>U});var A=T(26584),Q=T(63290),te=T(39406),G=T(64288);const se=Q.Z.getLogger("esri.views.2d.engine.webgl");function U(q){return(0,G.hj)(q.minDataValue)&&(0,G.hj)(q.maxDataValue)&&null!=q.minSize&&null!=q.maxSize?te.X.SIZE_MINMAX_VALUE:(q.expression&&"view.scale"===q.expression||q.valueExpression&&"$view.scale"===q.valueExpression)&&Array.isArray(q.stops)?te.X.SIZE_SCALE_STOPS:(null!=q.field||q.expression&&"view.scale"!==q.expression||q.valueExpression&&"$view.scale"!==q.valueExpression)&&(Array.isArray(q.stops)||"levels"in q&&q.levels)?te.X.SIZE_FIELD_STOPS:(null!=q.field||q.expression&&"view.scale"!==q.expression||q.valueExpression&&"$view.scale"!==q.valueExpression)&&null!=q.valueUnit?te.X.SIZE_UNIT_VALUE:(se.error(new A.Z("mapview-bad-type","Found invalid size VisualVariable",q)),te.X.NONE)}},68402:(et,pe,T)=>{T.r(pe),T.d(pe,{default:()=>vs});var A=T(15861),Q=T(17626),te=T(80542),G=T(8314),se=T(32917),U=T(77712),C=(T(85931),T(90912),T(76898)),Ne=T(37053),Ge=T(2584),b=T(62208),D=T(10699),X=T(82054),fe=T(58175),tt=T(60466),z=T(55746),ve=T(38305),Ae=T(84792),K=T(26584),Me=T(63290),bt=T(93662),Ce=T(7848),ct=T(89628),ke=T(20477),ye=T(64822),xt=T(24192),Be=T(66385),_e=T(88071),ht=T(25208),lt=T(71260);const rt=268435455;class Ct{constructor(){this.fieldMap=new Map,this.fields=[],this.hasFeatures=!1,this.fieldCount=0,this.featureCount=0,this.objectIdFieldIndex=0,this.vertexCount=0,this.offsets={attributes:new Array,geometry:new Array},this.centroid=new Array}hasField(e){return this.fieldMap.has(e)}isDateField(e){return this.fieldMap.get(e)?.isDate}getFieldIndex(e){return this.fieldMap.get(e)?.index}}function Ft(o){const s=o.getLength(),a=o.pos()+s,u={name:"",isDate:!1};for(;o.pos()<a&&o.next();)switch(o.tag()){case 1:u.name=o.getString();break;case 2:"esriFieldTypeDate"===(0,lt.O7)(o.getEnum())&&(u.isDate=!0);break;default:o.skip()}return u}function Tt(o){return o.toLowerCase().trim()}const At=Me.Z.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF"),ze=268435455,je={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(128e3),decoded:new Int32Array(128e3)}};function ft(o){return o<=je.small.delta.length?je.small:(o<=je.large.delta.length||(je.large.delta=new Int32Array(Math.round(1.25*o)),je.large.decoded=new Int32Array(Math.round(1.25*o))),je.large)}function pt(o){return o.toLowerCase().trim()}function Lt(o){for(;o.next();){if(1===o.tag())return o.getMessage();o.skip()}return null}
1function $t(o,e,t,s,a,u){return.5*Math.abs(o*s+t*u+a*e-o*u-t*e-a*s)}function st(o,e,t,s){return o*s-t*e==0&&o*t+e*s>0}class qe extends ht.s{constructor(e,t,s,a){super(e,a),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0,centroid:void 0,legacyFeature:void 0,optFeature:void 0},this._geometryType=a.geometryType,this._reader=t,this._header=s,this._hasNext=s.hasFeatures,this._isPoints="esriGeometryPoint"===a.geometryType}static fromBuffer(e,t,s=!1){const a=t.geometryType,u=function Et(o){try{const t=new xt.Z(new Uint8Array(o),new DataView(o));for(;t.next();){if(2===t.tag())return Lt(t.getMessage());t.skip()}}catch(e){const t=new K.Z("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:e});At.error(t)}return null}(e),c=function wt(o,e,t=!1){const _=o.pos(),m=new Ct;let x=0,w=0,L=null,P=null,O=null,B=!1;for(;o.next();)switch(o.tag()){case 1:L=o.getString();break;case 3:P=o.getString();break;case 12:O=o.processMessage(lt.G$);break;case 9:if(m.exceededTransferLimit=o.getBool(),m.exceededTransferLimit){m.offsets.geometry=t?new Float64Array(8e3):new Int32Array(8e3),m.centroid=t?new Float64Array(16e3):new Int32Array(16e3);for(let R=0;R<m.centroid.length;R++)m.centroid[R]=rt}break;case 13:{const R=Ft(o),H=R.name,re=Tt(R.name),V={fieldName:H,index:x++,isDate:R.isDate};m.fields.push(V),m.fieldMap.set(R.name,V),m.fieldMap.set(re,V);break}case 15:{const R=o.getLength(),H=o.pos()+R;if(!m.exceededTransferLimit){const J=m.centroid;m.offsets.geometry.push(0),J.push(rt),J.push(rt)}!B&&m.exceededTransferLimit&&(B=!0,m.offsets.attributes=t?new Float64Array(8e3*x):new Uint32Array(8e3*x));let re=w*x;for(;o.pos()<H&&o.next();)switch(o.tag()){case 1:{B?m.offsets.attributes[re++]=o.pos():m.offsets.attributes.push(o.pos());const V=o.getLength();o.skipLen(V);break}case 2:if(e){const V=o.getLength(),J=o.pos()+V;for(;o.pos()<J&&o.next();)switch(o.tag()){case 3:{o.getUInt32();const Y=o.getSInt64(),de=o.getSInt64();m.centroid[2*w]=Y,m.centroid[2*w+1]=de;break}default:o.skip()}}else{m.offsets.geometry[w]=o.pos();const V=o.getLength();m.vertexCount+=V,o.skipLen(V)}break;case 4:{const V=o.getLength(),J=o.pos()+V;for(;o.pos()<J&&o.next();)switch(o.tag()){case 3:{o.getUInt32();const Y=o.getSInt64(),de=o.getSInt64();m.centroid[2*w]=Y,m.centroid[2*w+1]=de;break}default:o.skip()}break}default:o.skip()}w++,m.hasFeatures=!0;break}default:o.skip()}const j=L||P;if(!j)throw new K.Z("FeatureSet has no objectId or globalId field name");return m.featureCount=w,m.fieldCount=x,m.objectIdFieldIndex=m.getFieldIndex(j),m.transform=O,m.displayIds=new Uint32Array(m.featureCount),m.groupIds=new Uint16Array(m.featureCount),o.move(_),m}(u,"esriGeometryPoint"===a,s),h=ht.s.createInstance();return new qe(h,u,c,t)}get geometryType(){return this._geometryType}get size(){return this._header.featureCount}get hasZ(){return!1}get hasM(){return!1}get stride(){return 2+(this.hasZ?1:0)+(this.hasM?1:0)}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}hasField(e){return this._header.hasField(e)||this._header.hasField(pt(e))}getFieldNames(){return this._header.fields.map(e=>e.fieldName)}getSize(){return this.size}getQuantizationTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(e){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0,this._featureIndex=e}getAttributeHash(){let e="";return this._header.fields.forEach(({index:t})=>{e+=this._readAttributeAtIndex(t)+"."}),e}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(e){this._header.displayIds[this._featureIndex]=e}getGroupId(){return this._header.groupIds[this._featureIndex]}setGroupId(e){this._header.groupIds[this._featureIndex]=e}readLegacyFeature(){if(void 0===this._cache.legacyFeature){const e=this.readCentroid(),t={attributes:this.readAttributes(),geometry:this._isPoints?this.readLegacyPointGeometry():this.readLegacyGeometry(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null};return this._cache.legacyFeature=t,t}return this._cache.legacyFeature}readOptimizedFeature(){if(void 0===this._cache.optFeature){const e=new Be.u_(this.readGeometry(),this.readAttributes(),this.readCentroid());return e.objectId=this.getObjectId(),e.displayId=this.getDisplayId(),this._cache.optFeature=e,e}return this._cache.optFeature}getXHydrated(){const e=this._header.centroid[2*this._featureIndex],t=this.getQuantizationTransform();return(0,b.Wi)(t)?e:e*t.scale[0]+t.translate[0]}getYHydrated(){const e=this._header.centroid[2*this._featureIndex+1],t=this.getQuantizationTransform();return(0,b.Wi)(t)?e:t.translate[1]-e*t.scale[1]}getX(){return this._header.centroid[2*this._featureIndex]*this._sx+this._tx}getY(){return this._header.centroid[2*this._featureIndex+1]*this._sy+this._ty}readLegacyPointGeometry(){return{x:this.getX(),y:this.getY()}}readLegacyGeometry(e){const t=this.readGeometry(e);return(0,X.di)(t,this.geometryType,!1,!1)}readLegacyCentroid(){const e=this.readCentroid();if(!e)return null;const[t,s]=e.coords;return{x:t,y:s}}readGeometryArea(){return this._cache.area||this.readGeometry(!0),this._cache.area}readUnquantizedGeometry(e=!1){if(void 0===this._cache.unquantGeometry){const t=this.readGeometry(e);if(!t)return this._cache.unquantGeometry=null,null;const s=ft(t.coords.length).decoded,a=t.clone(s),u=a.coords;let c=0;for(const h of a.lengths){for(let v=1;v<h;v++){const _=2*(c+v),m=2*(c+v-1);u[_]+=u[m],u[_+1]+=u[m+1]}c+=h}return this._cache.unquantGeometry=a,a}return this._cache.unquantGeometry}readHydratedGeometry(){if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===ze)return null;const a=this.getXHydrated(),u=this.getYHydrated();return new _e.Z([],[a,u])}const e=this.readGeometry();if(!e)return null;const t=e.clone(),s=this.getQuantizationTransform();return(0,b.pC)(s)&&(0,X.$g)(t,t,this.hasZ,this.hasM,s),t}readGeometry(e=!1){if(void 0===this._cache.geometry){let t=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===ze)return null;const s=this.getX(),a=this.getY();t=new _e.Z([],[s,a])}else{const s=this._header.offsets.geometry[this._featureIndex],a=this._reader;if(0===s)return null;a.move(s);try{t=e?this._parseGeometryForDisplay(a):this._parseGeometry(a)}catch(u){return console.error("Failed to parse geometry!",u),null}}return this._cache.geometry=t,t}return this._cache.geometry}readCentroid(){if(void 0===this._cache.centroid){let e=null;const t=this._header.centroid[2*this._featureIndex]+this._tx,s=this._header.centroid[2*this._featureIndex+1]+this._ty;return t===ze?(e=this._computeCentroid(),e&&(this._header.centroid[2*this._featureIndex]=e.coords[0]-this._tx,this._header.centroid[2*this._featureIndex+1]=e.coords[1]-this._ty)):e=new _e.Z([],[t,s]),this._cache.centroid=e,e}return this._cache.centroid}copy(){const e=this._reader.clone(),t=new qe(this.instance,e,this._header,this.fullSchema());return this.copyInto(t),t}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this.size&&!this._getExists(););return this._featureIndex<this.size}_readAttribute(e,t){const s=this._header.hasField(e)?e:pt(e),a=this._header.getFieldIndex(s);if(null==a)return;const u=this._readAttributeAtIndex(a);return t&&null!=u&&this._header.isDateField(s)?new Date(u):u}_readAttributes(){const e={};return this._header.fields.forEach(({fieldName:t,index:s})=>{e[t]=this._readAttributeAtIndex(s)}),e}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._featureOffset=this._featureOffset,e._hasNext=this._hasNext}_readAttributeAtIndex(e){const s=this._reader;return s.move(this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+e]),function Rt(o){const m=o.getLength(),x=o.pos()+m;for(;o.pos()<x&&o.next();)switch(o.tag()){case 1:return o.getString();case 2:return o.getFloat();case 3:return o.getDouble();case 4:return o.getSInt32();case 5:return o.getUInt32();case 6:return o.getInt64();case 7:return o.getUInt64();case 8:return o.getSInt64();case 9:return o.getBool();default:return o.skip(),null}return null}(s)}_parseGeometry(e){const a=e.getLength(),u=e.pos()+a,c=[],h=[];for(;e.pos()<u&&e.next();)switch(e.tag()){case 2:{const v=e.getUInt32(),_=e.pos()+v;for(;e.pos()<_;)h.push(e.getUInt32());break}case 3:{const v=e.getUInt32(),_=e.pos()+v;for(c.push(e.getSInt32()+this._tx),c.push(e.getSInt32()+this._ty),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();e.pos()<_;)c.push(e.getSInt32()),c.push(e.getSInt32()),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();break}default:e.skip()}return new _e.Z(h,c)}_parseGeometryForDisplay(e){const a=e.getLength(),u=e.pos()+a,c=[],h=[];let v=0,_=0,m=null,x=0;const w="esriGeometryPolygon"===this.geometryType;for(;e.pos()<u&&e.next();)switch(e.tag()){case 2:{const F=e.getUInt32(),M=e.pos()+F;for(;e.pos()<M;){const E=e.getUInt32();c.push(E),v+=E}m=ft(2*v).delta;break}case 3:{e.getUInt32();const F=2+(this.hasZ?1:0)+(this.hasM?1:0);for(const M of c)if(_+F*M>m.length)for(let E=0;E<M;E++)e.getSInt32(),e.getSInt32(),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();else if(w){const E=this.getAreaSimplificationThreshold(M,this._header.vertexCount);let Z=2,L=1;const P=!1;let O=e.getSInt32(),B=e.getSInt32();
1m[_++]=O,m[_++]=B,this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();let j=e.getSInt32(),R=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();Z<M;){let H=e.getSInt32(),re=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const V=O+j,J=B+R;$t(O,B,V,J,V+H,J+re)>=E?(x+=-.5*(V-O)*(J+B),L>1&&st(m[_-2],m[_-1],j,R)?(m[_-2]+=j,m[_-1]+=R):(m[_++]=j,m[_++]=R,L++),O=V,B=J):(H+=j,re+=R),j=H,R=re,Z++}L<3||P?_-=2*L:(x+=-.5*(O+j-O)*(B+R+B),st(m[_-2],m[_-1],j,R)?(m[_-2]+=j,m[_-1]+=R,h.push(L)):(m[_++]=j,m[_++]=R,h.push(++L)))}else{let E=0,Z=e.getSInt32(),L=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),m[_++]=Z,m[_++]=L,E+=1;for(let P=1;P<M;P++){const O=e.getSInt32(),B=e.getSInt32(),j=Z+O,R=L+B;x+=-.5*(j-Z)*(R+L),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),P>2&&st(m[_-2],m[_-1],O,B)?(m[_-2]+=O,m[_-1]+=B):(m[_++]=O,m[_++]=B,E+=1),Z=j,L=R}h.push(E)}break}default:e.skip()}if(this._cache.area=x,!h.length)return null;if(this._tx||this._ty){let F=0;for(const M of h)m[2*F]+=this._tx,m[2*F+1]+=this._ty,F+=M}return new _e.Z(h,m)}}class We{constructor(e){this.service=e}destroy(){}}function it(){return(it=(0,A.Z)(function*(o){const e=new bt.Z;return yield e.open(o,{}),e})).apply(this,arguments)}class Ot extends We{constructor(e){super(e),this._portsOpen=function Ut(o){return it.apply(this,arguments)}(e.source).then(t=>this.client=t)}destroy(){this.client.close(),this.client=null}executeQuery(e,t){var s=this;return(0,A.Z)(function*(){yield s._portsOpen;const a=yield s.client.invoke("queryFeatures",e.toJSON(),t);return ye.i.fromFeatureSet(a,s.service)})()}}class zt extends We{executeQuery(e,t){var s=this;return(0,A.Z)(function*(){const{data:a}=yield(0,ke.executeQueryPBFBuffer)(s.service.source,e,t);return qe.fromBuffer(a,s.service,!e.quantizationParameters)})()}}class jt extends We{executeQuery(e,t){var s=this;return(0,A.Z)(function*(){const{source:a,capabilities:u,spatialReference:c,objectIdField:h,geometryType:v}=s.service;if((0,b.pC)(e.quantizationParameters)&&!u.query.supportsQuantization){const m=e.clone(),x=(0,Ce.vY)((0,b.Wg)(m.quantizationParameters));m.quantizationParameters=null;const{data:w}=yield(0,ke.executeQuery)(a,m,c,t),F=(0,X.h_)(w,h);return(0,X.RZ)(x,F),ye.i.fromOptimizedFeatureSet(F,s.service)}const{data:_}=yield(0,ke.executeQuery)(a,e,s.service.spatialReference,t);return"esriGeometryPoint"===v&&(_.features=_.features?.filter(m=>{if((0,b.pC)(m.geometry)){const x=m.geometry;return Number.isFinite(x.x)&&Number.isFinite(x.y)}return!0})),ye.i.fromFeatureSet(_,s.service)})()}}class nt extends We{executeQuery(e,t){var s=this;return(0,A.Z)(function*(){const{capabilities:a}=s.service;if(e.quantizationParameters&&!a.query.supportsQuantization){const c=e.clone(),h=(0,Ce.vY)((0,b.Wg)(c.quantizationParameters));c.quantizationParameters=null;const v=yield(0,ct.WW)(s.service.source,e,t);return(0,X.RZ)(h,v),ye.i.fromOptimizedFeatureSet(v,s.service)}const u=yield(0,ct.WW)(s.service.source,e,t);return ye.i.fromOptimizedFeatureSet(u,s.service)})()}}var Zt=T(97478),ot=T(61885),Se=T(84682),yt=T(84952),Qe=T(65389);class ie{constructor(){this.version=0,this.source=!1,this.targets={feature:!1,aggregate:!1},this.storage={filters:!1,data:!1},this.mesh=!1,this.queryFilter=!1,this.why={mesh:[],source:[]}}static create(e){const t=new ie;for(const s in e){const a=e[s];if("object"==typeof a)for(const u in a)t[s][u]=a[u];t[s]=a}return t}static empty(){return ie.create({})}static all(){return ie.create({source:!0,targets:{feature:!0,aggregate:!0},storage:{filters:!0,data:!0},mesh:!0})}unset(e){this.version=e.version,e.source&&(this.source=!1),e.targets.feature&&(this.targets.feature=!1),e.targets.aggregate&&(this.targets.aggregate=!1),e.storage.filters&&(this.storage.filters=!1),e.storage.data&&(this.storage.data=!1),e.mesh&&(this.mesh=!1),e.queryFilter&&(this.queryFilter=!1)}any(){return this.source||this.mesh||this.storage.filters||this.storage.data||this.targets.feature||this.targets.aggregate||this.queryFilter}describe(){let e=0,t="";if(this.mesh){e+=20,t+="-> (20) Mesh needs update\n";for(const a of this.why.mesh)t+=` + ${a}\n`}if(this.source){e+=10,t+="-> (10) The source needs update\n";for(const a of this.why.source)t+=` + ${a}\n`}this.targets.feature&&(e+=5,t+="-> (5) Feature target parameters changed\n"),this.storage.filters&&(e+=5,t+="-> (5) Feature filter parameters changed\n"),this.targets.aggregate&&(e+=4,t+="-> (4) Aggregate target parameters changed\n"),this.storage.data&&(e+=1,t+="-> (1) Texture storage parameters changed"),console.debug(`Applying ${e<5?"Fastest":e<10?"Fast":e<15?"Moderate":e<20?"Slow":"Very Slow"} update of cost ${e}/45 `),console.debug(t)}toJSON(){return{queryFilter:this.queryFilter,source:this.source,targets:this.targets,storage:this.storage,mesh:this.mesh}}}class Dt{constructor(e,t){this.requests={done:new Array,stream:new Qe.Z(10)},this._edits=null,this._abortController=new AbortController,this._version=0,this._done=!1,this.didSend=!1,this.tile=e,this._version=t}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get empty(){return!this.requests.done.length}get edits(){return this._edits}get done(){return this._done}end(){this._done=!0}clear(){this.requests.done=[]}
1applyUpdate(e){this.requests.done.forEach(t=>t.message.status.unset(e)),this._version=e.version,(0,b.pC)(this._edits)&&this._edits.status.unset(e)}add(e){e.message.status=e.message.status??ie.empty(),e.message.status.version=this._version,(0,G.Z)("esri-2d-update-debug")&&console.debug(this.tile.id,"DataTileSubscription:add",this._version),e.message.end&&this.requests.done.forEach(t=>{(0,b.pC)(t.message)&&t.message.end&&(t.message.end=!1)}),this.requests.done.push(e)}edit(e,t){const s=e.getQuantizationTransform(),a=e.fullSchema(),u=Array.from(e.features()),c=[...t,...u.map(h=>h.objectId)];this.removeIds(c),this._invalidate(),(0,b.Wi)(this._edits)?this._edits={type:"append",addOrUpdate:ye.i.fromOptimizedFeatures(u,a,(0,b.Wg)(s)),id:this.tile.id,status:ie.empty(),end:!0}:(this.requests.done.forEach(h=>h.message.end=!1),(0,b.Wg)(this._edits.addOrUpdate).append(e.features()))}*readers(){for(const{message:e}of this.requests.done)(0,b.pC)(e.addOrUpdate)&&(yield e.addOrUpdate);(0,b.pC)(this._edits)&&(0,b.pC)(this._edits.addOrUpdate)&&(yield this._edits.addOrUpdate)}_invalidate(){for(const e of this.requests.done)e.message.status=ie.empty();(0,b.pC)(this._edits)&&(this._edits.status=ie.empty())}removeIds(e){this._invalidate();for(const{message:t}of this.requests.done){const s=t.addOrUpdate;(0,b.pC)(s)&&(s.removeIds(e),s.isEmpty&&(t.addOrUpdate=null))}(0,b.pC)(this._edits)&&(0,b.pC)(this._edits.addOrUpdate)&&this._edits.addOrUpdate.removeIds(e),this.requests.done=this.requests.done.filter(t=>t.message.addOrUpdate||t.message.end)}abort(){this._abortController.abort()}}class mt{constructor(e){this.events=new ot.Z,this._resolver=(0,D.hh)(),this._didEdit=!1,this._subscriptions=new Map,this._outSR=e.outSR,this._serviceInfo=e.serviceInfo,this._onTileUpdateMessage=e.onMessage}destroy(){}_onMessage(e){var t=this;return(0,A.Z)(function*(){const s=t._subscriptions.get(e.id);if(!s)return;const a={...e,remove:e.remove??[],status:e.status??ie.empty()};return(0,D.R8)(t._onTileUpdateMessage(a,s.options))})()}update(e,t){const s=t.fields.length;t.outFields=function _t(o,e){const t=new Set;return o&&o.forEach(s=>t.add(s)),e&&e.forEach(s=>t.add(s)),t.has("*")?["*"]:Array.from(t)}(this._schema?.outFields,t.outFields),t.outFields=t.outFields.length>=.75*s?["*"]:t.outFields,t.outFields.sort();const a=(0,Se.Hg)(this._schema,t);if(!a)return;(0,G.Z)("esri-2d-update-debug")&&console.debug("Applying Update - Source:",a);const u="orderByFields"in this._serviceInfo&&this._serviceInfo.orderByFields?this._serviceInfo.orderByFields:this._serviceInfo.objectIdField+" ASC",c={returnCentroid:(0,G.Z)("esri-2d-query-centroid-enabled")&&"esriGeometryPolygon"===this._serviceInfo.geometryType,returnGeometry:!0,timeReferenceUnknownClient:"stream"!==this._serviceInfo.type&&this._serviceInfo.timeReferenceUnknownClient,outFields:t.outFields,outSpatialReference:this._outSR,orderByFields:[u],where:t.definitionExpression||"1=1",gdbVersion:t.gdbVersion,historicMoment:t.historicMoment,timeExtent:Zt.Z.fromJSON(t.timeExtent)},h=this._schema&&(0,Se.uD)(a,"outFields");this._schema&&(0,Se.V7)(a,["timeExtent","definitionExpression","gdbVersion","historicMoment","customParameters"])&&(e.why.mesh.push("Layer filter and/or custom parameters changed"),e.why.source.push("Layer filter and/or custom parameters changed"),e.mesh=!0,e.source=!0,e.queryFilter=!0),h&&(e.why.source.push("Layer required fields changed"),e.source=!0),(0,Se.Hg)(c,this._queryInfo)&&(this._queryInfo=c),this._schema=t,this._resolver.resolve()}whenInitialized(){return this._resolver.promise}applyUpdate(e){var t=this;return(0,A.Z)(function*(){if(e.queryFilter||e.source&&t._didEdit)return t.refresh(e.version),void(t._didEdit=!1);t._subscriptions.forEach(s=>s.applyUpdate(e)),yield t.resend()})()}refresh(e){for(const t of this._tiles())this.unsubscribe(t),this.subscribe(t,e)}subscribe(e,t){const s=new Dt(e,t);this._subscriptions.set(e.id,s)}unsubscribe(e){const t=this.get(e.id);(0,b.pC)(t)&&t.abort(),this._subscriptions.delete(e.id)}createQuery(e={}){const t=this._queryInfo.historicMoment?new Date(this._queryInfo.historicMoment):null;return new yt.Z({...this._queryInfo,historicMoment:t,...e})}get(e){return this._subscriptions.has(e)?this._subscriptions.get(e):null}queryLastEditDate(){return(0,A.Z)(function*(){throw new Error("Service does not support query type")})()}query(e){return(0,A.Z)(function*(){throw new Error("Service does not support query")})()}*_tiles(){const e=Array.from(this._subscriptions.values());for(const t of e)yield t.tile}edit(e,t){var s=this;return(0,A.Z)(function*(){const a=Array.from(s._subscriptions.values()),u=a.map(({tile:c})=>c);for(const c of a)c.removeIds(t);if(e.length){const c=u.map(v=>{const _=s.createTileQuery(v);return _.objectIds=e,{tile:v,query:_}}).map(function(){var v=(0,A.Z)(function*({tile:_,query:m}){return{tile:_,result:yield s.query(m),query:m}});return function(_){return v.apply(this,arguments)}}()),h=(yield(0,D.WW)(c)).map(function(){var v=(0,A.Z)(function*({tile:_,result:m}){if(!m.hasFeatures&&!t.length&&!e.length)return;const x=s._subscriptions.get(_.key.id);x&&x.edit(m,e)});return function(_){return v.apply(this,arguments)}}());yield(0,D.as)(h)}s._didEdit=!0})()}}var at=T(71251);const Jt=Me.Z.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource");class Pt extends mt{constructor(e){var t,s;super(e),t=this,this.type="feature",this.mode="on-demand",this._adapter=function Bt(o){const{capabilities:e}=o;return function Gt(o){return o&&o.capabilities&&o.collection&&o.layerDefinition}(o.source)?new nt(o):function kt(o){return Array.isArray(o.source)}(o)?new Ot(o):e.query.supportsFormatPBF&&(0,G.Z)("featurelayer-pbf")?new zt(o):new jt(o)}(e.serviceInfo),this._queue=new at.e({concurrency:8,process:(s=(0,A.Z)(function*(a){if((0,D.k_)(a),(0,b.pC)(a.tile)){const u=a.tile.key.id,{signal:c}=a,h=(0,G.Z)("esri-tiles-debug")?{tile:u.replace(/\//g,"."),depth:a.depth}:void 0,v=yield t._adapter.executeQuery(a.query,{signal:c,query:{...h,...t._schema.customParameters}});return v.level=a.tile.key.level,v}return t._adapter.executeQuery(a.query,{...a,query:t._schema.customParameters})}),function(u){return s.apply(this,arguments)})}),this._patchQueue=new at.e({concurrency:8,process:function(){var s=(0,A.Z)(function*(a){if((0,D.k_)(a),(0,b.pC)(a.tile)){const u=a.tile.key.id,{signal:c}=a,h=(0,G.Z)("esri-tiles-debug")?{tile:u.replace(/\//g,"."),depth:a.depth}:void 0,v=yield t._adapter.executeQuery(a.query,{signal:c,query:{...h,...t._schema.customParameters}});return v.level=a.tile.key.level,v}return t._adapter.executeQuery(a.query,{...a,query:t._schema.customParameters})});return function(u){return s.apply(this,arguments)}}()})}destroy(){super.destroy(),this._adapter.destroy(),this._queue.destroy(),this._patchQueue.destroy()}get updating(){return!!this._queue.length||Array.from(this._subscriptions.values()).some(e=>!e.done)}get maxRecordCountFactor(){const{query:e}=this._serviceInfo.capabilities;
1return e.supportsMaxRecordCountFactor?4:null}get maxPageSize(){const{query:e}=this._serviceInfo.capabilities;return(e.maxRecordCount??8e3)*(0,b.Pt)(this.maxRecordCountFactor,1)}get pageSize(){return Math.min(8e3,this.maxPageSize)}enableEvent(e,t){}subscribe(e,t){super.subscribe(e,t);const s=this._subscriptions.get(e.id);this._fetchDataTile(e).catch(a=>{(0,D.D_)(a)||Jt.error(new K.Z("mapview-query-error","Encountered error when fetching tile",{tile:e,error:a}))}).then(()=>s.end())}unsubscribe(e){super.unsubscribe(e)}readers(e){return this._subscriptions.get(e).readers()}query(e){var t=this;return(0,A.Z)(function*(){return t._adapter.executeQuery(e,{query:t._schema.customParameters})})()}queryLastEditDate(){var e=this;return(0,A.Z)(function*(){const t=e._serviceInfo.source,s={...t.query,f:"json"};return(yield(0,Ae.default)(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate})()}createTileQuery(e,t={}){const s=this._serviceInfo.geometryType,a=this.createQuery(t);a.quantizationParameters=t.quantizationParameters??e.getQuantizationParameters(),a.resultType="tile",a.geometry=e.extent,this._serviceInfo.capabilities.query.supportsQuantization?"esriGeometryPolyline"===s&&(a.maxAllowableOffset=e.resolution*(0,G.Z)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==s&&"esriGeometryPolygon"!==s||(a.maxAllowableOffset=e.resolution,"esriGeometryPolyline"===s&&(a.maxAllowableOffset*=(0,G.Z)("feature-polyline-generalization-factor")));const u=this._serviceInfo.capabilities.query;return a.defaultSpatialReferenceEnabled=u.supportsDefaultSpatialReference,a.compactGeometryEnabled=u.supportsCompactGeometry,a}_executePatchQuery(e,t,s,a){var u=this;return(0,A.Z)(function*(){const c=t.clone();c.outFields=[u._serviceInfo.objectIdField,...s],c.returnCentroid=!1,c.returnGeometry=!1;const h=(0,b.pC)(c.start)?c.start/8e3:0;return u._patchQueue.push({tile:e,query:c,signal:a.signal,depth:h})})()}_resend(e,t){var s=this;return(0,A.Z)(function*(){const{query:a,message:u}=e,c=(0,b.pC)(a.outFields)?a.outFields:[],h=s._queryInfo.outFields,v=h.filter(_=>!c.includes(_));if((0,b.Wi)(u.addOrUpdate))s._onMessage({...u,type:"append"});else if(v.length)try{const _=s._subscriptions.get(u.id).tile,m=yield s._executePatchQuery(_,a,v,t);(0,D.k_)(t),a.outFields=h,u.addOrUpdate.joinAttributes(m),s._onMessage({...u,end:u.end,type:"append"})}catch{}else s._onMessage({...u,type:"append"})})()}_resendSubscription(e){var t=this;return(0,A.Z)(function*(){if((0,G.Z)("esri-2d-update-debug")&&console.debug(e.tile.id,"Resend Subscription"),e.empty)return t._onMessage({id:e.tile.id,addOrUpdate:null,end:!1,type:"append"});const s=e.signal;for(const a of e.requests.done)yield t._resend(a,{signal:s});return(0,b.pC)(e.edits)?t._onMessage(e.edits):void 0})()}resend(){var e=this;return(0,A.Z)(function*(){const t=Array.from(e._subscriptions.values());yield Promise.all(t.map(s=>e._resendSubscription(s)))})()}}const qt=(0,G.Z)("esri-mobile"),Wt={maxDrillLevel:qt?1:4,maxRecordCountFactor:qt?1:3};class er extends Pt{constructor(e){super(e)}_fetchDataTile(e){var t=this;return(0,A.Z)(function*(){const s=t._serviceInfo.capabilities.query.supportsMaxRecordCountFactor,a=t._subscriptions.get(e.key.id),u=a.signal,c=e.getQuantizationParameters();let h=0;const v=function(){var _=(0,A.Z)(function*(m,x){const w=t._queryInfo,F=t.createTileQuery(m,{maxRecordCountFactor:s?Wt.maxRecordCountFactor:void 0,returnExceededLimitFeatures:!1,quantizationParameters:c});h++;try{const M=yield t._queue.push({tile:e,query:F,signal:u,depth:x});if(h--,(0,D.k_)(u),!M)return;if(w!==t._queryInfo)return void v(m,x);if(M.exceededTransferLimit&&x<Wt.maxDrillLevel){for(const Z of m.createChildTiles())v(Z,x+1);return}const E={id:e.id,addOrUpdate:M,end:0===h,type:"append"};a.add({query:F,message:E}),t._onMessage(E)}catch(M){(0,D.D_)(M)||t._onMessage({id:e.id,addOrUpdate:null,end:!0,type:"append"})}});return function(x,w){return _.apply(this,arguments)}}();v(e,0)})()}}var Qt=T(76279),S=T(21286);const W="__esri_timestamp__";class me{constructor(e,t,s,a,u=128){this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=performance.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=s,this._purgeOptions=a,this.store=e,this.objectIdField=t,this.purgeInterval=u,this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}add(e){if(this._useGeneratedIds){const a=this._nextId();e.attributes[this.objectIdField]=a,e.objectId=a}else e.objectId=e.attributes[this.objectIdField];if(this._addOrUpdated.set(e.objectId,e),this._maxAge=Math.max(this._maxAge,e.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return(0,b.Wi)(this._trackIdLessObservations)&&(this._trackIdLessObservations=new Qe.Z(1e5)),void this._trackIdLessObservations.enqueue(e.objectId);const t=e.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(t)){const a=(0,b.pC)(this._purgeOptions)&&null!=this._purgeOptions.maxObservations?this._purgeOptions.maxObservations:1e3,u=(0,S.uZ)(a,0,1e3);this._trackIdToObservations.set(t,new Qe.Z(u))}const s=this._trackIdToObservations.get(t).enqueue(e.objectId);(0,b.pC)(s)&&(this._addOrUpdated.has(s)?this._addOrUpdated.delete(s):this._removed.push(s))}checkForUpdates(){const e=this._getToAdd(),t=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const a=[];if((0,b.pC)(t))for(const u of t){const c=this.store.removeById(u);(0,b.pC)(c)&&a.push(c)}if((0,b.pC)(e))for(const u of e)u.attributes[W]=s,this.store.add(u);(e||a)&&this.store.update(e,a)}_getToAdd(){if(!this._addOrUpdated.size)return null;const e=new Array(this._addOrUpdated.size);let t=0;return this._addOrUpdated.forEach(s=>e[t++]=s),this._addOrUpdated.clear(),e}_getToRemove(){const e=this._removed;return this._removed.length?(this._removed=[],e):null}_nextId(){const e=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,e}_purge(e){const t=this._purgeOptions;(0,b.pC)(t)&&(this._purgeSomeByDisplayCount(t),this._purgeByAge(t),this._purgeByAgeReceived(e,t),this._purgeTracks())}_purgeSomeByDisplayCount(e){if(!e.displayCount)return;let t=this.store.size;if(t>e.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(t>e.displayCount&&s.size){const a=(0,b.Wg)(s.dequeue());this._removed.push(a),t--}if((0,b.pC)(this._trackIdLessObservations)){let s=t-e.displayCount;for(;s-- >0;){const a=this._trackIdLessObservations.dequeue();(0,b.pC)(a)&&this._removed.push(a)}}}}_purgeByAge(e){if(!e.age||!this._timeInfo?.startTimeField)return;const s=this._maxAge-60*e.age*1e3;this.store.forEach(a=>{a.attributes[this._timeInfo.startTimeField]<s&&this._removed.push(a.objectId)})}_purgeByAgeReceived(e,t){if(!t.ageReceived)return;const s=e-60*t.ageReceived*1e3;this.store.forEach(a=>{a.attributes[W]<s&&this._removed.push(a.objectId)})}_purgeTracks(){this._trackIdToObservations.forEach((e,t)=>{0===e.size&&this._trackIdToObservations.delete(t)})}}
1T(29132);var Ee=T(21726),Fe=(T(82255),T(33696));let Oe=class extends(ot.Z.EventedMixin(te.r)){onFeature(o){this.emit("feature",o)}};Oe=(0,Q._)([(0,C.j)("esri.layers.graphics.sources.connections.StreamConnection")],Oe);const Nt=Oe,Te=Me.Z.getLogger("esri.layers.graphics.sources.connections.WebSocketConnection");var Ve,o;(o=Ve||(Ve={}))[o.CONNECTING=0]="CONNECTING",o[o.OPEN=1]="OPEN",o[o.CLOSING=2]="CLOSING",o[o.CLOSED=3]="CLOSED";let He=class extends Nt{constructor(o){super(),this.errorString=null;const{geometryType:e,spatialReference:t,sourceSpatialReference:s}=o;this._config=o,this._featureZScaler=(0,Fe.k)(e,s,t),this._open()}_open(){var o=this;return(0,A.Z)(function*(){yield o._tryCreateWebSocket(),o.destroyed||(yield o._handshake())})()}destroy(){(0,b.pC)(this._websocket)&&(this._websocket.onopen=null,this._websocket.onclose=null,this._websocket.onerror=null,this._websocket.onmessage=null,this._websocket.close()),this._websocket=null}get connectionStatus(){if((0,b.Wi)(this._websocket))return"disconnected";switch(this._websocket.readyState){case Ve.CONNECTING:case Ve.OPEN:return"connected";case Ve.CLOSING:case Ve.CLOSED:return"disconnected"}}_tryCreateWebSocket(o=this._config.source.path,e=1e3,t=0){var s=this;return(0,A.Z)(function*(){try{if(s.destroyed)return;const a=(0,Ee.fl)(o,s._config.customParameters);s._websocket=yield s._createWebSocket(a),s.notifyChange("connectionStatus")}catch(a){const u=e/1e3;return s._config.maxReconnectionAttempts&&t>=s._config.maxReconnectionAttempts?(Te.error(new K.Z("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void s.destroy()):(Te.error(new K.Z("websocket-connection",`Failed to connect. Attempting to reconnect in ${u}s`,a)),yield(0,D.e4)(e),s._tryCreateWebSocket(o,Math.min(1.5*e,1e3*s._config.maxReconnectionInterval),t+1))}})()}_createWebSocket(o){return new Promise((e,t)=>{const s=new WebSocket(o);s.onopen=()=>{if(s.onopen=null,this.destroyed)return s.onclose=null,void s.close();s.onclose=a=>this._onClose(a),s.onerror=a=>this._onError(a),s.onmessage=a=>this._onMessage(a),e(s)},s.onclose=a=>{s.onopen=s.onclose=null,t(a)}})}_handshake(o=1e4){var e=this;return(0,A.Z)(function*(){const t=e._websocket;if((0,b.Wi)(t))return;const s=(0,D.hh)(),a=t.onmessage,{filter:u,outFields:c,spatialReference:h}=e._config;return s.timeout(o),t.onmessage=v=>{let _=null;try{_=JSON.parse(v.data)}catch{}_&&"object"==typeof _||(Te.error(new K.Z("websocket-connection","Protocol violation. Handshake failed - malformed message",v.data)),s.reject(),e.destroy()),_.spatialReference?.wkid!==h?.wkid&&(Te.error(new K.Z("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${h.wkid}`,v.data)),s.reject(),e.destroy()),"json"!==_.format&&(Te.error(new K.Z("websocket-connection","Protocol violation. Handshake failed - format is not set",v.data)),s.reject(),e.destroy()),u&&_.filter!==u&&Te.error(new K.Z("websocket-connection","Tried to set filter, but server doesn't support it")),c&&_.outFields!==c&&Te.error(new K.Z("websocket-connection","Tried to set outFields, but server doesn't support it")),t.onmessage=a,s.resolve()},t.send(JSON.stringify({filter:u,outFields:c,format:"json",spatialReference:{wkid:h.wkid}})),s.promise})()}_onMessage(o){try{const e=JSON.parse(o.data);if("featureResult"!==e.type)throw new K.Z("websocket-connection","Protocol violation - Expected to find message of type 'featureResult'",e);for(const t of e.features)(0,b.pC)(this._featureZScaler)&&this._featureZScaler(t.geometry),this.onFeature(t)}catch(e){return Te.error(new K.Z("websocket-connection","Failed to parse message",e)),void this.destroy()}}_onError(o){const e="Encountered an error over WebSocket connection";this._set("errorString",e),Te.error("websocket-connection",e)}_onClose(o){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==o.code&&Te.error("websocket-connection",`WebSocket closed unexpectedly with error code ${o.code}`),this.destroyed||this._open()}};(0,Q._)([(0,U.Cb)()],He.prototype,"connectionStatus",null),(0,Q._)([(0,U.Cb)()],He.prototype,"errorString",void 0),He=(0,Q._)([(0,C.j)("esri.layers.graphics.sources.connections.WebSocketConnection")],He);var tr=T(91179),Le=T(65234);const Ie=Me.Z.getLogger("esri.layers.graphics.sources.connections.GeoEventConnection"),Lr={maxQueryDepth:5,maxRecordCountFactor:3};let rr=class extends He{constructor(o){super({...Lr,...o})}_open(){var o=this;return(0,A.Z)(function*(){const e=yield o._fetchServiceDefinition(o._config.source);e.timeInfo.trackIdField||Ie.warn("GeoEvent service was configured without a TrackIdField. This may result in certain functionality being disabled. The purgeOptions.maxObservations property will have no effect.");const t=o._fetchWebSocketUrl(e.streamUrls,o._config.spatialReference);
1o._buddyServicesQuery||(o._buddyServicesQuery=o._queryBuddyServices()),yield o._buddyServicesQuery,yield o._tryCreateWebSocket(t);const{filter:s,outFields:a}=o._config;o.destroyed||o._setFilter(s,a)})()}_onMessage(o){let e;try{e=this._enrich(JSON.parse(o.data)),(0,b.pC)(this._featureZScaler)&&this._featureZScaler(e.geometry)}catch(t){return void Ie.error(new K.Z("geoevent-connection","Failed to parse message",t))}this.onFeature(e)}_fetchServiceDefinition(o){var e=this;return(0,A.Z)(function*(){const t={f:"json",...e._config.customParameters},s=(0,Ae.default)(o.path,{query:t,responseType:"json"}),a=(yield s).data;return e._serviceDefinition=a,a})()}_fetchWebSocketUrl(o,e){const t=o[0],{urls:s,token:a}=t,u=this._inferWebSocketBaseUrl(s);return(0,Ee.fl)(`${u}/subscribe`,{outSR:""+e.wkid,token:a})}_inferWebSocketBaseUrl(o){if(1===o.length)return o[0];for(const e of o)if(e.includes("wss"))return e;return Ie.error(new K.Z("geoevent-connection","Unable to infer WebSocket url",o)),null}_setFilter(o,e){var t=this;return(0,A.Z)(function*(){const s=t._websocket;if((0,b.Wi)(s)||(0,b.Wi)(o)&&(0,b.Wi)(e))return;const a=JSON.stringify({filter:t._serializeFilter(o,e)});let u=!1;const c=(0,D.hh)();return s.onmessage=_=>{const m=JSON.parse(_.data);m.filter&&(m.error&&(Ie.error(new K.Z("geoevent-connection","Failed to set service filter",m.error)),t._set("errorString",`Could not set service filter - ${m.error}`),c.reject(m.error)),s.onmessage=t._onMessage.bind(t),u=!0,c.resolve())},s.send(a),setTimeout(()=>{u||(t.destroyed||t._websocket!==s||Ie.error(new K.Z("geoevent-connection","Server timed out when setting filter")),c.reject())},1e4),c.promise})()}_serializeFilter(o,e){const t={};if((0,b.Wi)(o)&&(0,b.Wi)(e))return t;if((0,b.pC)(o)&&o.geometry)try{const s=(0,tr.im)(o.geometry);if("extent"!==s.type)throw new K.Z(`Expected extent but found type ${s.type}`);t.geometry=JSON.stringify(s.shiftCentralMeridian())}catch(s){Ie.error(new K.Z("geoevent-connection","Encountered an error when setting connection geometryDefinition",s))}return(0,b.pC)(o)&&o.where&&"1 = 1"!==o.where&&(t.where=o.where),(0,b.pC)(e)&&(t.outFields=e.join(",")),t}_enrich(o){if(!this._relatedFeatures)return o;const t=o.attributes[this._serviceDefinition.relatedFeatures.joinField];if(!this._relatedFeatures.has(t))return Ie.warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",o),o;const{attributes:s,geometry:a}=this._relatedFeatures.get(t);for(const u in s)o.attributes[u]=s[u];return a&&(o.geometry=a),o.geometry||o.centroid||Ie.error(new K.Z("geoevent-connection","Found malformed feature - no geometry found",o)),o}_queryBuddyServices(){var o=this;return(0,A.Z)(function*(){try{const{relatedFeatures:e,keepLatestArchive:t}=o._serviceDefinition,s=o._queryRelatedFeatures(e),a=o._queryArchive(t);yield s;const u=yield a;if(!u)return;for(const c of u.features)o.onFeature(o._enrich(c))}catch(e){Ie.error(new K.Z("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}})()}_queryRelatedFeatures(o){var e=this;return(0,A.Z)(function*(){if(!o)return;const t=yield e._queryBuddy(o.featuresUrl);e._addRelatedFeatures(t)})()}_queryArchive(o){var e=this;return(0,A.Z)(function*(){if(o)return e._queryBuddy(o.featuresUrl)})()}_queryBuddy(o){var e=this;return(0,A.Z)(function*(){const t=new((yield Promise.resolve().then(T.bind(T,32258))).default)({url:o}),{capabilities:s}=yield t.load(),a=s.query.supportsMaxRecordCountFactor,u=s.query.supportsPagination,c=s.query.supportsCentroid,h=e._config.maxRecordCountFactor,v=t.capabilities.query.maxRecordCount,_=a?v*h:v,m=new yt.Z;if(m.outFields=(0,b.Pt)(e._config.outFields,["*"]),m.where=(0,b.Pt)((0,b.U2)(e._config.filter,"where"),"1=1"),m.returnGeometry=!0,m.returnExceededLimitFeatures=!0,m.outSpatialReference=Le.Z.fromJSON(e._config.spatialReference),c&&(m.returnCentroid=!0),a&&(m.maxRecordCountFactor=h),u)return m.num=_,t.destroy(),e._queryPages(o,m);const x=yield(0,ke.executeQuery)(o,m,e._config.sourceSpatialReference);return t.destroy(),x.data})()}_queryPages(o,e,t=[],s=0){var a=this;return(0,A.Z)(function*(){e.start=(0,b.pC)(e.num)?s*e.num:null;const{data:u}=yield(0,ke.executeQuery)(o,e,a._config.sourceSpatialReference);return u.exceededTransferLimit&&s<a._config.maxQueryDepth?(u.features.forEac
1h(c=>t.push(c)),a._queryPages(o,e,t,s+1)):(t.forEach(c=>u.features.push(c)),u)})()}_addRelatedFeatures(o){const e=new Map,t=o.features,s=this._serviceDefinition.relatedFeatures.joinField;for(const a of t)e.set(a.attributes[s],a);this._relatedFeatures=e}};rr=(0,Q._)([(0,C.j)("esri.layers.graphics.sources.connections.GeoEventConnection")],rr);const Rr=rr;function Zr(o,e){const t=o.weakClone();if((0,b.pC)(o.geometry)){const s=(0,X.Jd)(e,o.geometry.coords[0]),a=(0,X.IN)(e,o.geometry.coords[1]);t.geometry=new _e.Z([],[s,a])}return t}class Gr{constructor(e,t){this.onUpdate=e,this._geometryType=t,this._objectIdToFeature=new Map}get _features(){const e=[];return this._objectIdToFeature.forEach(t=>e.push(t)),e}add(e){this._objectIdToFeature.set(e.objectId,e),this._index=null}get(e){return this._objectIdToFeature.has(e)?this._objectIdToFeature.get(e):null}forEach(e){this._objectIdToFeature.forEach(e)}search(e){return this._index||(this._index=function Nr(o,e){const t=(0,Qt.r)(9,function Pr(o){return"esriGeometryPoint"===o?e=>(0,b.pC)(e.geometry)?{minX:e.geometry.coords[0],minY:e.geometry.coords[1],maxX:e.geometry.coords[0],maxY:e.geometry.coords[1]}:{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}:e=>{let t=1/0,s=1/0,a=-1/0,u=-1/0;return(0,b.pC)(e.geometry)&&e.geometry.forEachVertex((c,h)=>{t=Math.min(t,c),s=Math.min(s,h),a=Math.max(a,c),u=Math.max(u,h)}),{minX:t,minY:s,maxX:a,maxY:u}}}(e));return t.load(o),t}(this._features,this._geometryType)),function kr(o,e){return o.search({minX:e.bounds[0],minY:e.bounds[1],maxX:e.bounds[2],maxY:e.bounds[3]})}(this._index,e)}removeById(e){const t=this._objectIdToFeature.get(e);return t?(this._objectIdToFeature.delete(e),this._index=null,t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._objectIdToFeature.size}}class Br extends mt{constructor(e){super(e),this.type="geoevent",this._dataReceiveEventEnabled=!1,this._level=0,this._updateInfo={websocket:0,client:0};const{outSR:t}=e,{geometryType:s,objectIdField:a,timeInfo:u,purgeOptions:c,source:h,spatialReference:v,serviceFilter:_,maxReconnectionAttempts:m,maxReconnectionInterval:x,updateInterval:w,enableDataReceived:F,customParameters:M}=e.serviceInfo,E=new Gr(this._onUpdate.bind(this),s),Z=new me(E,a,u,c),L=function Ur(o,e,t,s,a,u,c,h){const v=0===o.path.indexOf("wss://")||0===o.path.indexOf("ws://"),_={source:o,sourceSpatialReference:e,spatialReference:t,geometryType:s,filter:a,maxReconnectionAttempts:u,maxReconnectionInterval:c,customParameters:h};return v?new He(_):new Rr(_)}(h,v,t,s,_,m,x,M);this._store=E,this._manager=Z,this._connection=L,this._quantize=function Dr(o){return"esriGeometryPoint"===o?Zr:(e,t)=>{const s=e.weakClone(),a=new _e.Z,h=(0,X.Nh)(a,e.geometry,!1,!1,o,t,!1,!1);return s.geometry=h,s}}(s),this._dataReceiveEventEnabled=F,this._handles=[this._connection.on("feature",P=>this._onFeature(P)),(0,se.YP)(()=>L.connectionStatus,P=>this.events.emit("connectionStatus",P)),(0,se.YP)(()=>L.errorString,P=>this.events.emit("errorString",P))],this._initUpdateInterval=()=>{let P=performance.now();this._updateIntervalId=setInterval(()=>{const O=performance.now(),B=O-P;if(B>2500){P=O;const j=Math.round(this._updateInfo.client/(B/1e3)),R=Math.round(this._updateInfo.websocket/(B/1e3));this._updateInfo.client=0,this._updateInfo.websocket=0,this.events.emit("updateRate",{client:j,websocket:R})}e.canAcceptRequest()&&this._manager.checkForUpdates()},w)},this._initUpdateInterval()}destroy(){super.destroy(),this._clearUpdateInterval(),this._handles.forEach(e=>e.remove()),this._connection.destroy()}_fetchDataTile(){}pauseStream(){this._clearUpdateInterval()}resumeStream(){this._initUpdateInterval()}enableEvent(e,t){"data-received"===e&&(this._dataReceiveEventEnabled=t)}get updating(){return!1}subscribe(e,t){super.subscribe(e,t);const s=this._subscriptions.get(e.id);this._level=e.level;const a=this._getTileFeatures(e);this._onMessage({type:"append",id:e.key.id,addOrUpdate:a,end:!0}),s.didSend=!0}unsubscribe(e){super.unsubscribe(e)}*readers(e){const t=this._subscriptions.get(e),{tile:s}=t;yield this._getTileFeatures(s);for(const a of t.requests.stream.entries)(0,b.pC)(a)&&(0,b.pC)(a.addOrUpdate)&&(yield a.addOrUpdate)}createTileQuery(e){throw new Error("Service does not support tile queries")}resend(){var e=this;return(0,A.Z)(function*(){e._subscriptions.forEach(t=>{const{tile:s}
1=t,a={type:"append",id:s.id,addOrUpdate:e._getTileFeatures(s),end:!0};e._onMessage(a)})})()}_getTileFeatures(e){const t=this._store.search(e).map(s=>this._quantize(s,e.transform));return ye.i.fromOptimizedFeatures(t,this._serviceInfo,e.transform)}_onFeature(e){this._updateInfo.websocket++;try{this._dataReceiveEventEnabled&&this.events.emit("feature",e);const t=(0,X.XA)(e,this._serviceInfo.geometryType,!1,!1,this._serviceInfo.objectIdField);this._manager.add(t)}catch{}}_clearUpdateInterval(){clearInterval(this._updateIntervalId),this._updateIntervalId=0}_onUpdate(e,t){(0,b.pC)(e)&&(this._updateInfo.client+=e.length),this._subscriptions.forEach((s,a)=>{s.didSend&&s.tile.level===this._level&&this._onMessage({type:"append",id:a,addOrUpdate:null,clear:!0,end:!1})}),this._subscriptions.forEach((s,a)=>{if(!s.didSend||s.tile.level!==this._level)return;const c={type:"append",id:a,addOrUpdate:this._getTileFeatures(s.tile),remove:[],end:!0,status:ie.empty()};s.requests.stream.enqueue(c),this._onMessage(c)})}}const zr=Me.Z.getLogger("esri.views.2d.layers.features.sources.FeatureSource");class jr extends Pt{constructor(e){super(e)}_fetchDataTile(e){var t=this;return(0,A.Z)(function*(){const u=t._subscriptions.get(e.key.id);let c=!1,h=0,v=0;const _=(w,F)=>{v--,(0,D.k_)(u);const M=e.id,E=w.reader,Z=w.query;if(!E.exceededTransferLimit){if(c=!0,0!==F&&!E.hasFeatures){const O={id:M,addOrUpdate:E,end:0===v,type:"append"};return u.add({message:O,query:Z}),void t._onMessage(O)}const P={id:M,addOrUpdate:E,end:0===v,type:"append"};return u.add({message:P,query:Z}),void t._onMessage(P)}const L={id:M,addOrUpdate:E,end:c&&0===v,type:"append"};u.add({message:L,query:Z}),t._onMessage(L)};let m=0,x=0;for(;!c&&x++<20;){let w;for(let F=0;F<m+1;F++){const M=h++;v++,w=t._fetchDataTilePage(e,M,u).then(E=>E&&_(E,M)).catch(E=>{c=!0,(0,D.D_)(E)||(zr.error(new K.Z("mapview-query-error","Encountered error when fetching tile",{tile:e,error:E})),t._onMessage({id:e.id,addOrUpdate:null,end:c,type:"append"}))})}yield w,(0,D.k_)(u),m=Math.min(m+2,6)}})()}_fetchDataTilePage(e,t,s){var a=this;return(0,A.Z)(function*(){(0,D.k_)(s);const u=a._queryInfo,c={start:a.pageSize*t,num:a.pageSize,returnExceededLimitFeatures:!0,quantizationParameters:e.getQuantizationParameters()};(0,b.pC)(a.maxRecordCountFactor)&&(c.maxRecordCountFactor=a.maxRecordCountFactor);const h=a.createTileQuery(e,c);try{const v=s.signal,_=yield a._queue.push({tile:e,query:h,signal:v,depth:t});return(0,D.k_)(s),_?u!==a._queryInfo?a._fetchDataTilePage(e,t,s):{reader:_,query:h}:null}catch(v){return(0,D.H9)(v),null}})()}}var qr=T(4619),Wr=T(52397);const Qr=Me.Z.getLogger("esri.views.2d.layers.features.sources.SnapshotFeatureSource");function Vr(o,e,t){const s=o.getXHydrated(),a=o.getYHydrated(),u=e.getColumnForX(s),c=Math.floor(e.normalizeCol(u));return`${t}/${Math.floor(e.getRowForY(a))}/${c}`}function sr(o,e){if((0,b.Wi)(o))return null;const t=e.transform,s=o.getQuantizationTransform();if((0,b.Wi)(s)){const[Z,L]=t.scale,[P,O]=t.translate;return o.transform(-P/Z,O/L,1/Z,1/-L)}const[a,u]=s.scale,[c,h]=s.translate,[v,_]=t.scale,[m,x]=t.translate;return o.transform((c-m)/v,(-h+x)/_,a/v,u/_)}class Hr extends Pt{constructor(e){super(e),this.mode="snapshot",this._loading=!0,this._controller=new AbortController,this._downloadPromise=null,this._didSendEnd=!1,this._queries=new Array,this._invalidated=!1,this._hasAggregates=!1,this._random=new qr.Z(1e3),this._store=e.store,this._markedIdsBufId=this._store.storage.createBitset()}destroy(){super.destroy(),this._controller.abort()}get loading(){return this._loading}get _signal(){return this._controller.signal}update(e,t){super.update(e,t),this._hasAggregates=e.targets.aggregate}resend(e=!1){var t=this;return(0,A.Z)(function*(){if(yield t._downloadPromise,t._invalidated||e){const a=(0,b.s3)(t._schema.featureCount,"Expected featureCount to be defined");return t._invalidated=!1,t._subscriptions.forEach(u=>u.clear()),t._downloadPromise=t._download(a),void(yield t._downloadPromise)}const s=t._queries.map(({query:a,reader:u})=>t._sendPatchQuery(a,u));yield Promise.all(s),t._subscriptions.forEach(a=>{a.requests.done.forEach(u=>t._onMessage(u.message))})})()}refresh(){var e=this;return(0,A.Z)(function*(){yield e.resend(!0)})()}_sendPatchQuery(e,t){var s=this;return(0,A.Z)(function*(){const a=(0,b.pC)(e.outFields)?e.outFields:[],u=s._queryInfo.outFields,c=u.filter(m=>!a.includes(m));if(!c.length)return;const h=e.clone(),v=s._signal;h.returnGeometry=!1,h.returnCentroid=!1,h.outFields=c,e.outFields=u;const _=yield s._queue.push({query:h,depth:0,signal:v});(0,D.k_)({signal:v}),t.joinAttributes(_)})()}_fetchDataTile(e){var t=this;return(0,A.Z)(function*(){if(!t._downloadPromise){const _=(0,b.s3)(t._schema.featureCount,"Expected featureCount to be defined");t._downloadPromise=t._download(_)}const s=t._store.search(e),a=t._subscriptions.get(e.key.id),u=s.length-1;for(let _=0;_<u;
1_++){const m=sr(s[_],e),x={type:"append",id:e.id,addOrUpdate:m,end:!1,status:ie.empty()};a.add({query:null,message:x}),t._hasAggregates||(yield(0,D.e4)(1)),t._onMessage(x)}const c=sr(u>=0?s[u]:null,e),v={type:"append",id:e.id,addOrUpdate:c,end:t._didSendEnd,status:ie.empty()};a.add({query:null,message:v}),t._onMessage(v)})()}_download(e){var t=this;return(0,A.Z)(function*(){try{yield t.whenInitialized();const s=t._store.storage.getBitset(t._markedIdsBufId),a=new Set;s.clear();const u=Math.ceil(e/t.pageSize),c=Array.from({length:u},(h,v)=>v).sort((h,v)=>t._random.getInt()-t._random.getInt()).map(h=>t._downloadPage(h,s,a));yield Promise.all(c),t._store.sweepFeatures(s,t._store.storage),t._store.sweepFeatureSets(a)}catch(s){Qr.error("mapview-snapshot-source","Encountered and error when downloading feature snapshot",s)}t._sendEnd(),t._loading=!1})()}_downloadPage(e,t,s){var a=this;return(0,A.Z)(function*(){const u=a.pageSize,c={start:e*u,num:u,cacheHint:!0};(0,b.pC)(a.maxRecordCountFactor)&&(c.maxRecordCountFactor=a.maxRecordCountFactor);const h=a.createQuery(c),v=a._signal,_=yield a._queue.push({query:h,depth:e,signal:v});(0,D.k_)({signal:v}),a._queries.push({query:h,reader:_}),a._store.insert(_),s.add(_.instance);const m=_.getCursor();for(;m.next();)t.set(m.getDisplayId());a._send(_)})()}_send(e){if(!this._subscriptions.size)return;let t=null;const s=new Map,a=new Set,u=new Map;this._subscriptions.forEach(c=>{const h=c.tile;s.set(h.key.id,null),t=h.tileInfoView,a.add(h.level);const{row:v,col:_}=h.key,m=`${h.level}/${v}/${_}`,x=u.get(m)??[];x.push(c),u.set(m,x)});for(const c of a){const h=t.getLODInfoAt(c),v=e.getCursor();for(;v.next();){const _=Vr(v,h,c),m=v.getIndex();if(u.has(_))for(const x of u.get(_)){const w=x.tile.id;let F=s.get(w);(0,b.Wi)(F)&&(F=[],s.set(w,F)),F.push(m)}}}s.forEach((c,h)=>{if((0,b.pC)(c)){const v=this._subscriptions.get(h),_={type:"append",id:h,addOrUpdate:sr(Wr.t.from(e,c),v.tile),end:!1,status:ie.empty()};v.add({query:null,message:_}),this._onMessage(_)}})}_sendEnd(){this._subscriptions.forEach(e=>{const t={type:"append",id:e.tile.id,addOrUpdate:null,end:!0,status:ie.empty()};e.add({query:null,message:t}),this._onMessage(t)}),this._didSendEnd=!0}}var $r=T(36682);function nr(o,e,t,s){s%2&&(s+=1);let a=0,u=0,c=-90,h=90,v=-180,_=180;for(let m=0;m<s/2;m++){for(let x=0;x<5;x++){const w=(v+_)/2,F=t>w?1:0;a|=F<<29-(x+5*m),v=(1-F)*v+F*w,_=(1-F)*w+F*_}for(let x=0;x<5;x++){const w=(c+h)/2,F=e>w?1:0;u|=F<<29-(x+5*m),c=(1-F)*c+F*w,h=(1-F)*w+F*h}}o.geohashX=a,o.geohashY=u}function Xt(o,e,t,s,a){a%2&&(a+=1);let u=0,c=0,h=-90,v=90,_=-180,m=180;for(let x=0;x<a/2;x++){for(let w=0;w<5;w++){const F=(_+m)/2,M=s>F?1:0;u|=M<<29-(w+5*x),_=(1-M)*_+M*F,m=(1-M)*F+M*m}for(let w=0;w<5;w++){const F=(h+v)/2,M=t>F?1:0;c|=M<<29-(w+5*x),h=(1-M)*h+M*F,v=(1-M)*F+M*v}}o[2*e]=u,o[2*e+1]=c}new Float64Array(2),new Float64Array(2);var Xe=T(82959);class br{constructor(e=[],t,s=8096){this.onRelease=a=>{},this._nodes=0,this._root=new ar(this,0,0,0),this._statisticFields=e,this._pool=s?new Qe.Z(8096):null,this._serviceInfo=t}destroy(){this.clear()}_acquire(e,t,s){this._nodes++;let a=null;return(0,b.pC)(this._pool)&&(a=this._pool.dequeue()),(0,b.pC)(a)?a.realloc(e,t,s):a=new ar(this,e,t,s),a}_release(e){this.onRelease(e),this._nodes--,(0,b.pC)(this._pool)&&this._pool.enqueue(e)}get count(){return this._root.count}get size(){return this._nodes}get poolSize(){return(0,b.R2)(this._pool,0,e=>e.size)}get depth(){let e=0;return this.forEach(t=>e=Math.max(e,t.depth)),e}dropLevels(e){this.forEach(t=>{if(t.depth>=e)for(let s=0;s<t.children.length;s++){const a=t.children[s];a&&this._release(a)}}),this.forEach(t=>{if(t.depth>=e)for(let s=0;s<t.children.length;s++)t.children[s]=null})}clear(){this.forEach(e=>this._release(e)),this._root=new ar(this,0,0,0)}insert(e,t,s=0){const a=ye.i.fromOptimizedFeatures([e],this._serviceInfo).getCursor();a.next();const u=a.readGeometry();if(!u)return;const[c,h]=u.coords;this.insertCursor(a,e.displayId,c,h,e.geohashX,e.geohashY,t,s)}insertCursor(e,t,s,a,u,c,h,v=0){let _=this._root,m=0,x=0,w=0;for(;null!==_;){if(_.depth>=v&&(_.count+=1,_.xTotal+=s,_.yTotal+=a,_.xGeohashTotal+=u,_.yGeohashTotal+=c,_.referenceId=t,this._updateStatisticsCursor(e,_,1)),m>=h)return void _.add(t);const F=Math.ceil((m+1)/2),M=Math.floor((m+1)/2),E=1-m%2,Z=30-(3*F+2*M),L=30-(2*F+3*M),P=(u&7*E+3*(1-E)<<Z)>>Z,O=(c&3*E+7*(1-E)<<L)>>L,B=P+O*(8*E+4*(1-E));x=x<<3*E+2*(1-E)|P,w=w<<2*E+3*(1-E)|O,null==_.children[B]&&(_.children[B]=this._acquire(x,w,m+1)),m+=1,_=_.children[B]}}remove(e,t){const s=ye.i.fromOptimizedFeatures([e],this._serviceInfo).getCursor();s.next();const a=s.readGeometry();if(!a)return;const[u,c]=a.coords;this.removeCursor(s,u,c,e.geohashX,e.geohashY,t)}removeCursor(e,t,s,a,u,c){let h=this._root,v=0;for(;null!==h;){if(h.count-=1,h.xTotal-=t,h.yTotal-=s,h.xGeohashTotal-=a,h.yGeohashTotal-=u,this._updateStatisticsCursor(e,h,-1),v>=c)return void h.remove(e.getDisplayId());const _=Math.ceil((v+1)/2),m=Math.floor((v+1)/2),x=1-v%2,w=30-(3*_+2*m),F=30-(2*_+3*m),M=((a&7*x+3*(1-x)<<w)>>w)+((u&3*x+7*(1-x)<<F)>>F)*(8*x+4*(1-x)),E=h.children[M];1===E.count&&(this._release(E),h.children[M]=null),v+=1,h=E}}forEach(e){let t=this._root;for(;null!==t;){const s=this._linkChildren(t)||t.next;e(t),t=s}}find(e,t,s){return this._root.find(e,t,s,0,0,0)}findIf(e){let t=null;return this.forEach(s=>{e(s)&&(t=s)}),t}findAllIf(e){const t=[];return this.forEach(s=>{e(s)&&t.push(s)}),t}findSingleOccupancyNode(e,t,s,a,u){let c=this._root;for(;null!==c;){const h=c.depth,v=c.xNode,_=c.yNode,m=1-h%2,x=c.xGeohashTotal/c.count,w=c.yGeohashTotal/c.count;if(1===c.count&&e<x&&x<=s&&t<w&&w<=a)return c;if(h>=u){c=c.next;continue}const F=Math.ceil((h+1)/2),M=Math.floor((h+1)/2),E=30-(3*F+2*M),Z=30-(2*F+3*M),L=~((1<<E)-1),P=~((1<<Z)-1),B=(t&P)>>Z,j=(s&L)>>E,R=(a&P)>>Z,H=v<<3*m+2*(1-m),re=_<<2*m+3*(1-m),V=H+8*m+4*(1-m),J=re+4*m+8*(1-m),Y=Math.max(H,(e&L)>>E),de=Math.max(re,B),he=Math.min(V,j),ae=Math.min(J,R);let ne=null,ue=null;for(let ce=de;ce<=ae;ce++)for(let oe=Y;oe<=he;oe++){const ge=c.children[oe-H+(ce-re)*(8*m+4*(1-m))];ge&&(ne||(ne=ge,ne.next=c.next),ue&&(ue.next=ge),ue=ge,ge.next=c.next)}c=ne||c.next}return null}getRegionDisplayIds(e,t,s,a,u){let c=this._root;const h=[];for(;null!==c;){const v=c.depth,_=c.xNode,m=c.yNode;if(v>=u){const ue=c.xGeohashTotal/c.count,ce=c.yGeohashTotal/c.count;e<=ue&&ue<=s&&t<=ce&&ce<=a&&c.displayIds.forEach(oe=>h.push(oe)),c=c.next;continue}const x=Math.ceil((v+1)/2),w=Math.floor((v+1)/2),F=1-v%2,M=30-(3*x+2*w),E=30-(2*x+3*w),Z=~((1<<M)-1),L=~((1<<E)-1),O=(t&L)>>E,B=(s&Z)>>M,j=(a&L)>>E,R=_<<3*F+2*(1-F),H=m<<2*F+3*(1-F),re=R+8*F+4*(1-F),V=H+4*F+8*(1-F),J=Math.max(R,(e&Z)>>M),Y=Math.max(H,O),de=Math.min(re,B),he=Math.min(V,j);let ae=null,ne=null;for(let ue=Y;ue<=he;ue++)for(let ce=J;ce<=de;ce++){const ee=c.children[ce-R+(ue-H)*(8*F+4*(1-F))];
1ee&&(ae||(ae=ee,ae.next=c.next),ne&&(ne.next=ee),ne=ee,ee.next=c.next)}c=ae||c.next}return h}getRegionStatistics(e,t,s,a,u){let c=this._root,h=0,v=0,_=0;const m={};let x=0;for(;null!==c;){const w=c.depth,F=c.xNode,M=c.yNode;if(w>=u){const ge=c.xGeohashTotal/c.count,Ke=c.yGeohashTotal/c.count;e<ge&&ge<=s&&t<Ke&&Ke<=a&&(h+=c.count,v+=c.xTotal,_+=c.yTotal,1===c.count&&(x=c.referenceId),this._aggregateStatistics(m,c.statistics)),c=c.next;continue}const E=Math.ceil((w+1)/2),Z=Math.floor((w+1)/2),L=1-w%2,P=30-(3*E+2*Z),O=30-(2*E+3*Z),B=~((1<<P)-1),j=~((1<<O)-1),H=(t&j)>>O,re=(s&B)>>P,V=(a&j)>>O,J=F<<3*L+2*(1-L),Y=M<<2*L+3*(1-L),de=J+8*L+4*(1-L),he=Y+4*L+8*(1-L),ae=Math.max(J,(e&B)>>P),ne=Math.max(Y,H),ue=Math.min(de,re),ce=Math.min(he,V);let oe=null,ee=null;for(let ge=ne;ge<=ce;ge++)for(let Ke=ae;Ke<=ue;Ke++){const be=c.children[Ke-J+(ge-Y)*(8*L+4*(1-L))];if(be){if(ge!==ne&&ge!==ce&&Ke!==ae&&Ke!==ue){const Ar=be.xGeohashTotal/be.count,Mr=be.yGeohashTotal/be.count;e<Ar&&Ar<=s&&t<Mr&&Mr<=a&&(h+=be.count,v+=be.xTotal,_+=be.yTotal,1===c.count&&(x=c.referenceId),this._aggregateStatistics(m,be.statistics));continue}oe||(oe=be,oe.next=c.next),ee&&(ee.next=be),ee=be,be.next=c.next}}c=oe||c.next}return{count:h,attributes:this.normalizeStatistics(m,h),xTotal:v,yTotal:_,referenceId:x}}getBins(e,t,s,a,u){const c=[];let h=this._root;for(;null!==h;){const v=h.depth,_=h.xNode,m=h.yNode;if(v>=u){c.push(h),h=h.next;continue}const x=Math.ceil((v+1)/2),w=Math.floor((v+1)/2),F=1-v%2,M=30-(3*x+2*w),E=30-(2*x+3*w),Z=~((1<<M)-1),L=~((1<<E)-1),O=(t&L)>>E,B=(s&Z)>>M,j=(a&L)>>E,R=_<<3*F+2*(1-F),H=m<<2*F+3*(1-F),re=R+8*F+4*(1-F),V=H+4*F+8*(1-F),J=Math.max(R,(e&Z)>>M),Y=Math.max(H,O),de=Math.min(re,B),he=Math.min(V,j);let ae=null,ne=null;for(let ue=Y;ue<=he;ue++)for(let ce=J;ce<=de;ce++){const ee=h.children[ce-R+(ue-H)*(8*F+4*(1-F))];ee&&(ae||(ae=ee,ae.next=h.next),ne&&(ne.next=ee),ne=ee,ee.next=h.next)}h=ae||h.next}return c}_linkChildren(e){let t=null,s=null;for(let a=0;a<=e.children.length;a++){const u=e.children[a];u&&(t||(t=u,t.next=e.next),s&&(s.next=u),s=u,u.next=e.next)}return t}_updateStatisticsCursor(e,t,s){for(const a of this._statisticFields){const u=a.name,c=a.inField?e.readAttribute(a.inField):e.getComputedNumericAtIndex(a.inFieldIndex);switch(a.statisticType){case"norm":{t.statistics[u]||(t.statistics[u]={});const v=e.readAttribute(a.inNormalizationField),_=t.statistics[u].onStatisticField||0,m=t.statistics[u].onStatisticNormalizationField||0;null==c||isNaN(c)||null==v||0===v||isNaN(v)||(t.statistics[u].onStatisticField=_+s*c,t.statistics[u].onStatisticNormalizationField=m+s*v);break}case"sum":case"avg":{t.statistics[u]||(t.statistics[u]={value:0,nanCount:0});const h=t.statistics[u].value,v=t.statistics[u].nanCount;null==c||isNaN(c)?t.statistics[u].nanCount=v+s:t.statistics[u].value=h+s*c;break}case"avg_angle":{t.statistics[u]||(t.statistics[u]={x:0,y:0,nanCount:0});const h=t.statistics[u].x,v=t.statistics[u].y,_=t.statistics[u].nanCount,m=Math.PI/180;null==c||isNaN(c)?t.statistics[u].nanCount=_+s:(t.statistics[u].x=h+s*Math.cos(c*m),t.statistics[u].y=v+s*Math.sin(c*m));break}case"mode":t.statistics[u]||(t.statistics[u]={}),t.statistics[u][c]=(t.statistics[u][c]||0)+s}}}_aggregateStatistics(e,t){for(const s of this._statisticFields){const a=s.name;switch(s.statisticType){case"sum":case"avg":case"avg_angle":case"mode":case"norm":e[a]||(e[a]={});for(const u in t[a])e[a][u]=(e[a][u]||0)+t[a][u]}}}normalizeStatistics(e,t){const s={};for(const a of this._statisticFields){const u=a.name;switch(a.statisticType){case"norm":{const c=e[u];if(t&&null==c.onStatisticNormalizationField)break;if(t&&c.onStatisticNormalizationField){s[u]=c.onStatisticField/c.onStatisticNormalizationField;break}s[u]=0;break}case"sum":{if(!t)break;const{value:c,nanCount:h}=e[u];if(!(t-h))break;s[u]=c;break}case"avg":{if(!t)break;const{value:c,nanCount:h}=e[u];if(!(t-h))break;s[u]=c/(t-h);break}case"avg_angle":{if(!t)break;const{x:c,y:h,nanCount:v}=e[u];if(!(t-v))break;const x=180/Math.PI,w=Math.atan2(h/(t-v),c/(t-v))*x;s[u]=w;break}case"mode":{const c=e[u];let h=0,v=null;for(const _ in c){const m=c[_];m>
1h&&(h=m,v=_)}s[u]="null"===v?null:v;break}}}return s}}class ar{constructor(e,t,s,a){this.count=0,this.xTotal=0,this.yTotal=0,this.statistics={},this.displayId=0,this.referenceId=0,this.displayIds=new Set,this.next=null,this.depth=0,this.xNode=0,this.yNode=0,this.xGeohashTotal=0,this.yGeohashTotal=0,this._tree=e,this.children=new Array(32);for(let u=0;u<this.children.length;u++)this.children[u]=null;this.xNode=t,this.yNode=s,this.depth=a}realloc(e,t,s){for(let a=0;a<this.children.length;a++)this.children[a]=null;return this.xNode=e,this.yNode=t,this.depth=s,this.next=null,this.xGeohashTotal=0,this.yGeohashTotal=0,this.displayId=0,this.referenceId=0,this.xTotal=0,this.yTotal=0,this.count=0,this.statistics={},this.displayIds.clear(),this}get id(){return`${this.xNode}.${this.yNode}`}add(e){this.displayIds.add(e)}remove(e){this.displayIds.delete(e)}getAttributes(){const e=this._tree.normalizeStatistics(this.statistics,this.count);return e.aggregateId=this.id,e.aggregateCount=this.count,e}getGeometry(e,t){const s=this.getLngLatBounds(),[a,u,c,h]=s,v=(0,Xe.iV)({rings:[[[a,u],[a,h],[c,h],[c,u],[a,u]]]},Le.Z.WGS84,e),_=(0,X.Uy)(new _e.Z,v,!1,!1);return(0,b.pC)(t)?(0,X.Nh)(new _e.Z,_,!1,!1,"esriGeometryPolygon",t,!1,!1):_}getLngLatBounds(){const e=this.depth,t=Math.ceil(e/2),s=Math.floor(e/2);return function es(o,e){let t=-90,s=90,a=-180,u=180;for(let c=0;c<e;c++){const h=Math.ceil((c+1)/2),v=Math.floor((c+1)/2),_=1-c%2,m=30-(3*h+2*v),x=30-(2*h+3*v),F=2*_+3*(1-_),E=(7*_+3*(1-_)<<m&o.geohashX)>>m,Z=(3*_+7*(1-_)<<x&o.geohashY)>>x;for(let L=3*_+2*(1-_)-1;L>=0;L--){const P=(a+u)/2,O=E&1<<L?1:0;a=(1-O)*a+O*P,u=(1-O)*P+O*u}for(let L=F-1;L>=0;L--){const P=(t+s)/2,O=Z&1<<L?1:0;t=(1-O)*t+O*P,s=(1-O)*P+O*s}}return[a,t,u,s]}({geohashX:this.xNode<<30-(3*t+2*s),geohashY:this.yNode<<30-(2*t+3*s)},this.depth)}find(e,t,s,a,u,c){if(a>=s)return this;const h=1-a%2,v=3*h+2*(1-h),_=2*h+3*(1-h),m=30-u-v,x=30-c-_,F=this.children[((e&7*h+3*(1-h)<<m)>>m)+((t&3*h+7*(1-h)<<x)>>x)*(8*h+4*(1-h))];return null==F?null:F.find(e,t,s,a+1,u+v,c+_)}}
1var $e=T(94425),ur=T(99666),xr=T(16669),is=T(37118),ns=T(2004);const cr=Me.Z.getLogger("esri.view.2d.layers.features.support.BinStore");function Fr(o){return 57.29577951308232*o}class us extends xr.J{constructor(e,t,s,a){super(e,s),this._geohashLevel=5,this._geohashBuf=[],this._serviceInfo=a,this.geometryInfo=e.geometryInfo,this._spatialReference=t,this._projectionSupportCheck=(0,Xe._W)(t,Le.Z.WGS84),this._bitsets.geohash=s.getBitset(s.createBitset()),this._bitsets.inserted=s.getBitset(s.createBitset())}destroy(){this._tree&&this._tree.destroy()}updateSchema(e,t){var s=()=>super.updateSchema,a=this;return(0,A.Z)(function*(){const u=a._schema;try{yield s().call(a,e,t),yield a._projectionSupportCheck}catch{}const c=(0,Se.Hg)(u,t);t&&(!(0,b.Wi)(c)||e.source||e.storage.filters)?(((0,Se.uD)(c,"params.fields")||(0,Se.uD)(c,"params")||!a._tree||e.source)&&(a._tree&&a._tree.destroy(),a._tree=new br(a._statisticFields,a._serviceInfo),a._tree.onRelease=h=>h.displayId&&a._storage.releaseDisplayId(h.displayId),a._geohashLevel=a._schema.params.fixedBinLevel,a._rebuildTree(),(0,G.Z)("esri-2d-update-debug")&&cr.info("Aggregate mesh needs update due to tree changing")),(0,G.Z)("esri-2d-update-debug")&&cr.info("Aggregate mesh needs update due to tree changing"),e.targets[t.name]=!0,e.mesh=!1):u&&(e.mesh=!0)})()}clear(){this._rebuildTree()}sweepFeatures(e,t){this._bitsets.inserted.forEachSet(s=>{if(!e.has(s)){const a=t.lookupByDisplayIdUnsafe(s);this._remove(a)}})}sweepAggregates(e,t,s){}onTileData(e,t,s,a,u=!0){if(!this._schema||(0,b.Wi)(t.addOrUpdate))return t;const c=this._getTransforms(e,this._spatialReference);{const v=t.addOrUpdate.getCursor();for(;v.next();)this._update(v,a)}if(t.status.mesh||!u)return t;const h=new Array;this._getBinsForTile(h,e,c,s),t.addOrUpdate=ye.i.fromOptimizedFeatures(h,{...this._serviceInfo,geometryType:"esriGeometryPolygon"}),t.addOrUpdate.attachStorage(s),t.clear=!0,t.end=!0;{const v=t.addOrUpdate.getCursor();for(;v.next();){const _=v.getDisplayId();this._bitsets.computed.unset(_),this.setComputedAttributes(s,v,_,e.scale)}}return t}forEach(e){this._tree.forEach(e)}onTileUpdate(e){}getAggregate(e){const t=(0,ur.QS)(e,!0),s=this._tree.findIf(a=>a.displayId===t);return(0,b.yw)(s,a=>this._toAggregateGraphic(a))}getAggregates(){return this._tree.findAllIf(e=>e.depth===this._geohashLevel).map(this._toAggregateGraphic.bind(this))}getDisplayId(e){const t=this._tree.findIf(s=>s.id===e);return(0,b.yw)(t,s=>s.displayId)}getFeatureDisplayIdsForAggregate(e){const t=this._tree.findIf(s=>s.id===e);return(0,b.R2)(t,[],s=>Array.from(s.displayIds))}getDisplayIdForReferenceId(e){const t=this._tree.findIf(s=>1===s.displayIds.size&&s.displayIds.has(e));return(0,b.yw)(t,s=>s.displayId)}_toAggregateGraphic(e){const t=this._spatialReference;return{referenceId:null,objectId:e.id,displayId:e.displayId,attributes:e.getAttributes(),geometry:(0,X.di)(e.getGeometry(t),"esriGeometryPolygon",!1,!1),centroid:null}}_rebuildTree(){this._bitsets.computed.clear(),this._bitsets.inserted.clear(),this._tree&&this._tree.clear()}_remove(e){const t=e.getDisplayId(),s=e.getXHydrated(),a=e.getYHydrated(),u=this._geohashBuf[2*t],c=this._geohashBuf[2*t+1];this._bitsets.inserted.has(t)&&(this._bitsets.inserted.unset(t),this._tree.removeCursor(e,s,a,u,c,this._geohashLevel))}_update(e,t){const s=e.getDisplayId(),a=this._bitsets.inserted,u=t.isVisible(s);if(u===a.has(s))return;if(!u)return void this._remove(e);const c=e.getXHydrated(),h=e.getYHydrated();this._setGeohash(s,c,h)&&(this._tree.insertCursor(e,s,c,h,this._geohashBuf[2*s],this._geohashBuf[2*s+1],this._geohashLevel),a.set(s))}_setGeohash(e,t,s){if(this._bitsets.geohash.has(e))return!0;const a=this._geohashBuf;if(this._spatialReference.isWebMercator){const u=Fr(t/$e.sv.radius),c=u-360*Math.floor((u+180)/360);Xt(a,e,Fr(Math.PI/2-2*Math.atan(Math.exp(-s/$e.sv.radius))),c,12)}else{const u=(0,Xe.iV)({x:t,y:s},this._spatialReference,Le.Z.WGS84);
1if(!u)return!1;Xt(a,e,u.y,u.x,12)}return this._bitsets.geohash.set(e),!0}_getBinsForTile(e,t,s,a){try{const{xLL:u,yLL:c,xTR:h,yTR:v,level:_}=this._getGeohashBounds(t),m=this._tree.getBins(u,c,h,v,_);for(const x of m){x.displayId||(x.displayId=a.createDisplayId(!0));const w=x.getGeometry(this._spatialReference,s.tile),F=new Be.u_(w,x.getAttributes());F.objectId=x.id,F.displayId=x.displayId,e.push(F)}}catch{return void cr.error("Unable to get bins for tile",t.key.id)}}_getGeohash(e,t,s){const a={geohashX:0,geohashY:0};return nr(a,t,e,s),a}_getGeohashBounds(e){const t=this._getGeohashLevel(e.key.level),a=is.Z.fromExtent(ns.Z.fromBounds([e.extent.xmin,e.extent.ymin,e.extent.xmax,e.extent.ymax],this._spatialReference)),u=(0,Xe.iV)(a,this._spatialReference,Le.Z.WGS84,{densificationStep:64*e.resolution}),c=(0,X.Uy)(new _e.Z,u,!1,!1),h=c.coords.filter((E,Z)=>!(Z%2)),v=c.coords.filter((E,Z)=>Z%2),_=Math.min(...h),m=Math.min(...v),x=Math.max(...h),w=Math.max(...v),F=this._getGeohash(_,m,t),M=this._getGeohash(x,w,t);return{xLL:F.geohashX,yLL:F.geohashY,xTR:M.geohashX,yTR:M.geohashY,level:t}}_getGeohashLevel(e){return this._schema.params.fixedBinLevel}_getTransforms(e,t){const s={originPosition:"upperLeft",scale:[e.resolution,e.resolution],translate:[e.bounds[0],e.bounds[3]]},a=(0,Ne.C5)(t);if(!a)return{tile:s,left:null,right:null};const[u,c]=a.valid;return{tile:s,left:{...s,translate:[c,e.bounds[3]]},right:{...s,translate:[u-c+e.bounds[0],e.bounds[3]]}}}}var we=T(39351);class lr extends Be.nd{constructor(e,t,s,a,u){super(new _e.Z([],[t,s]),a,null,e),this.geohashBoundsInfo=u}get count(){return this.attributes.cluster_count}static create(e,t,s,a,u,c,h,v){const _=new lr(t,s,a,c,h);return _.displayId=e.createDisplayId(!0),_.referenceId=v,_.tileLevel=u,_}update(e,t,s,a,u,c){return this.geometry.coords[0]=e,this.geometry.coords[1]=t,this.tileLevel=s,this.attributes=a,this.geohashBoundsInfo=u,this.referenceId=null,this.referenceId=c,this}toJSON(){return{objectId:this.objectId,referenceId:1===this.attributes.cluster_count?this.referenceId:null,attributes:{...this.attributes,clusterId:this.objectId},geometry:{x:this.geometry.coords[0],y:this.geometry.coords[1]}}}}function St(o){return 57.29577951308232*o}class cs extends xr.J{constructor(e,t,s,a){super(e,s),this.events=new ot.Z,this._geohashLevel=0,this._tileLevel=0,this._aggregateValueRanges={},this._aggregateValueRangesChanged=!1,this._geohashBuf=[],this._clusters=new Map,this._tiles=new Map,this._serviceInfo=a,this.geometryInfo=e.geometryInfo,this._spatialReference=t,this._projectionSupportCheck=(0,Xe._W)(t,Le.Z.WGS84),this._bitsets.geohash=s.getBitset(s.createBitset()),this._bitsets.inserted=s.getBitset(s.createBitset())}destroy(){this._tree.destroy()}updateSchema(e,t){var s=()=>super.updateSchema,a=this;return(0,A.Z)(function*(){const u=a._schema;try{yield s().call(a,e,t),yield a._projectionSupportCheck}catch{}const c=(0,Se.Hg)(u,t);t&&(!(0,b.Wi)(c)||e.source||e.storage.filters)?(((0,Se.uD)(c,"params.fields")||!a._tree||e.source)&&(a._tree&&a._tree.destroy(),a._tree=new br(a._statisticFields,a._serviceInfo),a._rebuildTree(),(0,G.Z)("esri-2d-update-debug")&&console.debug("Aggregate mesh needs update due to tree changing")),(0,G.Z)("esri-2d-update-debug")&&console.debug("Applying Update - ClusterStore:",c),e.targets[t.name]=!0,e.mesh=!1,a._aggregateValueRanges={}):u&&(e.mesh=!0)})()}clear(){this._rebuildTree()}sweepFeatures(e,t){this._bitsets.inserted.forEachSet(s=>{if(!e.has(s)){const a=t.lookupByDisplayIdUnsafe(s);this._remove(a)}})}sweepAggregates(e,t,s){this._clusters.forEach((a,u)=>{a&&a.tileLevel!==s&&(e.releaseDisplayId(a.displayId),t.unsetAttributeData(a.displayId),this._clusters.delete(u))})}onTileData(e,t,s,a,u=!0){if(!this._schema||(0,b.Wi)(t.addOrUpdate))return t;const c=this._getTransforms(e,this._spatialReference);{const _=t.addOrUpdate.getCursor();for(;_.next();)this._update(_,a)}if(t.status.mesh||!u)return t;const h=new Array;this._getClustersForTile(h,e,this._schema.params.clusterRadius,s,c),t.addOrUpdate=ye.i.fromOptimizedFeatures(h,this._serviceInfo),t.addOrUpdate.attachStorage(s),t.clear=!0,t.end=!0;{const _=t.addOrUpdate.getCursor();for(;_.next();){const m=_.getDisplayId();this._bitsets.computed.unset(m),this.setComputedAttributes(s,_,m,e.scale)}}return this._aggregateValueRangesChanged&&t.end&&(this.events.emit("valueRangesChanged",{valueRanges:this._aggregateValueRanges}),this._aggregateValueRangesChanged=!1),t}onTileUpdate({added:e,removed:t}){if(e.length){const a=e[0].level;this._tileLevel=a,this._setGeohashLevel(a)}if(!this._schema)return;const s=this._schema.params.clusterRadius;t.forEach(a=>
1{this._tiles.delete(a.key.id),this._markTileClustersForDeletion(a,s)})}getAggregate(e){for(const t of this._clusters.values())if((t?.displayId&ur._I)==(e&ur._I))return t.toJSON();return null}getAggregates(){const e=[];for(const t of this._clusters.values())t?.tileLevel===this._tileLevel&&e.push(t.toJSON());return e}getDisplayId(e){const t=this._clusters.get(e);return t?t.displayId:null}getFeatureDisplayIdsForAggregate(e){const t=this._clusters.get(e);if(!t)return[];const s=t.geohashBoundsInfo;return this._tree.getRegionDisplayIds(s.xLL,s.yLL,s.xTR,s.yTR,s.level)}getDisplayIdForReferenceId(e){for(const t of this._clusters.values())if(t?.referenceId===e)return t.displayId;return null}getAggregateValueRanges(){return this._aggregateValueRanges}forEach(e){for(const[t,s]of this._clusters)s&&e(s,t)}size(){let e=0;return this.forEach(t=>e++),e}_rebuildTree(){this._bitsets.computed.clear(),this._bitsets.inserted.clear(),this._tree&&this._tree.clear()}_remove(e){const t=e.getDisplayId(),s=e.getXHydrated(),a=e.getYHydrated(),u=this._geohashBuf[2*t],c=this._geohashBuf[2*t+1];this._bitsets.inserted.has(t)&&(this._bitsets.inserted.unset(t),this._tree.removeCursor(e,s,a,u,c,this._geohashLevel))}_update(e,t){const s=e.getDisplayId(),a=this._bitsets.inserted,u=t.isVisible(s);if(u===a.has(s))return;if(!u)return void this._remove(e);const c=e.getXHydrated(),h=e.getYHydrated();this._setGeohash(s,c,h)&&(this._tree.insertCursor(e,s,c,h,this._geohashBuf[2*s],this._geohashBuf[2*s+1],this._geohashLevel),a.set(s))}_setGeohash(e,t,s){if(this._bitsets.geohash.has(e))return!0;const a=this._geohashBuf;if(this._spatialReference.isWebMercator){const u=St(t/$e.sv.radius),c=u-360*Math.floor((u+180)/360);Xt(a,e,St(Math.PI/2-2*Math.atan(Math.exp(-s/$e.sv.radius))),c,12)}else{const u=(0,Xe.iV)({x:t,y:s},this._spatialReference,Le.Z.WGS84);
1if(!u)return!1;Xt(a,e,u.y,u.x,12)}return this._bitsets.geohash.set(e),!0}_getClustersForTile(e,t,s,a,u,c=!0){const h=this._schema.params.clusterPixelBuffer,v=2*s,_=this._getGeohashLevel(t.key.level),m=Math.ceil(2**t.key.level*we.I_/v),x=Math.ceil(h/v)+0,w=Math.ceil(we.I_/v),{row:F,col:M}=t.key,Z=F*we.I_,L=Math.floor(M*we.I_/v)-x,P=Math.floor(Z/v)-x,O=L+w+2*x,B=P+w+2*x,j=t.tileInfoView.getLODInfoAt(t.key.level);for(let R=L;R<=O;R++)for(let H=P;H<=B;H++){let re=R;j.wrap&&(re=R<0?R+m:R%m);const V=j.wrap&&R<0,J=j.wrap&&R%m!==R,Y=this._lookupCluster(a,j,t.key.level,re,H,_);if((0,b.pC)(Y)){const de=(0,b.yw)(u,he=>V?he.left:J?he.right:he.tile);if(c&&(0,b.Wi)(de)||!Y.count)continue;if((0,b.pC)(de)&&c){const he=Y.geometry.clone();let ae=Y.attributes;he.coords[0]=(0,X.Jd)(de,he.coords[0]),he.coords[1]=(0,X.IN)(de,he.coords[1]),1===Y.count&&(0,b.pC)(Y.referenceId)&&(ae={...Y.attributes,referenceId:Y.referenceId});const ne=new Be.u_(he,ae);ne.displayId=Y.displayId,e.push(ne)}}}}_getGeohashLevel(e){return Math.min(Math.ceil(e/2+2),12)}_setGeohashLevel(e){const t=this._getGeohashLevel(e),s=1*(Math.floor(t/1)+1)-1;if(this._geohashLevel!==s)return this._geohashLevel=s,this._rebuildTree(),void this._bitsets.geohash.clear()}_getTransforms(e,t){const s={originPosition:"upperLeft",scale:[e.resolution,e.resolution],translate:[e.bounds[0],e.bounds[3]]},a=(0,Ne.C5)(t);if(!a)return{tile:s,left:null,right:null};const[u,c]=a.valid;return{tile:s,left:{...s,translate:[c,e.bounds[3]]},right:{...s,translate:[u-c+e.bounds[0],e.bounds[3]]}}}_getClusterId(e,t,s){return(15&e)<<28|(16383&t)<<14|16383&s}_markForDeletion(e,t,s){const a=this._getClusterId(e,t,s);this._clusters.delete(a)}_getClusterBounds(e,t,s){const a=this._schema.params.clusterRadius,u=2*a;let c=s%2?t*u:t*u-a;const h=s*u;let v=c+u;const m=2**e.level*we.I_;e.wrap&&c<0&&(c=0),e.wrap&&v>m&&(v=m);const w=h/we.I_,F=v/we.I_,M=(h-u)/we.I_;return[e.getXForColumn(c/we.I_),e.getYForRow(w),e.getXForColumn(F),e.getYForRow(M)]}_lookupCluster(e,t,s,a,u,c){const h=this._getClusterId(s,a,u),v=this._clusters.get(h),[_,m,x,w]=this._getClusterBounds(t,a,u),F={x:_,y:m},M={x,y:w};let E=0,Z=0,L=0,P=0;if(this._spatialReference.isWebMercator){{const ee=St(F.x/$e.sv.radius);E=ee-360*Math.floor((ee+180)/360),Z=St(Math.PI/2-2*Math.atan(Math.exp(-F.y/$e.sv.radius)))}{const ee=St(M.x/$e.sv.radius);L=ee-360*Math.floor((ee+180)/360),P=St(Math.PI/2-2*Math.atan(Math.exp(-M.y/$e.sv.radius)))}}else{const ee=(0,Xe.iV)(F,this._spatialReference,Le.Z.WGS84),ge=(0,Xe.iV)(M,this._spatialReference,Le.Z.WGS84);
1if(!ee||!ge)return null;E=ee.x,Z=ee.y,L=ge.x,P=ge.y}const O={geohashX:0,geohashY:0},B={geohashX:0,geohashY:0};nr(O,Z,E,c),nr(B,P,L,c);const j=O.geohashX,R=O.geohashY,H=B.geohashX,re=B.geohashY,V={xLL:j,yLL:R,xTR:H,yTR:re,level:c},J=this._tree.getRegionStatistics(j,R,H,re,c),{count:Y,xTotal:de,yTotal:he,referenceId:ae}=J,ne=Y?de/Y:0,ue=Y?he/Y:0;if(0===Y)return this._clusters.set(h,null),null;const ce={cluster_count:Y,...J.attributes},oe=(0,b.pC)(v)?v.update(ne,ue,s,ce,V,ae):lr.create(e,h,ne,ue,s,ce,V,ae);return 0===Y&&(oe.geometry.coords[0]=(_+x)/2,oe.geometry.coords[1]=(m+w)/2),this._clusters.set(h,oe),this._updateAggregateValueRangeForCluster(oe,oe.tileLevel),oe}_updateAggregateValueRangeForCluster(e,t){const s=this._aggregateValueRanges[t]||{minValue:1/0,maxValue:0},a=s.minValue,u=s.maxValue;s.minValue=Math.min(a,e.count),s.maxValue=Math.max(u,e.count),this._aggregateValueRanges[t]=s,a===s.minValue&&u===s.maxValue||(this._aggregateValueRangesChanged=!0)}_markTileClustersForDeletion(e,t){const s=2*t,a=Math.ceil(we.I_/s),{row:u,col:c}=e.key,v=u*we.I_,_=Math.floor(c*we.I_/s),m=Math.floor(v/s);for(let x=_;x<_+a;x++)for(let w=m;w<m+a;w++)this._markForDeletion(e.key.level,x,w)}}var hs=T(93872);function Je(o){if(!(0,D.D_)(o)&&!function ps(o){return"worker:port-closed"===o.name}(o))throw o}function wr(o){return"feature"===o.type&&"snapshot"===o.mode}let Ue=class extends te.r{constructor(){super(...arguments),this._storage=new hs.O,this._markedIdsBufId=this._storage.createBitset(),this._lastCleanup=performance.now(),this._cleanupNeeded=!1,this._invalidated=!1,this._tileToResolver=new Map,this._didEdit=!1,this._updateVersion=1,this.tileStore=null,this.config=null,this.processor=null,this.remoteClient=null,this.service=null}initialize(){this._initStores(),this._initSource(),this._updateQueue=new at.e({concurrency:"geoevent"===this._source.type?1:4,process:(o,e)=>this._onTileMessage(o,{signal:e})}),this.handles.add([this.tileStore.on("update",this.onTileUpdate.bind(this)),(0,se.gx)(()=>!this.updating,()=>this.onIdle())]),this._checkUpdating=setInterval(()=>this.notifyChange("updating"),300)}_initSource(){this._source=function Yr(o,e,t,s,a,u){const c=function Xr(o,e,t,s,a,u){switch(o.type){case"snapshot":return{type:"feature",origin:"snapshot",featureCount:(0,b.Pt)(o.featureCount,0),serviceInfo:o,onMessage:s,outSR:e,tileInfoView:t,canAcceptRequest:a,store:u};case"stream":return{type:"geoevent",serviceInfo:o,onMessage:s,outSR:e,canAcceptRequest:a};case"memory":case"on-demand":return{type:"feature",serviceInfo:o,onMessage:s,outSR:e,origin:function c(h){return Array.isArray(h)?"local":"path"in h&&(0,ve.M8)(h.path)?"hosted":"unknown"}(o.source),tileInfoView:t,canAcceptRequest:a}}}(o,e,t,s,a,u);switch(c.type){case"feature":switch(c.origin){case"hosted":case"local":return new jr(c);case"snapshot":return new Hr(c);case"unknown":return new er(c)}case"geoevent":return new Br(c)}}(this.service,this.spatialReference,this.tileStore.tileScheme,(s,a)=>(this._invalidated=!0,this._patchTile(s,a)),()=>this._updateQueue.length<50,this.featureStore),this._proxyEvents()}_proxyEvents(){if("geoevent"===this._source.type){const o=this._source.events;this.handles.add([o.on("connectionStatus",e=>this.remoteClient.invoke("setProperty",{propertyName:"connectionStatus",value:e}).catch(Je)),o.on("errorString",e=>this.remoteClient.invoke("setProperty",{propertyName:"errorString",value:e}).catch(Je)),o.on("feature",e=>this.remoteClient.invoke("emitEvent",{name:"data-received",event:{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry}}).catch(Je)),o.on("updateRate",e=>this.remoteClient.invoke("emitEvent",{name:"update-rate",event:{...e}}).catch(Je))])}}_initAttributeStore(o){this.attributeStore?this.attributeStore.invalidateResources():this.attributeStore=new $r.Z({type:"remote",initialize:(e,t)=>(0,D.R8)(this.remoteClient.invoke("tileRenderer.featuresView.attributeView.initialize",e,{signal:t}).catch(Je)),update:(e,t)=>(0,D.R8)(this.remoteClient.invoke("tileRenderer.featuresView.attributeView.requestUpdate",e,{signal:t}).catch(Je)),render:e=>(0,D.R8)(this.remoteClient.invoke("tileRenderer.featuresView.requestRender",void 0,{signal:e}).catch(Je))},o,()=>this.notifyChange("updating"))}_initStores(){this.featureStore=new z.p({geometryInfo:{geometryType:this.service.geometryType,hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields},this._storage,"snapshot"===this.service.type?"snapshot":"on-demand")}_initQueryEngine(o){const e=this;this.queryEngine?.destroy(),this.queryEngine=new fe.q({definitionExpression:o.schema.source.definitionExpression,fields:this.service.fields,geometryType:this.service.geometryType,objectIdField:this.service.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.spatialReference.toJSON(),cacheSpatialQueries:!0,featureStore:this.featureStore,aggregateAdapter:{getFeatureObjectIds:t=>(0,b.Wi)(e.aggregateStore)?[]:e.aggregateStore.getFeatureDisplayIdsForAggregate(t).map(s=>e.getObjectId(s))},timeInfo:this.service.timeInfo})}destroy(){this._updateQueue.destroy(),this._source.destroy(),this.queryEngine.destroy(),this.attributeStore&&this.attributeStore.destroy();for(const o of this.tileStore.tiles)this._source.unsubscribe(o);clearInterval(this._checkUpdating)}get fieldsIndex(){return new tt.Z(this.service.fields)}get spatialReference(){return this.tileStore.tileScheme.spatialReference}get updating(){return this.isUpdating()}isUpdating(){const o=this._source.updating,e=!!this._updateQueue.length,t=!this.attributeStore||this.attributeStore.isUpdating(),s=o||e||t;return(0,G.Z)("esri-2d-log-updating")&&console.log(`Updating FeatureController2D: ${s}\n -> updatingSource ${o}\n -> updateQueue ${e}\n -> updatingAttributeStore ${t}\n`),s}enableEvent(o){this._source.enableEvent(o.name,o.value)}pause(){this._updateQueue.pause(),this._updateQueue.clear()}resume(){this._updateQueue.resume()}pauseStream(){"geoevent"===this._source.type&&this._source.pauseStream()}resumeStream(){"geoevent"===this._source.type&&this._source.resumeStream()}_initAggregateStore(o){const e={geometryInfo:{geometryType:this.service.geometryType,hasM:!1,hasZ:!1},spatialReference:this.spatialReference,fieldsIndex:this.fieldsIndex,fields:this.service.fields},t=o.schema.targets?.aggregate?.type;if((0,b.yw)(this.config,a=>a.schema.targets?.aggregate?.type)!==t&&((0,b.pC)(this.aggregateStore)&&(this.handles.remove("valueRangesChanged"),this.aggregateStore.destroy(),this.aggregateStore=null),t)){switch(t){case"cluster":this.aggregateStore=new cs(e,this.spatialReference,this._storage,this.service),this.handles.add(this.aggregateStore.events.on("valueRangesChanged",a=>{this.remoteClient.invoke("emitEvent",{name:"valueRangesChanged",event:{valueRanges:a.valueRanges}}).catch(Je)}),"valueRangesChanged");break;case"bin":this.aggregateStore=new us(e,this.spatialReference,this._storage,this.service)}this.aggregateStore.onTileUpdate({added:this.tileStore.tiles,removed:[]})}}update(o,e){var t=this;return(0,A.Z)(function*(){t._updateVersion++,t._initQueryEngine(e),t._initAttributeStore(e),t.pause(),yield Promise.all([t._source.update(o,e.schema.source),t.featureStore.updateSchema(o,e.schema.targets.feature),t.attributeStore.update(o,e),t.attributeStore.updateFilters(o,e,t)]),t._initAggregateStore(e),(0,b.pC)(t.aggregateStore)&&(yield t.aggregateStore.updateSchema(o,e.schema.targets.aggregate)),(0,G.Z)("esri-2d-update-debug")&&o.describe(),t._set("config",e)})()}applyUpdate(o){var e=this;return(0,A.Z)(function*(){o.version=e._updateVersion,(0,G.Z)("esri-2d-update-debug")&&console.debug(`Applying update ${o.version}`),o.mesh&&e.clearTiles(),e._updateQueue.resume(),yield e._source.applyUpdate(o),e.notifyChange("updating"),yield(0,se.N1)(()=>!e.updating),(0,b.pC)(e.aggregateStore)&&(yield(0,D.e4)(10),yield(0,se.N1)(()=>!e.updating))})()}onEdits({edits:o}){var e=this;return(0,A.Z)(function*(){(0,G.Z)("esri-2d-update-debug")&&console.debug("Applying Edit:",o),e._didEdit=!0;try{const t=o.removed.map(a=>a.objectId&&-1!==a.objectId?a.objectId:e._lookupObjectIdByGlobalId(a.globalId)),s=o.addOrModified.map(({objectId:a})=>a);
1e.featureStore.invalidate(),yield e._source.edit(s,t),e.clearTiles(),e.notifyChange("updating"),(0,b.pC)(e.aggregateStore)&&e.aggregateStore.clear(),yield e._source.resend(),yield(0,se.N1)(()=>!e.updating)}catch{}})()}refresh(o){var e=this;return(0,A.Z)(function*(){if(!o){const t=ie.empty();return t.storage.filters=!0,e.applyUpdate(t)}e.featureStore.invalidate(),e.clearTiles(),e._source.refresh(e._updateVersion),e._cleanupNeeded=!0,e.notifyChange("updating"),yield(0,se.N1)(()=>!e.updating)})()}clearTiles(){for(const o of this.tileStore.tiles)this.processor.onTileClear(o)}onTileUpdate(o){(0,b.pC)(this.aggregateStore)&&this.aggregateStore.onTileUpdate(o);for(const e of o.added)this._source.subscribe(e,this._updateVersion),this._level=e.level;for(const e of o.removed)this._source.unsubscribe(e),this._cleanupNeeded=!0,this._tileToResolver.has(e.id)&&(this._tileToResolver.get(e.id).resolve(),this._tileToResolver.delete(e.id));this.notifyChange("updating")}onIdle(){var o=this;return(0,A.Z)(function*(){o._invalidated&&(o._invalidated=!1,((0,b.pC)(o.aggregateStore)||"heatmap"===o.processor.type)&&(yield o._repushCurrentLevelTiles())),o._markAndSweep()})()}querySummaryStatistics({query:o,params:e}){var t=this;return(0,A.Z)(function*(){return t.queryEngine.executeQueryForSummaryStatistics(o,e)})()}queryUniqueValues({query:o,params:e}){var t=this;return(0,A.Z)(function*(){return t.queryEngine.executeQueryForUniqueValues(o,e)})()}queryClassBreaks({query:o,params:e}){var t=this;return(0,A.Z)(function*(){return t.queryEngine.executeQueryForClassBreaks(o,e)})()}queryHistogram({query:o,params:e}){var t=this;return(0,A.Z)(function*(){return t.queryEngine.executeQueryForHistogram(o,e)})()}queryExtent(o){return this.queryEngine.executeQueryForExtent(o)}queryFeatures(o){return this.queryEngine.executeQuery(o)}queryVisibleFeatures(o){var e=this;return(0,A.Z)(function*(){const t=yield e.queryEngine.executeQuery(o),s=t.objectIdFieldName;return t.features=t.features.filter(a=>{const c=e.getDisplayId(a.attributes[s]);return(0,b.yw)(c,h=>e.attributeStore.isVisible(h))}),t})()}queryFeatureCount(o){return this.queryEngine.executeQueryForCount(o)}queryLatestObservations(o){return this.queryEngine.executeQueryForLatestObservations(o)}queryObjectIds(o){return this.queryEngine.executeQueryForIds(o)}queryStatistics(){var o=this;return(0,A.Z)(function*(){return o.featureStore.storeStatistics})()}getObjectId(o){return this.featureStore.lookupObjectId(o,this._storage)}getDisplayId(o){if((0,b.pC)(this.aggregateStore)){const e=this.aggregateStore.getDisplayId(o);if((0,b.Wi)(e)){const t=this.featureStore.lookupDisplayId(o);return this.aggregateStore.getDisplayIdForReferenceId(t)}return e}return this.featureStore.lookupDisplayId(o)}getFeatures(o){const e=[],t=[];for(const s of o){const a=(0,b.pC)(this.aggregateStore)?this.getAggregate(s):null;if((0,b.pC)(a))if((0,b.pC)(a.referenceId)){const u=this.getFeature(a.referenceId);(0,b.pC)(u)&&e.push(u)}else t.push(a);else{const u=this.getFeature(s);(0,b.pC)(u)&&e.push(u)}}return{features:e,aggregates:t}}getFeature(o){const e=this.featureStore.lookupFeatureByDisplayId(o,this._storage);if((0,b.Wi)(e))return null;const t=e.readHydratedGeometry(),s=(0,X.di)(t,e.geometryType,e.hasZ,e.hasM);return{attributes:e.readAttributes(),geometry:s}}getAggregate(o){return(0,b.Wi)(this.aggregateStore)?null:this.aggregateStore.getAggregate(o)}getAggregates(){return(0,b.Wi)(this.aggregateStore)?[]:this.aggregateStore.getAggregates()}setHighlight(o){var e=this;return(0,A.Z)(function*(){const t=(0,b.lV)(o.map(s=>e.getDisplayId(s)));return e.attributeStore.setHighlight(o,t)})()}_lookupObjectIdByGlobalId(o){const e=this.service.globalIdField;if((0,b.Wi)(e))throw new Error("Expected globalIdField to be defined");let t=null;if(this.featureStore.forEach(s=>{o===s.readAttribute(e)&&(t=s.getObjectId())}),(0,b.Wi)(t))throw new Error(`Expected to find a feature with globalId ${o}`);return t}_repushCurrentLevelTiles(){var o=this;return(0,A.Z)(function*(){const e=o.tileStore.tiles.filter(t=>t.level===o._level).map(function(){var t=(0,A.Z)(function*(s){return o._patchTile({type:"append",
1id:s.key.id,addOrUpdate:ye.i.fromOptimizedFeatures([],o.service),remove:[],end:!0,status:ie.empty()})});return function(s){return t.apply(this,arguments)}}());yield Promise.all(e)})()}_maybeForceCleanup(){performance.now()-this._lastCleanup>5e3&&this._markAndSweep()}_patchTile(o,e){const t=this._updateQueue.push(o,e).then(()=>{this.notifyChange("updating")}).catch(s=>{this.notifyChange("updating")});return this.notifyChange("updating"),t}_onTileMessage(o,e){var t=this;return(0,A.Z)(function*(){(0,D.k_)(e);const s=t.tileStore.get(o.id);if(!s)return;if(o.clear)return t.processor.onTileClear(s);const a=o.status;t._cleanupNeeded=!0;const u=[];for(const c of o.remove){const h=t.featureStore.lookupDisplayId(c);h&&u.push(h)}o.remove=u;try{if((0,b.Wi)(o.addOrUpdate))return void t.processor.onTileMessage(s,{...o,addOrUpdate:null},(0,b.pC)(t.aggregateStore),e).catch(D.H9);if(o.addOrUpdate.setArcadeSpatialReference(t.spatialReference),t.featureStore.hasInstance(o.addOrUpdate.instance)&&a.targets.feature||(a.targets.feature=!0,t.featureStore.onTileData(s,o)),(!a.storage.data||!a.storage.filters)&&(a.storage.data=!0,a.storage.filters=!0,t.attributeStore.onTileData(s,o),"geoevent"===t._source.type||t._didEdit?(yield t.attributeStore.sendUpdates(),(0,D.k_)(e)):t.attributeStore.sendUpdates()),(0,b.pC)(t.aggregateStore)&&!a.targets.aggregate){a.targets.aggregate=!0;const c=wr(t._source)&&t._source.loading,h=!wr(t._source)||c||o.end;if(t.aggregateStore.onTileData(s,o,t._storage,t.attributeStore,h),!h)return;a.mesh||(t.attributeStore.onTileData(s,o),yield t.attributeStore.sendUpdates())}a.mesh||(a.mesh=!0,yield t.processor.onTileMessage(s,o,(0,b.pC)(t.aggregateStore),e),(0,D.k_)(e)),t._maybeForceCleanup()}catch(c){(0,D.H9)(c)}})()}_mark(o,e,t){const s=(4294901760&this._storage.getInstanceId(o))>>>16;o&&(e.add(s),t.set(o))}_markAndSweep(){if(this._lastCleanup=performance.now(),"feature"===this._source.type&&"snapshot"===this._source.mode||"geoevent"!==this._source.type&&!this._cleanupNeeded)return;this._cleanupNeeded=!1;const o=this._storage.getBitset(this._markedIdsBufId),e=new Set;o.clear();for(const t of this.tileStore.tiles)for(const s of this._source.readers(t.id)){const a=s.getCursor();for(;a.next();){let u=a.getDisplayId();if(!u){const c=a.getObjectId();u=this.featureStore.lookupDisplayId(c)}this._mark(u,e,o)}}"symbol"===this.processor.type&&this.processor.forEachBufferId(t=>{this._mark(t,e,o)}),this._updateQueue.forEach(t=>{for(const s of t.remove){const a=this.featureStore.lookupDisplayId(s);this._mark(a,e,o)}}),(0,b.pC)(this.aggregateStore)&&(this.aggregateStore.sweepFeatures(o,this.featureStore),"sweepAggregates"in this.aggregateStore&&this.aggregateStore.sweepAggregates(this._storage,this.attributeStore,this._level)),this.featureStore.sweepFeatures(o,this._storage,this.attributeStore),this.featureStore.sweepFeatureSets(e)}};(0,Q._)([(0,U.Cb)({constructOnly:!0})],Ue.prototype,"tileStore",void 0),(0,Q._)([(0,U.Cb)()],Ue.prototype,"config",void 0),(0,Q._)([(0,U.Cb)({readOnly:!0})],Ue.prototype,"fieldsIndex",null),(0,Q._)([(0,U.Cb)()],Ue.prototype,"processor",void 0),(0,Q._)([(0,U.Cb)({constructOnly:!0})],Ue.prototype,"remoteClient",void 0),(0,Q._)([(0,U.Cb)({constructOnly:!0})],Ue.prototype,"service",void 0),(0,Q._)([(0,U.Cb)()],Ue.prototype,"spatialReference",null),(0,Q._)([(0,U.Cb)()],Ue.prototype,"updating",null),Ue=(0,Q._)([(0,C.j)("esri.views.2d.layers.features.controllers.FeatureController2D")],Ue);const ys=Ue;var _s=T(56656),ms=T(9598);let ut=class extends te.r{constructor(){super(...arguments),this.controller=null,this.processor=null,this.remoteClient=null,this.tileStore=null,this.service=null,this.viewState=null,this._paused=!1,this._pendingTileUpdates=[]}initialize(){this.handles.add((0,se.YP)(()=>this.updating,o=>{this.remoteClient.invoke("setUpdating",o).catch(e=>{})}))}destroy(){this.stop(),this.controller?.destroy(),this.processor?.destroy(),this.controller=this.processor=this.tileStore=this.remoteClient=null}get updating(){return!this.controller||this.controller.updating}stop(){this._paused=!0,Array.isArray(this.service?.source)&&(this.service.source.forEach(o=>o.close()),this.service.source.length=0),this.tileStore?.updateTiles({added:[],removed:this.tileStore.tiles.map(o=>o.id)}),this.tileStore?.destroy(),this.tileStore=null,this._pendingTileUpdates.length=0}startup({service:o,config:e,tileInfo:t,tiles:s}){var a=this;return(0,A.Z)(function*(){if(a._paused=!0,Array.isArray(a.service?.source)&&(a.service.source.forEach(u=>u.close()),a.service.source.length=0),a.service=o,!a.tileStore||!(0,Ne.fS)(a.tileStore.tileScheme.spatialReference,t.spatialReference)){const u=new ms.Z(Ge.Z.fromJSON(t));s.added.length=s.removed.length=0,a.tileStore?.updateTiles({added:[],removed:a.tileStore.tiles.map(c=>c.id)}),a.tileStore?.destroy(),a.tileStore=new _s.Z(u),a._pendingTileUpdates.length=0}for(yield a._createProcessorAndController(e),yield a.update({config:e}),a.controller.resume(),a.tileStore.clear(),a.tileStore.updateTiles(s),a._paused=!1;
1a._pendingTileUpdates.length;)a.tileStore.updateTiles(a._pendingTileUpdates.pop())})()}updateTiles(o){var e=this;return(0,A.Z)(function*(){e._paused?e._pendingTileUpdates.push(o):e.tileStore.updateTiles(o)})()}update({config:o}){var e=this;return(0,A.Z)(function*(){const t=ie.empty();return yield Promise.all([e.processor.update(t,o),e.controller.update(t,o)]),t.toJSON()})()}applyUpdate(o){var e=this;return(0,A.Z)(function*(){return e.controller.applyUpdate(ie.create(o))})()}_createProcessorAndController(o){var e=this;return(0,A.Z)(function*(){yield Promise.all([e._handleControllerConfig(o),e._handleProcessorConfig(o)]),e.controller.processor=e.processor})()}_handleControllerConfig(o){var e=this;return(0,A.Z)(function*(){return e._createController(e.service,o)})()}_handleProcessorConfig(o){var e=this;return(0,A.Z)(function*(){return e._createProcessor(e.service,o)})()}_createController(o,e){var t=this;return(0,A.Z)(function*(){t.controller&&t.controller.destroy();const{tileStore:s,remoteClient:a}=t,u=new ys({service:o,tileStore:s,remoteClient:a});return t.controller=u,u})()}_createProcessor(o,e){var t=this;return(0,A.Z)(function*(){const s=e.schema.processors[0].type,a=(yield function N(o){return"heatmap"===o?Promise.all([T.e(8592),T.e(7434)]).then(T.bind(T,67434)):Promise.all([T.e(3751),T.e(5909),T.e(4175),T.e(4522),T.e(1619),T.e(8592),T.e(7118)]).then(T.bind(T,61517))}(s)).default,{remoteClient:u,tileStore:c}=t,h=new a({service:o,config:e,tileStore:c,remoteClient:u});return t.processor&&t.processor.destroy(),t.processor=h,h})()}};(0,Q._)([(0,U.Cb)()],ut.prototype,"controller",void 0),(0,Q._)([(0,U.Cb)()],ut.prototype,"processor",void 0),(0,Q._)([(0,U.Cb)()],ut.prototype,"updating",null),(0,Q._)([(0,U.Cb)()],ut.prototype,"viewState",void 0),ut=(0,Q._)([(0,C.j)("esri.views.2d.layers.features.Pipeline")],ut);const vs=ut},40852:(et,pe,T)=>{T.d(pe,{G:()=>A});class A{constructor(te,G,se,U,q,xe=!1,C=0){this.name=te,this.count=G,this.type=se,this.offset=U,this.stride=q,this.normalized=xe,this.divisor=C}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.