@arcgis/core 4.32.0-next.20250103 → 4.32.0-next.20250104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[6020],{40804:(t,e,s)=>{s.d(e,{U:()=>i});var r=s(34727);function i(t,e,s=0){const i=(0,r.qE)(t,0,a);for(let t=0;t<4;t++)e[s+t]=Math.floor(256*h(i*n[t]))}const n=[1,256,65536,16777216],o=[1/256,1/65536,1/16777216,1/4294967296],a=function(t,e=0){let s=0;for(let r=0;r<4;r++)s+=t[e+r]*o[r];return s}(new Uint8ClampedArray([255,255,255,255]));function h(t){return t-Math.floor(t)}},88340:(t,e,s)=>{function r(){return new Float32Array(2)}function i(t,e){const s=new Float32Array(2);return s[0]=t,s[1]=e,s}function n(){return r()}function o(){return i(1,1)}function a(){return i(1,0)}function h(){return i(0,1)}s.d(e,{Un:()=>l,fA:()=>i,uY:()=>c,vt:()=>r});const c=n(),l=o(),u=a(),d=h();Object.freeze(Object.defineProperty({__proto__:null,ONES:l,UNIT_X:u,UNIT_Y:d,ZEROS:c,clone:function(t){const e=new Float32Array(2);return e[0]=t[0],e[1]=t[1],e},create:r,createView:function(t,e){return new Float32Array(t,e,2)},fromValues:i,ones:o,unitX:a,unitY:h,zeros:n},Symbol.toStringTag,{value:"Module"}))},48163:(t,e,s)=>{function r(){return[0,0]}function i(t,e){return[t,e]}function n(){return i(1,1)}function o(){return i(1,0)}function a(){return i(0,1)}s.d(e,{Un:()=>h,fA:()=>i,vt:()=>r});const h=n(),c=o(),l=a();Object.freeze(Object.defineProperty({__proto__:null,ONES:h,UNIT_X:c,UNIT_Y:l,ZEROS:[0,0],clone:function(t){return[t[0],t[1]]},create:r,createView:function(t,e){return new Float64Array(t,e,2)},fromArray:function(t,e=[0,0]){const s=Math.min(2,t.length);for(let r=0;r<s;++r)e[r]=t[r];return e},fromValues:i,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},37585:(t,e,s)=>{s.d(e,{C:()=>i,Cc:()=>g,Io:()=>u,S8:()=>f,WQ:()=>o,e$:()=>y,hZ:()=>n,hs:()=>l,jb:()=>w,l0:()=>m,t2:()=>x});var r=s(34304);function i(t,e){return t[0]=e[0],t[1]=e[1],t}function n(t,e,s){return t[0]=e,t[1]=s,t}function o(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t}function a(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function h(t,e,s){return t[0]=e[0]*s[0],t[1]=e[1]*s[1],t}function c(t,e,s){return t[0]=e[0]/s[0],t[1]=e[1]/s[1],t}function l(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t}function u(t,e){const s=e[0]-t[0],r=e[1]-t[1];return Math.sqrt(s*s+r*r)}function d(t,e){const s=e[0]-t[0],r=e[1]-t[1];return s*s+r*r}function _(t){const e=t[0],s=t[1];return Math.sqrt(e*e+s*s)}function p(t){const e=t[0],s=t[1];return e*e+s*s}function f(t,e){const s=e[0],r=e[1];let i=s*s+r*r;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t}function g(t,e,s,r){const i=e[0],n=e[1];return t[0]=i+r*(s[0]-i),t[1]=n+r*(s[1]-n),t}function m(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[2]*i+s[4],t[1]=s[1]*r+s[3]*i+s[5],t}function y(t,e,s,r){const i=e[0]-s[0],n=e[1]-s[1],o=Math.sin(r),a=Math.cos(r);return t[0]=i*a-n*o+s[0],t[1]=i*o+n*a+s[1],t}function x(t,e){return t[0]===e[0]&&t[1]===e[1]}const b=_,w=a,v=h,S=c,I=u,M=d,P=p;Object.freeze(Object.defineProperty({__proto__:null,add:o,angle:function(t,e){const s=t[0],r=t[1],i=e[0],n=e[1];let o=s*s+r*r;o>0&&(o=1/Math.sqrt(o));let a=i*i+n*n;a>0&&(a=1/Math.sqrt(a));const h=(s*i+r*n)*o*a;return h>1?0:h<-1?Math.PI:Math.acos(h)},ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},copy:i,cross:function(t,e,s){const r=e[0]*s[1]-e[1]*s[0];return t[0]=t[1]=0,t[2]=r,t},dist:I,distance:u,div:S,divide:c,dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},equals:function(t,e){const s=t[0],i=t[1],n=e[0],o=e[1],a=(0,r.FD)();return Math.abs(s-n)<=a*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(i-o)<=a*Math.max(1,Math.abs(i),Math.abs(o))},exactEquals:x,floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},len:b,length:_,lerp:g,max:function(t,e,s){return t[0]=Math.max(e[0],s[0]),t[1]=Math.max(e[1],s[1]),t},min:function(t,e,s){return t[0]=Math.min(e[0],s[0]),t[1]=Math.min(e[1],s[1]),t},mul:v,multiply:h,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},normalize:f,projectAndScale:function(t,e,s,r,i){let n=e[0]-s[0],o=e[1]-s[1];const a=(r[0]*n+r[1]*o)*(i-1);return n=r[0]*a,o=r[1]*a,t[0]=e[0]+n,t[1]=e[1]+o,t},random:function(t,e=1){const s=2*(0,r.Ov)()*Math.PI;return t[0]=Math.cos(s)*e,t[1]=Math.sin(s)*e,t},rotate:y,round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:l,scaleAndAdd:function(t,e,s,r){return t[0]=e[0]+s[0]*r,t[1]=e[1]+s[1]*r,t},set:n,sqrDist:M,sqrLen:P,squaredDistance:d,squaredLength:p,str:function(t){return"vec2("+t[0]+", "+t[1]+")"},sub:w,subtract:a,transformMat2:function(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[2]*i,t[1]=s[1]*r+s[3]*i,t},transformMat2d:m,transformMat3:function(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[3]*i+s[6],t[1]=s[1]*r+s[4]*i+s[7],t},transformMat4:function(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[4]*i+s[12],t[1]=s[1]*r+s[5]*i+s[13],t}},Symbol.toStringTag,{value:"Module"}))},79897:(t,e,s)=>{s.d(e,{U:()=>l});var r=s(90237),i=s(69622),n=s(36563),o=s(36708),a=s(11932),h=s(10107),c=s(40608);let l=class extends i.A{constructor(){super(...arguments),this.updating=!1,this._handleId=0,this._scheduleHandleId=0,this._pendingPromises=new Set}destroy(){this.removeAll()}add(t,e,s={}){return this._installWatch(t,e,s,o.wB)}addWhen(t,e,s={}){return this._installWatch(t,e,s,o.z7)}addOnCollectionChange(t,e,{initial:s=!1,final:r=!1}={}){const i=++this._handleId;return this.addHandles([(0,o.on)(t,"after-changes",this._createSyncUpdatingCallback(),o.OH),(0,o.on)(t,"change",e,{onListenerAdd:s?t=>e({added:t.toArray(),removed:[]}):void 0,onListenerRemove:r?t=>e({added:[],removed:t.toArray()}):void 0})],i),(0,n.hA)((()=>this.removeHandles(i)))}addPromise(t){if(null==t)return t;const e=++this._handleId;this.addHandles((0,n.hA)((()=>{this._pendingPromises.delete(t)&&(0!==this._pendingPromises.size||this.hasHandles(u)||this._set("updating",!1))})),e),this._pendingPromises.add(t),this._set("updating",!0);const s=()=>this.removeHandles(e);return t.then(s,s),t}removeAll(){this._pendingPromises.clear(),this.removeAllHandles(),this._set("updating",!1)}_installWatch(t,e,s={},r){const i=++this._handleId;s.sync||this._installSyncUpdatingWatch(t,i);const o=r(t,e,s);return this.addHandles(o,i),(0,n.hA)((()=>this.removeHandles(i)))}_installSyncUpdatingWatch(t,e){const s=this._createSyncUpdatingCallback(),r=(0,o.wB)(t,s,{sync:!0,equals:()=>!1});return this.addHandles(r,e),r}_createSyncUpdatingCallback(){return()=>{this.removeHandles(u),++this._scheduleHandleId;const t=this._scheduleHandleId;this._get("updating")||this._set("updating",!0),this.addHandles((0,a._)((()=>{t===this._scheduleHandleId&&(this._set("updating",this._pendingPromises.size>0),this.removeHandles(u))})),u)}}};(0,r._)([(0,h.MZ)({readOnly:!0})],l.prototype,"updating",void 0),l=(0,r._)([(0,c.$)("esri.core.support.UpdatingHandles")],l);const u=-42},37730:(t,e,s)=>{s.d(e,{T:()=>i});var r=s(43334);const i={getObjectId:t=>t.objectId,getAttributes:t=>t.attributes,getAttribute:(t,e)=>t.attributes[e],cloneWithGeometry:(t,e)=>new r.Om(e,t.attributes,null,t.objectId),getGeometry:t=>t.geometry,getCentroid:(t,e)=>t.ensureCentroid(e)}},30624:(t,e,s)=>{s.r(e),s.d(e,{createConnection:()=>T});var r=s(90237),i=(s(59456),s(78888)),n=s(49186),o=s(53966),a=s(74887),h=s(84952),c=(s(44208),s(87811),s(40608)),l=s(10107),u=s(62815),d=s(65529);let _=class extends d.A.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.A("stream-connection",this.errorString):null}onFeature(t){this.emit("data-received",t)}onMessage(t){this.emit("message-received",t)}};(0,r._)([(0,l.MZ)({readOnly:!0})],_.prototype,"connectionError",null),_=(0,r._)([(0,c.$)("esri.layers.support.StreamConnection")],_);const p=_;var f,g;(g=f||(f={}))[g.CONNECTING=0]="CONNECTING",g[g.OPEN=1]="OPEN",g[g.CLOSING=2]="CLOSING",g[g.CLOSED=3]="CLOSED";let m=class extends p{constructor(t){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:r}=t;this._config=t,this._featureZScaler=(0,u.N)(e,r,s),this._open()}normalizeCtorArgs(){return{}}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),null!=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(null==this._websocket)return"disconnected";switch(this._websocket.readyState){case f.CONNECTING:case f.OPEN:return"connected";case f.CLOSING:case f.CLOSED:return"disconnected"}}sendMessageToSocket(t){null!=this._websocket?this._websocket.send(JSON.stringify(t)):this._outstandingMessages.push(t)}sendMessageToClient(t){this._onMessage(t)}updateCustomParameters(t){this._config.customParameters=t,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(t=this._config.source.path,e=1e3,s=0){try{if(this.destroyed)return;const e=(0,h.a6)(t,this._config.customParameters??{});this._websocket=await this._createWebSocket(e),this.notifyChange("connectionStatus")}catch(r){const i=e/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(o.A.getLogger(this).error(new n.A("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(o.A.getLogger(this).error(new n.A("websocket-connection",`Failed to connect. Attempting to reconnect in ${i}s`,r)),await(0,a.Pl)(e),this._tryCreateWebSocket(t,Math.min(1.5*e,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(t){t.onmessage=t=>{try{const e=JSON.parse(t.data);this._onMessage(e)}catch(t){return void o.A.getLogger(this).error(new n.A("websocket-connection","Failed to parse message, invalid JSON",{error:t}))}}}_createWebSocket(t){return new Promise(((e,s)=>{const r=new WebSocket(t);r.onopen=()=>{if(r.onopen=null,this.destroyed)return r.onclose=null,void r.close();r.onclose=t=>this._onClose(t),r.onerror=t=>this._onError(t),this._setWebSocketJSONParseHandler(r),e(r)},r.onclose=t=>{r.onopen=r.onclose=null,s(t)}}))}async _handshake(t=1e4){const e=this._websocket;if(null==e)return;const s=(0,a.Tw)(),r=e.onmessage,{filter:i,outFields:h,spatialReference:c}=this._config;return s.timeout(t),e.onmessage=t=>{let a=null;try{a=JSON.parse(t.data)}catch(t){}a&&"object"==typeof a||(o.A.getLogger(this).error(new n.A("websocket-connection","Protocol violation. Handshake failed - malformed message",t.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==c?.wkid&&(o.A.getLogger(this).error(new n.A("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${c.wkid}`,t.data)),s.reject(),this.destroy()),"json"!==a.format&&(o.A.getLogger(this).error(new n.A("websocket-connection","Protocol violation. Handshake failed - format is not set",t.data)),s.reject(),this.destroy()),i&&a.filter!==i&&o.A.getLogger(this).error(new n.A("websocket-connection","Tried to set filter, but server doesn't support it")),h&&a.outFields!==h&&o.A.getLogger(this).error(new n.A("websocket-connection","Tried to set outFields, but server doesn't support it")),e.onmessage=r;for(const t of this._outstandingMessages)e.send(JSON.stringify(t));this._outstandingMessages=[],s.resolve()},e.send(JSON.stringify({filter:i,outFields:h,format:"json",spatialReference:{wkid:c.wkid}})),s.promise}_onMessage(t){if(this.onMessage(t),"type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}}_onError(t){const e="Encountered an error over WebSocket connection";this._set("errorString",e),o.A.getLogger(this).error("websocket-connection",e)}_onClose(t){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==t.code&&o.A.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${t.code}`),this.destroyed||this._open()}};(0,r._)([(0,l.MZ)()],m.prototype,"connectionStatus",null),(0,r._)([(0,l.MZ)()],m.prototype,"errorString",void 0),m=(0,r._)([(0,c.$)("esri.layers.graphics.sources.connections.WebSocketConnection")],m);var y=s(80893),x=s(61956),b=s(65864),w=s(16930);const v={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends m{constructor(t){super({...v,...t}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const t=await this._fetchServiceDefinition(this._config.source);t.timeInfo.trackIdField||o.A.getLogger(this).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 e=this._fetchWebSocketUrl(t.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(e);const{filter:s,outFields:r}=this._config;this.destroyed||this._setFilter(s,r)}_onMessage(t){if("attributes"in t){let e;try{e=this._enrich(t),null!=this._featureZScaler&&this._featureZScaler(e.geometry)}catch(t){return void o.A.getLogger(this).error(new n.A("geoevent-connection","Failed to parse message",t))}this.onFeature(e)}else this.onMessage(t)}async _fetchServiceDefinition(t){const e={f:"json",...this._config.customParameters},s=(0,i.A)(t.path,{query:e,responseType:"json"}),r=(await s).data;return this._serviceDefinition=r,r}_fetchWebSocketUrl(t,e){const s=t[0],{urls:r,token:i}=s,n=this._inferWebSocketBaseUrl(r);return(0,h.a6)(`${n}/subscribe`,{outSR:""+e.wkid,token:i})}_inferWebSocketBaseUrl(t){if(1===t.length)return t[0];for(const e of t)if(e.includes("wss"))return e;return o.A.getLogger(this).error(new n.A("geoevent-connection","Unable to infer WebSocket url",t)),null}async _setFilter(t,e){const s=this._websocket;if(null==s||null==t&&null==e)return;const r=JSON.stringify({filter:this._serializeFilter(t,e)});let i=!1;const h=(0,a.Tw)();return s.onmessage=t=>{const e=JSON.parse(t.data);e.filter&&(e.error&&(o.A.getLogger(this).error(new n.A("geoevent-connection","Failed to set service filter",e.error)),this._set("errorString",`Could not set service filter - ${e.error}`),h.reject(e.error)),this._setWebSocketJSONParseHandler(s),i=!0,h.resolve())},s.send(r),setTimeout((()=>{i||(this.destroyed||this._websocket!==s||o.A.getLogger(this).error(new n.A("geoevent-connection","Server timed out when setting filter")),h.reject())}),1e4),h.promise}_serializeFilter(t,e){const s={};if(null==t&&null==e)return s;if(t?.geometry)try{const e=(0,b.rS)(t.geometry);if("extent"!==e.type)throw new n.A(`Expected extent but found type ${e.type}`);s.geometry=JSON.stringify(e.shiftCentralMeridian())}catch(t){o.A.getLogger(this).error(new n.A("geoevent-connection","Encountered an error when setting connection geometryDefinition",t))}return t?.where&&"1 = 1"!==t.where&&"1=1"!==t.where&&(s.where=t.where),null!=e&&(s.outFields=e.join(",")),s}_enrich(t){if(!this._relatedFeatures)return t;const e=this._serviceDefinition.relatedFeatures.joinField,s=t.attributes[e],r=this._relatedFeatures.get(s);if(!r)return o.A.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",t),t;const{attributes:i,geometry:a}=r;for(const e in i)t.attributes[e]=i[e];return a&&(t.geometry=a),t.geometry||t.centroid||o.A.getLogger(this).error(new n.A("geoevent-connection","Found malformed feature - no geometry found",t)),t}async _queryBuddyServices(){try{const{relatedFeatures:t,keepLatestArchive:e}=this._serviceDefinition,s=this._queryRelatedFeatures(t),r=this._queryArchive(e);await s;const i=await r;if(!i)return;for(const t of i.features)this.onFeature(this._enrich(t))}catch(t){o.A.getLogger(this).error(new n.A("geoevent-connection","Encountered an error when querying buddy services",{error:t}))}}async _queryRelatedFeatures(t){if(!t)return;const e=await this._queryBuddy(t.featuresUrl);this._addRelatedFeatures(e)}async _queryArchive(t){if(t)return this._queryBuddy(t.featuresUrl)}async _queryBuddy(t){const e=new((await Promise.all([s.e(6131),s.e(8219),s.e(3874),s.e(1147),s.e(13),s.e(5494),s.e(4796),s.e(3029),s.e(4111),s.e(5220),s.e(3600),s.e(812),s.e(655),s.e(1e3)]).then(s.bind(s,13600))).default)({url:t}),{capabilities:r}=await e.load(),i=r.query.supportsMaxRecordCountFactor,n=r.query.supportsPagination,o=r.query.supportsCentroid,a=this._config.maxRecordCountFactor,h=e.capabilities.query.maxRecordCount,c=i?h*a:h,l=new x.A;if(l.outFields=this._config.outFields??["*"],l.where=this._config.filter?.where??"1=1",l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=w.A.fromJSON(this._config.spatialReference),o&&(l.returnCentroid=!0),i&&(l.maxRecordCountFactor=a),n)return l.num=c,e.destroy(),this._queryPages(t,l);const u=await(0,y.eW)(t,l,this._config.sourceSpatialReference);return e.destroy(),u.data}async _queryPages(t,e,s=[],r=0){e.start=null!=e.num?r*e.num:null;const{data:i}=await(0,y.eW)(t,e,this._config.sourceSpatialReference);return i.exceededTransferLimit&&r<(this._config.maxQueryDepth??0)?(i.features.forEach((t=>s.push(t))),this._queryPages(t,e,s,r+1)):(s.forEach((t=>i.features.push(t))),i)}_addRelatedFeatures(t){const e=new Map,s=t.features,r=this._serviceDefinition.relatedFeatures.joinField;for(const t of s){const s=t.attributes[r];e.set(s,t)}this._relatedFeatures=e}};S=(0,r._)([(0,c.$)("esri.layers.graphics.sources.connections.GeoEventConnection")],S);const I=S;let M=class extends p{constructor(t){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:r}=t;this._featureZScaler=(0,u.N)(e,r,s)}normalizeCtorArgs(){return{}}updateCustomParameters(t){}sendMessageToSocket(t){}sendMessageToClient(t){if("type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}this.onMessage(t)}};function P(t,e){if(null==t&&null==e)return null;const s={};return null!=e&&(s.geometry=e),null!=t&&(s.where=t),s}function T(t,e,s,r,i,n,o,a,h){const c={source:t,sourceSpatialReference:e,spatialReference:s,geometryType:r,filter:P(i,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:h};return t?t.path.startsWith("wss://")||t.path.startsWith("ws://")?new m(c):new I(c):new M(c)}(0,r._)([(0,l.MZ)()],M.prototype,"connectionStatus",void 0),(0,r._)([(0,l.MZ)()],M.prototype,"errorString",void 0),M=(0,r._)([(0,c.$)("esri.layers.support.ClientSideConnection")],M)},91806:(t,e,s)=>{s.d(e,{A:()=>l});var r,i=s(90237),n=s(25482),o=s(10107),a=s(56507),h=(s(87811),s(44208),s(40608));let c=r=class extends n.A{constructor(t){super(t),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new r({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,i._)([(0,o.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"cols",void 0),(0,i._)([(0,o.MZ)({type:a.jz,json:{write:!0}})],c.prototype,"level",void 0),(0,i._)([(0,o.MZ)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,i._)([(0,o.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"origin",void 0),(0,i._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,i._)([(0,o.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"rows",void 0),(0,i._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=r=(0,i._)([(0,h.$)("esri.layers.support.LOD")],c);const l=c},87045:(t,e,s)=>{s.d(e,{A:()=>I});var r,i=s(90237),n=s(66552),o=s(25482),a=s(83047),h=s(10107),c=s(56507),l=(s(87811),s(44208),s(36005)),u=s(40608),d=s(43937),_=s(86738),p=s(16930),f=s(19419),g=s(21325),m=s(28735),y=s(91806),x=s(72802);const b=new n.J({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let w=r=class extends o.A{static create(t={}){const{resolutionFactor:e=1,scales:s,size:i=256,spatialReference:n=p.A.WebMercator,numLODs:o=24}=t;if(!(0,g.fn)(n)){const t=[];if(s)for(let e=0;e<s.length;e++){const r=s[e];t.push(new y.A({level:e,scale:r,resolution:r}))}else{let e=5e-4;for(let s=o-1;s>=0;s--)t.unshift(new y.A({level:s,scale:e,resolution:e})),e*=2}return new r({dpi:96,lods:t,origin:new _.A(0,0,n),size:[i,i],spatialReference:n})}const h=(0,g.Vp)(n),c=t.origin?new _.A({x:t.origin.x,y:t.origin.y,spatialReference:n}):new _.A(h?{x:h.origin[0],y:h.origin[1],spatialReference:n}:{x:0,y:0,spatialReference:n}),l=1/(39.37*(0,a.GA)(n)*96),u=[];if(s)for(let t=0;t<s.length;t++){const e=s[t],r=e*l;u.push(new y.A({level:t,scale:e,resolution:r}))}else{let t=(0,g.EA)(n)?512/i*591657527.5917094:256/i*591657527.591555;const s=Math.ceil(o/e);u.push(new y.A({level:0,scale:t,resolution:t*l}));for(let r=1;r<s;r++){const s=t/2**e,i=s*l;u.push(new y.A({level:r,scale:s,resolution:i})),t=s}}return new r({dpi:96,lods:u,origin:c,size:[i,i],spatialReference:n})}constructor(t){super(t),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:t,origin:e}=this;if(t&&e){const s=(0,g.Vp)(t);return t.isWrappable&&!!s&&Math.abs(s.origin[0]-e.x)<=s.dx}return!1}readOrigin(t,e){return _.A.fromJSON({spatialReference:e.spatialReference,...t})}set lods(t){let e=0,s=0;const r=[],i=this._levelToLOD={};t&&(e=-1/0,s=1/0,t.forEach((t=>{r.push(t.scale),e=t.scale>e?t.scale:e,s=t.scale<s?t.scale:s,i[t.level]=t}))),this._set("scales",r),this._set("lods",t),this._initializeUpsampleLevels()}readSize(t,e){return[e.cols,e.rows]}writeSize(t,e){e.cols=t[0],e.rows=t[1]}zoomToScale(t){const e=this.scales;if(t<=0)return e[0];if(t>=e.length-1)return e[e.length-1];const s=Math.floor(t),r=s+1;return e[s]/(e[s]/e[r])**(t-s)}scaleToZoom(t){const e=this.scales,s=e.length-1;let r=0;for(;r<s;r++){const s=e[r],i=e[r+1];if(s<=t)return r;if(i===t)return r+1;if(s>t&&i<t)return r+Math.log(s/t)/Math.log(s/i)}return r}tileAt(t,e,s,r){const i=this.lodAt(t);if(!i)return null;let n,o;if("number"==typeof e)n=e,o=s;else if((0,g.aI)(e.spatialReference,this.spatialReference))n=e.x,o=e.y,r=s;else{const t=(0,m.Cv)(e,this.spatialReference);if(null==t)return null;n=t.x,o=t.y,r=s}const a=i.resolution*this.size[0],h=i.resolution*this.size[1];return r||(r=new x.U(null,0,0,0,(0,f.vt)())),r.level=t,r.row=Math.floor((this.origin.y-o)/h+.001),r.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(r),r}updateTileInfo(t,e=r.ExtrapolateOptions.NONE){let s=this.lodAt(t.level);if(!s&&e===r.ExtrapolateOptions.POWER_OF_TWO){const e=this.lods[this.lods.length-1];e.level<t.level&&(s=e)}if(!s)return;const i=t.level-s.level,n=s.resolution*this.size[0]/2**i,o=s.resolution*this.size[1]/2**i;t.id=`${t.level}/${t.row}/${t.col}`,t.extent||(t.extent=(0,f.vt)()),t.extent[0]=this.origin.x+t.col*n,t.extent[1]=this.origin.y-(t.row+1)*o,t.extent[2]=t.extent[0]+n,t.extent[3]=t.extent[1]+o}upsampleTile(t){const e=this._upsampleLevels[t.level];return!(!e||-1===e.parentLevel||(t.level=e.parentLevel,t.row=Math.floor(t.row/e.factor+.001),t.col=Math.floor(t.col/e.factor+.001),this.updateTileInfo(t),0))}getTileBounds(t,e){const s=this.lodAt(e.level);if(null==s)return null;const{resolution:r}=s,i=r*this.size[0],n=r*this.size[1];return t[0]=this.origin.x+e.col*i,t[1]=this.origin.y-(e.row+1)*n,t[2]=t[0]+i,t[3]=t[1]+n,t}lodAt(t){return this._levelToLOD?.[t]??null}clone(){return r.fromJSON(this.write({}))}getCompatibleForVTL(t){if(this.size[0]!==this.size[1]||256===this.size[0]&&512===t)return null;const e=(512===this.size[0]&&256===t?-1:0)+(this.spatialReference.isGeographic?1:0);if(this.size[0]===t&&0===e)return this;const s=[],i=this.lods.length-e;for(let t=0;t<i;t++){const r=t+e,{scale:i,resolution:n}=r>=0?this.lods[r]:{scale:2*this.lods[0].scale,resolution:2*this.lods[0].resolution};s.push(new y.A({level:t,scale:i,resolution:n}))}return new r({size:[t,t],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:s})}_initializeUpsampleLevels(){const t=this.lods;this._upsampleLevels=[];let e=null;for(let s=0;s<t.length;s++){const r=t[s];this._upsampleLevels[r.level]={parentLevel:e?e.level:-1,factor:e?e.resolution/r.resolution:0},e=r}}};var v,S;(0,i._)([(0,h.MZ)({type:Number,json:{write:!0}})],w.prototype,"compressionQuality",void 0),(0,i._)([(0,h.MZ)({type:Number,json:{write:!0}})],w.prototype,"dpi",void 0),(0,i._)([(0,h.MZ)({type:String,json:{read:b.read,write:b.write,origins:{"web-scene":{read:!1,write:!1}}}})],w.prototype,"format",void 0),(0,i._)([(0,h.MZ)({readOnly:!0})],w.prototype,"isWrappable",null),(0,i._)([(0,h.MZ)({type:_.A,json:{write:!0}})],w.prototype,"origin",void 0),(0,i._)([(0,l.w)("origin")],w.prototype,"readOrigin",null),(0,i._)([(0,h.MZ)({type:[y.A],value:null,json:{write:!0}})],w.prototype,"lods",null),(0,i._)([(0,h.MZ)({readOnly:!0})],w.prototype,"scales",void 0),(0,i._)([(0,h.MZ)({cast:t=>Array.isArray(t)?t:"number"==typeof t?[t,t]:[256,256]})],w.prototype,"size",void 0),(0,i._)([(0,l.w)("size",["rows","cols"])],w.prototype,"readSize",null),(0,i._)([(0,d.K)("size",{cols:{type:c.jz},rows:{type:c.jz}})],w.prototype,"writeSize",null),(0,i._)([(0,h.MZ)({type:p.A,json:{write:!0}})],w.prototype,"spatialReference",void 0),w=r=(0,i._)([(0,u.$)("esri.layers.support.TileInfo")],w),v=w||(w={}),(S=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[S.NONE=0]="NONE",S[S.POWER_OF_TWO=1]="POWER_OF_TWO";const I=w},72802:(t,e,s)=>{s.d(e,{U:()=>r});class r{constructor(t,e,s,r,i=void 0){this.id=t,this.level=e,this.row=s,this.col=r,this.extent=i}}},60694:(t,e,s)=>{s.d(e,{Fi:()=>l,HZ:()=>m,Jf:()=>g,LS:()=>y,Wo:()=>f,bd:()=>x,cr:()=>_,iz:()=>d,qg:()=>u,yG:()=>p});var r=s(84952),i=s(97159);const n={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",knowledgegraphserver:"KnowledgeGraphServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer","3dtilesserver":"3DTilesServer",videoserver:"VideoServer"},o=Object.values(n),a=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),h=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^/\\n]+)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),c=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function l(t){return a.test(t)}function u(t){if(null==t)return null;const e=(0,r.An)(t),s=e?.path.match(a)||e?.path.match(h);if(!s)return null;const[,i,o,c,l]=s,u=o.indexOf("/");return{title:_(-1!==u?o.slice(u+1):o),serverType:n[c.toLowerCase()],sublayer:null!=l&&""!==l?parseInt(l,10):null,url:{path:i}}}function d(t){const e=(0,r.An)(t).path.match(c);return e?{serviceUrl:e[1],sublayerId:Number(e[2])}:null}function _(t){return(t=t.replaceAll(/\s*[/_]+\s*/g," "))[0].toUpperCase()+t.slice(1)}function p(t,e){const s=[];if(t){const e=u(t);null!=e&&e.title&&s.push(e.title)}if(e){const t=_(e);s.push(t)}if(2===s.length){if(s[0].toLowerCase().includes(s[1].toLowerCase()))return s[0];if(s[1].toLowerCase().includes(s[0].toLowerCase()))return s[1]}return s.join(" - ")}function f(t){let e=(0,r.$z)(t,!0);return!!e&&(e=e.toLowerCase(),e.endsWith(".arcgis.com")&&(e.startsWith("services")||e.startsWith("tiles")||e.startsWith("features")))}function g(t,e){return t?(0,r.UC)((0,r.zi)(t,e)):t}function m(t){let{url:e}=t;if(!e)return{url:e};e=(0,r.zi)(e,t.logger);const s=(0,r.An)(e),i=u(s.path);let n;if(null!=i)null!=i.sublayer&&null==t.layer.layerId&&(n=i.sublayer),e=i.url.path;else if(t.nonStandardUrlAllowed){const t=d(s.path);null!=t&&(e=t.serviceUrl,n=t.sublayerId)}return{url:(0,r.UC)(e),layerId:n}}function y(t,e,s,n,o){(0,i.w)(e,n,"url",o),n.url&&null!=t.layerId&&(n.url=(0,r.fj)(n.url,s,t.layerId.toString()))}function x(t){if(!t)return!1;const e=t.toLowerCase(),s=e.includes("/services/"),r=e.includes("/mapserver/wmsserver"),i=e.includes("/imageserver/wmsserver"),n=e.includes("/wmsserver");return s&&(r||i||n)}},16020:(t,e,s)=>{s.r(e),s.d(e,{default:()=>Rp});var r=s(49186),i=s(36563),n=s(44208),o=s(26390),a=s(74887),h=s(87811),c=s(36708),l=s(90629),u=s(8341),d=s(87045),_=s(21325),p=s(44159);function f(t,e){return[t,e]}function g(t,e,s){return t[0]=e,t[1]=s,t}const m=new p.A("0/0/0/0");class y{static create(t,e,s=null){const r=(0,_.Vp)(t.spatialReference),i=e.origin||f(t.origin.x,t.origin.y),n=f(t.size[0]*e.resolution,t.size[1]*e.resolution),o=f(-1/0,-1/0),a=f(1/0,1/0),h=f(1/0,1/0);null!=s&&(g(o,Math.max(0,Math.floor((s.xmin-i[0])/n[0])),Math.max(0,Math.floor((i[1]-s.ymax)/n[1]))),g(a,Math.max(0,Math.floor((s.xmax-i[0])/n[0])),Math.max(0,Math.floor((i[1]-s.ymin)/n[1]))),g(h,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:c,rows:l}=e;let u,d,p,m;return!s&&c&&l&&(g(o,c[0],l[0]),g(a,c[1],l[1]),g(h,c[1]-c[0]+1,l[1]-l[0]+1)),t.isWrappable?(u=f(Math.ceil(Math.round((r.valid[1]-r.valid[0])/e.resolution)/t.size[0]),h[1]),d=!0,p=r.origin,m=r.valid):(u=h,d=!1),new y(e.level,e.resolution,e.scale,i,o,a,h,n,u,d,p,m)}constructor(t,e,s,r,i,n,o,a,h,c,l,u){this.level=t,this.resolution=e,this.scale=s,this.origin=r,this.first=i,this.last=n,this.size=o,this.norm=a,this.worldSize=h,this.wrap=c,this._spatialReferenceOrigin=l,this._spatialReferenceValid=u}normalizeCol(t){if(!this.wrap)return t;const e=this.worldSize[0];return t<0?e-1-Math.abs((t+1)%e):t%e}normalizeKey(t){if(!this.wrap)return;const e=this.worldSize[0],s=t.col;s<0?(t.col=s+e,t.world-=1):s>=e&&(t.col=s-e,t.world+=1)}denormalizeCol(t,e){return this.wrap?this.worldSize[0]*e+t:t}getWorldForColumn(t){return this.wrap?Math.floor(t/this.worldSize[0]):0}getFirstColumnForWorld(t){return t*this.worldSize[0]+this.first[0]}getLastColumnForWorld(t){return t*this.worldSize[0]+this.first[0]+this.size[0]-1}getColumnForX(t){return(t-this.origin[0])/this.norm[0]}getXForColumn(t){const e=this.origin[0]+t*this.norm[0],s=this._spatialReferenceOrigin,r=this._spatialReferenceValid;return this.wrap&&s&&r?e===s[0]?r[0]:this.origin[0]===s[0]&&t===this.worldSize[0]?r[1]:e:e}getRowForY(t){return(this.origin[1]-t)/this.norm[1]}getYForRow(t){return this.origin[1]-t*this.norm[1]}getTileBounds(t,e,s=!1){m.set(e);const r=s?m.col:this.denormalizeCol(m.col,m.world),i=m.row;return function(t,e,s,r,i){t[0]=e,t[1]=s,t[2]=r,t[3]=i}(t,this.getXForColumn(r),this.getYForRow(i+1),this.getXForColumn(r+1),this.getYForRow(i)),t}getTileCoords(t,e,s=!1){m.set(e);const r=s?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(t)?g(t,this.getXForColumn(r),this.getYForRow(m.row)):(t.x=this.getXForColumn(r),t.y=this.getYForRow(m.row)),t}}var x=s(93687);class b{constructor(){this.spans=[]}acquire(t){this.lodInfo=t}release(){this.lodInfo=null,this.spans.length=0}*keys(){const t=this.lodInfo;for(const{row:e,colFrom:s,colTo:r}of this.spans)for(let i=s;i<=r;i++){const s=t.getWorldForColumn(i);yield new p.A(t.level,e,t.normalizeCol(i),s)}}forEach(t,e){const{spans:s,lodInfo:r}=this,{level:i}=r;if(0!==s.length)for(const{row:n,colFrom:o,colTo:a}of s)for(let s=o;s<=a;s++)t.call(e,i,n,r.normalizeCol(s),r.getWorldForColumn(s))}}b.pool=new x.A(b);class w{constructor(t,e,s){this.row=t,this.colFrom=e,this.colTo=s}}const v=new p.A("0/0/0/0");class S{static create(t,e){t[1]>e[1]&&([t,e]=[e,t]);const[s,r]=t,[i,n]=e,o=i-s,a=n-r,h=0!==a?o/a:0,c=(Math.ceil(r)-r)*h,l=(Math.floor(r)-r)*h;return new S(s,Math.floor(r),Math.ceil(n),h,o<0?c:l,o<0?l:c,o<0?i:s,o<0?s:i)}constructor(t,e,s,r,i,n,o,a){this.x=t,this.ymin=e,this.ymax=s,this.invM=r,this.leftAdjust=i,this.rightAdjust=n,this.leftBound=o,this.rightBound=a}incrRow(){this.x+=this.invM}getLeftCol(){return Math.max(this.x+this.leftAdjust,this.leftBound)}getRightCol(){return Math.min(this.x+this.rightAdjust,this.rightBound)}}const I=[[0,0],[0,0],[0,0],[0,0]];class M{constructor(t,e=null,s=t.lods[0].level,r=t.lods[t.lods.length-1].level){this.tileInfo=t,this.fullExtent=e,this.scales=[],this._infoByScale={},this._infoByLevel={};const i=t.lods.filter((t=>t.level>=s&&t.level<=r));this.minScale=i[0].scale,this.maxScale=i[i.length-1].scale;const n=this._lodInfos=i.map((s=>y.create(t,s,e)));i.forEach(((t,e)=>{this._infoByLevel[t.level]=n[e],this._infoByScale[t.scale]=n[e],this.scales[e]=t.scale}),this),this._wrap=t.isWrappable}get spatialReference(){return this.tileInfo.spatialReference}getLODInfoAt(t){return this._infoByLevel["number"==typeof t?t:t.level]}getTileBounds(t,e,s=!1){v.set(e);const r=this._infoByLevel[v.level];return r?r.getTileBounds(t,v,s):t}getTileCoords(t,e,s=!1){v.set(e);const r=this._infoByLevel[v.level];return r?r.getTileCoords(t,v,s):t}getTileCoverage(t,e=192,s=!0,r="closest"){if(!s&&(t.scale>this.minScale||t.scale<this.maxScale))return null;const i="closest"===r?this.getClosestInfoForScale(t.scale):this.getSmallestInfoForScale(t.scale),n=b.pool.acquire(i),o=this._wrap;let a,h,c,l=1/0,u=-1/0;const d=n.spans;I[0][0]=I[0][1]=I[1][1]=I[3][0]=-e,I[1][0]=I[2][0]=t.size[0]+e,I[2][1]=I[3][1]=t.size[1]+e;for(const e of I)t.toMap(e,e),e[0]=i.getColumnForX(e[0]),e[1]=i.getRowForY(e[1]);const _=[];let p=3;for(let t=0;t<4;t++){if(I[t][1]===I[p][1]){p=t;continue}const e=S.create(I[t],I[p]);l=Math.min(e.ymin,l),u=Math.max(e.ymax,u),void 0===_[e.ymin]&&(_[e.ymin]=[]),_[e.ymin].push(e),p=t}if(null==l||null==u||u-l>100)return null;let f=[];for(a=l;a<u;){null!=_[a]&&(f=f.concat(_[a])),h=1/0,c=-1/0;for(let t=f.length-1;t>=0;t--){const e=f[t];h=Math.min(h,e.getLeftCol()),c=Math.max(c,e.getRightCol())}if(h=Math.floor(h),c=Math.floor(c),a>=i.first[1]&&a<=i.last[1])if(o)if(i.size[0]<i.worldSize[0]){const t=Math.floor(c/i.worldSize[0]);for(let e=Math.floor(h/i.worldSize[0]);e<=t;e++)d.push(new w(a,Math.max(i.getFirstColumnForWorld(e),h),Math.min(i.getLastColumnForWorld(e),c)))}else d.push(new w(a,h,c));else h>i.last[0]||c<i.first[0]||(h=Math.max(h,i.first[0]),c=Math.min(c,i.last[0]),d.push(new w(a,h,c)));a+=1;for(let t=f.length-1;t>=0;t--){const e=f[t];e.ymax>=a?e.incrRow():f.splice(t,1)}}return n}getTileParentId(t){v.set(t);const e=this._infoByLevel[v.level],s=this._lodInfos.indexOf(e)-1;return s<0?null:(this._getTileIdAtLOD(v,this._lodInfos[s],v),v.id)}getTileResolution(t){const e=this._infoByLevel["object"==typeof t?t.level:t];return e?e.resolution:-1}getTileScale(t){const e=this._infoByLevel[t.level];return e?e.scale:-1}intersects(t,e){v.set(e);const s=this._infoByLevel[v.level],r=t.lodInfo;if(r.resolution>s.resolution){this._getTileIdAtLOD(v,r,v);const e=r.denormalizeCol(v.col,v.world);for(const s of t.spans)if(s.row===v.row&&s.colFrom<=e&&s.colTo>=e)return!0}if(r.resolution<s.resolution){const[e,i,n,o]=t.spans.reduce(((t,e)=>(t[0]=Math.min(t[0],e.row),t[1]=Math.max(t[1],e.row),t[2]=Math.min(t[2],e.colFrom),t[3]=Math.max(t[3],e.colTo),t)),[1/0,-1/0,1/0,-1/0]),a=s.denormalizeCol(v.col,v.world),h=r.getColumnForX(s.getXForColumn(a)),c=r.getRowForY(s.getYForRow(v.row)),l=r.getColumnForX(s.getXForColumn(a+1))-1,u=r.getRowForY(s.getYForRow(v.row+1))-1;return!(h>o||l<n||c>i||u<e)}const i=r.denormalizeCol(v.col,v.world);return t.spans.some((t=>t.row===v.row&&t.colFrom<=i&&t.colTo>=i))}normalizeBounds(t,e,s){if(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._wrap){const e=(0,_.Vp)(this.tileInfo.spatialReference),r=-s*(e.valid[1]-e.valid[0]);t[0]+=r,t[2]+=r}return t}getSmallestInfoForScale(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t];if(t>e[0])return this._infoByScale[e[0]];for(let s=1;s<e.length-1;s++)if(t>e[s]+1e-6)return this._infoByScale[e[s-1]];return this._infoByScale[e[e.length-1]]}getClosestInfoForScale(t){const e=this.scales;return this._infoByScale[t]||(t=e.reduce(((e,s)=>Math.abs(s-t)<Math.abs(e-t)?s:e),e[0])),this._infoByScale[t]}scaleToLevel(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t].level;for(let s=e.length-1;s>=0;s--)if(t<e[s])return s===e.length-1?this._infoByScale[e[e.length-1]].level:this._infoByScale[e[s]].level+(e[s]-t)/(e[s]-e[s+1]);return this._infoByScale[e[0]].level}scaleToZoom(t){return this.tileInfo.scaleToZoom(t)}zoomToScale(t){return this.tileInfo.zoomToScale(t)}_getTileIdAtLOD(t,e,s){const r=this._infoByLevel[s.level];return t.set(s),e.resolution<r.resolution?null:(e.resolution===r.resolution||(t.level=e.level,t.col=Math.floor(s.col*r.resolution/e.resolution+.01),t.row=Math.floor(s.row*r.resolution/e.resolution+.01)),t)}}var P=s(90237),T=s(69622),A=s(91869),C=s(97768),k=s(3483),F=s(10107),E=s(53966),z=s(40608),O=s(37585),R=s(89738);const D=[0,0];let L=class extends T.A{constructor(t){super(t),this._keyToItem=new Map,this._tilesByScale=new Map,this.concurrency=6}initialize(){const{concurrency:t,process:e,scheduler:s,priority:r}=this;this._queue=new R.e({concurrency:t,scheduler:s,priority:r,process:(t,s)=>{const r=this._keyToItem.get(t);return e(r,{signal:s})},peeker:t=>this._peek(t)})}destroy(){this.clear(),this._queue=(0,C.pR)(this._queue)}get length(){return this._queue?this._queue.length:0}abort(t){const e="string"==typeof t?t:t.id;this._queue.abort(e)}clear(){this._queue.clear(),this._keyToItem.clear(),this._tilesByScale.clear()}has(t){return"string"==typeof t?this._keyToItem.has(t):this._keyToItem.has(t.id)}pause(){this._queue.pause()}push(t){const e=t.key.id;if(this._queue.has(e))return this._queue.get(e);const s=this._queue.push(e),r=this.tileInfoView.getTileScale(t.key),i=(0,A.tE)(this._tilesByScale,r,(()=>new Set)),n=()=>{i.delete(t.key),0===i.size&&this._tilesByScale.delete(r),this._keyToItem.delete(e)};return i.add(t.key),this._keyToItem.set(e,t),s.then(n,n),s}reset(){this._queue.reset()}resume(){this._queue.resume()}_peek(t){if(!this.state)return t.values().next().value;const e=new Set;for(const s of t)e.add(this._keyToItem.get(s).key);const s=this.state.scale;let r,i=Number.POSITIVE_INFINITY;for(const[t,n]of this._tilesByScale)if((0,k.bw)(n,(t=>e.has(t)))){const e=Math.abs(t-s);e<i&&(r=n,i=e)}return this._getClosestTileKey(r,t).id}_getClosestTileKey(t,e){const s=this.tileInfoView,r=this.state.center;let i,n=Number.POSITIVE_INFINITY;for(const o of t)if(e.has(o.id)){s.getTileCoords(D,o);const t=(0,O.Io)(D,r);t<n&&(n=t,i=o)}return i}};(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"concurrency",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"priority",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"process",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"scheduler",void 0),(0,P._)([(0,F.MZ)()],L.prototype,"state",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"tileInfoView",void 0),L=(0,P._)([(0,z.$)("esri.views.2d.tiling.TileQueue")],L);var N=s(19419);new p.A(0,0,0,0),new Map;var B=s(76213);class G{constructor(t){this._client=t,this.layerView=this._client.createInvokeProxy(""),this.container=this._client.createInvokeProxy("container"),this._eventLog=this._client.createInvokeProxy("eventLog")}onEvent(t){(0,u.oV)(this._eventLog.onEvent(t))}}var U=s(93637),V=s(6797),q=s(16930);class W{constructor(t,e,s,r,i,n,o){this.instanceId=t,this.textureKey=e,this.indexStart=s,this.indexCount=r,this.vertexStart=i,this.vertexCount=n,this.overlaps=o}updateBaseOffsets(t){this.vertexStart+=t.vertexFrom,this.indexStart+=t.indexFrom}clone(){return new W(this.instanceId,this.textureKey,this.indexStart,this.indexCount,this.vertexStart,this.vertexCount,this.overlaps)}static write(t,e,s,r,i,n,o,a){t.push(e),t.push(s),t.push(r),t.push(i),t.push(n),t.push(o),t.push(a)}serialize(t){return t.push(this.instanceId),t.push(this.textureKey),t.push(this.indexStart),t.push(this.indexCount),t.push(this.vertexStart),t.push(this.vertexCount),t.push(this.overlaps),t}static deserialize(t){const e=t.readInt32(),s=t.readInt32(),r=t.readInt32(),i=t.readInt32(),n=t.readInt32(),o=t.readInt32(),a=t.readInt32();return new W(e,s,r,i,n,o,a)}}function j(t,e){if(null!==e){t.push(e.length);for(const s of e)s.serialize(t);return t}t.push(0)}function Y(t,e,s){const r=t.readInt32(),i=new Array(r);for(let r=0;r<i.length;r++)i[r]=e.deserialize(t,s);return i}W.byteSizeHint=7*Uint32Array.BYTES_PER_ELEMENT;class X{constructor(t,e){this.id=t,this.sortKey=e,this.records=[]}serialize(t){return t.push(this.id),t.writeF32(this.sortKey),j(t,this.records),t}static deserialize(t){const e=t.readInt32(),s=t.readF32(),r=new X(e,s);return r.records=Y(t,W)??[],r}}X.byteSizeHint=2*Uint32Array.BYTES_PER_ELEMENT+W.byteSizeHint;class ${get length(){return this._pos}constructor(t,e){this._pos=0;const s=e?this._roundToNearest(e,t.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(s),this._buffer=new t(this._array),this._ctor=t,this._i16View=new Int16Array(this._array)}_roundToNearest(t,e){const s=Math.round(t);return 1===e?s:s+(e-s%e)}_ensureSize(t){if(this._pos+t>=this._buffer.length){const e=this._roundToNearest(1.25*(this._array.byteLength+t*this._buffer.BYTES_PER_ELEMENT),this._buffer.BYTES_PER_ELEMENT),s=new ArrayBuffer(e),r=new this._ctor(s);r.set(this._buffer,0),this._array=s,this._buffer=r,this._i16View=new Int16Array(this._array)}}ensureSize(t){this._ensureSize(t)}writeF32(t){this._ensureSize(1);const e=this._pos;return new Float32Array(this._array,4*this._pos,1)[0]=t,this._pos++,e}push(t){this._ensureSize(1);const e=this._pos;return this._buffer[this._pos++]=t,e}writeFixed(t){this._buffer[this._pos++]=t}setValue(t,e){this._buffer[t]=e}i1616Add(t,e,s){this._i16View[2*t]+=e,this._i16View[2*t+1]+=s}getValue(t){return this._buffer[t]}getValueF32(t){return new Float32Array(this._array,4*t,1)[0]}incr(t){if(this._buffer.length<t)throw new Error("Increment index overflows the target buffer");this._buffer[t]++}decr(t){this._buffer[t]--}writeRegion(t){this._ensureSize(t.length);const e=this._pos;return this._buffer.set(t,this._pos),this._pos+=t.length,e}writeManyFrom(t,e,s){this._ensureSize(s-e);for(let r=e;r!==s;r++)this.writeFixed(t._buffer[r])}buffer(){const t=this._array.slice(0,4*this._pos);return this.destroy(),t}toArray(){return[...this._buffer]}seek(t){this._pos=t}destroy(){this._array=null,this._buffer=null}}class H{constructor(t,e,s=0){const r=6*s*Uint32Array.BYTES_PER_ELEMENT,i=4*s*e.stride,n=e.stride/4,o=e.attributes.find((t=>"pos"===t.name||"position"===t.name));if(!o)throw new Error("InternalError: Unable to find position attribute");this.layout={...e,position:o},this._indices=new $(Uint32Array,r),this._vertices=new $(Uint32Array,i),this._metrics=new $(Uint32Array,0),this._metricCountOffset=this._metrics.push(0),this._strideInt=n,this._instanceId=t}serialize(t){const e=this._indices.buffer(),s=this._vertices.buffer(),r=this._metrics.length?this._metrics.buffer():null;return t.push(e,s),{instanceId:this._instanceId,layout:this.layout,indices:e,vertices:s,metrics:r}}get strideInt(){return this._strideInt}get vertexCount(){return this._vertices.length/this._strideInt}get indexCount(){return this._indices.length}get indexWriter(){return this._indices}get vertexWriter(){return this._vertices}get metricWriter(){return this._metrics}vertexEnsureSize(t){this._vertices.ensureSize(t)}indexEnsureSize(t){this._indices.ensureSize(t)}writeIndex(t){this._indices.push(t)}writeVertex(t){this._vertices.push(t)}writeVertexRegion(t){this._vertices.writeRegion(t)}writeVertexF32(t){this._vertices.writeF32(t)}writeMetric(t){this._metrics.incr(this._metricCountOffset),t.serialize(this._metrics)}}class Z{constructor(t,e=0){this._id=t,this._sizeHint=e,this._entityRecordCountOffset=0,this._entityCountOffset=0,this._entityIdIndex=0,this._entitySortKeyIndex=0,this._didEntityStart=!1,this._instanceIdToVertexData=new Map,this._recordIndexStart=0,this._recordIndexCount=0,this._recordVertexStart=0,this._recordVertexCount=0,this._current={metric:null,writer:null,start:0,sortKey:0,instanceId:0,layoutHash:0,indexStart:0,vertexStart:0,textureKey:0,metricBoxLenPointer:0},this._entities=new $(Uint32Array,this._sizeHint*X.byteSizeHint),this._entityCountOffset=this._entities.push(0)}get id(){return this._id}serialize(){const t=new Array,e=[],s=this._entities.buffer();for(const s of this._instanceIdToVertexData.values())e.push(s.serialize(t));return{message:{data:e,entities:s},transferList:t}}vertexCount(){return this._current.writer?.vertexCount??0}indexCount(){return this._current.writer?.indexCount??0}vertexEnsureSize(t){this._current.writer.vertexEnsureSize(t)}indexEnsureSize(t){this._current.writer.indexEnsureSize(t)}vertexWrite(t){this._current.writer.writeVertex(t)}vertexWriteRegion(t){this._current.writer.writeVertexRegion(t)}vertexWriteF32(t){this._current.writer.writeVertexF32(t)}recordBounds(t,e,s,r){}indexWrite(t){this._current.writer.writeIndex(t)}metricStart(t){this._current.metric=t}metricEnd(){const t=this._current.writer;this._current.metric.bounds.length&&t.writeMetric(this._current.metric)}metricBoxWrite(t){this._current.metric.bounds.push(t)}entityStart(t,e=t){this._entityIdIndex=this._entities.push(t),this._entitySortKeyIndex=this._entities.writeF32(e),this._entityRecordCountOffset=this._entities.push(0),this._didEntityStart=!0}entityRecordCount(){return this._entities.getValue(this._entityRecordCountOffset)}entityEnd(){this._didEntityStart&&(0===this.entityRecordCount()?this._entities.seek(this._entityIdIndex):this._entities.incr(this._entityCountOffset),this._didEntityStart=!1)}recordCount(){return this._entities.getValue(this._entityRecordCountOffset)}recordStart(t,e,s=0){this._current.writer=this._getVertexWriter(t,e),this._current.indexStart=this._current.writer.indexCount,this._current.vertexStart=this._current.writer.vertexCount,this._current.instanceId=t,this._current.layoutHash=e.hash,this._current.textureKey=s}recordEnd(t=0){const e=this._current.vertexStart,s=this._current.writer.vertexCount-e;if(!s)return!1;const r=this._current.indexStart,i=this._current.writer.indexCount-r;return this._recordIndexStart=r,this._recordIndexCount=i,this._recordVertexStart=e,this._recordVertexCount=s,this._entities.incr(this._entityRecordCountOffset),W.write(this._entities,this._current.instanceId,this._current.textureKey,r,i,e,s,t),!0}copyLast(t,e){const s=this._recordVertexStart+this._recordVertexCount;this._entities.incr(this._entityRecordCountOffset),W.write(this._entities,this._current.instanceId,this._current.textureKey,this._recordIndexStart+this._recordIndexCount,this._recordIndexCount,s,this._recordVertexCount,0);const r=this._current.writer.indexWriter,i=this._current.writer.vertexWriter,n=this._recordIndexStart+this._recordIndexCount,o=this._recordVertexCount;for(let t=this._recordIndexStart;t!==n;t++){const e=r.getValue(t);r.push(e+o)}const a=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,h=this._recordVertexStart*a,c=(this._recordVertexStart+this._recordVertexCount)*a;for(let t=h;t!==c;t++){const e=i.getValue(t);i.push(e)}const l=this._current.writer.layout.position,u=l.packPrecisionFactor??1,d=l.offset/Uint32Array.BYTES_PER_ELEMENT,_=t*u,p=e*u;for(let t=s*a;t<=i.length;t+=a)i.i1616Add(t+d,_,p)}copyLastFrom(t,e,s){const r=t._entities.getValue(t._entityIdIndex);if(r!==this._entities.getValue(this._entityIdIndex)){const e=t._entities.getValueF32(t._entitySortKeyIndex);this.entityStart(r,e)}this.recordStart(t._current.instanceId,t._current.writer.layout,t._current.textureKey);const i=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,n=this._current.vertexStart,o=t._current.vertexStart-n,a=this._current.writer.indexWriter,h=this._current.writer.vertexWriter,c=t._current.writer.indexWriter,l=t._current.writer.vertexWriter;for(let e=t._current.indexStart;e!==c.length;e++){const t=c.getValue(e);a.push(t-o)}for(let e=t._current.vertexStart*i;e!==l.length;e++){const t=l.getValue(e);h.push(t)}const u=this._current.writer.layout.position,d=u.packPrecisionFactor??1,_=u.offset/Uint32Array.BYTES_PER_ELEMENT,p=e*d,f=s*d;for(let t=n*i;t<=h.length;t+=i)h.i1616Add(t+_,p,f);this.recordEnd()}_getVertexWriter(t,e){const s=this._instanceIdToVertexData;return s.has(t)||s.set(t,new H(t,e,this._sizeHint)),s.get(t)}}function Q(t){switch(t){case 1:case 8:case 32:return-1;case 2:case 64:return 0;case 4:case 16:case 128:return 1}}function K(t){switch(t){case 1:case 2:case 4:return-1;case 8:case 16:return 0;case 32:case 64:case 128:return 1}}class J{constructor(t,e,s,r,i=0){this.tileKey=t,this._bufferingEnabled=e,this._sizeHint=i,this._meshes={self:new Z(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0;const n=r?1:0;this._copyBufferedDataIntoSelf=s&&this._bufferingEnabled&&t.level===n}get id(){return this.tileKey.id}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(t){this._meshes.self.indexEnsureSize(t)}entityStart(t,e=t){this._currentEntityOverlaps=0,this._meshes.self.entityStart(t,e)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled){if(this._copyBufferedDataIntoSelf)return;for(let t=0;t<8;t++){const e=1<<t;this._currentEntityOverlaps&e&&this._meshes.neighbors[t].entityEnd()}}}recordStart(t,e,s){this._currentRecordOverlaps=0,this._meshes.self.recordStart(t,e,s)}recordEnd(t=0){const e=this._meshes.self.recordEnd(this._currentRecordOverlaps);return e&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):e}recordBounds(t,e,s,r){this._bufferingEnabled&&this._addOverlap(t,e,s,r)}recordCount(){return this._meshes.self.recordCount()}metricStart(t){this._meshes.self.metricStart(t)}metricBoxWrite(t){this._meshes.self.metricBoxWrite(t)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(t){this._meshes.self.vertexWrite(t)}vertexWriteF32(t){this._meshes.self.vertexWriteF32(t)}vertexWriteRegion(t){this._meshes.self.vertexWriteRegion(t)}indexWrite(t){this._meshes.self.indexWrite(t)}serialize(t){const e={message:[],transferList:[]},s=this._meshes.self.serialize();return e.message.push({tileId:this.tileKey.id,...s.message}),e.transferList.push(...s.transferList),this._meshes.neighbors.forEach(((s,r)=>{const i=s.serialize(),n=1<<r,o=Q(n),a=K(n),h=new p.A(this.tileKey).getNormalizedNeighbor(o,a,t);e.message.push({tileId:h.id,...i.message}),e.transferList.push(...i.transferList)})),e}_addOverlap(t,e,s,r){const i=Math.min(B.CQ/2,s),n=Math.min(B.CQ/2,r),o=255^((t<0+i?148:t>=B.CQ-i?41:189)|(e<0+n?224:e>=B.CQ-n?7:231));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let t=0;t<8;t++){const e=1<<t;if(this._currentRecordOverlaps&e){if(this._copyBufferedDataIntoSelf){const t=-Q(e)*B.CQ,s=-K(e)*B.CQ;if(0!==s)continue;this._meshes.self.copyLast(t,s);continue}if(!this._meshes.neighbors[t]){const s=Math.floor(this._sizeHint/16);this._meshes.neighbors[t]=new Z(e,s)}const s=this._meshes.neighbors[t],r=-Q(e)*B.CQ,i=-K(e)*B.CQ;s.copyLastFrom(this._meshes.self,r,i)}}}}class tt{}class et{constructor(){this._defaultResult=null,this._backgroundFillResult=null}static async from(t,e){const s=new et;return s.setDefault(await t.createMeshWriters(e.meshes)),s}size(){return 1}getDefault(){return this._defaultResult}setDefault(t){this._defaultResult=t}getBackgroundFill(){return this._backgroundFillResult}setBackgroundFill(t){this._backgroundFillResult=t}hasArcadeDependency(t){return this._defaultResult?.some((e=>e.hasArcadeDependency(t)))??!1}match(t,e){const s=this.doMatch(t,e)||this.getDefault();if(s&&s.length>0){const t=this.getBackgroundFill();if(t)return[...t,...s]}return s}getSortKey(t,e){return 0}doMatch(t,e){return null}async fetchResources(t,e){}}class st extends et{static async fromDictionaryRenderer(t,e){return new st(t,e)}constructor(t,e){super(),this._context=t,this._schema=e,this._hashToGroup=new Map}get fieldMap(){return this._schema.fieldMap}async fetchResources(t,e){const s=e.getCursor(),r=[];for(;s.next();)r.push(this._updateMeshWriterGroup(t,s));await Promise.all(r)}match(t,e){const s=t.getAttributeHash();return this._hashToGroup.get(s)}async _updateMeshWriterGroup(t,e){const s=e.readLegacyFeatureForDisplay(),r=e.getAttributeHash();if(this._hashToGroup.has(r))return;this._hashToGroup.set(r,null);const i=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:s});if(!i)return;const n=await this._context.createMeshWriters(i.meshes);this._hashToGroup.set(r,n)}}class rt extends et{constructor(t,e){super(),this._intervals=[],this._isMaxInclusive=e,this._field=t}static async fromIntervalSchema(t,e){const s=await t.storage.createComputedField(e),r=new rt(s,e.isMaxInclusive);await Promise.all(e.intervals.map((async e=>{const s=await t.createMeshWriters(e.meshes);r.add(e,s)})));const i=await t.createMeshWriters(e.defaultSymbol);r.setDefault(i);const n=await t.createMeshWriters(e.backgroundFill);return r.setBackgroundFill(n),r}add(t,e){this._intervals.push({interval:t,result:e}),this._intervals.sort(((t,e)=>t.interval.min-e.interval.min))}size(){return super.size()+this._intervals.length}hasArcadeDependency(t){return this._field?.hasArcadeDependency(t)||this._intervals.some((e=>e.result.some((e=>e.hasArcadeDependency(t)))))}doMatch(t,e){const s=this._field?.read(t,e);if(null==s||isNaN(s)||s===1/0||s===-1/0)return null;for(let t=0;t<this._intervals.length;t++){const{interval:e,result:r}=this._intervals[t],i=s>=e.min,n=this._isMaxInclusive?s<=e.max:s<e.max;if(i&&n)return r}return null}}class it extends et{static async fromLabelSchema(t,e){const s=e.classes.map((async e=>{const s=await t.createMeshWriters(e.meshes);return{minScale:e.minScale,maxScale:e.maxScale,meshes:s,expression:null,where:await t.storage.createWhereClause(e.where)}})),r=await Promise.all(s);return new it(r)}constructor(t){super(),this._labels=t}match(t,e){if(!this._labels.length)return null;const s=this._getLabels(e.$view.scale),r=[];for(const e of s)e.where&&!e.where(t)||r.push(...e.meshes);return r}_getLabels(t){return this._labels.filter((e=>this._validForTileScale(e,t)))}_validForTileScale(t,e){const s=e-e/4,r=e+e/2;return(!t.minScale||t.minScale>=s)&&(!t.maxScale||t.maxScale<=r)}}class nt extends et{constructor(t,e){super(),this._defaultSymbolSortKey=0,this._nullResult=null,this._resultsMap=new Map,this._fields=[],this._fields=t,this._separator=e||""}static async fromMatcherSchema(t,e){const s=e.expression?[t.storage.createComputedField({expression:e.expression})]:[e.field?t.storage.createComputedField({field:e.field}):null,e.field2?t.storage.createComputedField({field:e.field2}):null,e.field3?t.storage.createComputedField({field:e.field3}):null],r=(await Promise.all(s)).filter((t=>!!t)),i=new nt(r,e.fieldDelimiter),n=await t.createMeshWriters(e.defaultSymbol);i.setDefault(n);const o=await t.createMeshWriters(e.backgroundFill);return i.setBackgroundFill(o),await Promise.all(e.map.map((async(e,s)=>{const r=await t.createMeshWriters(e.symbol);"<Null>"===e.value?i.setNullResult(r):i.add(e.value,r,s+1)}))),i}setNullResult(t){this._nullResult=t}getSortKey(t,e){const s=this._getValueFromFields(t,e);if(null==s||""===s||"<Null>"===s)return 0;const r=this._resultsMap.get(s.toString());return r?r.sortKey:this._defaultSymbolSortKey}add(t,e,s){this._resultsMap.set(t.toString(),{meshWriters:e,sortKey:s}),this._defaultSymbolSortKey=Math.max(this._defaultSymbolSortKey,s+1)}size(){return super.size()+this._resultsMap.size}hasArcadeDependency(t){return this._fields.some((e=>e.hasArcadeDependency(t)))||[...this._resultsMap.values()].some((e=>e.meshWriters.some((e=>e.hasArcadeDependency(t)))))||this._nullResult?.some((e=>e.hasArcadeDependency(t)))||!1}doMatch(t,e){const s=this._getValueFromFields(t,e);if(null!==this._nullResult&&(null==s||""===s||"<Null>"===s))return this._nullResult;if(null==s)return null;const r=s.toString();return this._resultsMap.get(r)?.meshWriters}_getValueFromFields(t,e){const s=[];for(const r of this._fields){const i=r.read(t,e);null==i||""===i?s.push("<Null>"):s.push(i)}return s.join(this._separator)}}async function ot(t,e){switch(e.type){case"simple":case"heatmap":case"dot-density":case"pie-chart":return et.from(t,e);case"interval":return rt.fromIntervalSchema(t,e);case"dictionary":return st.fromDictionaryRenderer(t,e);case"label":return it.fromLabelSchema(t,e);case"map":return nt.fromMatcherSchema(t,e);case"subtype":return at.fromSubtypes(t,e);case"cluster":return ht.fromClusterSchema(t,e);default:throw new Error("Impl")}}class at extends et{constructor(t,e){super(),this._subMatchers=t,this._subtypeField=e}static async fromSubtypes(t,e){const s=new Map,r=[];for(const i in e.renderers){const n=parseInt(i,10),o=ot(t,e.renderers[i]).then((t=>s.set(n,t)));r.push(o)}return await Promise.all(r),new at(s,e.subtypeField)}match(t,e){const s=t.readAttribute(this._subtypeField),r=this._subMatchers.get(s);return r?r.match(t,e):null}}class ht extends et{static async fromClusterSchema(t,e){const[s,r]=await Promise.all([ot(t,e.feature),ot(t,e.cluster)]);return new ht(s,r)}constructor(t,e){super(),this._featureMatcher=t,this._clusterMatcher=e}match(t,e){return 1===t.readAttribute("cluster_count")?this._featureMatcher.match(t,e):this._clusterMatcher.match(t,e)}}class ct extends tt{static async create(t,e){const s=await ot(t,e.symbology),r=e.labels?await ot(t,e.labels):null;return new ct(s,r)}constructor(t,e){super(),this._symbology=t,this._labels=e}destroy(){}async enqueueMatcherRequests(t,e){await Promise.all([this._symbology.fetchResources(t,e),this._labels?.fetchResources(t,e)])}enqueueWriterRequests(t,e,s){const r=this._symbology.match(e,s);if(r){for(const i of r)i.enqueueRequest(t,e,s);if(this._labels){const r=this._labels.match(e,s);if(!r)return;for(const i of r)i.enqueueRequest(t,e,s)}}}write(t,e,s,r,i){const n=this._symbology.match(s,r);if(n){for(const o of n)o.write(t,e,s,r,i);if(t.entityRecordCount()>=1&&this._labels){const o=this._labels.match(s,r);if(!o)return;for(const a of o)a.setReferences(n),a.write(t,e,s,r,i)}}}getSortKey(t,e){return this._symbology.getSortKey(t,e)}hasArcadeDependency(t){return this._symbology.hasArcadeDependency(t)}}var lt=s(799),ut=s(94656),dt=s(63907),_t=s(48852),pt=s(36421),ft=s(42293);class gt{constructor(t,e){this._context=t,this._descriptor=e,this.type=pt.p.RenderBuffer,this._context.instanceCounter.increment(dt.vt.Renderbuffer,this);const s=this._context.gl;this.glName=s.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:r,height:i,internalFormat:n,multisampled:o}=e;o?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,n,r,i):s.renderbufferStorage(s.RENDERBUFFER,n,r,i),this._context.bindRenderbuffer(null)}get descriptor(){return this._descriptor}get samples(){const t=this._descriptor.samples,e=this._context.parameters.maxSamples;return t?Math.min(t,e):e}get usedMemory(){return(t=this._descriptor).width<=0||t.height<=0||null==t.internalFormat?0:t.width*t.height*(0,ft.IB)(t.internalFormat);var t}resize(t,e){const s=this._descriptor;if(s.width===t&&s.height===e)return;s.width=t,s.height=e;const r=this._context.gl;this._context.bindRenderbuffer(this),s.multisampled?r.renderbufferStorageMultisample(r.RENDERBUFFER,this.samples,s.internalFormat,s.width,s.height):r.renderbufferStorage(r.RENDERBUFFER,s.internalFormat,s.width,s.height),this._context.bindRenderbuffer(null)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(dt.vt.Renderbuffer,this),this._context=null)}}var mt=s(72626);class yt{constructor(t,e,s=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(dt.vt.FramebufferObject,this);const r=xt(e)?e:new mt.g(this._context,e);if(this._colorAttachments.set(dt.Nm.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(dt.Nm.COLOR_ATTACHMENT0),null!=s)if(function(t){return xt(t)||null!=t&&"pixelFormat"in t}(s))this._depthStencilTexture=xt(s)?s:new mt.g(this._context,s),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=function(t){return null!=t&&"type"in t&&t.type===pt.p.RenderBuffer}(s)?s:new gt(this._context,s);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName&&(this._context.gl.deleteFramebuffer(this._glName),this._glName=null),this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(dt.vt.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(dt.Nm.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(dt.Nm.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(dt.Nm.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,s])=>t+s.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&xt(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=dt.Nm.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const s=t.descriptor;this._validateTextureDescriptor(s),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=dt.Nm.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=dt.Nm.COLOR_ATTACHMENT0){const s=this._colorAttachments.get(e);s&&this._framebufferTexture2D(s.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case pt.p.Texture:return this._attachDepthStencilTexture(t);case pt.p.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==dt.Ab.DEPTH_STENCIL&&e.pixelFormat!==dt.Ab.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==dt.ld.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,dt.nI)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;if(t&&this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,dt.nI),this._context.bindFramebuffer(t)}return this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const s=this._context.gl,r=this._getGLAttachmentPoint(e);s.framebufferRenderbuffer(dt.R.FRAMEBUFFER,r,s.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this);const s=this._context.gl,r=this._getGLAttachmentPoint(t.descriptor);s.framebufferRenderbuffer(dt.R.FRAMEBUFFER,r,s.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,s,r,i,n,o){(t<0||e<0||i<0||n<0)&&console.error("Offsets cannot be negative!"),(s<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==dt.Ap.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||t+s>this.width||e+r>this.height||i+s>a.width||n+r>a.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const h=this._context,c=h.bindTexture(o,mt.g.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(mt.g.TEXTURE_UNIT_FOR_UPDATES),h.bindFramebuffer(this),h.gl.copyTexSubImage2D(dt.Ap.TEXTURE_2D,0,i,n,t,e,s,r),h.bindTexture(c,mt.g.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,s,r,i,n,o){(s<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),o||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,s,r,i,n,o)}async readPixelsAsync(t,e,s,r,i,n,o){const{gl:a}=this._context,h=_t.g.createPixelPack(this._context,dt._U.STREAM_READ,o.byteLength);this._context.bindBuffer(h);const c=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),a.readPixels(t,e,s,r,i,n,0),this._context.unbindBuffer(dt.NZ.PIXEL_PACK_BUFFER),this._context.bindFramebuffer(c),await h.getSubDataAsync(o),h.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const s={width:t,height:e};bt(s,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(s.width,s.height))),this._depthStencilTexture?.resize(s.width,s.height),this._initialized&&(bt(s,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(s.width,s.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=dt.R.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const s=e.createFramebuffer();if(e.bindFramebuffer(t,s),this._colorAttachments.forEach(((e,s)=>this._framebufferTexture2D(e.glName,s,wt(e),t))),this._depthStencilBuffer){const s=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,s,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,wt(this._depthStencilTexture),t);(0,ut.en)()&&e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=s,this._initialized=!0}_framebufferTexture2D(t,e=dt.Nm.COLOR_ATTACHMENT0,s=dt.Ap.TEXTURE_2D,r=dt.R.FRAMEBUFFER,i=0){this._context.gl.framebufferTexture2D(r,e,s,t,i)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(dt.R.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=(0,C.WD)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,C.WD)(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==dt.Ap.TEXTURE_2D&&t.target!==dt.Ap.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),bt(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){bt(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case dt.yQ.DEPTH_COMPONENT16:case dt.yQ.DEPTH_COMPONENT24:case dt.yQ.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case dt.yQ.DEPTH24_STENCIL8:case dt.yQ.DEPTH32F_STENCIL8:case dt.yQ.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case dt.yQ.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(t){if(-1===yt._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;yt._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const e=t-dt.Nm.COLOR_ATTACHMENT0;e+1>yt._MAX_COLOR_ATTACHMENTS&&E.A.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${e+1}. Implementation supports up to ${yt._MAX_COLOR_ATTACHMENTS} color attachments`)}}function xt(t){return null!=t&&"type"in t&&t.type===pt.p.Texture}function bt(t,e){const s=Math.max(t.width,t.height);if(s>e){E.A.getLogger("esri.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/s;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function wt(t){return t.descriptor.target===dt.Ap.TEXTURE_CUBE_MAP?dt.Ap.TEXTURE_CUBE_MAP_POSITIVE_X:dt.Ap.TEXTURE_2D}yt._MAX_COLOR_ATTACHMENTS=-1,s(62298);var vt=s(67171);function St(t,e,s){const r=new vt.R(e.width,e.height);return r.dataType=e.dataType,e.depth&&(r.depth=e.depth),e.flipped&&(r.flipped=e.flipped),e.hasMipmap&&(r.hasMipmap=e.hasMipmap),r.internalFormat=e.internalFormat,e.isImmutable&&(r.isImmutable=e.isImmutable),e.isOpaque&&(r.isOpaque=e.isOpaque),e.maxAnisotropy&&(r.maxAnisotropy=e.maxAnisotropy),r.pixelFormat=e.pixelFormat,e.preMultiplyAlpha&&(r.preMultiplyAlpha=e.preMultiplyAlpha),e.samplingMode&&(r.samplingMode=e.samplingMode),e.target&&(r.target=e.target),r.uniform=e.uniform,e.unpackAlignment&&(r.unpackAlignment=e.unpackAlignment),e.wrapMode&&(r.wrapMode=e.wrapMode),new mt.g(t,r,s)}new Map;class It{}class Mt extends It{constructor(t){super(),this._fetcher=t,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destroy(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(t){const e="url"in(r=t.resource)&&"urlHash"in r?{...r,url:""}:r,s=(0,lt.Wm)(JSON.stringify(e));var r;return this._pendingIds.has(s)||(this._pendingIds.add(s),this._pendingRequests.push({...t,resourceId:s})),s}async fetchEnqueuedResources(){const t=this._pendingRequests;if(this._pendingIds.clear(),this._pendingRequests=[],0===t.length)return;const e=await this._fetcher.fetch(t,this._abortOptions);for(let s=0;s<e.length;s++){const r=t[s].resourceId;this._resourceIdToResource.set(r,e[s])}}async fetchResourceImmediate(t){const e=await this._fetcher.fetch([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return e[0]}async fetchDictionaryResourceImmediate(t){const e=await this._fetcher.fetchDictionary([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return e[0]}getResource(t){return this._resourceIdToResource.get(t)}}var Pt,Tt;(Tt=Pt||(Pt={}))[Tt.AnimatedMarker=0]="AnimatedMarker",Tt[Tt.Blend=1]="Blend",Tt[Tt.ComplexFill=2]="ComplexFill",Tt[Tt.ComplexOutlineFill=3]="ComplexOutlineFill",Tt[Tt.DotDensity=4]="DotDensity",Tt[Tt.Fill=5]="Fill",Tt[Tt.GradientFill=6]="GradientFill",Tt[Tt.GradientStroke=7]="GradientStroke",Tt[Tt.Grid=8]="Grid",Tt[Tt.Heatmap=9]="Heatmap",Tt[Tt.Label=10]="Label",Tt[Tt.Line=11]="Line",Tt[Tt.Magnifier=12]="Magnifier",Tt[Tt.Marker=13]="Marker",Tt[Tt.OutlineFill=14]="OutlineFill",Tt[Tt.Overlay=15]="Overlay",Tt[Tt.PatternFill=16]="PatternFill",Tt[Tt.PatternOutlineFill=17]="PatternOutlineFill",Tt[Tt.PieChart=18]="PieChart",Tt[Tt.Test=19]="Test",Tt[Tt.Text=20]="Text",Tt[Tt.TexturedLine=21]="TexturedLine",Tt[Tt.Bitmap=22]="Bitmap";var At=s(68197),Ct=s(15294);function kt(t,e){return[!!t?.minScale&&e.scaleToZoom(t.minScale)||0,!!t?.maxScale&&e.scaleToZoom(t.maxScale)||100]}function Ft(t){return 1<<t}function Et(t){let e=0;for(const[s,r]of t)r&&(e|=1<<s);return e}function zt(t){let e;if(!t)return[0,0,0,0];if("string"==typeof t){const s=At.A.fromString(t);if(!s)return E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new r.A("mapview:mesh-processing","Unable to parse string into color",{color:t})),[0,0,0,0];e=s.toArray()}else e=t;const[s,i,n,o]=e;return[s*(o/255),i*(o/255),n*(o/255),o]}function Ot(t,e){return Math.round(Math.min(Math.sqrt(t*e),255))}function Rt(t,e){return Math.round(t*e)/e}const Dt=0,Lt=1,Nt=2,Bt=3,Gt=4,Ut=5;var Vt=s(4718),qt=s(51118),Wt=s(65864),jt=s(92722);class Yt{static fromOptimized(t,e,s=!1,r=!1,i=1){return(new Xt).initialize(t,e,s,r,i)}static fromJSON(t,e=!1,s=!1){const[r,i]=Ht(t);return(new Zt).initialize(r,i,e,s,1)}static fromOptimizedCIM(t,e,s=!1,r=!1,i=1){return(new Qt).initialize(t,e,s,r,i)}static fromJSONCIM(t,e=!1,s=!1,r=1){const[i,n]=Ht(t);return(new Kt).initialize(i,n,e,s,r)}static fromFeatureSetReader(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimized(e,s):null}static fromFeatureSetReaderCIM(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimizedCIM(e,s):null}static createEmptyOptimized(t,e=!1,s=!1,r=1){return(new Xt).initialize(new jt.A,t,e,s,r)}static createEmptyJSON(t,e=!1,s=!1){return(new Zt).initialize([],t,e,s,1)}static createEmptyOptimizedCIM(t,e=!1,s=!1,r=1){return(new Qt).initialize(new jt.A,t,e,s,r)}static createEmptyJSONCIM(t,e=!1,s=!1,r=1){return(new Kt).initialize([],t,e,s,r)}asJSON(){const t=(0,qt.x)(this);return"esriGeometryEnvelope"===this.geometryType?{xmin:t[0][0][0],ymin:t[0][0][1],xmax:t[0][2][0],ymax:t[0][2][1]}:"esriGeometryMultipoint"===this.geometryType?{points:t.flat()}:"esriGeometryPoint"===this.geometryType?{x:t[0][0][0],y:t[0][0][1]}:"esriGeometryPolygon"===this.geometryType?{rings:t}:{paths:t}}getCurrentRingArea(){if(this.pathSize<3)return 0;let t,e,s=0;if(this.seekPathStart(),!this.nextPoint())return 0;t=this.x,e=this.y;const r=t,i=e;for(;this.nextPoint();)s+=(t-this.x)*(e+this.y),t=this.x,e=this.y;return s+=(t-r)*(e+i),-.5*s}invertY(){this.yFactor*=-1}}class Xt extends Yt{constructor(){super(...arguments),this._end=-1}initialize(t,e,s,r,i){return this.hasZ=s,this.hasM=r,this.geometryType=e,this._stride=2+Number(s)+Number(r),this._geometry=t,this._pathIndex=-1,this._pathOffset=0,this._pointOffset=-this._stride,this._end=-1,this.yFactor=i,this}reset(){this.initialize(this._geometry,this.geometryType,this.hasZ,this.hasM,this.yFactor)}seekPath(t){if(t>=0&&t<this.totalSize){if(this._pathIndex<t)for(;this._pathIndex<t&&this.nextPath(););else if(this._pathIndex>t)for(;this._pathIndex>t&&this.prevPath(););return!0}return!1}seekPathStart(){this._pointOffset=this._pathOffset-this._stride}seekPathEnd(){this._pointOffset=this._end}seekInPath(t){const e=this._pathOffset+t*this._stride;return e>=0&&e<this._end&&(this._pointOffset=e,!0)}nextPoint(){return(this._pointOffset+=this._stride)<this._end}prevPoint(){return(this._pointOffset-=this._stride)>=this._pathOffset}nextPath(){return!(this.pathIndex>=this.totalSize-1||(this._pathIndex>=0&&(this._pathOffset+=this._stride*this.pathSize),this._pathIndex++,this._pointOffset=this._pathOffset-this._stride,this._end=this._pointOffset+this._stride+this._stride*this.pathSize,0))}prevPath(){return!(this.pathIndex<=0||(this._pathIndex--,this._end=this._pathOffset,this._pathOffset-=this._stride*this.pathSize,this._pointOffset=this._pathOffset-this._stride,0))}getCurrentPath(){const t=this._end,e=this._geometry.coords,s=this._pathOffset;return(new Xt).initialize(new jt.A([this.pathSize],e.slice(s,t)),this.geometryType,this.hasZ,this.hasM,this.yFactor)}pathLength(){const t=this._end,e=this._stride,s=this._geometry.coords;let r=0;for(let i=this._pathOffset+e;i<t;i+=e){const t=s[i-e],n=s[i-e+1],o=s[i]-t,a=s[i+1]-n;r+=Math.sqrt(o*o+a*a)}return r}startPath(){this._geometry.lengths.push(0)}pushPath(t){this.startPath(),this.pushPoints(t)}pushPoint(t){for(let e=0;e<this._stride;++e)this._geometry.coords.push(t[e]);this._geometry.lengths[this.totalSize-1]++}pushXY(t,e){this._geometry.coords.push(t,e),this._geometry.lengths[this.totalSize-1]++}pushPoints(t){for(const e of t)for(let t=0;t<this._stride;++t)this._geometry.coords.push(e[t]);this._geometry.lengths[this.totalSize-1]+=t.length}pushCursor(t){const e=t.asOptimized();this._geometry.coords.push(...e.coords),this._geometry.lengths.push(...e.lengths)}asOptimized(){const t=this._geometry.clone();if(1!==this.yFactor)for(let e=1;e<t.coords.length;e+=this._stride)t.coords[e]*=this.yFactor;return"esriGeometryPoint"===this.geometryType&&(t.lengths.length=0),t}isClosed(){const t=this._geometry.coords,e=this._pathOffset,s=this._end-this._stride;for(let r=0;r<this._stride;r++)if(t[e+r]!==t[s+r])return!1;return!0}clone(){return(new Xt).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._geometry.isPoint?1:this._geometry.lengths.reduce(((t,e)=>t+e))}get pathSize(){const{lengths:t}=this._geometry;return this._geometry.isPoint?1:this._pathIndex<0||this._pathIndex>t.length-1?0:t[this._pathIndex]}get totalSize(){return this._geometry.isPoint?1:this._geometry.lengths.length}get x(){return this._geometry.coords[this._pointOffset]}set x(t){this._geometry.coords[this._pointOffset]=t}get y(){return this.yFactor*this._geometry.coords[this._pointOffset+1]}set y(t){this._geometry.coords[this._pointOffset+1]=this.yFactor*t}get z(){return this._geometry.coords[this._pointOffset+2]}set z(t){this._geometry.coords[this._pointOffset+2]=t}get m(){const t=this.hasZ?3:2;return this._geometry.coords[this._pointOffset+t]}set m(t){this._geometry.coords[this._pointOffset+3]=t}get pathIndex(){return this._pathIndex}get _coordIndex(){return this._pointOffset/this._stride}}function $t(t){const e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e}function Ht(t){return(0,Wt.Bi)(t)?[t.rings,"esriGeometryPolygon"]:(0,Wt.Rg)(t)?[t.paths,"esriGeometryPolyline"]:(0,Wt.U9)(t)?[[t.points],"esriGeometryMultipoint"]:(0,Wt.ZC)(t)?[[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]],"esriGeometryEnvelope"]:(0,Wt.fT)(t)?[[[$t(t)]],"esriGeometryPoint"]:[[],"esriGeometryPolyline"]}class Zt extends Yt{initialize(t,e,s,r,i){return this._paths=t,this.geometryType=e,this.hasZ=s,this.hasM=r,this._pathIndex=this._pointIndex=-1,this.yFactor=i,this._mIndex=this.hasZ?3:2,this}reset(){this._pathIndex=this._pointIndex=-1}seekPath(t){return this._pathIndex=t,this._pointIndex=-1,t>=0&&t<this.totalSize&&(this._currentPath=this._paths[t],!0)}seekPathStart(){this._pointIndex=-1}seekPathEnd(){this._pointIndex=this._currentPath.length}seekInPath(t){return t>=0&&t<this._currentPath.length&&(this._pointIndex=t,this._currentPoint=this._currentPath[this._pointIndex],!0)}nextPoint(){return this._currentPoint=this._currentPath[++this._pointIndex],this._pointIndex<this._currentPath.length}prevPoint(){return this._currentPoint=this._currentPath[--this._pointIndex],this._pointIndex>=0}nextPath(){return this._pointIndex=-1,this._currentPath=this._paths[++this._pathIndex],this._pathIndex<this.totalSize}prevPath(){return this.pathIndex>0&&(this._pointIndex=-1,this._pathIndex--,this._currentPath=this._paths[this._pathIndex],!0)}pathLength(){const t=this._currentPath.length,e=this._currentPath;let s=0;for(let r=1;r<t;r++){const t=e[r-1],i=e[r],n=t[0],o=t[1],a=i[0]-n,h=i[1]-o;s+=Math.sqrt(a*a+h*h)}return s}startPath(){this._paths.push([])}getCurrentPath(){return(new Zt).initialize([this._currentPath],this.geometryType,this.hasZ,this.hasM,this.yFactor)}pushPath(t){this._paths.push(t)}pushPoint(t){this._paths[this.totalSize-1].push(t)}pushXY(t,e){this._paths[this.totalSize-1].push([t,e])}pushPoints(t){this._paths[this.totalSize-1].push(...t)}pushCursor(t){const e=(0,qt.x)(t);for(const t of e)this.pushPath(t)}asOptimized(){const t=new jt.A;if("esriGeometryPoint"===this.geometryType)t.coords.push(...this._paths[0][0]),t.lengths.length=0;else for(const e of this._paths){for(const s of e)t.coords.push(s[0]),t.coords.push(s[1]*this.yFactor),this.hasZ&&t.coords.push(s[2]),this.hasM&&t.coords.push(s[this._mIndex]);t.lengths.push(e.length)}return t}isClosed(){const t=this._currentPath[0],e=this._currentPath[this._currentPath.length-1];for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}clone(){return(new Zt).initialize((0,Vt.o8)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._paths.map((t=>t.length)).reduce(((t,e)=>t+e))}get pathSize(){return this._pathIndex<0||this._pathIndex>this.totalSize-1?-1:this._paths[this._pathIndex].length}get totalSize(){return this._paths.length}get x(){return this._currentPoint[0]}set x(t){this._currentPoint[0]=t}get y(){return this.yFactor*this._currentPoint[1]}set y(t){this._currentPoint[1]=this.yFactor*t}get z(){return this._currentPoint[2]}set z(t){this._currentPoint[2]=t}get m(){return this._currentPoint[this._mIndex]}set m(t){this._currentPoint[this._mIndex]=t}get pathIndex(){return this._pathIndex}}class Qt extends Xt{initialize(t,e,s,r,i){return super.initialize(t,e,s,r,i),this._controlPoints||(this._controlPoints=this._controlPoints=new Array(this.totalSize).fill(void 0).map((t=>new Set))),this}startPath(){super.startPath(),this._controlPoints.push(new Set)}clone(){const t=(new Qt).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor);return t._controlPoints=this._controlPoints,t}setControlPoint(){this._controlPoints[this.pathIndex].add(this._coordIndex)}getControlPoint(){return this._controlPoints[this.pathIndex].has(this._coordIndex)}setControlPointAt(t){this._controlPoints[this.pathIndex].add(t)}getControlPointAt(t){return this._controlPoints[this.pathIndex].has(t)}}class Kt extends Zt{initialize(t,e,s,r,i){return super.initialize(t,e,s,r,i)}clone(){return(new Kt).initialize((0,Vt.o8)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}setControlPoint(){this._paths[this.pathIndex][this._pointIndex][4]=1}getControlPoint(){return 1===this._paths[this.pathIndex][this._pointIndex][4]}setControlPointAt(t){this._paths[this.pathIndex][t][4]=1}getControlPointAt(t){return 1===this._paths[this.pathIndex][t][4]}}var Jt=s(6774);let te;class ee{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}function se(t,e){te||(te=new Jt.O3(0,0,0,1));const s="esriGeometryPolygon"===t.geometryType,r=s?Jt.dC.Polygon:Jt.dC.LineString,i=s?3:2;let n,o;for(te.reset(r),te.setPixelMargin(e+1),te.setExtent(512);t.nextPath();)if(!(t.pathSize<i)){for(t.nextPoint(),n=t.x,o=-t.y,te.moveTo(n,o);t.nextPoint();)n=t.x,o=-t.y,te.lineTo(n,o);s&&te.close()}const a=te.result(!1);if(a){const e=Yt.createEmptyOptimizedCIM(t.geometryType);for(const t of a){e.startPath();for(const s of t)e.pushXY(s.x,-s.y)}return e.reset(),e}return null}class re{static local(){return null===re.instance&&(re.instance=new re),re.instance}execute(t,e,s,r,i){return new ie(t,e,s)}}re.instance=null;class ie{constructor(t,e,s){this._inputGeometries=t,this._angleTolerance=void 0!==e.angleTolerance?e.angleTolerance:120,this._maxCosAngle=Math.cos((1-Math.abs(this._angleTolerance)/180)*Math.PI)}next(){let t=this._inputGeometries.next();for(;t;){if("esriGeometryPolygon"===t.geometryType)this._isClosed=!0;else if("esriGeometryPolyline"===t.geometryType)this._isClosed=!1;else{if("esriGeometryEnvelope"!==t.geometryType){t=this._inputGeometries.next();continue}if(this._maxCosAngle)return t;this._isClosed=!0}for(;t.nextPath();)this._processPath(t);return t.reset(),t}return null}_processPath(t){if(t.nextPoint()){const e=t.x,s=t.y;let r=e,i=s,n=t.pathSize,o=0,a=0,h=0,c=0,l=0,u=0;this._isClosed&&++n;for(let d=1;t.nextPoint()||d<n;++d){let _,p;this._isClosed&&d===n-1?(_=e,p=s):(_=t.x,p=t.y);const f=_-r,g=p-i,m=Math.sqrt(f*f+g*g);d>1&&m>0&&h>0&&(o*f+a*g)/m/h<=this._maxCosAngle&&t.setControlPointAt(d-1),1===d&&(c=f,l=g,u=m),m>0&&(r=_,i=p,o=f,a=g,h=m)}this._isClosed&&h>0&&u>0&&(o*c+a*l)/u/h<=this._maxCosAngle&&t.setControlPointAt(0)}}}class ne{constructor(){this.setIdentity()}getAngle(){return(null==this.rz||0===this.rz&&1!==this.rzCos&&0!==this.rzSin)&&(this.rz=Math.atan2(this.rzSin,this.rzCos)),this.rz}setIdentity(){this.tx=0,this.ty=0,this.tz=0,this.s=1,this.rx=0,this.ry=0,this.rz=0,this.rzCos=1,this.rzSin=0}setTranslate(t,e){this.tx=t,this.ty=e}setTranslateZ(t){this.tz=t}setRotateCS(t,e){this.rz=void 0,this.rzCos=t,this.rzSin=e}setRotate(t){this.rz=t,this.rzCos=void 0,this.rzSin=void 0}setRotateY(t){this.ry=t}setScale(t){this.s=t}setMeasure(t){this.m=t}}function oe(t,e){t[4]=e}class ae{constructor(t,e=!0,s=!0,r=0){this.isClosed=!1,this.geometryCursor=null,this.geometryCursor=!e&&"esriGeometryPolygon"===t.geometryType||!s&&"esriGeometryPolyline"===t.geometryType?null:t,this.geomUnitsPerPoint=r,this.iterateMultiPath=!1,this.iteratePath=!1,this.internalPlacement=new ne}next(){if(!this.geometryCursor)return null;const t=this.processMultiPath(this.geometryCursor);return this.iterateMultiPath&&t||(this.geometryCursor=null),t}processMultiPath(t){for(;this.iteratePath||t.pathIndex<t.totalSize-1;){this.iteratePath||t.nextPath(),this.iterateMultiPath=!0;const e=this.processPath(t);if(e)return e}return this.iterateMultiPath=!1,null}}class he{constructor(t,e,s,r=0){this.isClosed=!1,this.inputGeometries=t,this.acceptPolygon=e,this.acceptPolyline=s,this.geomUnitsPerPoint=r,this.iteratePath=!1,this.multiPathCursor=null}next(){for(;;){if(!this.multiPathCursor){let t=this.inputGeometries.next();for(;t&&(this.isClosed=this.acceptPolygon&&"esriGeometryPolygon"===t.geometryType||"esriGeometryEnvelope"===t.geometryType,this.multiPathCursor=t,!this.multiPathCursor);)t=this.inputGeometries.next();if(!this.multiPathCursor)return null}for(;this.iteratePath||this.multiPathCursor.nextPath();){this.multiPathCursor.seekPathStart();const t=this.processPath(this.multiPathCursor);if(t)return t}this.multiPathCursor=null}}}const ce=.03;class le{constructor(t=0,e=!1){}isEmpty(t){if(!t.nextPoint())return!0;let e,s,r,i;for(e=t.x,s=t.y;t.nextPoint();e=s,s=i)if(r=t.x,i=t.y,r!==e||i!==s)return t.seekPathStart(),!1;return t.seekPathStart(),!0}normalize(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);0!==e&&(t[0]/=e,t[1]/=e)}getLength(t,e,s,r){const i=s-t,n=r-e;return Math.sqrt(i*i+n*n)}getSegLength(t){const[[e,s],[r,i]]=t;return this.getLength(e,s,r,i)}getCoord2D(t,e,s,r,i){return[t+(s-t)*i,e+(r-e)*i]}getSegCoord2D(t,e){const[[s,r],[i,n]]=t;return this.getCoord2D(s,r,i,n,e)}getAngle(t,e,s,r,i){const n=s-t,o=r-e;return Math.atan2(o,n)}getAngleCS(t,e,s,r,i){const n=s-t,o=r-e,a=Math.sqrt(n*n+o*o);return a>0?[n/a,o/a]:[1,0]}getSegAngleCS(t,e){const[[s,r],[i,n]]=t;return this.getAngleCS(s,r,i,n,e)}cut(t,e,s,r,i,n){return[i<=0?[t,e]:this.getCoord2D(t,e,s,r,i),n>=1?[s,r]:this.getCoord2D(t,e,s,r,n)]}getSubCurve(t,e,s){const r=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");return this.appendSubCurve(r,t,e,s)?r:null}appendSubCurve(t,e,s,r){t.startPath(),e.seekPathStart();let i=0,n=!0;if(!e.nextPoint())return!1;let o=e.x,a=e.y;for(;e.nextPoint();){const h=this.getLength(o,a,e.x,e.y);if(0!==h){if(n){if(i+h>s){const c=(s-i)/h;let l=1,u=!1;i+h>=r&&(l=(r-i)/h,u=!0);const d=this.cut(o,a,e.x,e.y,c,l);if(d&&t.pushPoints(d),u)break;n=!1}}else{if(i+h>r){const s=this.cut(o,a,e.x,e.y,0,(r-i)/h);s&&t.pushPoint(s[1]);break}t.pushXY(e.x,e.y)}i+=h,o=e.x,a=e.y}else o=e.x,a=e.y}return!0}getCIMPointAlong(t,e){if(!t.nextPoint())return null;let s,r,i,n,o=0;for(s=t.x,r=t.y;t.nextPoint();s=i,r=n){i=t.x,n=t.y;const a=this.getLength(s,r,i,n);if(0!==a){if(o+a>e){const t=(e-o)/a;return this.getCoord2D(s,r,i,n,t)}o+=a}}return null}offset(t,e,s,r,i){if(!t||t.length<2)return null;let n=0,o=t[n++],a=n;for(;n<t.length;){const e=t[n];e[0]===o[0]&&e[1]===o[1]||(n!==a&&(t[a]=t[n]),o=t[a++]),n++}const h=t[0][0]===t[a-1][0]&&t[0][1]===t[a-1][1];if(h&&--a,a<(h?3:2))return null;const c=[];o=h?t[a-1]:null;let l=t[0];for(let i=0;i<a;i++){const n=i===a-1?h?t[0]:null:t[i+1];if(o)if(n){const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t);const i=[l[0]-o[0],l[1]-o[1]];this.normalize(i);const a=i[0]*t[1]-i[1]*t[0],h=i[0]*t[0]+i[1]*t[1];if(0===a&&1===h){l=n;continue}if(a>=0==e<=0){if(h<1){const s=[t[0]-i[0],t[1]-i[1]];this.normalize(s);const n=Math.sqrt((1+h)/2);if(n>1/r){const t=-Math.abs(e)/n;c.push([l[0]-s[0]*t,l[1]-s[1]*t])}}}else switch(s){case Ct.xw.Mitered:{const s=Math.sqrt((1+h)/2);if(s>0&&1/s<r){const r=[t[0]-i[0],t[1]-i[1]];this.normalize(r);const n=Math.abs(e)/s;c.push([l[0]-r[0]*n,l[1]-r[1]*n]);break}}case Ct.xw.Bevelled:c.push([l[0]+i[1]*e,l[1]-i[0]*e]),c.push([l[0]+t[1]*e,l[1]-t[0]*e]);break;case Ct.xw.Rounded:if(h<1){c.push([l[0]+i[1]*e,l[1]-i[0]*e]);const s=Math.floor(2.5*(1-h));if(s>0){const r=1/s;let n=r;for(let o=1;o<s;o++,n+=r){const s=[i[1]*(1-n)+t[1]*n,-i[0]*(1-n)-t[0]*n];this.normalize(s),c.push([l[0]+s[0]*e,l[1]+s[1]*e])}}c.push([l[0]+t[1]*e,l[1]-t[0]*e])}break;case Ct.xw.Square:default:if(a<0)c.push([l[0]+(i[1]+i[0])*e,l[1]+(i[1]-i[0])*e]),c.push([l[0]+(t[1]-t[0])*e,l[1]-(t[0]+t[1])*e]);else{const s=Math.sqrt((1+Math.abs(h))/2),r=[t[0]-i[0],t[1]-i[1]];this.normalize(r);const n=e/s;c.push([l[0]-r[0]*n,l[1]-r[1]*n])}}}else{const t=[l[0]-o[0],l[1]-o[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}else{const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}o=l,l=n}return c.length<(h?3:2)?null:(h&&c.push([c[0][0],c[0][1]]),c)}}const ue=Ct.oF.OpenEnded;class de{static local(){return null===de.instance&&(de.instance=new de),de.instance}execute(t,e,s,r,i){return new _e(t,e,s)}}de.instance=null;class _e extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new le,this._width=(void 0!==e.width?e.width:5)*s,this._arrowType=void 0!==e.geometricEffectArrowType?e.geometricEffectArrowType:void 0!==e.arrowType?e.arrowType:ue,this._offsetFlattenError=ce*s}processPath(t){const e=Yt.createEmptyOptimizedCIM(t.geometryType);switch(this._arrowType){case Ct.oF.OpenEnded:default:this._constructSimpleArrow(e,t,!0);break;case Ct.oF.Block:this._constructSimpleArrow(e,t,!1);break;case Ct.oF.Crossed:this._constructCrossedArrow(e,t)}return e}_constructSimpleArrow(t,e,s){const r=e.pathLength();let i=this._width;r<2*i&&(i=r/2);const n=this._curveHelper.getSubCurve(e,0,r-i);if(!n||!n.nextPath())return;n.seekPathStart();const o=i/2;if(this._curveHelper.isEmpty(n))return;const a=(0,qt.A)(n),h=this._constructOffset(a,-o);if(!h)return;const c=this._constructOffset(a,o);if(!c)return;const l=this._constructArrowBasePoint(h,-o/2);if(!l)return;const u=this._constructArrowBasePoint(c,o/2);if(!u)return;e.seekInPath(e.pathSize-1);const d=[e.x,e.y];t.pushPath(c),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(u),t.nextPoint(),t.setControlPoint(),t.pushPoint(d),t.nextPoint(),t.setControlPoint(),t.pushPoint(l),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.setControlPoint(),s||(t.setControlPointAt(0),t.setControlPointAt(t.pathSize-1),t.pushPoint(c[0])),t.reset()}_constructCrossedArrow(t,e){const s=e.pathLength();let r=this._width;s<3.732050807568877*r&&(r=s/3.732050807568877),e.seekPathStart();const i=this._curveHelper.getSubCurve(e,0,s-2.732050807568877*r);if(!i)return;i.nextPath();const n=r/2;if(this._curveHelper.isEmpty(i))return;const o=(0,qt.A)(i),a=this._constructOffset(o,n);if(!a)return;const h=this._constructOffset(o,-n);if(!h)return;const c=this._curveHelper.getSubCurve(e,0,s-r);if(!c)return;if(c.nextPath(),this._curveHelper.isEmpty(c))return;const l=(0,qt.A)(c),u=this._constructOffset(l,n);if(!u)return;const d=this._constructOffset(l,-n);if(!d)return;const _=u[u.length-1],p=this._constructArrowBasePoint(u,n/2);if(!p)return;const f=d[d.length-1],g=this._constructArrowBasePoint(d,-n/2);if(!g)return;e.seekInPath(e.pathSize-1);const m=[e.x,e.y];t.pushPath(a),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(f),t.nextPoint(),t.setControlPoint(),t.pushPoint(g),t.nextPoint(),t.setControlPoint(),t.pushPoint(m),t.nextPoint(),t.setControlPoint(),t.pushPoint(p),t.nextPoint(),t.setControlPoint(),t.pushPoint(_),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.nextPoint(),t.setControlPoint(),t.reset()}_constructOffset(t,e){return this._curveHelper.offset(t,e,Ct.xw.Rounded,4,this._offsetFlattenError)}_constructArrowBasePoint(t,e){if(!t||t.length<2)return null;const s=t[t.length-2],r=t[t.length-1],i=[r[0]-s[0],r[1]-s[1]];return this._curveHelper.normalize(i),[r[0]+i[1]*e,r[1]-i[0]*e]}}s(59456);class pe{static local(){return null===pe.instance&&(pe.instance=new pe),pe.instance}execute(t,e,s,r,i,n,o){return new fe(t,e,s,r,i,n,o)}}pe.instance=null;class fe{constructor(t,e,s,r,i,n,o){this._preventClipping=o,this._inputGeometries=t,this._tileKey=r,this._geometryEngine=i,this._curveHelper=new le,this._size=(void 0!==e.size?e.size:1)*s,this._maxInflateSize=n*s,this._offsetFlattenError=ce*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._size)return t;if("esriGeometryEnvelope"===t.geometryType)if(this._size>0){const e=Yt.createEmptyOptimizedCIM(t.geometryType),s=(0,qt.x)(t)[0],r=this._curveHelper.offset(s,this._size,Ct.xw.Rounded,4,this._offsetFlattenError);if(r)return e.pushPath(r),e}else if(this._size<0){const e=t.asJSON();if(Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._size>0)return Yt.fromJSONCIM({xmin:e.xmin-this._size,xmax:e.xmax+this._size,ymin:e.ymin-this._size,ymax:e.ymax+this._size})}const e=this._geometryEngine;if(null==e)return null;const s=!this._preventClipping&&this._tileKey?se(t,this._maxInflateSize):t;if(!s)continue;const r=e.buffer(q.A.WebMercator,s.asJSON(),this._size,1);return r?Yt.fromJSONCIM(r):null}return null}}var ge,me,ye=s(95108);class xe{static local(){return null===xe.instance&&(xe.instance=new xe),xe.instance}execute(t,e,s,r,i){return new be(t,e,s)}}xe.instance=null;class be{constructor(t,e,s){this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=e.rule??Ct.uQ.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){const e=this._processGeom((0,qt.x)(t));if(e?.length)return Yt.fromJSONCIM({paths:e})}return null}_clone(t){return[t[0],t[1]]}_mid(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}_mix(t,e,s,r){return[t[0]*e+s[0]*r,t[1]*e+s[1]*r]}_add(t,e){return[t[0]+e[0],t[1]+e[1]]}_add2(t,e,s){return[t[0]+e,t[1]+s]}_sub(t,e){return[t[0]-e[0],t[1]-e[1]]}_dist(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}_norm(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}_normalize(t,e=1){const s=e/this._norm(t);t[0]*=s,t[1]*=s}_leftPerpendicular(t){const e=-t[1],s=t[0];t[0]=e,t[1]=s}_leftPerp(t){return[-t[1],t[0]]}_rightPerpendicular(t){const e=t[1],s=-t[0];t[0]=e,t[1]=s}_rightPerp(t){return[t[1],-t[0]]}_dotProduct(t,e){return t[0]*e[0]+t[1]*e[1]}_crossProduct(t,e){return t[0]*e[1]-t[1]*e[0]}_rotateDirect(t,e,s){const r=t[0]*e-t[1]*s,i=t[0]*s+t[1]*e;t[0]=r,t[1]=i}_makeCtrlPt(t){const e=[t[0],t[1]];return oe(e,1),e}_addAngledTicks(t,e,s,r){const i=this._sub(s,e);this._normalize(i);const n=this._crossProduct(i,this._sub(r,e));let o;o=n>0?this._rightPerp(i):this._leftPerp(i);const a=Math.abs(n)/2,h=[];h.push([e[0]+(o[0]-i[0])*a,e[1]+(o[1]-i[1])*a]),h.push(e),h.push(s),h.push([s[0]+(o[0]+i[0])*a,s[1]+(o[1]+i[1])*a]),t.push(h)}_addBezier2(t,e,s,r,i){if(0==i--)return void t.push(r);const n=this._mid(e,s),o=this._mid(s,r),a=this._mid(n,o);this._addBezier2(t,e,n,a,i),this._addBezier2(t,a,o,r,i)}_addBezier3(t,e,s,r,i,n){if(0==n--)return void t.push(i);const o=this._mid(e,s),a=this._mid(s,r),h=this._mid(r,i),c=this._mid(o,a),l=this._mid(a,h),u=this._mid(c,l);this._addBezier3(t,e,o,c,u,n),this._addBezier3(t,u,l,h,i,n)}_add90DegArc(t,e,s,r,i){const n=i??this._crossProduct(this._sub(s,e),this._sub(r,e))>0,o=this._mid(e,s),a=this._sub(o,e);n?this._leftPerpendicular(a):this._rightPerpendicular(a),o[0]+=a[0],o[1]+=a[1],this._addBezier3(t,e,this._mix(e,.33333,o,.66667),this._mix(s,.33333,o,.66667),s,4)}_addArrow(t,e,s){const r=e[0],i=e[1],n=e[e.length-1],o=this._sub(r,i),a=this._norm(o);this._normalize(o);const h=Math.abs(this._crossProduct(o,this._sub(n,i)));let c=this._dotProduct(o,this._sub(n,i));c<.05*a?c=.05*a:c>.95*a&&(c=.95*a);const l=.5*h,u=this._leftPerp(o),d=[i[0]+o[0]*c,i[1]+o[1]*c],_=e.length-1,p=[];p.push(s?[-u[0],-u[1]]:u);let f=[-o[0],-o[1]];for(let t=1;t<_-1;t++){const s=this._sub(e[t+1],e[t]);this._normalize(s);const r=this._dotProduct(s,f),i=this._crossProduct(s,f),n=Math.sqrt((1+r)/2),o=this._sub(s,f);this._normalize(o),o[0]/=n,o[1]/=n,p.push(i<0?[-o[0],-o[1]]:o),f=s}p.push(this._rightPerp(f));for(let s=p.length-1;s>0;s--)t.push([e[s][0]+p[s][0]*l,e[s][1]+p[s][1]*l]);t.push([d[0]+p[0][0]*l,d[1]+p[0][1]*l]),t.push([d[0]+p[0][0]*h,d[1]+p[0][1]*h]),t.push(r),t.push([d[0]-p[0][0]*h,d[1]-p[0][1]*h]),t.push([d[0]-p[0][0]*l,d[1]-p[0][1]*l]);for(let s=1;s<p.length;s++)t.push([e[s][0]-p[s][0]*l,e[s][1]-p[s][1]*l])}_addDash(t,e,s){const r=this._norm(s)/7;this._normalize(s);let i=[];for(let n=0;n<=7;n++)i.push([e[0]+s[0]*n*r,e[1]+s[1]*n*r]),1&n&&(t.push(i),i=[])}_cp2(t,e,s){return t.length>=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,r){if(t.length>=3)return t[2];const i=this._mix(t[0],1-s,e,s),n=this._sub(e,t[0]);return this._normalize(n),this._rightPerpendicular(n),[i[0]+n[0]*r*this._defaultSize,i[1]+n[1]*r*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),r=this._sub(e,s);this._normalize(r);const i=this._rightPerp(r);return[e,s,[e[0]+(i[0]-r[0])*this._defaultSize,e[1]+(i[1]-r[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let r;if(t.length>=3)r=t[t.length-1];else{const t=this._sub(e,s);this._normalize(t);const i=this._rightPerp(t);r=[e[0]+(i[0]-t[0])*this._defaultSize,e[1]+(i[1]-t[1])*this._defaultSize]}return[s,r]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){const t=s.length>1&&(0,ye.Yl)(s)<this._defaultSize;if(!s||0===s.length||t)continue;const r=s.length;let i=s[0];switch(this._rule){case Ct.uQ.PerpendicularFromFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=[];n.push(r),n.push(this._mid(i,t)),e.push(n);break}case Ct.uQ.ReversedFirstSegment:{const t=this._cp2(s,0,-1);e.push([t,i]);break}case Ct.uQ.PerpendicularToSecondSegment:{if(s.length<3)return[];const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=[];n.push(this._mid(t,r)),n.push(i),e.push(n);break}case Ct.uQ.SecondSegmentWithTicks:{if(s.length<3)return[];const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);let o;o=this._crossProduct(n,this._sub(i,t))>0?this._rightPerp(n):this._leftPerp(n);const a=[];a.push([t[0]+(o[0]-n[0])/3,t[1]+(o[1]-n[1])/3]),a.push(t),a.push(r),a.push([r[0]+(o[0]+n[0])/3,r[1]+(o[1]+n[1])/3]),e.push(a);break}case Ct.uQ.DoublePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push(i),h.push([r[0]+o[0]*a,r[1]+o[1]*a]),e.push(h);const c=[];c.push([r[0]-o[0]*a,r[1]-o[1]*a]),c.push(t),e.push(c);break}case Ct.uQ.OppositeToFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a,r[1]+o[1]*a]),h.push([r[0]-o[0]*a,r[1]-o[1]*a]),e.push(h);break}case Ct.uQ.TriplePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a*.8,r[1]+o[1]*a*.8]),h.push([n[0]+.8*(i[0]-n[0]),n[1]+.8*(i[1]-n[1])]),e.push(h),e.push([r,n]);const c=[];c.push([r[0]-o[0]*a*.8,r[1]-o[1]*a*.8]),c.push([n[0]+.8*(t[0]-n[0]),n[1]+.8*(t[1]-n[1])]),e.push(c);break}case Ct.uQ.HalfCircleFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t);let o=this._sub(t,i);const a=Math.cos(Math.PI/18),h=Math.sin(Math.PI/18),c=Math.sqrt((1+a)/2),l=Math.sqrt((1-a)/2),u=[];let d;this._crossProduct(o,this._sub(r,i))>0?(u.push(i),o=this._sub(i,n),d=t):(u.push(t),o=this._sub(t,n),d=i),this._rotateDirect(o,c,l),o[0]/=c,o[1]/=c;for(let t=1;t<=18;t++)u.push(this._add(n,o)),this._rotateDirect(o,a,h);u.push(d),e.push(u);break}case Ct.uQ.HalfCircleSecondSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,1,-1);let n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t))/2;this._leftPerpendicular(n);const a=[t[0]+n[0]*o,t[1]+n[1]*o];n=this._sub(t,a);const h=Math.cos(Math.PI/18);let c=Math.sin(Math.PI/18);o>0&&(c=-c);const l=[t];for(let t=1;t<=18;t++)this._rotateDirect(n,h,c),l.push(this._add(a,n));e.push(l);break}case Ct.uQ.HalfCircleExtended:{const t=this._cp2(s,0,-2),n=this._cp3(s,t,1,-1);let o;if(r>=4)o=s[3];else{const e=this._sub(i,t);o=this._add(n,e)}const a=this._dist(t,n)/2/.75,h=this._sub(t,i);this._normalize(h,a);const c=this._sub(n,o);this._normalize(c,a);const l=[o,n];e.push(l);const u=[this._clone(n)];this._addBezier3(u,n,this._add(n,c),this._add(t,h),t,4),u.push(i),e.push(u);break}case Ct.uQ.OpenCircle:{const t=this._cp2(s,-2,0),r=this._sub(t,i),n=Math.cos(Math.PI/18),o=-Math.sin(Math.PI/18),a=[t];for(let t=1;t<=33;t++)this._rotateDirect(r,n,o),a.push(this._add(i,r));e.push(a);break}case Ct.uQ.CoverageEdgesWithTicks:{const t=this._cp2(s,0,-1);let n,o;if(r>=3)n=s[2];else{const e=this._sub(t,i),s=this._leftPerp(e);n=[i[0]+s[0]-.25*e[0],i[1]+s[1]-.25*e[1]]}if(r>=4)o=s[3];else{const e=this._mid(i,t),s=this._sub(i,t);this._normalize(s),this._leftPerpendicular(s);const r=this._crossProduct(s,this._sub(n,e));this._rightPerpendicular(s),o=[n[0]+s[0]*r*2,n[1]+s[1]*r*2]}const a=this._sub(t,i);let h,c;h=this._crossProduct(a,this._sub(n,i))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push(n),c.push(i),c.push([i[0]+(h[0]-a[0])/3,i[1]+(h[1]-a[1])/3]),e.push(c),h=this._crossProduct(a,this._sub(o,t))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push([t[0]+(h[0]+a[0])/3,t[1]+(h[1]+a[1])/3]),c.push(t),c.push(o),e.push(c);break}case Ct.uQ.GapExtentWithDoubleTicks:{const t=this._cp2(s,0,2),n=this._cp3(s,t,0,1);let o;if(r>=4)o=s[3];else{const e=this._sub(t,i);o=this._add(n,e)}this._addAngledTicks(e,i,t,this._mid(n,o)),this._addAngledTicks(e,n,o,this._mid(i,t));break}case Ct.uQ.GapExtentMidline:{const t=this._cp2(s,2,0),n=this._cp3(s,t,0,1);let o;if(r>=4)o=s[3];else{const e=this._sub(t,i);o=this._add(n,e)}const a=[];a.push(this._mid(i,n)),a.push(this._mid(t,o)),e.push(a);break}case Ct.uQ.Chevron:{const t=this._cp2(s,-1,-1);let n;if(r>=3)n=s[2];else{const e=this._sub(t,i);this._leftPerpendicular(e),n=this._add(i,e)}e.push([t,this._makeCtrlPt(i),n]);break}case Ct.uQ.PerpendicularWithArc:{const t=this._cp2(s,0,-2),n=this._cp3(s,t,.5,-1),o=this._sub(t,i),a=this._norm(o);o[0]/=a,o[1]/=a;const h=this._crossProduct(o,this._sub(n,i));let c=this._dotProduct(o,this._sub(n,i));c<.05*a?c=.05*a:c>.95*a&&(c=.95*a);const l=[i[0]+o[0]*c,i[1]+o[1]*c];let u=this._leftPerp(o),d=[];if(d.push([l[0]-u[0]*h,l[1]-u[1]*h]),d.push([l[0]+u[0]*h,l[1]+u[1]*h]),e.push(d),r>=4){const t=s[3];let r=this._dotProduct(o,this._sub(t,i));r<.1*a?r=.1*a:r>.9*a&&(r=.9*a);const n=[i[0]+o[0]*r,i[1]+o[1]*r],h=this._crossProduct(o,this._sub(t,i)),c=[];c.push([n[0]-u[0]*h,n[1]-u[1]*h]),c.push([n[0]+u[0]*h,n[1]+u[1]*h]),e.push(c)}const _=[t[0]+u[0]*h,t[1]+u[1]*h];u=this._sub(t,_);const p=Math.cos(Math.PI/18);let f=Math.sin(Math.PI/18);h<0&&(f=-f),d=[i,t];for(let t=1;t<=9;t++)this._rotateDirect(u,p,f),d.push(this._add(_,u));e.push(d);break}case Ct.uQ.ClosedHalfCircle:{const t=this._cp2(s,2,0),r=this._mid(i,t),n=this._sub(t,r),o=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18),h=[i,t];for(let t=1;t<=18;t++)this._rotateDirect(n,o,a),h.push(this._add(r,n));e.push(h);break}case Ct.uQ.TripleParallelExtended:{const t=this._cp2(s,0,-2),r=this._cp3(s,t,1,-2),n=this._mid(i,t),o=this._sub(r,t);this._normalize(o);const a=Math.abs(this._crossProduct(o,this._sub(n,t)))/2,h=this._dist(t,r),c=[t,i];c.push([i[0]+o[0]*h*.5,i[1]+o[1]*h*.5]),e.push(c);const l=[];l.push([n[0]-o[0]*a,n[1]-o[1]*a]),l.push([n[0]+o[0]*h*.375,n[1]+o[1]*h*.375]),oe(l[l.length-1],1),l.push([n[0]+o[0]*h*.75,n[1]+o[1]*h*.75]),e.push(l);const u=[t,r];e.push(u);break}case Ct.uQ.ParallelWithTicks:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(r,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n),this._addAngledTicks(e,i,t,r),this._addAngledTicks(e,this._mix(i,1,n,o),this._mix(t,1,n,o),this._mid(i,t));break}case Ct.uQ.Parallel:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._leftPerp(n),a=this._crossProduct(n,this._sub(r,i));let h=[i,t];e.push(h),h=[],h.push([i[0]+o[0]*a,i[1]+o[1]*a]),h.push([t[0]+o[0]*a,t[1]+o[1]*a]),e.push(h);break}case Ct.uQ.PerpendicularToFirstSegment:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._mid(i,t),o=this._sub(t,i);this._normalize(o);const a=this._crossProduct(o,this._sub(r,i));this._leftPerpendicular(o);const h=[];h.push([n[0]-o[0]*a*.25,n[1]-o[1]*a*.25]),h.push([n[0]+o[0]*a*1.25,n[1]+o[1]*a*1.25]),e.push(h);break}case Ct.uQ.ParallelOffset:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);const h=[];h.push([i[0]+n[0]*o,i[1]+n[1]*o]),h.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(h);break}case Ct.uQ.OffsetOpposite:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);break}case Ct.uQ.OffsetSame:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]+n[0]*o,i[1]+n[1]*o]),a.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(a);break}case Ct.uQ.CircleWithArc:{let t=this._cp2(s,3,0);const n=this._cp3(s,t,.5,-1);let o,a;if(r>=4)o=s[3],a=this._crossProduct(this._sub(o,t),this._sub(n,t))>0;else{o=t,a=this._crossProduct(this._sub(o,i),this._sub(n,i))>0;const e=24*this._geomUnitsPerPoint,s=this._sub(o,i);this._normalize(s,e);const r=Math.sqrt(2)/2;this._rotateDirect(s,r,a?r:-r),t=this._add(i,s)}const h=this._sub(t,i),c=Math.cos(Math.PI/18),l=Math.sin(Math.PI/18),u=[t];for(let t=1;t<=36;t++)this._rotateDirect(h,c,l),u.push(this._add(i,h));this._add90DegArc(u,t,o,n,a),oe(u[u.length-8],1),e.push(u);break}case Ct.uQ.DoubleJog:{let t,n=this._cp2(s,-3,1),o=this._cp3(s,n,-1,-.5);if(r>=4)t=s[3];else{const e=i;i=n,t=o;const s=this._dist(i,e),r=this._dist(t,e);let a=30*this._geomUnitsPerPoint;.5*s<a&&(a=.5*s),.5*r<a&&(a=.5*r),n=this._mix(i,a/s,e,(s-a)/s),o=this._mix(t,a/r,e,(r-a)/r)}const a=this._mid(i,n),h=this._mid(t,o),c=this._dist(i,n),l=this._dist(o,t);let u=Math.min(c,l)/8;u=Math.min(u,24*this._geomUnitsPerPoint);const d=Math.cos(Math.PI/4);let _=this._sub(i,n);this._normalize(_,u),this._crossProduct(_,this._sub(t,n))>0?this._rotateDirect(_,d,-d):this._rotateDirect(_,d,d);let p=[];p.push(n),p.push(this._add(a,_)),p.push(this._sub(a,_)),p.push(i),e.push(p),_=this._sub(t,o),this._normalize(_,u),this._crossProduct(_,this._sub(i,o))<0?this._rotateDirect(_,d,d):this._rotateDirect(_,d,-d),p=[],p.push(o),p.push(this._add(h,_)),p.push(this._sub(h,_)),p.push(t),e.push(p);break}case Ct.uQ.PerpendicularOffset:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o);e.push([a,i]);break}case Ct.uQ.LineExcludingLastSegment:{const t=this._arrowPath(s),r=[];let i=t.length-2;for(;i--;)r.push(t[i]);e.push(r);break}case Ct.uQ.MultivertexArrow:{const t=this._arrowPath(s),r=[];this._addArrow(r,t,!1),e.push(r);break}case Ct.uQ.CrossedArrow:{const t=this._arrowPath(s),r=[];this._addArrow(r,t,!0),e.push(r);break}case Ct.uQ.ChevronArrow:{const[t,r]=this._arrowLastSeg(s),n=10*this._geomUnitsPerPoint,o=this._sub(i,t),a=this._norm(o);this._normalize(o);const h=this._crossProduct(o,this._sub(r,t));let c=this._dotProduct(o,this._sub(r,t));c<.05*a?c=.05*a:c>.95*a-n&&(c=.95*a-n);const l=[t[0]+o[0]*c,t[1]+o[1]*c],u=this._leftPerp(o),d=[];d.push([l[0]+u[0]*h+o[0]*n,l[1]+u[1]*h+o[1]*n]),d.push(i),d.push([l[0]-u[0]*h+o[0]*n,l[1]-u[1]*h+o[1]*n]),e.push(d);break}case Ct.uQ.ChevronArrowOffset:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t),o=this._norm(n);this._normalize(n);const a=this._crossProduct(n,this._sub(r,t));let h=this._dotProduct(n,this._sub(r,t));h<.05*o?h=.05*o:h>.95*o&&(h=.95*o);const c=[t[0]+n[0]*h,t[1]+n[1]*h];this._leftPerpendicular(n);const l=[];l.push([c[0]+n[0]*a*.5,c[1]+n[1]*a*.5]),l.push(this._mid(c,i)),l.push([c[0]-n[0]*a*.5,c[1]-n[1]*a*.5]),e.push(l);break}case Ct.uQ.PartialFirstSegment:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t),o=this._norm(n);this._normalize(n);let a=this._dotProduct(n,this._sub(r,t));a<.05*o?a=.05*o:a>.95*o&&(a=.95*o);const h=[t[0]+n[0]*a,t[1]+n[1]*a];e.push([t,h]);break}case Ct.uQ.Arch:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=this._sub(i,t),o=this._mix(r,1,n,.55),a=this._mix(r,1,n,-.55),h=[i];this._addBezier2(h,i,o,r,4),this._addBezier2(h,r,a,t,4),e.push(h);break}case Ct.uQ.CurvedParallelTicks:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o),h=this._sub(this._mix(t,.75,r,.25),o),c=this._sub(this._mix(t,.25,r,.75),o),l=[t];this._addBezier2(l,t,h,a,3),this._addBezier2(l,a,c,r,3),e.push(l);for(let t=0;t<8;t++){const s=l[2*t+1],r=[this._clone(s)];r.push(this._add(s,[n[0]/4,n[1]/4])),e.push(r)}break}case Ct.uQ.Arc90Degrees:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=[t];this._add90DegArc(n,t,i,r),e.push(n);break}case Ct.uQ.TipWithPerpendicularAndTicks:{const[t,r]=this._arrowLastSeg(s),n=10*this._geomUnitsPerPoint,o=this._sub(i,t),a=this._norm(o);this._normalize(o);let h=this._crossProduct(o,this._sub(r,t)),c=this._dotProduct(o,this._sub(r,t));c<.05*a?c=.05*a:c>.95*a-n&&(c=.95*a-n);const l=this._leftPerp(o),u=[i[0]-o[0]*n,i[1]-o[1]*n],d=.5*Math.max(a-c-n,n);h=Math.abs(h);const _=[];_.push([u[0]+l[0]*(h+d)-o[0]*d,u[1]+l[1]*(h+d)-o[1]*d]),_.push([u[0]+l[0]*h,u[1]+l[1]*h]),_.push([u[0]-l[0]*h,u[1]-l[1]*h]),_.push([u[0]-l[0]*(h+d)-o[0]*d,u[1]-l[1]*(h+d)-o[1]*d]),e.push(_),e.push([u,i]);break}case Ct.uQ.ConcentricCircles:{const t=this._cp2(s,1,0),n=this._cp3(s,t,2,0),o=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18);let h=this._dist(t,i),c=[h,0],l=[];for(let t=0;t<=36;t++)l.push(this._add(i,c)),this._rotateDirect(c,o,a);if(e.push(l),r>=4){l=[];const t=s[3];h=this._dist(t,i),c=[h,0];for(let t=0;t<=36;t++)l.push(this._add(i,c)),0===t&&(l.push(this._add(i,c)),oe(l[1],1)),this._rotateDirect(c,o,a);e.push(l)}l=[],h=this._dist(n,i),c=[h,0];for(let t=0;t<=36;t++)l.push(this._add(i,c)),this._rotateDirect(c,o,a);e.push(l);break}case Ct.uQ.DoubleJogArrow:{i=this._arrowPath(s)[0];const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t),o=this._norm(n);this._normalize(n);const a=Math.abs(this._crossProduct(n,this._sub(r,i)));let h=Math.abs(this._dotProduct(n,this._sub(r,i)));h<.05*o?h=.05*o:h>.95*o&&(h=.95*o);const c=Math.max(a,h),l=this._leftPerp(n);let u=[];const d=[i[0]-n[0]*h*.5+l[0]*a*.5,i[1]-n[1]*h*.5+l[1]*a*.5];u.push([d[0],d[1]]),d[0]+=n[0]*c*.5+l[0]*c*.4,d[1]+=n[1]*c*.5+l[1]*c*.4,u.push([d[0],d[1]]),d[0]-=l[0]*c*.25,d[1]-=l[1]*c*.25,u.push([d[0],d[1]]),d[0]+=n[0]*c*.5+l[0]*c*.4,d[1]+=n[1]*c*.5+l[1]*c*.4,u.push([d[0],d[1]]),e.push(u),u=[],d[0]=i[0]-n[0]*h*.5-l[0]*a*.5,d[1]=i[1]-n[1]*h*.5-l[1]*a*.5,u.push([d[0],d[1]]),d[0]+=n[0]*c*.5-l[0]*c*.4,d[1]+=n[1]*c*.5-l[1]*c*.4,u.push([d[0],d[1]]),d[0]+=l[0]*c*.25,d[1]+=l[1]*c*.25,u.push([d[0],d[1]]),d[0]+=n[0]*c*.5-l[0]*c*.4,d[1]+=n[1]*c*.5-l[1]*c*.4,u.push([d[0],d[1]]),e.push(u);break}case Ct.uQ.LinkedChevrons:{const t=this._cp2(s,-5,0),r=this._cp3(s,t,-.2,1),n=this._sub(i,t);this._normalize(n);const o=this._leftPerp(n),a=Math.abs(this._crossProduct(n,this._sub(r,t)));e.push([t,i]);const h=[];h.push([i[0]-n[0]*a+o[0]*a,i[1]-n[1]*a+o[1]*a]),h.push(i),h.push([i[0]-n[0]*a-o[0]*a,i[1]-n[1]*a-o[1]*a]),e.push(h),this._addDash(e,t,[-n[0]*a+o[0]*a,-n[1]*a+o[1]*a]),this._addDash(e,t,[-n[0]*a-o[0]*a,-n[1]*a-o[1]*a]);break}case Ct.uQ.SegmentThenHalfCircle:{const t=this._cp2(s,2,0),n=this._cp3(s,t,1.5,0);let o;o=r>=4?s[3]:this._cp3(s,t,1.25,-.5);const a=this._sub(t,i);this._normalize(a);const h=.5*this._dist(t,n),c=this._crossProduct(a,this._sub(o,i))>0,l=Math.cos(Math.PI/18);let u=Math.sin(Math.PI/18);c&&(u=-u);const d=[i,t];a[0]*=h,a[1]*=h;const _=this._add(t,a);a[0]=-a[0],a[1]=-a[1];for(let t=1;t<=18;t++)this._rotateDirect(a,l,u),d.push(this._add(_,a));e.push(d);break}case Ct.uQ.LineWithStraightTicks:{const t=this._cp2(s,-2,1),r=this._cp3(s,t,-1,-.5),n=this._sub(r,t);this._normalize(n);const o=this._dotProduct(n,this._sub(t,i)),a=this._dotProduct(n,this._sub(r,i));let h=[i];h.push([i[0]+n[0]*o,i[1]+n[1]*o]),h.push(t),e.push(h),h=[i],h.push([i[0]+n[0]*a,i[1]+n[1]*a]),h.push(r),e.push(h);break}case Ct.uQ.DoubleCurve:{const t=this._cp2(s,-5,-1),r=this._cp3(s,t,2,0),n=Math.atan2(1,5),o=Math.cos(n),a=Math.sin(n),h=this._sub(t,i),c=this._dist(i,t);this._normalize(h),this._rotateDirect(h,o,-a);const l=[i];l.push([i[0]+h[0]*c*.5,i[1]+h[1]*c*.5]),oe(l[1],1),l.push([i[0]+h[0]*c*.8,i[1]+h[1]*c*.8]),this._addBezier2(l,l[2],[i[0]+h[0]*c,i[1]+h[1]*c],t,3);const u=this._sub(r,t),d=this._dist(t,r);this._normalize(u),this._rotateDirect(u,o,-a),this._addBezier2(l,t,[r[0]-u[0]*d,r[1]-u[1]*d],[r[0]-u[0]*d*.8,r[1]-u[1]*d*.8],3),l.push(r),e.push(l);break}case Ct.uQ.ParallelWithTicksByWidth:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n),o>0?(this._addAngledTicks(e,i,[i[0]+n[0]*o,i[1]+n[1]*o],t),this._addAngledTicks(e,t,[t[0]+n[0]*o,t[1]+n[1]*o],i)):(this._addAngledTicks(e,[i[0]+n[0]*o,i[1]+n[1]*o],i,t),this._addAngledTicks(e,[t[0]+n[0]*o,t[1]+n[1]*o],i,t));break}case Ct.uQ.EnclosingRoundedRectangle:{const t=this._cp2(s,3,-2),e=[Math.min(i[0],t[0]),Math.max(i[1],t[1])],r=[Math.max(i[0],t[0]),Math.min(i[1],t[1])],n=r[0]-e[0],o=e[1]-r[1],a=Math.min(n,o)/10,h=[];h.push([e[0]+a+.75*(n-2*a),e[1]]),h.push([r[0]-a,e[1]]),this._add90DegArc(h,[r[0]-a,e[1]],[r[0],e[1]-a],[r[0],e[1]]),h.push([r[0],r[1]+a]),this._add90DegArc(h,[r[0],r[1]+a],[r[0]-a,r[1]],r),h.push([e[0]+a,r[1]]),this._add90DegArc(h,[e[0]+a,r[1]],[e[0],r[1]+a],[e[0],r[1]]),h.push([e[0],e[1]-a]),this._add90DegArc(h,[e[0],e[1]-a],[e[0]+a,e[1]],e),h.push([e[0]+a+.75*(n-2*a),e[1]]);break}case Ct.uQ.FullGeometry:default:e.push(s)}}return e}}class we{static local(){return null===we.instance&&(we.instance=new we),we.instance}execute(t,e,s,r,i){return new ve(t,e,s)}}we.instance=null;class ve extends he{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new le,this._beginCut=(void 0!==e.beginCut?e.beginCut:1)*s,this._endCut=(void 0!==e.endCut?e.endCut:1)*s,this._middleCut=(void 0!==e.middleCut?e.middleCut:0)*s,this._invert=void 0!==e.invert&&e.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const{_beginCut:e,_endCut:s,_middleCut:r}=this,i=t.pathLength(),n=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==e||0!==s||0!==r)if(e+s+r>=i)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else this._curveHelper.appendSubCurve(n,t,0,e),this._curveHelper.appendSubCurve(n,t,.5*(i-r),.5*(i+r)),this._curveHelper.appendSubCurve(n,t,i-s,s)}else if(0===e&&0===s&&0===r)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else e+s+r<i&&(0===r?this._curveHelper.appendSubCurve(n,t,e,i-s):(this._curveHelper.appendSubCurve(n,t,e,.5*(i-r)),this._curveHelper.appendSubCurve(n,t,.5*(i+r),i-s)));return 0===n.totalSize?null:n}}class Se{constructor(){this._values=[],this.extPtGap=0,this.ctrlPtGap=0,this._length=0,this._currentValue=0}isEmpty(){return 0===this._values.length}size(){return this._values.length}init(t,e,s=!0){if(this._setEmpty(),!t||0===t.length)return!1;for(let e=0;e<t.length;e++){let r=Math.abs(t[e]);s&&r<1e-7&&(r=1e-7),this._values.push(r),this._length+=r}return e&&1&t.length&&(this._length*=2),0!==this._length&&(this.ctrlPtGap=this.extPtGap=0,this._currentValue=-1,!0)}scale(t){const e=this._values?this._values.length:0;for(let s=0;s<e;++s)this._values[s]*=t;this._length*=t,this.extPtGap*=t,this.ctrlPtGap*=t}addValue(t){this._length+=t,this._values.push(t)}firstValue(){return this._values[0]}lastValue(){return this._values[this._values.length-1]}nextValue(){return this._currentValue++,this._currentValue===this._values.length&&(this._currentValue=0),this._values[this._currentValue]}reset(){this._currentValue=-1}length(){return this._length}_setEmpty(){this.extPtGap=this.ctrlPtGap=this._length=0,this._currentValue=-1,this._values.length=0}}class Ie{constructor(){this.pt=null,this.ca=0,this.sa=0}}(me=ge||(ge={}))[me.FAIL=0]="FAIL",me[me.END=1]="END",me[me.CONTINUE=2]="CONTINUE";class Me{constructor(){this.reset()}reset(){this.segment=null,this.segmentLength=0,this.abscissa=0,this.isPathEnd=!1,this.isPartEnd=!1}isValid(){return null!==this.segment}copyTo(t){t.segment=this.segment,t.segmentLength=this.segmentLength,t.abscissa=this.abscissa,t.isPathEnd=this.isPathEnd,t.isPartEnd=this.isPartEnd}}class Pe extends le{constructor(t=0,e=!1){super(t,e),this._tolerance=ce,this._currentPosition=new Me}updateTolerance(t){this._tolerance=ce*t}init(t,e,s=!0){return s?(this._patternLength=e.length(),this._partExtPtGap=e.extPtGap,this._partCtrlPtGap=e.ctrlPtGap):(this._patternLength=0,this._partExtPtGap=0,this._partCtrlPtGap=0),this._currentPosition.reset(),this._partSegCount=0,this._pathCursor=t,this._seg=-1,this._setPosAtNextPart()}curPositionIsValid(){return this._currentPosition.isValid()}nextPosition(t,e=ge.FAIL){const s=new Me;return!!this._nextPosition(t,s,null,e)&&(s.copyTo(this._currentPosition),!0)}curPointAndAngle(t){t.pt=this._getPoint(this._currentPosition);const[e,s]=this._getAngleCS(this._currentPosition);t.ca=e,t.sa=s}nextPointAndAngle(t,e,s=ge.FAIL){const r=new Me;if(!this._nextPosition(t,r,null,s))return!1;r.copyTo(this._currentPosition),e.pt=this._getPoint(r);const[i,n]=this._getAngleCS(r);return e.ca=i,e.sa=n,!0}nextCurve(t){if(0===t)return null;const e=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");e.startPath(),e.nextPath();const s=new Me;return this._nextPosition(t,s,e,ge.END)?(s.copyTo(this._currentPosition),e):null}isPathEnd(){return this._currentPosition.isPathEnd}getPathEnd(){return this._currentPosition.segment[1]}getPt(t){return this._pathCursor.seekInPath(t),[this._pathCursor.x,this._pathCursor.y]}getSeg(t){return[this.getPt(t),this.getPt(t+1)]}_nextPosition(t,e,s,r){if(this._currentPosition.isPathEnd)return!1;let i=this._currentPosition.abscissa;for(this._currentPosition.segmentLength>0&&(i/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(0===s.pathSize)if(0===i){const t=e.segment[0];s.pushXY(t[0],t[1])}else s.pushPoint(this.getSegCoord2D(e.segment,i));const t=e.segment[1];s.pushXY(t[0],t[1])}if(i=0,t-=(e.segmentLength-e.abscissa)/this._partLengthRatio,this._partSegCount)e.segment=this._nextSegment(),e.segmentLength=this.getSegLength(e.segment),e.abscissa=0,this._partSegCount--;else{if(!this._setPosAtNextPart())return r!==ge.FAIL&&(e.segmentLength=this.getSegLength(e.segment),e.isPartEnd=!0,r===ge.END?(e.abscissa=e.segmentLength,e.isPathEnd=!0):e.abscissa=e.segmentLength+t,!0);this._currentPosition.copyTo(e)}}if(e.abscissa+=t*this._partLengthRatio,s){0===s.pathSize&&(0===i?s.pushPoint(e.segment[0]):s.pushPoint(this.getSegCoord2D(e.segment,i)));const t=e.abscissa/e.segmentLength;1===t?s.pushPoint(e.segment[1]):s.pushPoint(this.getSegCoord2D(e.segment,t))}return this._partSegCount||Math.abs(e.abscissa-e.segmentLength)<this._tolerance&&(e.isPathEnd=this._partIsLast,e.isPartEnd=!0),!0}_getPoint(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegCoord2D(this._currentPosition.segment,e)}_getAngleCS(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegAngleCS(this._currentPosition.segment,e)}_setPosAtNextPart(){for(;this._partSegCount;)this._hasNextSegment()&&this._nextSegment(),this._partSegCount--;if(!this._hasNextSegment())return!1;for(this._partLength=0,this._partIsLast=!0,this._partSegCount=0;this._hasNextSegment();)if(this._partLength+=this.getSegLength(this._nextSegment()),this._partSegCount++,this._pathCursor.getControlPointAt(this._getEndPointIndex())){this._partIsLast=!this._hasNextSegment();break}let t=this._partSegCount;for(;t;)this._previousSegment(),--t;this._currentPosition.segment=this._nextSegment(),this._currentPosition.segmentLength=this.getSegLength(this._currentPosition.segment),this._currentPosition.abscissa=0,this._currentPosition.isPathEnd=this._currentPosition.isPartEnd=!1,--this._partSegCount;const e=this._getStartPointIndex();this._ctrlPtBegin=this._pathCursor.getControlPointAt(e);let s=e+this._partSegCount+1;if(s>=this._pathCursor.pathSize&&(s=0),this._ctrlPtEnd=this._pathCursor.getControlPointAt(s),this._patternLength>0){const t=this._ctrlPtBegin?this._partCtrlPtGap:this._partExtPtGap,e=this._ctrlPtEnd?this._partCtrlPtGap:this._partExtPtGap;let s=Math.round((this._partLength-(t+e))/this._patternLength);s<=0&&(s=t+e>0?0:1),this._partLengthRatio=this._partLength/(t+e+s*this._patternLength),this._partLengthRatio<.01&&(this._partLengthRatio=1)}else this._partLengthRatio=1;return!0}_hasNextSegment(){return this._seg<this._pathCursor.pathSize-2}_previousSegment(){return this.getSeg(--this._seg)}_nextSegment(){return this.getSeg(++this._seg)}_getStartPointIndex(){return this._seg}_getEndPointIndex(){return this._seg+1}}var Te=s(93397);class Ae{static local(){return null===Ae.instance&&(Ae.instance=new Ae),Ae.instance}execute(t,e,s,r,i){return new Ce(t,e,s)}}Ae.instance=null;class Ce extends he{constructor(t,e,s){super(t,!0,!0),this._firstCurve=null,this._walker=new Pe,this._walker.updateTolerance(s),this._endings=e.lineDashEnding,this._customDashPos=-(e.offsetAlongLine??0)*s,this._offsetAtEnd=(e.customEndingOffset??0)*s;let r=(0,Te.FH)(e).dashTemplate;null==r&&(r=[]),r.length%2&&(r=[...r,...r]),this._pattern=new Se,this._pattern.init(r,!0),this._pattern.scale(s)}processPath(t){if(0===this._pattern.length()){this.iteratePath=!1;const e=(0,qt.A)(t);return Yt.fromJSONCIM({paths:[e]})}if(!this.iteratePath){let e=!0;switch(this._endings){case Ct.yS.HalfPattern:case Ct.yS.HalfGap:default:this._pattern.extPtGap=0;break;case Ct.yS.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case Ct.yS.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case Ct.yS.NoConstraint:this.isClosed||(e=!1);break;case Ct.yS.Custom:this.isClosed||(this._pattern.extPtGap=.5*this._offsetAtEnd)}const s=t.pathLength();if(this._pattern.isEmpty()||s<.1*this._pattern.length()){const e=(0,qt.A)(t);return Yt.fromJSONCIM({paths:[e]})}if(!this._walker.init(t,this._pattern,e)){const e=(0,qt.A)(t);return Yt.fromJSONCIM({paths:[e]})}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case Ct.yS.HalfPattern:default:t=.5*this._pattern.firstValue();break;case Ct.yS.HalfGap:t=.5*-this._pattern.lastValue();break;case Ct.yS.FullGap:t=-this._pattern.lastValue();break;case Ct.yS.FullPattern:t=0;break;case Ct.yS.NoConstraint:case Ct.yS.Custom:t=-this._customDashPos}let s=t/this._pattern.length();s-=Math.floor(s),t=s*this._pattern.length(),this._pattern.reset(),e=this._pattern.nextValue();let r=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),r=!r;e-=t,r?(this._walker.nextPosition(e),e=this._pattern.nextValue()):this.isClosed&&(this._firstCurve=this._walker.nextCurve(e),e=this._pattern.nextValue(),this._walker.nextPosition(e),e=this._pattern.nextValue())}let s=this._walker.nextCurve(e);if(s)if(this._walker.isPathEnd()){if(this.iteratePath=!1,this._firstCurve){for(this._firstCurve.nextPath();this._firstCurve.nextPoint();)s.pushXY(this._firstCurve.x,this._firstCurve.y);this._firstCurve=null}}else e=this._pattern.nextValue(),!this._walker.nextPosition(e)||this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(s.pushCursor(this._firstCurve),this._firstCurve=null)):this.iteratePath=!0;else this.iteratePath=!1,s=this._firstCurve,this._firstCurve=null;return s?.reset(),s}}class ke{static local(){return null===ke.instance&&(ke.instance=new ke),ke.instance}execute(t,e,s,r,i,n,o){return new Fe(t,e,s,r,i,n,o)}}ke.instance=null;class Fe{constructor(t,e,s,r,i,n,o){switch(this._preventClipping=o,this._inputGeometries=t,this._tileKey=r,this._geometryEngine=i,this._maxInflateSize=n*s,this._width=(void 0!==e.width?e.width:2)*s,e.method){case Ct.M1.Mitered:case Ct.M1.Bevelled:case Ct.M1.Rounded:case Ct.M1.TrueBuffer:case Ct.M1.Square:}this._option=e.option}next(){let t;for(;t=this._inputGeometries.next();){if("esriGeometryEnvelope"===t.geometryType&&this._width>0){const e=t.asJSON();return Math.min(e.xmax-e.xmin,e.ymax-e.ymin)-2*this._width<0?t:Yt.fromJSONCIM({paths:[[[e.xmin+this._width,e.ymin+this._width],[e.xmax-this._width,e.ymin+this._width],[e.xmax-this._width,e.ymax-this._width],[e.xmin+this._width,e.ymax-this._width],[e.xmin+this._width,e.ymin+this._width]],[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}if("esriGeometryPolygon"===t.geometryType){if(0===this._width)return t.clone();const e=this._geometryEngine;if(null==e)return null;const s=!this._preventClipping&&this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const r=e.buffer(q.A.WebMercator,s.asJSON(),-this._width,1);if(r)for(const t of r.rings)if(t){s.startPath();for(const e of t.reverse())s.pushXY(e[0],s.yFactor*e[1])}return s}}return null}}class Ee{static local(){return null===Ee.instance&&(Ee.instance=new Ee),Ee.instance}execute(t,e,s,r,i){return new ze(t,e,s)}}Ee.instance=null;class ze extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new le,this._length=(void 0!==e.length?e.length:20)*s,this._angle=void 0!==e.angle?e.angle:225,this._position=void 0!==e.position?e.position:50,this._length<0&&(this._length=-this._length),this._position<20&&(this._position=20),this._position>80&&(this._position=80),this._mirror=!1}processPath(t){const e=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._curveHelper.isEmpty(t))return null;t.seekInPath(0);const s=t.x,r=t.y;t.seekInPath(t.pathSize-1);const i=t.x,n=t.y,o=[i-s,n-r];this._curveHelper.normalize(o);const a=s+(i-s)*this._position/100,h=r+(n-r)*this._position/100,c=Math.cos((90-this._angle)/180*Math.PI);let l=Math.sin((90-this._angle)/180*Math.PI);this._mirror&&(l=-l),this._mirror=!this._mirror;const u=[a-this._length/2*c,h-this._length/2*l],d=[a+this._length/2*c,h+this._length/2*l];return e.pushPath([[s,r],u,d,[i,n]]),e}}class Oe{static local(){return null===Oe.instance&&(Oe.instance=new Oe),Oe.instance}execute(t,e,s,r,i){return new Re(t,e,s)}}Oe.instance=null;class Re{constructor(t,e,s){this._inputGeometries=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0}next(){let t=this._inputGeometries.next();for(;t;){if(t.totalSize>0)return this._move(t.clone(),this._offsetX,this._offsetY);t=this._inputGeometries.next()}return null}_move(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=t.x+e,t.y=t.y+s;return t.reset(),t}}class De{static local(){return null===De.instance&&(De.instance=new De),De.instance}execute(t,e,s,r,i,n,o){return new Le(t,e,s,r,i,n,o)}}De.instance=null;class Le{constructor(t,e,s,r,i,n,o){this._preventClipping=o,this._inputGeometries=t,this._tileKey=r,this._geometryEngine=i,this._curveHelper=new le,this._offset=(e.offset??1)*s,this._method=e.method,this._maxInflateSize=Math.max(Math.abs(n*s),10),this._option=e.option,this._offsetFlattenError=ce*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._offset)return t.clone();if("esriGeometryEnvelope"===t.geometryType){if(this._method===Ct.xw.Rounded&&this._offset>0){const e=(0,qt.A)(t),s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=Yt.createEmptyOptimizedCIM(t.geometryType);return e.pushPath(s),e}return null}const e=t.asJSON();if((0,Wt.ZC)(e)&&Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._offset>0)return Yt.fromJSONCIM({xmin:e.xmin-this._offset,xmax:e.xmax+this._offset,ymin:e.ymin-this._offset,ymax:e.ymax+this._offset})}const e=this._geometryEngine;if(null==e)continue;const s=!this._preventClipping&&this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const r=e.offset(q.A.WebMercator,s.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return r?Yt.fromJSONCIM(r):null}return null}}class Ne{static local(){return null===Ne.instance&&(Ne.instance=new Ne),Ne.instance}execute(t,e,s,r,i){return new Be(t,e,s)}}Ne.instance=null;class Be{constructor(t,e,s){this._inputGeometries=t,this._reverse=void 0===e.reverse||e.reverse}next(){let t=this._inputGeometries.next();for(;t;){if(!this._reverse)return t;if("esriGeometryPolyline"===t.geometryType)return Ge(t.clone());t=this._inputGeometries.next()}return null}}function Ge(t){for(;t.nextPath();)for(let e=0;e<t.pathSize/2;e++){t.seekInPath(e);const s=t.x,r=t.y;t.seekInPath(t.pathSize-e-1);const i=t.x,n=t.y;t.x=s,t.y=r,t.seekInPath(e),t.x=i,t.y=n}return t.reset(),t}var Ue=s(537);class Ve{static local(){return null===Ve.instance&&(Ve.instance=new Ve),Ve.instance}execute(t,e,s,r,i){return new qe(t,e,s)}}Ve.instance=null;class qe{constructor(t,e,s){this._inputGeometries=t,this._rotateAngle=void 0!==e.angle?e.angle*Math.PI/180:0}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._rotateAngle||"esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ue.z8)(t),s=(e[2]+e[0])/2,r=(e[3]+e[1])/2;return t.reset(),this._rotate(t.clone(),s,r)}t=this._inputGeometries.next()}return null}_rotate(t,e,s){const r=Math.cos(this._rotateAngle),i=Math.sin(this._rotateAngle);for(;t.nextPath();)for(;t.nextPoint();){const n=t.x-e,o=t.y-s;t.x=e+n*r-o*i,t.y=s+n*i+o*r}return t.reset(),t}}class We{static local(){return null===We.instance&&(We.instance=new We),We.instance}execute(t,e,s,r,i){return new je(t,e,s)}}We.instance=null;class je{constructor(t,e,s){this._inputGeometries=t,this._xFactor=void 0!==e.xScaleFactor?e.xScaleFactor:1.15,this._yFactor=void 0!==e.yScaleFactor?e.yScaleFactor:1.15}next(){const t=this._inputGeometries.next();if(t){if(1===this._xFactor&&1===this._yFactor)return t;if("esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ue.z8)(t),s=(e[2]+e[0])/2,r=(e[3]+e[1])/2;return t.reset(),this._scaleCursor(t.clone(),s,r)}}return null}_scaleCursor(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=e+(t.x-e)*this._xFactor,t.y=s+(t.y-s)*this._yFactor;return t.reset(),t}}class Ye{static local(){return null===Ye.instance&&(Ye.instance=new Ye),Ye.instance}execute(t,e,s,r,i){return new Xe(t,e,s)}}Ye.instance=null;class Xe{constructor(t,e,s){this._inputGeometries=t,this._height=(void 0!==e.amplitude?e.amplitude:2)*s,this._period=(void 0!==e.period?e.period:3)*s,this._style=e.waveform,this._height<=0&&(this._height=Math.abs(this._height)),this._period<=0&&(this._period=Math.abs(this._period)),this._pattern=new Se,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new Pe,this._walker.updateTolerance(s)}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._height||0===this._period)return t;const e=this._processGeom(t);if(e)return e;t=this._inputGeometries.next()}return null}_processGeom(t){const e=Yt.createEmptyOptimizedCIM(t.geometryType);for(;t.nextPath();){e.startPath();const s=t.pathLength();if(this._walker.init(t,this._pattern))switch(this._style){case Ct.WE.Sinus:default:this._constructCurve(e,s,!1);break;case Ct.WE.Square:this._constructSquare(e,s);break;case Ct.WE.Triangle:this._constructTriangle(e,s);break;case Ct.WE.Random:this._constructCurve(e,s,!0)}else for(;t.nextPoint();)e.pushXY(t.x,t.y)}return e}_constructCurve(t,e,s){let r=Math.round(e/this._period);0===r&&(r=1);const i=16*r+1,n=e/r,o=this._period/16,a=1/i,h=2*Math.PI*e/n,c=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),u=2*Math.PI*Math.random(),d=.75-Math.random()/2,_=.75-Math.random()/2,p=new Ie;this._walker.curPointAndAngle(p),t.pushPoint(p.pt);let f=0;for(;;){if(!this._walker.nextPointAndAngle(o,p)){t.pushPoint(this._walker.getPathEnd());break}{const e=f;let r;if(f+=a,s){const t=this._height/2*(1+.3*Math.sin(d*h*e+c));r=t*Math.sin(h*e+l),r+=t*Math.sin(_*h*e+u),r/=2}else r=.5*this._height*Math.sin(.5*h*e);t.pushXY(p.pt[0]-r*p.sa,p.pt[1]+r*p.ca)}}}_constructSquare(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const r=new Ie;this._walker.curPointAndAngle(r);const i=new Ie;if(this._walker.nextPointAndAngle(this._period,i)){const n=new Ie;this._walker.nextPointAndAngle(this._period,n)&&(s?(t.pushPoint(r.pt),s=!1):t.pushPoint(r.pt),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(i.pt[0]+this._height/2*i.sa,i.pt[1]-this._height/2*i.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}_constructTriangle(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const r=new Ie;this._walker.curPointAndAngle(r);const i=new Ie;if(this._walker.nextPointAndAngle(this._period/2,i)){const n=new Ie;this._walker.nextPointAndAngle(this._period,n)&&(this._walker.nextPosition(this._period/2)&&(s?(t.pushPoint(r.pt),s=!1):t.pushPoint(r.pt),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca)),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}}class $e{static local(){return null===$e.instance&&($e.instance=new $e),$e.instance}execute(t,e,s,r,i){return new He(t,e,s)}}$e.instance=null;class He extends ae{constructor(t,e,s){super(t),this._geometryWalker=new Pe,this._geometryWalker.updateTolerance(s),this._angleToLine=e.angleToLine??!0,this._offset=(e.offset?e.offset:0)*s,this._originalEndings=e.endings,this._offsetAtEnd=(e.customEndingOffset?e.customEndingOffset:0)*s,this._position=-(e.offsetAlongLine?e.offsetAlongLine:0)*s,this._pattern=new Se,this._pattern.init(e.placementTemplate,!1),this._pattern.scale(s),this._endings=this._originalEndings}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath)e=this._pattern.nextValue();else{this._originalEndings===Ct.e_.WithFullGap&&this.isClosed?this._endings=Ct.e_.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let s,r=!0;switch(this._endings){case Ct.e_.NoConstraint:s=-this._position,s=this._adjustPosition(s),r=!1;break;case Ct.e_.WithHalfGap:default:s=-this._pattern.lastValue()/2;break;case Ct.e_.WithFullGap:s=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case Ct.e_.WithMarkers:s=0;break;case Ct.e_.Custom:s=-this._position,s=this._adjustPosition(s),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,r))return null;this._pattern.reset();let i=0;for(;s>i;)s-=i,i=this._pattern.nextValue();i-=s,e=i,this.iteratePath=!0}const s=new Ie;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===Ct.e_.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===Ct.e_.WithMarkers&&this._geometryWalker.isPathEnd()&&(this.iteratePath=!1,this.isClosed)?null:(this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca),this._angleToLine&&this.internalPlacement.setRotateCS(s.ca,s.sa),this.internalPlacement):(this.iteratePath=!1,null)}_adjustPosition(t){let e=t/this._pattern.length();return e-=Math.floor(e),e*this._pattern.length()}}class Ze{static local(){return null===Ze.instance&&(Ze.instance=new Ze),Ze.instance}execute(t,e,s,r,i){return new Qe(t,e,s)}}Ze.instance=null;class Qe extends ae{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new le,this._placePerPart=e.placePerPart??!1,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._type=e.extremityPlacement,this._position=void 0!==e.offsetAlongLine?e.offsetAlongLine*s:0,this._beginProcessed=!1}processMultiPath(t){return this._placePerPart?super.processMultiPath(t):this.processPath(t)}processPath(t){let e;switch(this._type){case Ct.$2.Both:default:this._beginProcessed?(e=this._atExtremities(t,this._position,!1),this._beginProcessed=!1,this.iterateMultiPath=!1,this.iteratePath=!1):(e=this._atExtremities(t,this._position,!0),this._beginProcessed=!0,this.iterateMultiPath=!0,this.iteratePath=!0);break;case Ct.$2.JustBegin:e=this._atExtremities(t,this._position,!0);break;case Ct.$2.JustEnd:e=this._atExtremities(t,this._position,!1);case Ct.$2.None:}return e}_atExtremities(t,e,s){if(this._placePerPart||(s?t.seekPath(0):t.seekPath(t.totalSize-1)),s||t.seekPathEnd(),s?t.nextPoint():t.prevPoint()){let r=0,[i,n]=[0,0],[o,a]=[t.x,t.y];for(;s?t.nextPoint():t.prevPoint();){i=o,n=a,o=t.x,a=t.y;const s=this._curveHelper.getLength(i,n,o,a);if(r+s>e){const t=(e-r)/s,[h,c]=this._curveHelper.getAngleCS(i,n,o,a,t),l=this._curveHelper.getCoord2D(i,n,o,a,t);return this.internalPlacement.setTranslate(l[0]-this._offset*c,l[1]+this._offset*h),this._angleToLine&&this.internalPlacement.setRotateCS(-h,-c),this.internalPlacement}r+=s}}return null}}class Ke{static local(){return null===Ke.instance&&(Ke.instance=new Ke),Ke.instance}execute(t,e,s,r,i){return new Je(t,e,s)}}Ke.instance=null;class Je extends ae{constructor(t,e,s){super(t),this._walker=new Pe,this._walker.updateTolerance(s),this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._beginGap=void 0!==e.beginPosition?e.beginPosition*s:0,this._endGap=void 0!==e.endPosition?e.endPosition*s:0,this._flipFirst=void 0===e.flipFirst||e.flipFirst,this._pattern=new Se,this._pattern.init(e.positionArray,!1,!1),this._subPathLen=0,this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath){const t=this._pattern.nextValue()*this._subPathLen,s=this._beginGap+t;e=s-this._prevPos,this._prevPos=s}else{if(this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0,this._subPathLen=t.pathLength()-this._beginGap-this._endGap,this._subPathLen<0)return this.iteratePath=!1,null;if(!this._walker.init(t,this._pattern,!1))return null;this._pattern.reset();const s=this._pattern.nextValue()*this._subPathLen,r=this._beginGap+s;e=r-this._prevPos,this._prevPos=r,this.iteratePath=!0}const s=new Ie;if(!this._walker.nextPointAndAngle(e,s,ge.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const r=this._isFirst&&this._flipFirst;let i,n;return this._angleToLine?(i=s.ca,n=s.sa):(i=1,n=0),r&&(i=-i,n=-n),this.internalPlacement.setRotateCS(i,n),this._isFirst=!1,this._posCount--,0===this._posCount&&(this.iteratePath=!1),this.internalPlacement}}const ts=512,es=24,ss=1e-6;class rs{static local(){return null===rs.instance&&(rs.instance=new rs),rs.instance}execute(t,e,s,r,i){return new is(t,e,s,r,i)}}rs.instance=null;class is{constructor(t,e,s,r,i){if(this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,this._currentX=0,this._currentY=0,this._accelerationMap=null,this._testInsidePolygon=!1,this._verticalSubdivision=!0,this._stepX=Math.abs(e.stepX??16)*s,this._stepY=Math.abs(e.stepY??16)*s,this._stepX=Math.round(128*this._stepX)/128,this._stepY=Math.round(128*this._stepY)/128,0!==this._stepX&&0!==this._stepY){if(this._gridType=e.gridType??Ct.Q1.Fixed,this._gridType===Ct.Q1.Random){const t=e.seed??13,s=1;this._randomLCG=new h.A(t*s),this._randomness=(e.randomness??100)/100,this._gridAngle=0,this._shiftOddRows=!1,this._cosAngle=1,this._sinAngle=0,this._offsetX=0,this._offsetY=0,this._buildRandomValues()}else{if(this._randomness=0,this._gridAngle=e.gridAngle??0,this._shiftOddRows=e.shiftOddRows??!1,this._offsetX=(e.offsetX??0)*s,this._offsetY=(e.offsetY??0)*s,this._cosAngle=Math.cos(this._gridAngle/180*Math.PI),this._sinAngle=-Math.sin(this._gridAngle/180*Math.PI),this._stepX)if(this._offsetX<0)for(;this._offsetX<-.5*this._stepX;)this._offsetX+=this._stepX;else for(;this._offsetX>=.5*this._stepX;)this._offsetX-=this._stepX;if(this._stepY)if(this._offsetY<0)for(;this._offsetY<-.5*this._stepY;)this._offsetY+=this._stepY;else for(;this._offsetY>=.5*this._stepY;)this._offsetY-=this._stepY}if(this._graphicOriginX=0,this._graphicOriginY=0,null!=r){const[t,e,s,i]=r.split("/"),n=parseFloat(t),o=parseFloat(e),a=parseFloat(s),h=parseFloat(i);this._graphicOriginX=-(h*2**n+a)*ts,this._graphicOriginY=o*ts,this._testInsidePolygon=!0}this._internalPlacement=new ne,this._calculateMinMax(t),this._geometryCursor=t}}next(){return this._geometryCursor?this._nextInside():null}_buildRandomValues(){if(!is._randValues){is._randValues=[];for(let t=0;t<es;t++)for(let t=0;t<es;t++)is._randValues.push(this._randomLCG.getFloat()),is._randValues.push(this._randomLCG.getFloat())}}_calculateMinMax(t){let e,s,r,i,n,o,a,h,c,l,u,d,_,p;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=h=_=u=Number.MAX_VALUE,c=l=p=d=-Number.MAX_VALUE;const f=1!==this._cosAngle;for(t.reset();t.nextPath();)for(;t.nextPoint();)o=t.x,n=t.y,e=o-this._graphicOriginX-this._offsetX,s=n-this._graphicOriginY-this._offsetY,f?(r=this._cosAngle*e-this._sinAngle*s,i=this._sinAngle*e+this._cosAngle*s):(r=e,i=s),a=Math.min(a,r),c=Math.max(c,r),h=Math.min(h,i),l=Math.max(l,i),u=Math.min(u,n),d=Math.max(d,n),_=Math.min(_,o),p=Math.max(p,o);u=u!==Number.MAX_VALUE?u:-512-this._stepY,d=d!==-Number.MAX_VALUE?d:this._stepY,_=_!==Number.MAX_VALUE?_:-this._stepX,p=p!==-Number.MAX_VALUE?p:ts+this._stepX;const g=d-u,m=p-_;if(this._verticalSubdivision=g>=m,this._polygonMin=this._verticalSubdivision?u:_,this._testInsidePolygon){let t=0-this._graphicOriginX-this._offsetX-this._stepX,e=ts-this._graphicOriginX-this._offsetX+this._stepX,s=-512-this._graphicOriginY-this._offsetY-this._stepY,r=0-this._graphicOriginY-this._offsetY+this._stepY;if(f){const i=[[t,s],[t,r],[e,s],[e,r]];t=s=Number.MAX_VALUE,e=r=-Number.MAX_VALUE;for(const n of i){const i=this._cosAngle*n[0]-this._sinAngle*n[1],o=this._sinAngle*n[0]+this._cosAngle*n[1];t=Math.min(t,i),e=Math.max(e,i),s=Math.min(s,o),r=Math.max(r,o)}}a=a!==Number.MAX_VALUE?Math.max(a,t):t,h=h!==Number.MAX_VALUE?Math.max(h,s):s,c=c!==-Number.MAX_VALUE?Math.min(c,e):e,l=l!==-Number.MAX_VALUE?Math.min(l,r):r}this._xMin=Math.round(a/this._stepX),this._xMax=Math.round(c/this._stepX),this._yMin=Math.round(h/this._stepY),this._yMax=Math.round(l/this._stepY),this._currentX=this._xMax+1,this._currentY=this._yMin-1,this._buildAccelerationMap(t,_,p,u,d)}_buildAccelerationMap(t,e,s,r,i){t.reset();const n=new Map,o=this._verticalSubdivision,a=o?i-r:s-e;let h=Math.ceil(a/10);if(h<=1)return;const c=Math.floor(a/h);let l,u,d,_,p,f,g,m,y,x,b;for(h++,this._delta=c,o?(y=-512-2*this._stepY,x=2*this._stepY,b=r):(y=-2*this._stepX,x=ts+2*this._stepX,b=e);t.nextPath();)if(!(t.pathSize<2)&&t.nextPoint())for(l=t.x,u=t.y;t.nextPoint();l=d,u=_){if(d=t.x,_=t.y,o){if(u===_||u<y&&_<y||u>x&&_>x)continue;p=Math.min(u,_),f=Math.max(u,_)}else{if(l===d||l<y&&d<y||l>x&&d>x)continue;p=Math.min(l,d),f=Math.max(l,d)}for(;p<f;)g=Math.floor((p-b)/c),ns(g,l,u,d,_,n),p+=c;m=Math.floor((f-b)/c),m>g&&ns(m,l,u,d,_,n)}this._accelerationMap=n}_nextInside(){for(;;){if(this._currentX>this._xMax){if(this._currentY++,this._currentY>this._yMax)return null;this._currentX=this._xMin,this._shiftOddRows&&this._currentY%2&&this._currentX--}let t=this._currentX*this._stepX+this._offsetX;this._shiftOddRows&&this._currentY%2&&(t+=.5*this._stepX);const e=this._currentY*this._stepY+this._offsetY;let s,r;if(this._currentX++,this._gridType===Ct.Q1.Random){const i=(this._currentX%es+es)%es,n=(this._currentY%es+es)%es;s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-is._randValues[n*es+i])*2/3,r=this._graphicOriginY+e+this._stepY*this._randomness*(.5-is._randValues[n*es+i+1])*2/3}else s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,r=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e;if(!this._testInsidePolygon||this._isInsidePolygon(s,r,this._geometryCursor))return this._internalPlacement.setTranslate(s,r),this._internalPlacement}}_isInsidePolygon(t,e,s){if(null==this._accelerationMap)return function(t,e,s){let r,i,n,o,a=0;for(t+=ss,e+=ss,s.reset();s.nextPath();)if(s.nextPoint())for(r=s.x,i=s.y;s.nextPoint();r=n,i=o)n=s.x,o=s.y,i>e!=o>e&&((n-r)*(e-i)-(o-i)*(t-r)>0?a++:a--);return 0!==a}(t,e,s);t+=ss,e+=ss;const r=this._verticalSubdivision,i=r?e:t,n=Math.floor((i-this._polygonMin)/this._delta),o=this._accelerationMap.get(n);if(!o)return!1;let a,h,c,l=0;for(const s of o){if(a=s[0],h=s[1],r){if(a[1]>e==h[1]>e)continue;c=(h[0]-a[0])*(e-a[1])-(h[1]-a[1])*(t-a[0])}else{if(a[0]>t==h[0]>t)continue;c=(h[1]-a[1])*(t-a[0])-(h[0]-a[0])*(e-a[1])}c>0?l++:l--}return 0!==l}}function ns(t,e,s,r,i,n){let o=n.get(t);o||(o=[],n.set(t,o)),o.push([[e,s],[r,i]])}class os{static local(){return null===os.instance&&(os.instance=new os),os.instance}execute(t,e,s,r,i){return new as(t,e,s)}}os.instance=null;class as extends ae{constructor(t,e,s){super(t),this._curveHelper=new le,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._relativeTo=e.relativeTo,this._position=void 0!==e.startPointOffset?e.startPointOffset*s:0,this._epsilon=.001*s}processPath(t){const e=this._position;if(this._relativeTo===Ct.ip.SegmentMidpoint){if(this.iteratePath||(this.iteratePath=!0),t.nextPoint()){let[e,s]=[t.x,t.y],[r,i]=[0,0];for(;t.nextPoint();){r=t.x,i=t.y;const n=this._curveHelper.getLength(e,s,r,i);if(n<this._epsilon){e=r,s=i;continue}const o=.5+this._position/n,[a,h]=this._curveHelper.getAngleCS(e,s,r,i,o),c=this._curveHelper.getCoord2D(e,s,r,i,o);return this.internalPlacement.setTranslate(c[0]-this._offset*h,c[1]+this._offset*a),this._angleToLine&&this.internalPlacement.setRotateCS(a,h),this.internalPlacement}}return this.iteratePath=!1,null}const s=this._relativeTo===Ct.ip.LineEnd;return this.onLine(t,e,s)}onLine(t,e,s){let r,i=!1;switch(this._relativeTo){case Ct.ip.LineMiddle:default:t.seekPathStart(),r=t.pathLength()/2+e;break;case Ct.ip.LineBeginning:r=e;break;case Ct.ip.LineEnd:r=e,i=!0}s?t.seekPathEnd():t.seekPathStart();let n=0;if(s?t.prevPoint():t.nextPoint()){let[e,o]=[t.x,t.y],[a,h]=[0,0];for(;s?t.prevPoint():t.nextPoint();){a=t.x,h=t.y;const s=this._curveHelper.getLength(e,o,a,h);if(n+s>r){const t=(r-n)/s,[c,l]=this._curveHelper.getAngleCS(e,o,a,h,t),u=this._curveHelper.getCoord2D(e,o,a,h,t),d=i?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-d*l,u[1]+d*c),this._angleToLine&&(i?this.internalPlacement.setRotateCS(-c,-l):this.internalPlacement.setRotateCS(c,l)),this.internalPlacement}e=a,o=h,n+=s}}return null}}class hs{static local(){return null===hs.instance&&(hs.instance=new hs),hs.instance}execute(t,e,s,r,i){return new cs(t,e,s)}}hs.instance=null;class cs extends ae{constructor(t,e,s){super(t),this._curveHelper=new le,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._endPoints=void 0===e.placeOnEndPoints||e.placeOnEndPoints,this._controlPoints=void 0===e.placeOnControlPoints||e.placeOnControlPoints,this._regularVertices=void 0===e.placeOnRegularVertices||e.placeOnRegularVertices,this._tags=[],this._tagIterator=0}processPath(t){if(this.iteratePath||(this._preparePath(t),this.iteratePath=!0),this._tagIterator>=this._tags.length)return this._tags.length=0,this._tagIterator=0,this.iteratePath=!1,null;const e=this._tags[this._tagIterator];this._angleToLine&&this.internalPlacement.setRotate(e[2]);let s=e[0],r=e[1];if(0!==this._offset){const t=Math.cos(e[2]),i=Math.sin(e[2]);s-=this._offset*i,r+=this._offset*t}return this.internalPlacement.setTranslate(s,r),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0,t.seekPathStart();const e=t.isClosed();let s=0,r=!1,i=0,n=0;if(t.seekPathStart(),t.nextPoint()){let o=t.x,a=t.y,h=t.getControlPoint(),c=!0,l=t.nextPoint();for(;l;){const u=t.x,d=t.y,_=t.getControlPoint();(this._angleToLine||0!==this._offset)&&(i=this._curveHelper.getAngle(o,a,u,d,0)),c?(c=!1,e?(s=i,r=h):(this._endPoints||this._controlPoints&&h)&&this._tags.push([o,a,i])):h?this._controlPoints&&this._tags.push([o,a,ls(n,i)]):this._regularVertices&&this._tags.push([o,a,ls(n,i)]),(this._angleToLine||0!==this._offset)&&(n=this._curveHelper.getAngle(o,a,u,d,1)),l=t.nextPoint(),l||(e?_||r?this._controlPoints&&this._tags.push([u,d,ls(n,s)]):this._regularVertices&&this._tags.push([u,d,ls(n,s)]):(this._endPoints||this._controlPoints&&_)&&this._tags.push([u,d,n])),o=u,a=d,h=_}}this._tagIterator=0}}function ls(t,e){const s=Math.PI;for(;Math.abs(e-t)>s+2e-15;)e-t>s?e-=2*s:e+=2*s;return(t+e)/2}var us=s(12359),ds=s(12176);function _s(t){if(0===t.totalSize)return null;const e=(0,Ue.z8)(t);if(!e)return null;const s=4*(Math.abs(e[0])+Math.abs(e[2])+Math.abs(e[1])+Math.abs(e[3])+1)*222045e-19;let r=0,i=0;t.reset();for(let e=0;t.nextPath();e++){const s=t.getCurrentRingArea();s>i&&(i=s,r=e)}if(t.seekPath(r),0===t.pathSize)return null;t.seekPathStart();const n=(0,Ue.B$)(t);if(Math.abs(i)<=2*s*s)return[(n[0]+n[2])/2,(n[1]+n[3])/2];t.seekPathStart();const o=(0,us.w2)(t,(0,N.vt)());if(null===o)return null;if(t.totalPoints<4)return o;const a=[[NaN,NaN],[NaN,NaN],[NaN,NaN],[NaN,NaN]],h=[NaN,NaN,NaN,NaN],c=[NaN,NaN,NaN,NaN];let l=!1,u=fs(o,t,!0);0===u.distance&&(l=!0,a[0][0]=o[0],a[0][1]=o[1],u=fs(o,t,!1)),h[0]=u.distance,c[0]=0;const d=[NaN,NaN];let _=!1,p=.25,f=-1,g=NaN;do{if(g=NaN,a[1]=gs(t,Is(n[0],n[2],p),0,e),isNaN(a[1][0])||isNaN(a[1][1])||(u=fs(a[1],t,!1),g=u.distance),!isNaN(g)&&g>s&&ps(a[1],t))_=!0,h[1]=g,c[1]=Ms(a[1],o);else if(!isNaN(g)&&g>f&&(f=g,d[0]=a[1][0],d[1]=a[1][1]),p-=.01,p<.1){if(!(f>=0))break;_=!0,h[1]=f,a[1][0]=d[0],a[1][1]=d[1],c[1]=Ms(a[1],o)}}while(!_);_=!1,p=.5,f=-1;let m=.01,y=1;do{if(g=NaN,a[2]=gs(t,Is(n[0],n[2],p),0,e),isNaN(a[2][0])||isNaN(a[2][1])||(u=fs(a[2],t,!1),g=u.distance),!isNaN(g)&&g>s&&ps(a[2],t))_=!0,h[2]=g,c[2]=Ms(a[2],o);else if(!isNaN(g)&&g>f)f=g,d[0]=a[2][0],d[1]=a[2][1];else if(g>f&&(f=g,d[0]=a[2][0],d[1]=a[2][1]),p=.5+m*y,m+=.01,y*=-1,p<.3||p>.7){if(!(f>=0))break;_=!0,h[2]=f,a[2][0]=d[0],a[2][1]=d[1],c[2]=Ms(a[2],o)}}while(!_);_=!1,p=.75,f=-1;do{if(g=NaN,a[3]=gs(t,Is(n[0],n[2],p),0,e),isNaN(a[3][0])||isNaN(a[3][1])||(u=fs(a[3],t,!1),g=u.distance),!isNaN(g)&&g>s&&ps(a[3],t))_=!0,h[3]=g,c[3]=Ms(a[3],o);else if(g>f&&(f=g,d[0]=a[3][0],d[1]=a[3][1]),p+=.01,p>.9){if(!(f>=0))break;_=!0,h[3]=f,a[3][0]=d[0],a[3][1]=d[1],c[3]=Ms(a[3],o)}}while(!_);const x=[0,1,2,3],b=l?0:1;let w;for(let t=b;t<4;t++)for(let t=b;t<3;t++){const e=c[t],s=c[t+1];Ps(e,s)>0&&(w=x[t],x[t]=x[t+1],x[t+1]=w,c[t]=s,c[t+1]=e)}let v=b,S=0,I=0;for(let t=b;t<4;t++){switch(t){case 0:I=2*h[x[t]];break;case 1:I=1.66666666*h[x[t]];break;case 2:I=1.33333333*h[x[t]];break;case 3:I=h[x[t]]}I>S&&(S=I,v=x[t])}return a[v]}function ps(t,e){let s,r,i,n,o=0;for(e.reset();e.nextPath()&&e.nextPoint();)for(s=e.x,r=e.y;e.nextPoint();s=i,r=n)i=e.x,n=e.y,r>t[1]!=n>t[1]&&((i-s)*(t[1]-r)-(n-r)*(t[0]-s)>0?o++:o--);return 0!==o}function fs(t,e,s){if(s&&ps(t,e))return{coord:t,distance:0};let r=1/0,i=0,n=0,o=[0,0],a=[0,0];const h=[0,0];for(e.reset();e.nextPath()&&e.nextPoint();)if(!(e.pathSize<2))for(o[0]=e.x,o[1]=e.y;e.nextPoint();o=a){a=[e.x,e.y],(0,ye.gR)(h,t,o,a);const s=Ms(t,h);s<r&&(r=s,i=h[0],n=h[1])}return{coord:[i,n],distance:Math.sqrt(r)}}function gs(t,e,s,r){const i=[e,0];let n=1/0,o=1/0,a=!1,h=!1;const c=[[e,r[1]-1],[e,r[3]+1]],l=[0,0],u=[0,0],d=[0,0],_=[[0,0],[0,0]],p=(0,N.vt)();for(t.reset();t.nextPath()&&t.nextPoint();)if(!(t.pathSize<2))for(_[0][0]=t.x,_[0][1]=t.y;t.nextPoint();_[0][0]=_[1][0],_[0][1]=_[1][1]){if(_[1][0]=t.x,_[1][1]=t.y,null===ms(p,_))continue;if(u[0]=c[0][0],u[1]=c[0][1],d[0]=c[1][0],d[1]=c[1][1],0===vs(p,u,d))continue;if(!(0,ds.Ql)(c[0],c[1],_[0],_[1],l))continue;const e=l[1];n>o?e<n&&(n=e,a=!0):e<o&&(o=e,h=!0)}return a&&h?i[1]=(n+o)/2:i[0]=i[1]=NaN,i}function ms(t,e){if(e.length<2)return null;t||(t=(0,N.vt)());const[s,r]=e[0],[i,n]=e[1];return t[0]=Math.min(s,i),t[1]=Math.min(r,n),t[2]=Math.max(s,i),t[3]=Math.max(r,n),t}const ys=1,xs=4,bs=3,ws=12;function vs(t,e,s){let r=Ss(e,t),i=Ss(s,t);const n=t[0],o=t[1],a=t[2],h=t[3];if(r&i)return 0;if(!(r|i))return 4;const c=(r?1:0)|(i?2:0);do{const c=s[0]-e[0],l=s[1]-e[1];if(c>l)r&bs?(r&ys?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),r=Ss(e,t)):i&bs?(i&ys?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),i=Ss(s,t)):r?(r&xs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),r=Ss(e,t)):(i&xs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),i=Ss(s,t));else if(r&ws?(r&xs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),r=Ss(e,t)):i&ws?(i&xs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),i=Ss(s,t)):r?(r&ys?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),r=Ss(e,t)):(i&ys?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),i=Ss(s,t)),r&i)return 0}while(r|i);return c}function Ss(t,e){return(t[0]<e[0]?1:0)|(t[0]>e[2]?1:0)<<1|(t[1]<e[1]?1:0)<<2|(t[1]>e[3]?1:0)<<3}function Is(t,e,s){return t+(e-t)*s}function Ms(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])}function Ps(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;const s=isNaN(t),r=isNaN(e);return s<r?-1:s>r?1:0}class Ts{static local(){return null===Ts.instance&&(Ts.instance=new Ts),Ts.instance}execute(t,e,s,r,i){return new As(t,e,s)}}Ts.instance=null;class As{constructor(t,e,s){this._geometryCursor=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0,this._method=void 0!==e.method?e.method:Ct.YI.OnPolygon,this._placementPerPart=void 0!==e.placePerPart&&e.placePerPart,this._internalPlacement=new ne}next(){const t=this._geometryCursor;if(!t)return null;if(!this._placementPerPart)return this._geometryCursor=null,this._polygonCenter(t);for(;t.nextPath();)if(!(t.getCurrentRingArea()<0))return this._polygonCenter(t.getCurrentPath());return this._geometryCursor=null,null}_polygonCenter(t){let e=!1;switch(this._method){case Ct.YI.CenterOfMass:{const s=(0,us.TP)(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case Ct.YI.BoundingBoxCenter:{const s=(0,Ue.z8)(t);s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case Ct.YI.OnPolygon:default:{const s=_s(t);null!==s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function Cs(t){if(!t)return null;switch(t.type){case"CIMGeometricEffectAddControlPoints":return re.local();case"CIMGeometricEffectArrow":return de.local();case"CIMGeometricEffectBuffer":return pe.local();case"CIMGeometricEffectControlMeasureLine":return xe.local();case"CIMGeometricEffectCut":return we.local();case"CIMGeometricEffectDashes":return Ae.local();case"CIMGeometricEffectDonut":return ke.local();case"CIMGeometricEffectJog":return Ee.local();case"CIMGeometricEffectMove":return Oe.local();case"CIMGeometricEffectOffset":return De.local();case"CIMGeometricEffectReverse":return Ne.local();case"CIMGeometricEffectRotate":return Ve.local();case"CIMGeometricEffectScale":return We.local();case"CIMGeometricEffectWave":return Ye.local()}return null}new(s(32488).A),s(11831),s(92602),new Map,new Set;var ks=s(34727);s(28076),s(40804),s(5760);var Fs=s(34304);function Es(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function zs(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1],u=s[2],d=s[3],_=s[4],p=s[5];return t[0]=r*c+n*l,t[1]=i*c+o*l,t[2]=r*u+n*d,t[3]=i*u+o*d,t[4]=r*_+n*p+a,t[5]=i*_+o*p+h,t}function Os(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=Math.sin(s),l=Math.cos(s);return t[0]=r*l+n*c,t[1]=i*l+o*c,t[2]=r*-c+n*l,t[3]=i*-c+o*l,t[4]=a,t[5]=h,t}function Rs(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=r,t[1]=i,t[2]=n,t[3]=o,t[4]=r*c+n*l+a,t[5]=i*c+o*l+h,t}function Ds(t,e){const s=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=s,t[2]=-s,t[3]=r,t[4]=0,t[5]=0,t}function Ls(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t[2]=e[2]-s[2],t[3]=e[3]-s[3],t[4]=e[4]-s[4],t[5]=e[5]-s[5],t}const Ns=zs,Bs=Ls;function Gs(){const t=new Float32Array(6);return t[0]=1,t[3]=1,t}function Us(t,e,s,r){const i=e[r],n=e[r+1];t[r]=s[0]*i+s[2]*n+s[4],t[r+1]=s[1]*i+s[3]*n+s[5]}function Vs(t,e,s,r=0,i=0,n=2){const o=i||e.length/n;for(let i=r;i<o;i++)Us(t,e,s,i*n)}Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t[2]=e[2]+s[2],t[3]=e[3]+s[3],t[4]=e[4]+s[4],t[5]=e[5]+s[5],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},equals:function(t,e){const s=t[0],r=t[1],i=t[2],n=t[3],o=t[4],a=t[5],h=e[0],c=e[1],l=e[2],u=e[3],d=e[4],_=e[5],p=(0,Fs.FD)();return Math.abs(s-h)<=p*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(r-c)<=p*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-l)<=p*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(n-u)<=p*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(o-d)<=p*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-_)<=p*Math.max(1,Math.abs(a),Math.abs(_))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},frob:function(t){return Math.sqrt(t[0]**2+t[1]**2+t[2]**2+t[3]**2+t[4]**2+t[5]**2+1)},fromRotation:Ds,fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},identity:Es,invert:function(t,e){const s=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5];let h=s*n-r*i;return h?(h=1/h,t[0]=n*h,t[1]=-r*h,t[2]=-i*h,t[3]=s*h,t[4]=(i*a-n*o)*h,t[5]=(r*o-s*a)*h,t):null},mul:Ns,multiply:zs,multiplyScalar:function(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s,t[4]=e[4]*s,t[5]=e[5]*s,t},multiplyScalarAndAdd:function(t,e,s,r){return t[0]=e[0]+s[0]*r,t[1]=e[1]+s[1]*r,t[2]=e[2]+s[2]*r,t[3]=e[3]+s[3]*r,t[4]=e[4]+s[4]*r,t[5]=e[5]+s[5]*r,t},rotate:Os,scale:function(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=r*c,t[1]=i*c,t[2]=n*l,t[3]=o*l,t[4]=a,t[5]=h,t},set:function(t,e,s,r,i,n,o){return t[0]=e,t[1]=s,t[2]=r,t[3]=i,t[4]=n,t[5]=o,t},str:function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},sub:Bs,subtract:Ls,translate:Rs},Symbol.toStringTag,{value:"Module"})),Object.freeze(Object.defineProperty({__proto__:null,clone:function(t){const e=new Float32Array(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},create:Gs,createView:function(t,e){return new Float32Array(t,e,6)},fromValues:function(t,e,s,r,i,n){const o=new Float32Array(6);return o[0]=t,o[1]=e,o[2]=s,o[3]=r,o[4]=i,o[5]=n,o},transform:Us,transformMany:Vs},Symbol.toStringTag,{value:"Module"}));var qs,Ws,js=s(88340);function Ys(t){if(!t)return qs.Center;switch(t){case"Left":case"left":return qs.Left;case"Right":case"right":return qs.Right;case"Justify":return E.A.getLogger("esri.views.2d.engine.webgl.alignmentUtils").warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),qs.Center;case"Center":case"center":return qs.Center}}function Xs(t){if(!t)return Ws.Center;switch(t){case"Top":case"top":return Ws.Top;case"Center":case"middle":return Ws.Center;case"Baseline":case"baseline":return Ws.Baseline;case"Bottom":case"bottom":return Ws.Bottom}}!function(t){t[t.Left=-1]="Left",t[t.Center=0]="Center",t[t.Right=1]="Right"}(qs||(qs={})),function(t){t[t.Top=1]="Top",t[t.Center=0]="Center",t[t.Bottom=-1]="Bottom",t[t.Baseline=2]="Baseline"}(Ws||(Ws={}));var $s=s(18989);class Hs{constructor(t,e,s,r){this.transformedX=0,this.transformedY=0,this.center=(0,js.fA)(t,e),this.centerT=(0,js.vt)(),this.halfWidth=s/2,this.halfHeight=r/2,this.width=s,this.height=r}get x(){return this.center[0]}get y(){return this.center[1]}get blX(){return this.center[0]+this.halfWidth}get blY(){return this.center[1]+this.halfHeight}get trX(){return this.center[0]-this.halfWidth}get trY(){return this.center[1]-this.halfHeight}get xmin(){return this.x-this.halfWidth}get xmax(){return this.x+this.halfWidth}get ymin(){return this.y-this.halfHeight}get ymax(){return this.y+this.halfHeight}set x(t){this.center[0]=t}set y(t){this.center[1]=t}clone(){return new Hs(this.x,this.y,this.width,this.height)}serialize(t){return t.writeF32(this.center[0]),t.writeF32(this.center[1]),t.push(this.width),t.push(this.height),t}findCollisionDelta(t,e=4){const s=Math.abs(t.centerT[0]-this.centerT[0]),r=Math.abs(t.centerT[1]-this.centerT[1]),i=(t.halfWidth+this.halfWidth+e)/s,n=(t.halfHeight+this.halfHeight+e)/r,o=Math.min(i,n);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),r=Math.max(this.xmax,t.xmax)-e,i=Math.max(this.ymax,t.ymax)-s,n=e+r/2,o=s+i/2;this.width=r,this.height=i,this.halfWidth=r/2,this.halfHeight=i/2,this.x=n,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),r=t.readInt32(),i=t.readInt32();return new Hs(e,s,r,i)}}const Zs=Math.PI/180;class Qs{constructor(t,e,s,r){this._rotationT=Gs(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const i=s.rect,n=new Float32Array(8);t*=r,e*=r;const o=s.code?i.width*r:s.metrics.width,a=s.code?i.height*r:s.metrics.height;this.width=o,this.height=a,n[0]=t,n[1]=e,n[2]=t+o,n[3]=e,n[4]=t,n[5]=e+a,n[6]=t+o,n[7]=e+a,this._data=n,this._setTextureCoords(i),this._scale=r,this._mosaic=s,this.x=t,this.y=e,this.maxOffset=Math.max(t+o,e+a)}get mosaic(){return this._mosaic}set angle(t){this._angle=t,Ds(this._rotationT,-t),this._setOffsets()}get angle(){return this._angle}get xTopLeft(){return this._data[0]}get yTopLeft(){return this._data[1]}get xBottomRight(){return this._data[6]}get yBottomRight(){return this._data[7]}get texcoords(){return this._texcoords}get textureBinding(){return this._mosaic.textureBinding}get offsets(){return this._offsets||this._setOffsets(),this._offsets}get char(){return String.fromCharCode(this._mosaic.code)}get code(){return this._mosaic.code}get bounds(){if(!this._bounds){const{height:t,width:e}=this._mosaic.metrics,s=e*this._scale,r=Math.abs(t)*this._scale,i=new Float32Array(8);i[0]=this.x,i[1]=this.y,i[2]=this.x+s,i[3]=this.y,i[4]=this.x,i[5]=this.y+r,i[6]=this.x+s,i[7]=this.y+r,Vs(i,i,zs(Gs(),this._rotationT,this._transform));let n=1/0,o=1/0,a=-1/0,h=-1/0;for(let t=0;t<4;t++){const e=i[2*t],s=i[2*t+1];n=Math.min(n,e),o=Math.min(o,s),a=Math.max(a,e),h=Math.max(h,s)}const c=a-n,l=h-o,u=n+c/2,d=o+l/2;this._bounds=new Hs(u,d,c,l)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}_setOffsets(){this._offsets||(this._offsets={topLeft:[0,0],topRight:[0,0],bottomLeft:[0,0],bottomRight:[0,0]});const t=zs(Gs(),this._rotationT,this._transform);this._offsets.topLeft[0]=this._data[0],this._offsets.topLeft[1]=this._data[1],this._offsets.topRight[0]=this._data[2],this._offsets.topRight[1]=this._data[3],this._offsets.bottomLeft[0]=this._data[4],this._offsets.bottomLeft[1]=this._data[5],this._offsets.bottomRight[0]=this._data[6],this._offsets.bottomRight[1]=this._data[7],(0,O.l0)(this._offsets.topLeft,this._offsets.topLeft,t),(0,O.l0)(this._offsets.topRight,this._offsets.topRight,t),(0,O.l0)(this._offsets.bottomLeft,this._offsets.bottomLeft,t),(0,O.l0)(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:e,width:s,height:r}){this._texcoords={topLeft:[t,e],topRight:[t+s,e],bottomLeft:[t,e+r],bottomRight:[t+s,e+r]}}}const Ks=(t,e)=>({code:0,page:0,sdf:!0,rect:new $s.A(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function Js(t,e){return t.forEach((t=>(0,O.l0)(t,t,e))),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class tr{constructor(t,e,s){this._rotation=0,this._decorate(t,e,s),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==s.angle,this._transform=this._createGlyphTransform(this.bounds,s),this._borderLineSizePx=s.borderLineSizePx,(s.borderLineSizePx||s.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const e of t)e.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const e=this._transform;zs(e,Ds(Gs(),t),e);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,s){if(!s.decoration||"none"===s.decoration||!t.length)return;const r=s.scale,i="underline"===s.decoration?26:16,n=t[0].textureBinding;for(const s of e){const e=s.startX*r,o=s.startY*r,a=(s.width+s.glyphWidthEnd)*r;t.push(new Qs(e,o+i*r,Ks(a,n),1))}}shapeBackground(t){const e=(1.5+(this._borderLineSizePx||0))/2,s=this._borderLineSizePx?e:0,{xmin:r,ymin:i,xmax:n,ymax:o,x:a,y:h,width:c,height:l}=this.bounds,u=[r-8,i-8],d=[n+8,i-8],_=[r-8,o+8],p=[n+8,o+8],f=Js([[u[0]-e,u[1]-e],[d[0]+e,d[1]-e],[u[0]+s,u[1]+s],[d[0]-s,d[1]+s]],t),g=Js([[_[0]+s,_[1]-s],[p[0]-s,p[1]-s],[_[0]-e,_[1]+e],[p[0]+e,p[1]+e]],t),m=Js([[u[0]-e,u[1]-e],[u[0]+s,u[1]+s],[_[0]-e,_[1]+e],[_[0]+s,_[1]-s]],t),y=Js([[d[0]-s,d[1]+s],[d[0]+e,d[1]-e],[p[0]-s,p[1]-s],[p[0]+e,p[1]+e]],t),x={main:Js([u,d,_,p],t),top:f,bot:g,left:m,right:y};return[new Hs(a,h,c+2*e,l+2*e),x]}get boundsT(){const t=this.bounds,e=(0,O.hZ)((0,js.vt)(),t.x,t.y);if((0,O.l0)(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Hs(e[0],e[1],s,s)}return new Hs(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,r=0,i=0;for(const n of t)e=Math.min(e,n.xTopLeft),s=Math.min(s,n.yTopLeft),r=Math.max(r,n.xBottomRight),i=Math.max(i,n.yBottomRight);const n=r-e,o=i-s;return new Hs(e+n/2,s+o/2,n,o)}_createGlyphTransform(t,e){const s=Zs*e.angle,r=Gs(),i=(0,js.vt)();return Rs(r,r,(0,O.hZ)(i,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?Os(r,r,s):(Rs(r,r,(0,O.hZ)(i,t.x,t.y)),Os(r,r,s),Rs(r,r,(0,O.hZ)(i,-t.x,-t.y))),r}}class er{constructor(t,e,s,r,i,n){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=r,this.yMin=i,this.yMax=n}}const sr=t=>10===t,rr=t=>32===t;var ir=s(39829);Math.PI,s(59868);var nr=s(13195);function or(t){if(!t)return 0;switch(t.type){case"CIMGeometricEffectArrow":return Math.abs(.5*t.width);case"CIMGeometricEffectBuffer":return Math.abs(t.size);case"CIMGeometricEffectControlMeasureLine":return 500;case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(t.length);case"CIMGeometricEffectJog":return Math.abs(.5*t.length);case"CIMGeometricEffectMove":return Math.max(Math.abs((0,Te.$w)(t.offsetX)),Math.abs((0,Te.$w)(t.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(t.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(t.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(t.fromWidth),Math.abs(t.toWidth));case"CIMGeometricEffectWave":return Math.abs(t.amplitude);case"CIMGeometricEffectDonut":return Math.abs(t.width)}}function ar(t){if(!t)return 0;let e=0;for(const s of t)e+=or(s);return e}Math.PI,Math.PI;const hr=96/72;class cr{static executeEffects(t,e,s,r,i){const n=hr,o=ar(t);let a=new ee(e);for(const e of t){const t=Cs(e);t&&(a=t.execute(a,e,n,s,r,o,i))}return a}static applyEffects(t,e,s){if(!t)return e;const r=ar(t);let i,n=new ee(Yt.fromJSONCIM(e));for(const e of t){const t=Cs(e);t&&(n=t.execute(n,e,1,null,s,r,!1))}const o=[];let a=null;for(;i=n.next();)o.push(...(0,qt.x)(i)),a=i.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let lr=null;function ur(){return lr}const dr=new Float32Array(1),_r=new Uint32Array(dr.buffer);function pr(t){const e=function(t){return dr[0]=t,_r[0]}(t),s=e>>>31;let r=e>>>23&255,i=8388607&e;return r-=127,r>15?s<<15|31744:r<-25?0:(r<-14&&(i+=8388608,i/=2**(-14-r),r=-15),r+=15,i/=8192,i=function(t){const e=Math.floor(t),s=t-e;return e<1023&&(s>.5||.5===s&&e%2==1)?e+1:e}(i),s<<15|r<<10|i)}function fr(t,e,s,r,i,n,o){if(t.primitiveName===e){let e=r?.readWithDefault(i,n,t[s]&&o);return"text"===t.type&&(e=e.toString()),void(t[s]=e)}if("type"in t&&null!=t.type){if(t.effects)for(const a of t.effects)fr(a,e,s,r,i,n,o);switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.symbolLayers)for(const a of t.symbolLayers)fr(a,e,s,r,i,n,o);break;case"CIMTextSymbol":t.symbol&&fr(t.symbol,e,s,r,i,n,o);break;case"CIMHatchFill":t.lineSymbol&&fr(t.lineSymbol,e,s,r,i,n,o);break;case"CIMPictureMarker":case"CIMCharacterMarker":case"CIMVectorMarker":if(t.markerPlacement&&fr(t.markerPlacement,e,s,r,i,n,o),"CIMVectorMarker"===t.type&&t.markerGraphics)for(const a of t.markerGraphics)fr(a,e,s,r,i,n,o),fr(a.symbol,e,s,r,i,n,o)}}}function gr(t){const e=t.width;return null!=t.effects?400:Math.max(1.25*e,8)}function mr(t){switch(t){case dt.pe.BYTE:case dt.pe.UNSIGNED_BYTE:return 1;case dt.pe.SHORT:case dt.pe.UNSIGNED_SHORT:case dt.pe.HALF_FLOAT:return 2;case dt.pe.FLOAT:case dt.pe.INT:case dt.pe.UNSIGNED_INT:return 4}}class yr{static fromVertexSpec(t,e){const{attributes:s,optionalAttributes:r}=t;let i,n,o;const a=[];for(const t in s){const e=s[t];"position"===e.pack?i={...e,name:t,offset:0}:"id"===e.pack?n={...e,name:t,offset:4}:"bitset"===t?o={...e,name:t,offset:7}:a.push({...e,name:t})}for(const t in r)if(!0===e[t]){const e=r[t];a.push({...e,name:t})}const h=function(t){const e=[],s=[],r=[];for(const i of t){const t=mr(i.type)*i.count;switch(t%2||t%4||4){case 4:e.push(i);continue;case 2:s.push(i);continue;case 1:r.push(i);continue;default:throw new Error("Found unexpected dataType byte count")}}return e.push(...s),e.push(...r),e}(a),c=[];let l=8,u=1;for(const t of h)c.push({...t,offset:l}),l+=mr(t.type)*t.count,t.packAlternating&&(u=Math.max(t.packAlternating.count,u));const d=Uint32Array.BYTES_PER_ELEMENT,_=l%d;return new yr(i,n,o,c,l+(_?d-_:0),u)}constructor(t,e,s,r,i,n){this.position=t,this.id=e,this.bitset=s,this.standardAttributes=r,this.stride=i,this.packVertexCount=n,r.push(s),this._attributes=[t,e,s,...r]}get attributeLayout(){if(!this._attributeLayout){const t=function(t){const e=t.map((({name:t,count:e,type:s})=>`${t}.${e}.${s}`)).join(",");return(0,lt.Wm)(e)}(this._attributes),e=this._attributes.map((t=>({name:t.name,count:t.count,offset:t.offset,type:t.type,packPrecisionFactor:t.packPrecisionFactor,normalized:t.normalized??!1})));this._attributeLayout={attributes:e,hash:t,stride:this.stride}}return this._attributeLayout}}class xr{static fromVertexSpec(t,e){const s=yr.fromVertexSpec(t,e);return new xr(s)}constructor(t){this._spec=t,this._packed=new Uint8Array(this._spec.stride*this._spec.packVertexCount),this._packedU32View=new Uint32Array(this._packed.buffer),this._dataView=new DataView(this._packed.buffer)}get attributeLayout(){return this._spec.attributeLayout}get stride(){return this._spec.stride}writeVertex(t,e,s,r,i,n){for(let t=0;t<this._spec.packVertexCount;t++){const o=t*this._spec.stride;this._packPosition(s,r,o),this._packId(e,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const t=a.packTessellation(n,i,s,r);this._pack(t,a,o)}for(const t of this._spec.standardAttributes)if(null!=t.packTessellation){const e=t.packTessellation(n,i,s,r);this._pack(e,t,o)}else if(t.packAlternating?.packTessellation){const e=t.packAlternating.packTessellation(n,i,s,r);for(let s=0;s<this._spec.packVertexCount;s++){const r=e[s];this._pack(r,t,s*this._spec.stride)}}}}t.vertexWriteRegion(this._packedU32View)}pack(t,e){for(const s of this._spec.standardAttributes)if(s.pack&&"string"!=typeof s.pack){const r=s.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++)this._pack(r,s,t*this._spec.stride)}else if(s.packAlternating?.pack){const r=s.packAlternating.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++){const e=r[t];this._pack(e,s,t*this._spec.stride)}}}_packPosition(t,e,s){const{offset:r}=this._spec.position,i=this._spec.position.packPrecisionFactor??1,n=function(t,e){return 65535&t|e<<16}(t*i,e*i);this._dataView.setUint32(s+r,n,!0)}_packId(t,e){const s=t*(this._spec.id.packPrecisionFactor??1),r=4278190080&this._dataView.getUint32(e+this._spec.id.offset,!0);this._dataView.setUint32(e+this._spec.id.offset,s|r,!0)}_pack(t,e,s){!function(t,e,s,r){const i=s.packPrecisionFactor??1;switch(s.type){case dt.pe.BYTE:if(1===s.count)t.setInt8(r+s.offset,e*i);else for(let n=0;n<s.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;t.setInt8(r+s.offset+o,e[n]*i)}break;case dt.pe.UNSIGNED_BYTE:if(1===s.count)t.setUint8(r+s.offset,e*i);else for(let n=0;n<s.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;t.setUint8(r+s.offset+o,e[n]*i)}break;case dt.pe.SHORT:if(1===s.count)t.setInt16(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;t.setInt16(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.UNSIGNED_SHORT:if(1===s.count)t.setUint16(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.INT:if(1===s.count)t.setInt32(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;t.setInt32(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.UNSIGNED_INT:if(1===s.count)t.setUint32(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;t.setUint32(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.FLOAT:if(1===s.count)t.setFloat32(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;t.setFloat32(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.HALF_FLOAT:if(1===s.count)t.setUint16(r+s.offset,pr(e*i),!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(r+s.offset+o,pr(e[n]*i),!0)}}}(this._dataView,t,e,s)}}class br{constructor(t,e,s,r){this._instanceId=t,this._evaluator=e,this._enabledOptionalAttributes=s,this._viewParams=r,this._evaluator.evaluator=t=>this.vertexSpec.createComputedParams(t)}get _vertexPack(){if(!this._cachedVertexPack){const t=xr.fromVertexSpec(this.vertexSpec,this._enabledOptionalAttributes);this._evaluator.hasDynamicProperties||t.pack(this._evaluator.evaluatedMeshParams,this._viewParams),this._cachedVertexPack=t}return this._cachedVertexPack}get evaluatedMeshParams(){return this._evaluator.evaluatedMeshParams}get hasEffects(){return!!this.evaluatedMeshParams.effects}get instanceId(){return this._instanceId}get attributeLayout(){return this._vertexPack.attributeLayout}get _preventEffectClipping(){return!1}setReferences(t){this._references=t}getBoundsInfo(){return null}getTileInfo(){return this._viewParams.tileInfo}async loadDependencies(){(function(t){if(!t)return!1;for(const e of t)switch(e.effect.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":case"CIMGeometricEffectDonut":return!0}return!1})(this._evaluator.inputMeshParams.effects?.effectInfos)&&await async function(){lr=await Promise.all([s.e(9930),s.e(3656)]).then(s.bind(s,47559))}()}enqueueRequest(t,e,s){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(t,e,s)}write(t,e,s,r,i){this.ensurePacked(e,s,r);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(t,s,void 0,i);const o=s.readGeometryForDisplay()?.clone();if(!o)return;const a=Yt.fromOptimizedCIM(o,s.geometryType),h=ur();a.invertY();const c=t.id||"",l=cr.executeEffects(n,a,c,h,this._preventEffectClipping);let u;for(;u=l.next();)u.invertY(),this._write(t,s,u,i)}ensurePacked(t,e,s){if(!this._evaluator.hasDynamicProperties)return;const r=this._evaluator.evaluateMeshParams(t,e,s);this._vertexPack.pack(r,this._viewParams)}hasArcadeDependency(t){return this._evaluator.hasArcadeDependency(t)}_writeVertex(t,e,s,r,i){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(t,e,s,r,n,i)}}class wr extends br{}function vr(t){const{sprite:e,isMapAligned:s,colorLocked:r,scaleSymbolsProportionally:i,isStroke:n}=t;let o=0;return s&&(o|=Ft(Lt)),r&&(o|=Ft(Gt)),e.sdf&&(o|=Ft(Dt)),i&&(o|=Ft(Nt)),n&&(o|=Ft(Ut)),o}var Sr,Ir;(Ir=Sr||(Sr={}))[Ir.Geographic=0]="Geographic",Ir[Ir.Arithmatic=1]="Arithmatic";const Mr=3.14159265359/128;class Pr extends wr{get vertexSpec(){return{createComputedParams:t=>{let{pixelDimensions:e,texelDimensions:s,baseSize:r,referenceSize:i,strokeWidth:n,sizeRatio:o}=t;e||(e=t.sprite.sdf?[0,0]:[t.sprite.width,t.sprite.height]),s||(s=t.sprite.sdf?[0,0]:e),r=(0,l.Lz)(r),i=(0,l.Lz)(i),n=(0,l.Lz)(n);const a=(t.sprite.sdfDecodeCoeff??1)*o;return{...t,pixelDimensions:e,texelDimensions:s,baseSize:r,referenceSize:i,strokeWidth:n,sdfDecodeCoeff:a}},optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:vr},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:1},offset:{type:dt.pe.FLOAT,count:2,packAlternating:{count:4,pack:t=>{const e=t.texelDimensions;return[[-.5*e[0],-.5*e[1]],[.5*e[0],-.5*e[1]],[-.5*e[0],.5*e[1]],[.5*e[0],.5*e[1]]]}}},uv:{type:dt.pe.SHORT,count:2,packPrecisionFactor:1,packAlternating:{count:4,packTessellation:({texXmax:t,texXmin:e,texYmax:s,texYmin:r})=>[[e,r],[t,r],[e,s],[t,s]]}},animationPointerAndBaseSizeAndReferenceSize:{type:dt.pe.UNSIGNED_SHORT,count:4,packPrecisionFactor:1,pack:({animations:t,baseSize:e,referenceSize:s})=>[t.dataColumn,t.dataRow,e,s]},sizing:{type:dt.pe.UNSIGNED_SHORT,count:4,packPrecisionFactor:8,pack:({strokeWidth:t,pixelDimensions:e,baseSize:s,sprite:r,sizeRatio:i})=>{const n=Math.max(s*r.width/r.height,s),o=r.sdfDecodeCoeff*n*i;return[e[0],e[1],t,o]}},angle:{type:dt.pe.BYTE,count:1,packTessellation:({angle:t})=>t}}}}_write(t,e){const s=this.evaluatedMeshParams.sprite,{textureBinding:r}=s;t.recordStart(this.instanceId,this.attributeLayout,r);const i=e.getDisplayId();if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[r,n]=s.coords;this._writeQuad(t,i,r,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),r=e.readYForDisplay();this._writeQuad(t,i,s,r)}else{const s=e.readGeometryForDisplay();if(s){const{angleToLine:e}=this.evaluatedMeshParams;if(e){let e=!0,r=null,n=null;s.forEachVertex(((s,o)=>{if(null!=r&&null!=n){const a=Math.atan2(o-n,s-r)/Mr;e&&(this._writeQuad(t,i,r,n,a),e=!1),this._writeQuad(t,i,s,o,a)}r=s,n=o}))}else s.forEachVertex(((e,s)=>{this._writeQuad(t,i,e,s)}))}}t.recordEnd()}_writeQuad(t,e,s,r,i=0){const n=this.evaluatedMeshParams.sprite,{rect:o}=n,a=o.x+B.hM,h=o.y+B.hM,c=o.x+o.width-B.hM,l=o.y+o.height-B.hM,u=t.vertexCount();t.recordBounds(s,r,64,64);const d={texXmin:a,texYmin:h,texXmax:c,texYmax:l,angle:i};for(let i=0;i<4;i++)this._writeVertex(t,e,s,r,d);t.indexEnsureSize(6),t.indexWrite(u),t.indexWrite(u+1),t.indexWrite(u+2),t.indexWrite(u+1),t.indexWrite(u+3),t.indexWrite(u+2)}}var Tr=s(15585);function Ar(t,e,s,r,i,n,o){Kr=0;const a=(r-s)*n,h=i&&i.length,c=h?(i[0]-s)*n:a;let l,u,d,_,p,f=Cr(e,s,0,0,c,n,!0);if(f&&f.next!==f.prev){if(h&&(f=function(t,e,s,r,i,n){const o=new Array;for(let i=0,a=r.length;i<a;i++){const h=Cr(t,e,0,r[i]*n,i<a-1?r[i+1]*n:s*n,n,!1);h===h.next&&(h.steiner=!0),o.push(Dr(h))}o.sort(jr);for(const t of o)i=Lr(t,i);return i}(e,s,r,i,f,n)),a>80*n){l=d=e[0+s*n],u=_=e[1+s*n];for(let t=n;t<c;t+=n){const r=e[t+s*n],i=e[t+1+s*n];l=Math.min(l,r),u=Math.min(u,i),d=Math.max(d,r),_=Math.max(_,i)}p=Math.max(d-l,_-u),p=0!==p?1/p:0}Fr(f,t,n,l,u,p,o,0)}}function Cr(t,e,s,r,i,n,o){let a;if(o===function(t,e,s,r,i,n){let o=0;for(let s=r,a=i-n;s<i;s+=n)o+=(t[a+e*n]-t[s+e*n])*(t[s+1+e*n]+t[a+1+e*n]),a=s;return o}(t,e,0,r,i,n)>0)for(let s=r;s<i;s+=n)a=Or(s+e*n,t[s+e*n],t[s+1+e*n],a);else for(let s=i-n;s>=r;s-=n)a=Or(s+e*n,t[s+e*n],t[s+1+e*n],a);return a&&Wr(a,a.next)&&(Rr(a),a=a.next),a}function kr(t,e=t){if(!t)return t;let s,r=t;do{if(s=!1,r.steiner||!Wr(r,r.next)&&0!==Br(r.prev,r,r.next))r=r.next;else{if(Rr(r),r=e=r.prev,r===r.next)break;s=!0}}while(s||r!==e);return e}function Fr(t,e,s,r,i,n,o,a){if(!t)return;!a&&n&&(t=Nr(t,r,i,n));let h=t;for(;t.prev!==t.next;){const c=t.prev,l=t.next;if(n?zr(t,r,i,n):Er(t))e.push(c.index/s+o),e.push(t.index/s+o),e.push(l.index/s+o),Rr(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?Fr(t=Yr(t,e,s,o),e,s,r,i,n,o,2):2===a&&Xr(t,e,s,r,i,n,o):Fr(kr(t),e,s,r,i,n,o,1);break}}}function Er(t){const e=t.prev,s=t,r=t.next;if(Br(e,s,r)>=0)return!1;let i=t.next.next;const n=i;let o=0;for(;i!==t.prev&&(0===o||i!==n);){if(o++,Ur(e.x,e.y,s.x,s.y,r.x,r.y,i.x,i.y)&&Br(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function zr(t,e,s,r){const i=t.prev,n=t,o=t.next;if(Br(i,n,o)>=0)return!1;const a=i.x<n.x?i.x<o.x?i.x:o.x:n.x<o.x?n.x:o.x,h=i.y<n.y?i.y<o.y?i.y:o.y:n.y<o.y?n.y:o.y,c=i.x>n.x?i.x>o.x?i.x:o.x:n.x>o.x?n.x:o.x,l=i.y>n.y?i.y>o.y?i.y:o.y:n.y>o.y?n.y:o.y,u=qr(a,h,e,s,r),d=qr(c,l,e,s,r);let _=t.prevZ,p=t.nextZ;for(;_&&_.z>=u&&p&&p.z<=d;){if(_!==t.prev&&_!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Br(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,p!==t.prev&&p!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Br(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;_&&_.z>=u;){if(_!==t.prev&&_!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Br(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Br(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Or(t,e,s,r){const i=Zr.create(t,e,s);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Rr(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dr(t){let e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function Lr(t,e){const s=function(t,e){let s=e;const r=t.x,i=t.y;let n,o=-1/0;do{if(i<=s.y&&i>=s.next.y&&s.next.y!==s.y){const t=s.x+(i-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=r&&t>o){if(o=t,t===r){if(i===s.y)return s;if(i===s.next.y)return s.next}n=s.x<s.next.x?s:s.next}}s=s.next}while(s!==e);if(!n)return null;if(r===o)return n.prev;const a=n,h=n.x,c=n.y;let l,u=1/0;for(s=n.next;s!==a;)r>=s.x&&s.x>=h&&r!==s.x&&Ur(i<c?r:o,i,h,c,i<c?o:r,i,s.x,s.y)&&(l=Math.abs(i-s.y)/(r-s.x),(l<u||l===u&&s.x>n.x)&&Vr(s,t)&&(n=s,u=l)),s=s.next;return n}(t,e);if(!s)return e;const r=Hr(s,t);return kr(r,r.next),kr(s,s.next)}function Nr(t,e,s,r){let i;for(;i!==t;i=i.next){if(i=i||t,null===i.z&&(i.z=qr(i.x,i.y,e,s,r)),i.prev.next!==i||i.next.prev!==i)return i.prev.next=i,i.next.prev=i,Nr(t,e,s,r);i.prevZ=i.prev,i.nextZ=i.next}return t.prevZ.nextZ=null,t.prevZ=null,function(t){let e,s=1;for(;;){let r,i=t;t=null,e=null;let n=0;for(;i;){n++,r=i;let o=0;for(;o<s&&r;o++)r=r.nextZ;let a=s;for(;o>0||a>0&&r;){let s;0===o?(s=r,r=r.nextZ,a--):0!==a&&r?i.z<=r.z?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,a--):(s=i,i=i.nextZ,o--),e?e.nextZ=s:t=s,s.prevZ=e,e=s}i=r}if(e.nextZ=null,s*=2,n<2)return t}}(t)}function Br(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function Gr(t,e,s,r){return!!(Wr(t,e)&&Wr(s,r)||Wr(t,r)&&Wr(s,e))||Br(t,e,s)>0!=Br(t,e,r)>0&&Br(s,r,t)>0!=Br(s,r,e)>0}function Ur(t,e,s,r,i,n,o,a){return(i-o)*(e-a)-(t-o)*(n-a)>=0&&(t-o)*(r-a)-(s-o)*(e-a)>=0&&(s-o)*(n-a)-(i-o)*(r-a)>=0}function Vr(t,e){return Br(t.prev,t,t.next)<0?Br(t,e,t.next)>=0&&Br(t,t.prev,e)>=0:Br(t,e,t.prev)<0||Br(t,t.next,e)<0}function qr(t,e,s,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Wr(t,e){return t.x===e.x&&t.y===e.y}function jr(t,e){return t.x-e.x}function Yr(t,e,s,r){let i=t;do{const n=i.prev,o=i.next.next;!Wr(n,o)&&Gr(n,i,i.next,o)&&Vr(n,o)&&Vr(o,n)&&(e.push(n.index/s+r),e.push(i.index/s+r),e.push(o.index/s+r),Rr(i),Rr(i.next),i=t=o),i=i.next}while(i!==t);return i}function Xr(t,e,s,r,i,n,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.index!==t.index&&$r(a,t)){let h=Hr(a,t);return a=kr(a,a.next),h=kr(h,h.next),Fr(a,e,s,r,i,n,o,0),void Fr(h,e,s,r,i,n,o,0)}t=t.next}a=a.next}while(a!==t)}function $r(t,e){return t.next.index!==e.index&&t.prev.index!==e.index&&!function(t,e){let s=t;do{if(s.index!==t.index&&s.next.index!==t.index&&s.index!==e.index&&s.next.index!==e.index&&Gr(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&Vr(t,e)&&Vr(e,t)&&function(t,e){let s=t,r=!1;const i=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&i<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(r=!r),s=s.next}while(s!==t);return r}(t,e)}function Hr(t,e){const s=Zr.create(t.index,t.x,t.y),r=Zr.create(e.index,e.x,e.y),i=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=i,i.prev=s,r.next=s,s.prev=r,n.next=r,r.prev=n,r}s(83349);class Zr{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(t,e,s){const r=Kr<Qr.length?Qr[Kr++]:new Zr;return r.index=t,r.x=e,r.y=s,r.prev=null,r.next=null,r.z=null,r.prevZ=null,r.nextZ=null,r.steiner=!1,r}}const Qr=[];let Kr=0;for(let t=0;t<8096;t++)Qr.push(new Zr);const Jr=new Jt.O3(0,0,0,1,0),ti=new Jt.O3(0,0,0,1,0);function ei(t,e,s){let r=0;for(let i=1;i<s;i++){const s=t[2*(e+i-1)],n=t[2*(e+i-1)+1];r+=(t[2*(e+i)]-s)*(t[2*(e+i)+1]+n)}return r}function si(t,e,s,r,i){let n=0;for(let o=s;o<r;o+=3){const s=2*(t[o]-i),r=2*(t[o+1]-i),a=2*(t[o+2]-i);n+=Math.abs((e[s]-e[a])*(e[r+1]-e[s+1])-(e[s]-e[r])*(e[a+1]-e[s+1]))}return n}function ri(t,e){if(null==t)return null;if(!function(t,e,s){let r=0;for(let e=0;e<t.lengths.length;e++){const i=t.lengths[e];for(let e=0;e<i;e++){const i=t.coords[2*(e+r)],n=t.coords[2*(e+r)+1];if(i<-128||i>s||n<-128||n>s)return!0}r+=i}return!1}(t,0,B.CQ+128))return t;Jr.setPixelMargin(e),Jr.reset(Jt.dC.Polygon);let s=0;for(let e=0;e<t.lengths.length;e++){const r=t.lengths[e];let i=t.coords[2*(0+s)],n=t.coords[2*(0+s)+1];Jr.moveTo(i,n);for(let e=1;e<r;e++)i=t.coords[2*(e+s)],n=t.coords[2*(e+s)+1],Jr.lineTo(i,n);Jr.close(),s+=r}const r=Jr.result(!1);if(!r)return null;const i=[],n=[];for(const t of r){let e=0;for(const s of t)n.push(s.x),n.push(s.y),e++;i.push(e)}return new jt.A(i,n)}Jr.setExtent(B.CQ),ti.setExtent(B.CQ);const ii=(0,n.A)("featurelayer-fast-triangulation-enabled");class ni extends br{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,Tr.F)()])}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);i&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,i),t.recordEnd())}_clip(t){return t?ri(t,this.hasEffects?256:8):null}_writeGeometry(t,e,s){const r=s.maxLength>100,i=[],n=this.createTesselationParams(e);if(!r&&ii&&function(t,e){const{coords:s,lengths:r}=e,i=t;let n=0;for(let t=0;t<r.length;){let e=t,o=r[t],a=ei(s,n,o);const h=[];for(;++e<r.length;){const t=r[e],i=ei(s,n+o,t);if(!(i>0))break;a+=i,h.push(n+o),o+=t}const c=i.length;Ar(i,s,n,n+o,h,2,0);const l=si(i,s,c,i.length,0),u=Math.abs(a);if(Math.abs((l-u)/Math.max(1e-7,u))>1e-5)return i.length=0,!1;t=e,n+=o}return!0}(i,s))return void(i.length&&this._writeVertices(t,e,s.coords,n,i));const o=function(t){const{coords:e,lengths:s}=t,{buffer:r}=(0,Tr.l)(e,s);return r}(s);this._writeVertices(t,e,o,n)}_writeVertices(t,e,s,r,i){const n=e.getDisplayId(),o=t.vertexCount(),a=this.hasEffects;let h=0;if(i)for(const e of i){const i=s[2*e],o=s[2*e+1];a&&t.recordBounds(i,o,0,0),this._writeVertex(t,n,i,o,r),h++}else for(let e=0;e<s.length;e+=2){const i=Math.round(s[e]),o=Math.round(s[e+1]);a&&t.recordBounds(i,o,0,0),this._writeVertex(t,n,i,o,r),h++}t.indexEnsureSize(h);for(let e=0;e<h;e++)t.indexWrite(e+o)}}const oi={createComputedParams:t=>t,optionalAttributes:{},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:dt.pe.FLOAT,count:1,packTessellation:({inverseArea:t})=>t}}};class ai extends ni{constructor(){super(...arguments),this.vertexSpec=oi}createTesselationParams(t){return{inverseArea:1/t.readGeometryArea()}}}const hi={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)}}};class ci extends ni{constructor(){super(...arguments),this.vertexSpec=hi}createTesselationParams(t){return null}}const li={createComputedParams:t=>t,optionalAttributes:hi.optionalAttributes,attributes:{...hi.attributes,tlbr:{count:4,type:dt.pe.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM,n=e.y+B.hM;return[i,n,i+s,n+r]}},inverseRasterizationScale:{count:1,type:dt.pe.BYTE,packPrecisionFactor:16,pack:({sprite:t})=>1/t.rasterizationScale}}};class ui extends ci{constructor(){super(...arguments),this.vertexSpec=li}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),t.recordEnd()}}function di(t){const{sprite:e,aspectRatio:s,scaleProportionally:r}=t,i=(0,l.Lz)(t.height),n=i>0?i:e.height;let o=i*s;return o<=0?o=e.width:r&&(o*=e.width/e.height),{width:o,height:n}}function _i(t){const{applyRandomOffset:e,sampleAlphaOnly:s}=t;return Et([[2,e],[4,s]])}const pi={createComputedParams:t=>t,optionalAttributes:li.optionalAttributes,attributes:{...li.attributes,bitset:{count:1,type:dt.pe.UNSIGNED_BYTE,pack:_i},width:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).width},height:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).height},offset:{count:2,type:dt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),-(0,l.Lz)(e)]},scale:{count:2,type:dt.pe.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:t,scaleY:e})=>[t,e]},angle:{count:1,type:dt.pe.UNSIGNED_BYTE,pack:({angle:t})=>(0,nr.wV)(t)}}};class fi extends ui{constructor(){super(...arguments),this.vertexSpec=pi}}var gi=s(83773);class mi{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0,this.pathLength=0}}const yi={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)},offset:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[Rt(t,16),Rt(e,16)]},normal:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:t,normalY:e})=>[Rt(t,16),Rt(e,16)]},halfWidth:{type:dt.pe.HALF_FLOAT,count:1,pack:({width:t})=>(0,l.Lz)(.5*t)},referenceHalfWidth:{type:dt.pe.HALF_FLOAT,count:1,pack:({referenceWidth:t})=>(0,l.Lz)(.5*t)}}};class xi{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0,this.pathLength=0}}class bi extends br{constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=yi,this._currentWrite=new xi,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new mi,this._initializeTessellator()}writeLineVertices(t,e,s){const r=this._getLines(e);null!=r&&this._writeVertices(t,s,r)}_initializeTessellator(){this._lineTessellator=new gi.i(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(t,e,s){const r=s??Yt.fromFeatureSetReaderCIM(e);r&&this._writeGeometry(t,e,r)}_writeGeometry(t,e,s,r){t.recordStart(this.instanceId,this.attributeLayout,r),this.writeLineVertices(t,s,e),t.recordEnd()}_getLines(t){return function(t,e){ti.setPixelMargin(e);const s=ti,r=-e,i=B.CQ+e;let n=[],o=!1;if(!t.nextPath())return null;let a=t.pathLength(),h=!0;for(;h;){t.seekPathStart();const e=[];if(!t.pathSize)return null;s.reset(Jt.dC.LineString),t.nextPoint();let c=t.x,l=t.y;if(o)s.moveTo(c,l);else{if(c<r||c>i||l<r||l>i){o=!0;continue}e.push({x:c,y:l})}let u=!1;for(;t.nextPoint();)if(c=t.x,l=t.y,o)s.lineTo(c,l);else{if(c<r||c>i||l<r||l>i){u=!0;break}e.push({x:c,y:l})}if(u)o=!0;else{if(o){const t=s.resultWithStarts();if(t)for(const e of t)n.push({...e,pathLength:a})}else n.push({line:e,start:0,pathLength:a});h=t.nextPath(),a=h?t.pathLength():0,o=!1}}return n=n.filter((t=>t.line.length>1)),0===n.length?null:n}(t,gr(this.evaluatedMeshParams))}_writeVertices(t,e,s){const{_currentWrite:r,_tessellationOptions:i,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:h,miterLimit:c,hasSizeVV:u}=n,d=(0,l.Lz)(.5*o);i.halfWidth=d,i.capType=function(t){switch(t){case"butt":case Ct.uT.Butt:return Ct.xR.BUTT;case"round":case Ct.uT.Round:return Ct.xR.ROUND;case"square":case Ct.uT.Square:return Ct.xR.SQUARE}}(a),i.joinType=function(t){switch(t){case"bevel":case Ct.wd.Bevel:return Ct.JO.BEVEL;case"miter":case Ct.wd.Miter:return Ct.JO.MITER;case"round":case Ct.wd.Round:return Ct.JO.ROUND}}(h),i.miterLimit=c;const _=!u;r.out=t,r.id=e.getDisplayId(),r.vertexCount=0,r.indexCount=0,r.vertexFrom=t.vertexCount(),r.vertexBounds=_&&d<B.Gh?0:1;for(const{line:t,start:e,pathLength:n}of s)i.initialDistance=e%65535,r.pathLength=n,this._lineTessellator.tessellate(t,i,_)}_writeTesselatedVertex(t,e,s,r,i,n,o,a,h,c,l){const{out:u,id:d,vertexBounds:_,pathLength:p}=this._currentWrite;return this.hasEffects&&u.recordBounds(t,e,_,_),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=c,this._tessParams.directionX=i,this._tessParams.directionY=n,this._tessParams.distance=l,this._tessParams.pathLength=p,this._writeVertex(u,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,s){const{out:r}=this._currentWrite;r.indexEnsureSize(3),r.indexWrite(t),r.indexWrite(e),r.indexWrite(s),this._currentWrite.indexCount+=3}}const wi={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)}}},vi={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>Et([[0,!0]])},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>zt(t)}}};class Si extends bi{constructor(){super(...arguments),this.vertexSpec=vi}}class Ii extends ci{constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=wi,this._lineMeshWriter=this._createOutlineWriter(t,e,s,r)}_createOutlineWriter(t,e,s,r){return new Si(t,e,s,r)}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);i&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,i),this._lineMeshWriter.writeLineVertices(t,Yt.fromOptimizedCIM(i,"esriGeometryPolyline"),e),t.recordEnd())}_clip(t){return t?ri(t,gr(this.evaluatedMeshParams)):null}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}var Mi=s(46263),Pi=s(620);class Ti{constructor(){this._includedModules=new Map}include(t,e){this._includedModules.has(t)?this._includedModules.get(t):(this._includedModules.set(t,e),t(this.builder,e))}}class Ai extends Ti{constructor(){super(...arguments),this.vertex=new Fi,this.fragment=new Fi,this.attributes=new Ei,this.varyings=new zi,this.extensions=new Oi,this.constants=new Ri}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(t,e=!0){const s=this.extensions.generateSource(t),r=this.attributes.generateSource(t),i=this.varyings.generateSource(t),n="vertex"===t?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),h="vertex"===t?Di:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif\n",c=this.constants.generateSource().concat(n.constants.generateSource());return`${e?"#version 300 es":""}\n${s.join("\n")}\n${h}\n${c.join("\n")}\n${o.join("\n")}\n${r.join("\n")}\n${i.join("\n")}\n${a.join("\n")}`}generateBindPass(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Pass];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Pass];s&&e.set(t.name,s)}));const s=Array.from(e.values()),r=s.length;return(e,i)=>{for(let n=0;n<r;++n)s[n](t,e,i)}}generateBindDraw(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Draw];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Draw];s&&e.set(t.name,s)}));const s=Array.from(e.values()),r=s.length;return(e,i,n)=>{for(let o=0;o<r;++o)s[o](t,n,e,i)}}}class Ci{constructor(){this._entries=new Map}add(...t){for(const e of t)this._add(e)}get(t){return this._entries.get(t)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new r.A(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else E.A.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder").error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((t=>null!=t.arraySize?`uniform ${t.type} ${t.name}[${t.arraySize}];`:`uniform ${t.type} ${t.name};`))}get entries(){return Array.from(this._entries.values())}}class ki{constructor(){this._entries=new Array}add(t){this._entries.push(t)}generateSource(){return this._entries}}class Fi extends Ti{constructor(){super(...arguments),this.uniforms=new Ci,this.code=new ki,this.constants=new Ri}get builder(){return this}}class Ei{constructor(){this._entries=new Array}add(t,e){this._entries.push([t,e])}generateSource(t){return"fragment"===t?[]:this._entries.map((t=>`in ${t[1]} ${t[0]};`))}}class zi{constructor(){this._entries=new Map}add(t,e){this._entries.has(t)&&(0,Pi.vA)(this._entries.get(t)===e),this._entries.set(t,e)}generateSource(t){const e=new Array;return this._entries.forEach(((s,r)=>e.push("vertex"===t?`out ${s} ${r};`:`in ${s} ${r};`))),e}}class Oi{constructor(){this._entries=new Set}add(t){this._entries.add(t)}generateSource(t){const e="vertex"===t?Oi.ALLOWLIST_VERTEX:Oi.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((t=>e.includes(t))).map((t=>`#extension ${t} : enable`))}}Oi.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],Oi.ALLOWLIST_VERTEX=[];class Ri{constructor(){this._entries=new Set}add(t,e,s){let r="ERROR_CONSTRUCTOR_STRING";switch(e){case"float":r=Ri._numberToFloatStr(s);break;case"int":r=Ri._numberToIntStr(s);break;case"bool":r=s.toString();break;case"vec2":r=`vec2(${Ri._numberToFloatStr(s[0])}, ${Ri._numberToFloatStr(s[1])})`;break;case"vec3":r=`vec3(${Ri._numberToFloatStr(s[0])}, ${Ri._numberToFloatStr(s[1])}, ${Ri._numberToFloatStr(s[2])})`;break;case"vec4":r=`vec4(${Ri._numberToFloatStr(s[0])}, ${Ri._numberToFloatStr(s[1])}, ${Ri._numberToFloatStr(s[2])}, ${Ri._numberToFloatStr(s[3])})`;break;case"ivec2":r=`ivec2(${Ri._numberToIntStr(s[0])}, ${Ri._numberToIntStr(s[1])})`;break;case"ivec3":r=`ivec3(${Ri._numberToIntStr(s[0])}, ${Ri._numberToIntStr(s[1])}, ${Ri._numberToIntStr(s[2])})`;break;case"ivec4":r=`ivec4(${Ri._numberToIntStr(s[0])}, ${Ri._numberToIntStr(s[1])}, ${Ri._numberToIntStr(s[2])}, ${Ri._numberToIntStr(s[3])})`;break;case"mat2":case"mat3":case"mat4":r=`${e}(${Array.prototype.map.call(s,(t=>Ri._numberToFloatStr(t))).join(", ")})`}return this._entries.add(`const ${e} ${t} = ${r};`),this}static _numberToIntStr(t){return t.toFixed(0)}static _numberToFloatStr(t){return Number.isInteger(t)?t.toFixed(1):t.toString()}generateSource(){return Array.from(this._entries)}}const Di="precision highp float;\nprecision highp sampler2D;";function Li(t,e){const s=[];for(s.push(e);s.length;){const e=s.pop();if("object"==typeof e&&!t.has(e.uid)){t.add(e.uid);for(const t of e.children)s.push(t)}}}class Ni{constructor(){this.uid=Ni.NodeCount++,this._debugName=null,this._isMutable=!1,this.isImplicit=!1}get isMutable(){return this._isMutable}setMutable(){return this._isMutable=!0,this}setDebugName(t){return t=function(t){return t.split(" ").map(((t,e)=>e>0?t.charAt(0).toUpperCase()+t.slice(1):t)).join("")}(t),this._debugName=t,this.isImplicit&&this.children[0]instanceof Ni&&this.children[0].setDebugName(t),this}get debugInfo(){return{name:this._debugName??""}}cloneInto(t){t._debugName=this._debugName,t._isMutable=this._isMutable,t.isImplicit=this.isImplicit,t.uid=this.uid}}function Bi(t){return"object"==typeof t?t.clone():t}Ni.NodeCount=0;class Gi extends Ni{constructor(){super(...arguments),this.shaderType="primitive-node"}}class Ui extends Ni{constructor(t){super(),this.child=t,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const t=new Ui(Bi(this.child));return this.cloneInto(t),t}}class Vi extends Ni{constructor(t,e,s){super(),this.property=t,this.target=e,this.returnType=s,this.shaderType="property-access-node"}get children(){const t=[this.target];return"string"!=typeof this.property&&t.push(this.property),t}clone(){const t=new Vi(this.property,Bi(this.target),this.returnType);return this.cloneInto(t),t}}class qi extends Ni{constructor(t,e,s,r){super(),this.x=t,this.y=e,this.target=s,this.returnType=r,this.shaderType="property-access-2d-node"}get children(){return[this.target,this.x,this.y]}clone(){const t=new qi(this.x,this.y,Bi(this.target),this.returnType);return this.cloneInto(t),t}}class Wi extends Ni{constructor(t,e,s){super(),this.condition=t,this.ifTrue=e,this.ifFalse=s,this.shaderType="condition-node"}get children(){return[this.condition,this.ifTrue,this.ifFalse]}clone(){const t=Bi(this.ifTrue),e=this.ifFalse?Bi(this.ifFalse):null,s=new Wi(this.condition,t,e);return this.cloneInto(s),s}}class ji extends Ni{constructor(t,e,s,r){super(),this.captureList=t,this.returnType=e,this.generator=r,this.shaderType="block-node",s&&(this.subgraph=new Ui(s))}get children(){return Object.keys(this.captureList).map((t=>this.captureList[t])).concat(this.subgraph??[])}clone(){const t={};for(const e in this.captureList)t[e]=Bi(this.captureList[e]);const e=new ji(t,this.returnType,this.subgraph?Bi(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(e),e}}class Yi extends Ni{constructor(t,e,s,r,i,n=!1){super(),this.token=t,this._children=e,this.isInfix=s,this.isPropertyAccess=r,this.returnType=i,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const t=new Yi(this.token,this._children.map(Bi),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(t),t}}var Xi,$i,Hi,Zi,Qi,Ki,Ji,tn,en,sn,rn,nn,on,an;function hn(t){return new Proxy(t,{get(e,s){if("constructor"===s)return new Proxy(e.constructor,{construct:(t,e,s)=>hn(new t(...e))});if(s in e)return e[s];if("string"==typeof s){const e=function(t){const e=[["float","vec2","vec3","vec4"],["int","ivec2","ivec3","ivec4"],["uint","uvec2","uvec3","uvec4"],["bool","bvec2","bvec3","bvec4"]];for(const s of e)if(s.includes(t))return s.map((t=>On[t]));throw new Error("Unable to find type family")}(t.type);return Bn(t,s,e[s.length-1])}}})}function cn(t){return new Proxy(t,{construct:(t,e,s)=>hn(new t(...e))})}class ln extends Error{}let un=Xi=class extends Gi{constructor(t,e){super(),this.elementType=t,this.size=e,this.children=[],this.type="array"}clone(){const t=new Xi(this.elementType,this.size);return super.cloneInto(t),t}get(t,e){const s=new Tn(t),r=null!=e?new Tn(e):null;return null!=r?Gn(this,s,r,function(t){switch(t.type){case"bool":case"bvec2":case"bvec3":case"bvec4":return vn;case"float":case"vec2":case"vec3":case"vec4":return pn;case"int":case"ivec2":case"ivec3":case"ivec4":return Tn;case"uint":case"uvec2":case"uvec3":case"uvec4":return yn;default:throw new Error("Unable to handle type")}}(this.elementType.constructor)):Bn(this,s,this.elementType.constructor)}last(){return this.get(this.size-1)}first(){return this.get(0)}findIndex(t,e,s){return function(t,e,s=0,r=t.size){const i=new Tn(s).setMutable().setDebugName("FindIndexIterator"),n=e(t.get(i)).setDebugName("FindIndexPredicate"),o=Yn({iter:i},Tn,n,(({out:t,iter:e,subgraph:s})=>`\n${t} = -1;\n\nfor (; ${e} < ${r}; ${e}++) {\n\n${s.body}\n\n if (${s.varName}) {\n ${t} = ${e};\n break;\n }\n\n}\n`)).setDebugName("FindIndexBlock");return o}(this,t,e,s)}glslFindIndex(t,e,s){return function(t,e,s=0,r=t.size){const i=Yn({array:t},Tn,null,(({out:t,array:i})=>`\n${t} = -1;\nfor (int i = ${s}; i < ${r}; i++) {\n bool condition;\n ${e({array:i,i:"i",out:"condition"})}\n if (condition) {\n ${t} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return i}(this,t,e,s)}static ofType(t,e){const s={construct:(s,r)=>new Xi(new t,e)};return new Proxy(Xi,s)}};un.type="array",un=Xi=(0,P._)([function(t){return new Proxy(t,{construct:(t,e,s)=>function(t){return new Proxy(t,{get(e,s){if(s in e)return e[s];if("string"==typeof s){const e=parseInt(s,10);if(!isNaN(e))return Bn(t,`[${e}]`,t.elementType.constructor)}}})}(new t(...e))})}],un);class dn extends Gi{constructor(t,e,s,r=!1){super(),this.elementType=t,this.xSize=e,this.ySize=s,this.isRowMajor=r,this.children=[],this.type="array-2d"}clone(){const t=new dn(this.elementType,this.xSize,this.ySize,this.isRowMajor);return super.cloneInto(t),t}get size(){return this.xSize*this.ySize}get(t,e){return this.isRowMajor?this._getRowMajor(t,e):this._getColumnMajor(t,e)}_getColumnMajor(t,e){const s=new Tn(t);return Bn(this,new Tn(e).add(s.multiply(this.xSize)),this.elementType.constructor)}_getRowMajor(t,e){const s=new Tn(t),r=new Tn(e);return Bn(this,s.add(r.multiply(this.ySize)),this.elementType.constructor)}static ofType(t,e,s,r=!1){return new Proxy(un,{construct:(i,n)=>new dn(new t,e,s,r)})}}dn.type="array-2d";class _n extends Gi{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const t=new _n;return t.children=this.children.map(Bi),super.cloneInto(t),t}}_n.type="sampler2D";class pn extends Gi{constructor(t){super(),this.type="float",this.children=[t]}clone(){const t=new pn(Bi(this.children[0]));return super.cloneInto(t),t}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}}pn.type="float";let fn=$i=class extends Gi{constructor(t,e){super(),this.type="vec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new $i(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}get 0(){return Bn(this,"[0]",pn)}get 1(){return Bn(this,"[1]",pn)}get 2(){throw new ln}get 3(){throw new ln}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}};fn.type="vec2",fn=$i=(0,P._)([cn],fn);let gn=Hi=class extends Gi{constructor(t,e,s){super(),this.type="vec3",this.children=[t,e,s].filter((t=>null!=t))}get 0(){return Bn(this,"[0]",pn)}get 1(){return Bn(this,"[1]",pn)}get 2(){return Bn(this,"[2]",pn)}get 3(){throw new ln}clone(){const t=new Hi(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}};gn.type="vec3",gn=Hi=(0,P._)([cn],gn);let mn=Zi=class extends Gi{constructor(t,e,s,r){super(),this.type="vec4",this.children=[t,e,s,r].filter((t=>null!=t))}clone(){const t=new Zi(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}get 0(){return Bn(this,"[0]",pn)}get 1(){return Bn(this,"[1]",pn)}get 2(){return Bn(this,"[2]",pn)}get 3(){return Bn(this,"[3]",pn)}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}};mn.type="vec4",mn=Zi=(0,P._)([cn],mn);let yn=Qi=class extends Gi{constructor(t){super(),this.type="uint",this.children=[t]}clone(){const t=new Qi(Bi(this.children[0]));return super.cloneInto(t),t}};yn.type="uint",yn=Qi=(0,P._)([cn],yn);let xn=Ki=class extends Gi{constructor(t,e){super(),this.type="uvec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Ki(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}};xn.type="uvec2",xn=Ki=(0,P._)([cn],xn);let bn=Ji=class extends Gi{constructor(t,e,s){super(),this.type="uvec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new Ji(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}};bn.type="uvec3",bn=Ji=(0,P._)([cn],bn);let wn=tn=class extends Gi{constructor(t,e,s,r){super(),this.type="uvec4",this.children=[t,e,s,r].filter((t=>null!=t))}clone(){const t=new tn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}};wn.type="uvec4",wn=tn=(0,P._)([cn],wn);class vn extends Gi{constructor(t){super(),this.type="bool",this.children=[t]}and(t){return io(this,t)}or(t){return ro(this,t)}clone(){const t=new vn(Bi(this.children[0]));return super.cloneInto(t),t}}vn.type="bool";let Sn=en=class extends Gi{constructor(t,e){super(),this.type="bvec2",this.children=[t,e].filter((t=>null!=t))}all(){return no(this)}any(){return oo(this)}clone(){const t=new en(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}};Sn.type="bvec2",Sn=en=(0,P._)([cn],Sn);let In=sn=class extends Gi{constructor(t,e,s){super(),this.type="bvec3",this.children=[t,e,s].filter((t=>null!=t))}all(){return no(this)}any(){return oo(this)}clone(){const t=new sn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}};function Mn(t,e){return"number"==typeof t?new e(t):t}In.type="bvec3",In=sn=(0,P._)([cn],In);let Pn=rn=class extends Gi{constructor(t,e,s,r){super(),this.type="bvec4",this.children=[t,e,s,r].filter((t=>null!=t))}all(){return no(this)}any(){return oo(this)}clone(){const t=new rn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}};Pn.type="bvec4",Pn=rn=(0,P._)([cn],Pn);class Tn extends Gi{constructor(t){super(),this.type="int",this.children=[t]}multiply(t){return Hn(this,Mn(t,Tn))}add(t){return Qn(this,Mn(t,Tn))}subtract(t){return Kn(this,Mn(t,Tn))}divide(t){return Zn(this,Mn(t,Tn))}clone(){const t=new Tn(Bi(this.children[0]));return super.cloneInto(t),t}}Tn.type="int";let An=nn=class extends Gi{constructor(t,e){super(),this.type="ivec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new nn(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}};An.type="ivec2",An=nn=(0,P._)([cn],An);let Cn=on=class extends Gi{constructor(t,e,s){super(),this.type="ivec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new on(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}};Cn.type="ivec3",Cn=on=(0,P._)([cn],Cn);let kn=an=class extends Gi{constructor(t,e,s,r){super(),this.type="ivec4",this.children=[t,e,s,r].filter((t=>null!=t))}clone(){const t=new an(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}};kn.type="ivec4",kn=an=(0,P._)([cn],kn);class Fn extends Gi{constructor(t,e,s,r){super(),this.type="mat2",this.children=[t,e,s,r]}clone(){const t=new Fn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}get(t,e){return Gn(this,new Tn(t),new Tn(e),pn)}multiply(t){return Hn(this,t)}}Fn.type="mat2";class En extends Gi{static identity(){return new En(1,0,0,0,1,0,0,0,1)}static fromRotation(t){const e=yo(t),s=ho(t);return new En(s,e,0,jn(e),s,0,0,0,1)}constructor(t,e,s,r,i,n,o,a,h){super(),this.type="mat3",this.children=[t,e,s,r,i,n,o,a,h]}add(t){return Qn(this,t)}multiply(t){return Hn(this,t)}get(t,e){return Gn(this,new Tn(t),new Tn(e),pn)}clone(){const t=new En(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]),Bi(this.children[4]),Bi(this.children[5]),Bi(this.children[6]),Bi(this.children[7]),Bi(this.children[8]));return super.cloneInto(t),t}}En.type="mat3";class zn extends Gi{static identity(){return new zn(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t,e,s,r,i,n,o,a,h,c,l,u,d,_,p,f){super(),this.type="mat4",this.children=[t,e,s,r,i,n,o,a,h,c,l,u,d,_,p,f]}static fromColumns(t,e,s,r){return new zn(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,s.x,s.y,s.z,s.w,r.x,r.y,r.z,r.w)}multiply(t){return Hn(this,t)}get(t,e){return Gn(this,new Tn(t),new Tn(e),pn)}clone(){const t=new zn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]),Bi(this.children[4]),Bi(this.children[5]),Bi(this.children[6]),Bi(this.children[7]),Bi(this.children[8]),Bi(this.children[9]),Bi(this.children[10]),Bi(this.children[11]),Bi(this.children[12]),Bi(this.children[13]),Bi(this.children[14]),Bi(this.children[15]));return super.cloneInto(t),t}}zn.type="mat4";const On={float:pn,vec2:fn,vec3:gn,vec4:mn,int:Tn,ivec2:An,ivec3:Cn,ivec4:kn,uint:yn,uvec2:xn,uvec3:bn,uvec4:wn,bool:vn,bvec2:Sn,bvec3:In,bvec4:Pn},Rn=(...t)=>new Tn(...t),Dn=(...t)=>new pn(...t),Ln=(...t)=>new fn(...t),Nn=(...t)=>new En(...t);function Bn(t,e,s){const r=new s(new Vi(e,t,s));return r.isImplicit=!0,r}function Gn(t,e,s,r){const i=new r(new qi(e,s,t,r));return i.isImplicit=!0,i}function Un(t,e,s,r=null){if(r){const i=new r,n=new r(new Yi(t,[e,s],!0,!1,i));return n.isImplicit=!0,n}if("float"===e.type||"int"===e.type){const r=new s.constructor(new Yi(t,[e,s],!0,!1,s.constructor));return r.isImplicit=!0,r}if(("mat2"===e.type||"mat3"===e.type||"mat4"===e.type)&&"float"!==s.type){const r=new s.constructor(new Yi(t,[e,s],!0,!1,s.constructor));return r.isImplicit=!0,r}const i=new e.constructor(new Yi(t,[e,s],!0,!1,e.constructor));return i.isImplicit=!0,i}function Vn(t,e,s=e.constructor){const r=new s(new Yi(t,[e],!1,!1,s));return r.isImplicit=!0,r}function qn(t,e,s,r=e.constructor){const i=new r(new Yi(t,[e,s],!1,!1,r));return i.isImplicit=!0,i}function Wn(t,e,s,r,i=e.constructor){const n=new i(new Yi(t,[e,s,r],!1,!1,i));return n.isImplicit=!0,n}function jn(t){return Hn(t,Dn(-1))}function Yn(t,e,s,r){return new e(new ji(t,e,s,r))}function Xn(t,e,s){const r="function"==typeof e?e():e,i="function"==typeof s?s():s,n=new r.constructor(new Wi(t,r,i));return n.isImplicit=!0,n}function $n(...t){const e=t.map((([t,e])=>"function"==typeof e?[t,e()]:[t,e])),s=e[0][1].constructor,r=e.findIndex((t=>!0===t[0]));if(-1===r)throw new Error("A cond must have a fallthrough case with `true`/; ");const i=e.slice(0,r),n=e[r][1],o=new s(i.reduceRight(((t,e)=>Xn(e[0],e[1],t)),n));return o.isImplicit=!0,o}function Hn(t,e){return Un("*",t,e)}function Zn(t,e){return Un("/",t,e)}function Qn(t,e){return Un("+",t,e)}function Kn(t,e){return Un("-",t,e)}function Jn(t,e){return Un("==",t,e,vn)}function to(t,e){return Un("<=",t,e,vn)}function eo(t,e){return Un(">",t,e,vn)}function so(t,e){return Un(">=",t,e,vn)}function ro(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Un("||",t,e,vn)}(t,e)),t[0])}function io(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Un("&&",t,e,vn)}(t,e)),t[0])}function no(t){return Vn("all",t,vn)}function oo(t){return Vn("any",t,vn)}function ao(t,e,s){return Wn("clamp",t,e,s,t.constructor)}function ho(t){return Vn("cos",t)}function co(t,e){return qn("dot",t,e,pn)}function lo(t){return Vn("fract",t)}function uo(t){return Vn("length",t,pn)}function _o(t,e){return qn("max",t,e)}function po(t,e){return qn("min",t,e)}function fo(t,e,s){return Wn("mix",t,e,s)}function go(t,e){return qn("mod",t,e)}function mo(t){return"bool"===t.type?Vn("!",t):Vn("not",t)}function yo(t){return Vn("sin",t)}function xo(t,e){return qn("step",t,e,e.constructor)}function bo(t,e){return qn("texture",t,e,mn)}function wo(t,e,s){const r=e.split("\n");for(const e of r)if(e.trim().length){{let e="";null!=s&&(e+=`/*id:${s??"000"}*/ `),t.body+=e.padEnd(14)}t.body+=" ".repeat(t.indent)+e+"\n"}}class vo{write(t){for(const e of t.rootOutputNodes())t.shouldPruneOutputNode(e)||(e.variableName=this._write(t,e.node));return t}_createVarName(t,e){let s="";return"boolean"!=typeof e&&"number"!=typeof e&&e.debugInfo.name&&(s=`${e.debugInfo.name}_`),`${s}v${t.varCount++}`}_write(t,e,s=!1){if("number"==typeof e)return e.toString();if("boolean"==typeof e)return e.toString();let r=t.getEmit(e);if(r)return r;switch(e.shaderType){case"scope-node":r=this._writeScopeNode(t,e);break;case"primitive-node":r=this._writePrimitiveNode(t,e,s);break;case"function-node":r=this._writeFunctionNode(t,e);break;case"property-access-node":r=this._writePropertyAccessNode(t,e);break;case"property-access-2d-node":r=this._writePropertyAccess2DNode(t,e);break;case"text-node":r=e.text;break;case"block-node":r=this._writeBlockNode(t,e);break;case"condition-node":r=this._writeConditionNode(t,e)}return t.setEmit(e,r),r}_writeScopeNode(t,e){const s=new e.child.constructor;s.setDebugName(e.debugInfo.name);const r=this._write(t,s,!0);return wo(t,`{ /*ScopeStart: ${e.uid} ${e.debugInfo.name}*/`),t.indent+=2,wo(t,`${r} = ${this._write(t,e.child)};`),t.indent-=2,wo(t,`} /*ScopeEnd: ${e.uid} ${e.debugInfo.name}*/`),r}_writeConditionNode(t,e){const s=new e.ifTrue.constructor,r=this._write(t,s,!0);wo(t,`if (${this._write(t,e.condition)}) {`),t.indent+=2;const i=t.createSubgraphContext(),n=this._write(i,e.ifTrue);if(t.body+=i.body,n&&wo(t,`${r} = ${n};`),t.indent-=2,wo(t,"}"),e.ifFalse){wo(t,"else {"),t.indent+=2;const s=t.createSubgraphContext(),i=this._write(s,e.ifFalse);t.body+=s.body,i&&wo(t,`${r} = ${i};`),t.indent-=2,wo(t,"}")}return r}_writeBlockNode(t,e){const{captureList:s,generator:r,returnType:i}=e,n={};for(const e in s){if(!s[e])continue;const r=this._write(t,s[e]);n[e]=r}const o=new i,a=this._write(t,o,!0);if(n.out=a,e.subgraph){const s=t.createSubgraphContext(),r=this._write(s,e.subgraph.child),i=s.body;n.subgraph={varName:r,body:i}}const h=r(n);return wo(t,"{\n"),t.indent+=2,wo(t,h),t.indent-=2,wo(t,"}\n"),a}_writePropertyAccessNode(t,e){const s=this._write(t,e.target);return"string"==typeof e.property&&e.property.includes("[")?`${s}${e.property}`:"string"!=typeof e.property?`${s}[${this._write(t,e.property)}]`:`${s}.${e.property}`}_writePropertyAccess2DNode(t,e){return`${this._write(t,e.target)}[${this._write(t,e.x)}][${this._write(t,e.y)}]`}_writeFunctionNode(t,e){const s=e.returnType.type;if(e.isInfix){const[r,i]=e.children.map((e=>this._write(t,e))),n=this._createVarName(t,e);return wo(t,`${s.padEnd(5)} ${n} = ${r} ${e.token} ${i};`,e.uid),n}const r=e.children.map((e=>this._write(t,e))).join(", "),i=this._createVarName(t,e);return wo(t,`${s.padEnd(5)} ${i} = ${e.token}(${r});`,e.uid),i}_writePrimitiveNode(t,e,s=!1){const r=t.getInput(e);if(r)return r.isUsed=!0,r.variableName;const i=1===e.children.length&&e.children[0]?.type===e.type;if(!e.isMutable&&(e.isImplicit||i))return this._write(t,e.children[0]);const n=this._createVarName(t,e);if(s)return wo(t,`${e.type.padEnd(5)} ${n};`,e.uid),n;const o=!e.debugInfo.name&&!e.isMutable;if(o&&"float"===e.type&&"number"==typeof e.children[0])return Number.isInteger(e.children[0])?e.children[0].toFixed(1):e.children[0].toString();if(o&&"int"===e.type&&"number"==typeof e.children[0]&&Number.isInteger(e.children[0]))return e.children[0].toString();const a=e.children.map((e=>this._write(t,e))).join(", ");return"array"===e.type?(wo(t,`${e.type.padEnd(5)} ${n} = [${a}];`,e.uid),n):o?`${e.type}(${a})`:(wo(t,`${e.type.padEnd(5)} ${n} = ${e.type}(${a});`,e.uid),n)}}class So{constructor(t,e,s){this.variableName=t,this.variableInputType=e,this.node=s,this.type="shader-input",this.isUsed=!1}clone(){return new So(this.variableName,this.variableInputType,Bi(this.node))}}class Io{constructor(t,e,s){this.outVariableName=t,this.outVariableType=e,this.node=s,this.type="shader-output"}clone(){const t=new Io(this.outVariableName,this.outVariableType,Bi(this.node));return t.variableName=this.variableName,t}}class Mo{static createVertex(t,e,s,r,i,n){const o=[];for(const e in t){const r=t[e],i=s.get(e);i?o.push(new So(i,"builtin",r)):o.push(new So("a_"+e,"in",r))}for(const t of r){const e=t.uniformHydrated;o.push(new So(t.uniformName,"uniform",e))}const a=[];for(const t in e){const s=e[t];"glPosition"===t?a.push(new Io("gl_Position","builtin",s)):"glPointSize"===t?a.push(new Io("gl_PointSize","builtin",s)):a.push(new Io("v_"+t,"out",s))}return new Mo(o,a,i,n)}static createFragment(t,e,s,r,i,n){const o=[],a=Array.from(i.rootOutputNodes());for(const e in t){const r=t[e],i=s.get(e);if(i){o.push(new So(i,"builtin",r));continue}const n=a.find((t=>t.node===r));n&&o.push(new So(n.outVariableName,"in",r))}for(const t of r){const e=t.uniformHydrated;o.push(new So(t.uniformName,"uniform",e))}const h=[];for(const t in e){const r=e[t],i=s.get(t);"discard"===t?h.push(new Io(null,"discard",r)):i?h.push(new Io(i,"builtin",r)):h.push(new Io(t,"out",r))}return new Mo(o,h,n)}constructor(t,e,s,r){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const e of t)this._inputShaderTypesByNodeUid.set(e.node.uid,e);this._outputShaderTypes=e,this._transformFeedbackBindings=s,this._transformFeedbackNames=new Set(s.map((t=>"v_"+t.propertyKey))),this._usedInFragmentShader=r}shouldPruneOutputNode(t){return!!this._usedInFragmentShader&&"builtin"!==t.outVariableType&&!this._transformFeedbackNames.has(t.outVariableName)&&!this._usedInFragmentShader.has(t.node.uid)}setEmit(t,e){this._nodeEmitMap.set(t.uid,e)}getEmit(t){return this._nodeEmitMap.get(t.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(t){return this._inputShaderTypesByNodeUid.get(t.uid)}*rootOutputNodes(){for(const t of this._outputShaderTypes)yield t}*nodes(){const t=[];for(const e of this._outputShaderTypes.values())t.push(e.node);for(;t.length;){const e=t.pop();"number"!=typeof e&&"boolean"!=typeof e&&t.push(...e.children.filter(Boolean)),yield e}}*nodesOfTypeOrFunction(){for(const t of this.nodes())"number"!=typeof t&&"boolean"!=typeof t&&(yield t)}createSubgraphContext(){const t=this.clone();return t.body="",t.indent=this.indent+2,t._nodeEmitMap=new Map(this._nodeEmitMap),t}clone(){const t=new Mo([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return t._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,t.indent=this.indent,t.body=this.body,t.varCount=this.varCount,t._nodeEmitMap=this._nodeEmitMap,t}insertVertexShader(t){t.vertex.code.add(""),this._insertInputs(t,"vertex"),t.vertex.code.add(""),t.vertex.code.add("// OUTPUTS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this.rootOutputNodes()){const s="builtin"===e.outVariableType;this.shouldPruneOutputNode(e)||(s?t.vertex.code.add(`// ${e.outVariableType.padEnd(7)} ${e.node.type.padEnd(9)} ${e.outVariableName};`):t.vertex.code.add(`${e.outVariableType.padEnd(10)} ${e.node.type.padEnd(9)} ${e.outVariableName};`))}t.vertex.code.add(""),t.vertex.code.add("void main() {"),t.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())this.shouldPruneOutputNode(e)||t.vertex.code.add(` ${e.outVariableName} = ${e.variableName};`);t.vertex.code.add("}")}insertFragmentShader(t){this._insertInputs(t,"fragment"),t.fragment.code.add(""),t.fragment.code.add("// OUTPUTS: "),t.fragment.code.add("// --------------------------------------------------------- ");for(const e of this.rootOutputNodes())"builtin"===e.outVariableType?t.fragment.code.add(`// ${e.outVariableType.padEnd(7)} ${e.node.type.padEnd(9)} ${e.outVariableName};`):t.fragment.code.add(`${e.outVariableType.padEnd(10)} ${e.node.type.padEnd(9)} ${e.outVariableName};`);t.fragment.code.add(""),t.fragment.code.add("void main() {"),t.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())"discard"===e.outVariableType?(t.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),t.fragment.code.add(` if (${e.variableName}) {`),t.fragment.code.add(" discard;"),t.fragment.code.add(" }"),t.fragment.code.add(" ")):t.fragment.code.add(` ${e.outVariableName} = ${e.variableName};`);t.fragment.code.add("}")}_insertInputs(t,e){t[e].code.add("// INPUTS: "),t[e].code.add("// --------------------------------------------------------- ");for(const s of this.inputs())s.isUsed&&"builtin"!==s.variableInputType&&("array"===s.node.type?t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.elementType.type.padEnd(9)} ${s.variableName}[${s.node.size}];`):"array-2d"===s.node.type?t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.elementType.type.padEnd(9)} ${s.variableName}[${s.node.size}]; // Emulated 2D Array. Not supported by ES3.0`):t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.type.padEnd(9)} ${s.variableName};`))}}const Po=["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"],To=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"],Ao=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],Co=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"];var ko=999,Fo=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Eo(t){return function(t){var e=function(){var t,e,s,r=0,i=0,n=ko,o=[],a=[],h=1,c=0,l=0,u=!1,d=!1,_="";return function(t){return a=[],null!==t?f(t.replace?t.replace(/\r\n/g,"\n"):t):(o.length&&p(o.join("")),n=10,p("(eof)"),a)};function p(t){t.length&&a.push({type:Fo[n],data:t,position:l,line:h,column:c})}function f(e){var o;for(r=0,s=(_+=e).length;t=_[r],r<s;){switch(o=r,n){case 0:r=x();break;case 1:case 2:r=y();break;case 3:r=b();break;case 4:r=S();break;case 11:r=v();break;case 5:r=I();break;case 9999:r=M();break;case 9:r=m();break;case ko:r=g()}o!==r&&("\n"===_[o]?(c=0,++h):++c)}return i+=r,_=_.slice(r),a}function g(){return o=o.length?[]:o,"/"===e&&"*"===t?(l=i+r-1,n=0,e=t,r+1):"/"===e&&"/"===t?(l=i+r-1,n=1,e=t,r+1):"#"===t?(n=2,l=i+r,r):/\s/.test(t)?(n=9,l=i+r,r):(u=/\d/.test(t),d=/[^\w_]/.test(t),l=i+r,n=u?4:d?3:9999,r)}function m(){return/[^\s]/g.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function y(){return"\r"!==t&&"\n"!==t||"\\"===e?(o.push(t),e=t,r+1):(p(o.join("")),n=ko,r)}function x(){return"/"===t&&"*"===e?(o.push(t),p(o.join("")),n=ko,r+1):(o.push(t),e=t,r+1)}function b(){if("."===e&&/\d/.test(t))return n=5,r;if("/"===e&&"*"===t)return n=0,r;if("/"===e&&"/"===t)return n=1,r;if("."===t&&o.length){for(;w(o););return n=5,r}if(";"===t||")"===t||"("===t){if(o.length)for(;w(o););return p(t),n=ko,r+1}var s=2===o.length&&"="!==t;if(/[\w_\d\s]/.test(t)||s){for(;w(o););return n=ko,r}return o.push(t),e=t,r+1}function w(t){for(var e,s,r=0;;){if(e=Ao.indexOf(t.slice(0,t.length+r).join("")),s=Ao[e],-1===e){if(r--+t.length>0)continue;s=t.slice(0,1).join("")}return p(s),l+=s.length,(o=o.slice(s.length)).length}}function v(){return/[^a-fA-F0-9]/.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function S(){return"."===t||/[eE]/.test(t)?(o.push(t),n=5,e=t,r+1):"x"===t&&1===o.length&&"0"===o[0]?(n=11,o.push(t),e=t,r+1):/[^\d]/.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function I(){return"f"===t&&(o.push(t),e=t,r+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(o.push(t),e=t,r+1):/[^\d]/.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function M(){if(/[^\d\w_]/.test(t)){var s=o.join("");return n=To.indexOf(s)>-1?8:Co.indexOf(s)>-1?7:6,p(o.join("")),n=ko,r}return o.push(t),e=t,r+1}}(),s=[];return(s=s.concat(e(t))).concat(e(null))}(t)}const zo=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function Oo(t,e){for(let s=e-1;s>=0;s--){const e=t[s];if("whitespace"!==e.type&&"block-comment"!==e.type){if("keyword"!==e.type)break;if("attribute"===e.data||"in"===e.data)return!0}}return!1}function Ro(t,e,s,r){r=r||s;for(const i of t)if("ident"===i.type&&i.data===s)return r in e?e[r]++:e[r]=0,Ro(t,e,r+"_"+e[r],r);return s}function Do(t,e,s="afterVersion"){function r(t,e){for(let s=e;s<t.length;s++){const e=t[s];if("operator"===e.type&&";"===e.data)return s}return null}const i={data:"\n",type:"whitespace"},n=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let o=function(t){let e=-1,i=0,n=-1;for(let o=0;o<t.length;o++){const a=t[o];if("preprocessor"===a.type&&(/#(if|ifdef|ifndef)\s+.+/.test(a.data)?++i:/#endif\s*.*/.test(a.data)&&--i),"afterVersion"!==s&&"afterPrecision"!==s||"preprocessor"===a.type&&a.data.startsWith("#version")&&(n=Math.max(n,o)),"afterPrecision"===s&&"keyword"===a.type&&"precision"===a.data){const e=r(t,o);if(null===e)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,e)}e<n&&0===i&&(e=o)}return e+1}(t);n(o-1)&&t.splice(o++,0,i);for(const s of e)t.splice(o++,0,s);n(o-1)&&n(o)&&t.splice(o,0,i)}function Lo(t,e,s,r="lowp"){Do(t,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function No(t,e,s,r,i="lowp"){Do(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:r.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:i},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function Bo(t,e){let s,r,i=-1;for(let n=e;n<t.length;n++){const e=t[n];if("operator"===e.type&&("["===e.data&&(s=n),"]"===e.data)){r=n;break}"integer"===e.type&&(i=parseInt(e.data,10))}return s&&r&&t.splice(s,r-s+1),i}function Go(t,e){if(t.startsWith("#version 300"))return t;const s=Eo(t);if("300 es"===function(t,e="100",s="300 es"){const r=/^\s*#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const i of t)if("preprocessor"===i.type){const t=r.exec(i.data);if(t){const r=t[1].replaceAll(/\s{2,}/g," ");if(r===s)return r;if(r===e)return i.data="#version "+s,e;throw new Error("unknown glsl version: "+r)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+s},{type:"whitespace",data:"\n"}),null}(s,"100","300 es"))return t;let r=null,i=null;const n={},o={};for(let t=0;t<s.length;++t){const a=s[t];switch(a.type){case"keyword":e===dt.Co.VERTEX_SHADER&&"attribute"===a.data?a.data="in":"varying"===a.data&&(a.data=e===dt.Co.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(a.data.trim())&&(a.data=a.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===dt.Co.FRAGMENT_SHADER&&"gl_FragColor"===a.data&&(r||(r=Ro(s,n,"fragColor"),Lo(s,r,"vec4")),a.data=r),e===dt.Co.FRAGMENT_SHADER&&"gl_FragData"===a.data){const e=Bo(s,t+1),r=Ro(s,n,"fragData");No(s,r,"vec4",e,"mediump"),a.data=r}else e===dt.Co.FRAGMENT_SHADER&&"gl_FragDepthEXT"===a.data&&(i||(i=Ro(s,n,"gl_FragDepth")),a.data=i);break;case"ident":if(Po.includes(a.data)){if(e===dt.Co.VERTEX_SHADER&&Oo(s,t))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");a.data in o||(o[a.data]=Ro(s,n,a.data)),a.data=o[a.data]}}}for(let t=s.length-1;t>=0;--t){const e=s[t];if("preprocessor"===e.type){const r=e.data.match(/#extension\s+(.*):/);if(r?.[1]&&zo.has(r[1].trim())){const e=s[t+1];s.splice(t,e&&"whitespace"===e.type?2:1)}const i=e.data.match(/#ifdef\s+(.*)/);i?.[1]&&zo.has(i[1].trim())&&(e.data="#if 1");const n=e.data.match(/#ifndef\s+(.*)/);n?.[1]&&zo.has(n[1].trim())&&(e.data="#if 0")}}return function(t,e){return e}(0,function(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}(s))}new Map;class Uo{constructor(t,e,s,r,i=new Map,n=[]){this._context=t,this._locations=r,this._uniformBlockBindings=i,this._transformFeedbackVaryings=n,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,t||console.error("RenderingContext isn't initialized!"),0===e.length&&console.error("Shaders source should not be empty!"),e=Go(e,dt.Co.VERTEX_SHADER),s=Go(s,dt.Co.FRAGMENT_SHADER),this._vShader=Vo(this._context,dt.Co.VERTEX_SHADER,e),this._fShader=Vo(this._context,dt.Co.FRAGMENT_SHADER,s),Wo.enabled&&(this._linesOfCode=e.match(/\n/g).length+s.match(/\n/g).length+2,this._context.instanceCounter.increment(dt.vt.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(dt.vt.Shader,this),(0,ut.Xc)()&&(this.vertexShader=e,this.fragmentShader=s),this.usedMemory=e.length+s.length;const o=this._context.gl,a=o.createProgram();o.attachShader(a,this._vShader),o.attachShader(a,this._fShader),this._locations.forEach(((t,e)=>o.bindAttribLocation(a,t,e))),this._transformFeedbackVaryings?.length&&o.transformFeedbackVaryings(a,this._transformFeedbackVaryings,o.SEPARATE_ATTRIBS),o.linkProgram(a),(0,ut.Xc)()&&!o.getProgramParameter(a,o.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${o.getProgramParameter(a,o.VALIDATE_STATUS)}, gl error ${o.getError()}, vertex: ${o.getShaderParameter(this._vShader,o.COMPILE_STATUS)}, fragment: ${o.getShaderParameter(this._fShader,o.COMPILE_STATUS)}, info log: ${o.getProgramInfoLog(a)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`);for(const[t,e]of this._uniformBlockBindings){const s=o.getUniformBlockIndex(a,t);s<4294967295&&o.uniformBlockBinding(a,s,e)}this._glName=a,this._context.instanceCounter.increment(dt.vt.Program,this)}get glName(){return this._glName}get hasGLName(){return null!=this._glName}get hasTransformFeedbackVaryings(){return!!this._transformFeedbackVaryings?.length}get compiled(){if(this._compiled)return!0;const t=this._context.gl.getExtension("KHR_parallel_shader_compile");return null==t||null==this.glName?(this._compiled=!0,!0):(this._compiled=!!this._context.gl.getProgramParameter(this.glName,t.COMPLETION_STATUS_KHR),this._compiled)}dispose(){if(--this._refCount>0)return;const t=this._context.gl,e=this._context.instanceCounter;this._nameToUniformLocation.forEach((t=>t&&e.decrement(dt.vt.Uniform,t))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(dt.vt.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(dt.vt.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(dt.vt.Program,this))}ref(){++this._refCount}_getUniformLocation(t){const e=this._nameToUniformLocation.get(t);if(void 0!==e)return e;if(this.glName){const e=this._context.gl.getUniformLocation(this.glName,t);return this._nameToUniformLocation.set(t,e),e&&this._context.instanceCounter.increment(dt.vt.Uniform,e),e}return null}hasUniform(t){return null!=this._getUniformLocation(t)}setUniform1i(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1i(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1iv(t,e){qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e){qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e){qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e){qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4iv(this._getUniformLocation(t),e)}setUniform1f(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1f(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1fv(t,e){qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,s){const r=this._nameToUniform2.get(t);void 0===r?(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),this._nameToUniform2.set(t,[e,s])):e===r[0]&&s===r[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),r[0]=e,r[1]=s)}setUniform2fv(t,e){qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,s,r){const i=this._nameToUniform3.get(t);void 0===i?(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,r),this._nameToUniform3.set(t,[e,s,r])):e===i[0]&&s===i[1]&&r===i[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,r),i[0]=e,i[1]=s,i[2]=r)}setUniform3fv(t,e){const s=this._getUniformLocation(t);null!=s&&qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(s,e)}setUniform4f(t,e,s,r,i){const n=this._nameToUniform4.get(t);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,r,i),this._nameToUniform4.set(t,[e,s,r,i])):void 0!==n&&e===n[0]&&s===n[1]&&r===n[2]&&i===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,r,i),n[0]=e,n[1]=s,n[2]=r,n[3]=i)}setUniform4fv(t,e){const s=this._getUniformLocation(t);null!=s&&qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(s,e)}setUniformMatrix3fv(t,e,s=!1){const r=this._getUniformLocation(t);null!=r&&qo(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(r,s,e)}setUniformMatrix4fv(t,e,s=!1){const r=this._getUniformLocation(t);null!=r&&qo(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(r,s,e)}stop(){}}function Vo(t,e,s){const r=t.gl,i=r.createShader(e);return r.shaderSource(i,s),r.compileShader(i),(0,ut.Xc)()&&!r.getShaderParameter(i,r.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===dt.Co.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(r.getShaderInfoLog(i)),console.error(function(t){let e=2;return t.replaceAll("\n",(()=>"\n"+function(t){return t>=1e3?t.toString():(" "+t).slice(-3)}(e++)+":"))}(s))),i}function qo(t,e,s){const r=t.get(e);if(!r)return t.set(e,Array.from(s)),!0;const i=s.length;if(r.length!==i)return t.set(e,Array.from(s)),!0;for(let t=0;t<i;++t){const e=s[t];if(r[t]!==e){for(r[t]=e;t<i;++t)r[t]=s[t];return!0}}return!1}const Wo={enabled:!1};function jo(t,e,s){const i=e.length;if(i!==s){const n=new r.A("Invalid Uniform",`Invalid length, expected ${s} but got ${i}`,{uniformName:t,values:e});E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}class Yo{constructor(t,e,s,r,i,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=t,this.fragmentShader=e,this._locations=s,this._locationInfo=r,this._uniformBindings=i,this._transformFeedbackBindings=n}destroy(){this._program&&this._program.dispose(),this.cleanupTemporaryTextures()}get locations(){return this._locations}get locationInfo(){return this._locationInfo}setUniforms(t){this._uniforms=t}cleanupTemporaryTextures(){for(const t of this._temporaryTextures)t.dispose();this._temporaryTextures=[]}bind(t){const e=this._uniforms;if(!this._program){const e=new Map;for(const[t,s]of this._locations)e.set(t,s);const s=[];for(const t of this._transformFeedbackBindings??[]){const{index:e,propertyKey:r}=t;s[e]=`v_${r}`}this._program=new Uo(t,this.vertexShader,this.fragmentShader,e,new Map,s)}const s=this._program;t.useProgram(s);for(const r of this._uniformBindings){const{shaderModulePath:i,uniformName:n,uniformType:o,uniformArrayLength:a}=r,h=(0,U.wc)(i,e);if(null==h){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${i}`)}switch("array"===o||"array-2d"===o?r.uniformArrayElementType:o){case"sampler2D":{const{unit:e,texture:r}=h;if(s.setUniform1i(n,e),"type"in r)t.bindTexture(r,e);else{const s=St(t,r.descriptor,r.data);t.bindTexture(s,e)}break}case"int":if(!a){s.setUniform1i(n,h);break}jo(r.uniformName,h,a),s.setUniform1iv(n,h);break;case"float":if(!a){s.setUniform1f(n,h);break}jo(r.uniformName,h,a),s.setUniform1fv(n,h);break;case"vec2":if(!a){s.setUniform2f(n,h[0],h[1]);break}jo(r.uniformName,h,a),s.setUniform2fv(n,h.flat());break;case"vec3":if(!a){s.setUniform3f(n,h[0],h[1],h[2]);break}jo(r.uniformName,h,a),s.setUniform3fv(n,h.flat());break;case"vec4":if(!a){s.setUniform4f(n,h[0],h[1],h[2],h[3]);break}jo(r.uniformName,h,a),s.setUniform4fv(n,h.flat());break;case"mat3":s.setUniformMatrix3fv(n,h);break;case"mat4":s.setUniformMatrix4fv(n,h);break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function Xo(t){return new t}function $o(t,e,s){const r=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:r.slice()}),t.constructor[e].push(s)}function Ho(t,e){return(s,r)=>{$o(s,"locations",{typeCtor:e,propertyKey:r,parameterIndex:null,index:t})}}const Zo=t=>(e,s,r)=>{$o(e,"inputs",{inputCtor:t,propertyKey:s,parameterIndex:r})},Qo=t=>(e,s)=>{$o(e,"uniforms",{typeCtor:t,propertyKey:s})},Ko=t=>(e,s)=>{$o(e,"options",{typeCtor:t,propertyKey:s})},Jo=(t,e)=>{$o(t,"defines",{propertyKey:e})},ta=(t,e)=>(s,r)=>{s.constructor.builtins.push({builtin:t,propertyKey:r,typeCtor:e})};class ea{}ea.builtins=[],(0,P._)([ta("gl_VertexID",Tn)],ea.prototype,"glVertexID",void 0);class sa{}class ra{}ra.builtins=[],(0,P._)([ta("gl_FragCoord",mn)],ra.prototype,"glFragCoord",void 0),(0,P._)([ta("gl_PointCoord",fn)],ra.prototype,"glPointCoord",void 0);class ia{}class na{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class oa{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=this._shaderModuleClass.inputs.findLast((t=>"vertex"===t.propertyKey&&0===t.parameterIndex));if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return this._shaderModuleClass.inputs.findLast((t=>"vertex"===t.propertyKey&&1===t.parameterIndex))}get fragmentInput(){const t=this._shaderModuleClass.inputs.findLast((t=>"fragment"===t.propertyKey));if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,e=new Set;for(const s of this.locations)e.has(s.index)?E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${s.propertyKey} to ${s.index}. Index already in use`,{locationsMap:t}):(t.set(s.propertyKey,s.index),e.add(s.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map((([t,e])=>`${t}.${e}`)).join("."),s=(0,lt.Wm)(e),r=this.computeAttributes;this._locationInfo={hash:s,locations:t,computeAttributeMap:r}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,s,r){try{const{vertex:i,fragment:n,uniformBindings:o}=this._generateShaders(t,e,s,r);return new Yo(i,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(t){return new Yo("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find((e=>e.propertyKey===t));if(e)return{type:"option",className:e.typeCtor};const s=this._uniforms.find((e=>e.propertyKey===t));if(!s)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:s.typeCtor}}getShaderKey(t,e,s,r){const i=Object.keys(t).map((e=>`${e}.${t[e]}`)).join("."),n=Object.keys(s).map((t=>`${t}.${s[t]}`)).join("."),o=Object.keys(r).map((t=>`${t}.${r[t]}`)).join("."),a=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${i}.${n}.${o}.${a}`}_generateShaders(t,e,s,r){const i=[];this._setDefines(s),this._setOptionalUniforms(i,e),this._setRequiredUniforms(i);const n=this._hydrateVertexInput(r),o=this._injectPackPrecisionFactor(n,t),a=this._hydrateComputeInput(),h=a&&this._injectComputePackPrecisionFactor(a,t),c=this.vertex(o,h),l=this._hydrateFragmentInput(c),u=this.fragment(l),d=new Set;for(const t in u)Li(d,u[t]);const _=this._getVertexInputBuiltins(),p=Mo.createVertex({...n,...a},c,_,i,this.transformFeedbackBindings,d);(new vo).write(p);const f=this._getFragmentInputBuiltins(u);f.set("glPointCoord","gl_PointCoord");const g=Mo.createFragment(l,u,f,i,p,this.transformFeedbackBindings);(new vo).write(g);const m=this._createShaderBuilder(p,g),y=m.generate("vertex",!0),x=m.generate("fragment",!0);return this.logShader&&(console.log(y),console.log(x)),{vertex:y,fragment:x,uniformBindings:i}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const s of this._options)e[s.propertyKey]?this[s.propertyKey]=this._hydrateUniformGroup(t,s):this[s.propertyKey]=null}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const s=new(0,e.typeCtor);for(const r of s._uniforms??[]){const i=Xo(r.typeCtor),n=`u_${e.propertyKey}_${r.propertyKey}`,o=i.type,a=[e.propertyKey,r.propertyKey].join(".");if("type"in r.typeCtor&&"array"===r.typeCtor.type){const e=i;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:i})}else if("type"in r.typeCtor&&"array-2d"===r.typeCtor.type){const e=i;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:i})}else t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:i});s[r.propertyKey]=i}return s}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,s=e.locations.reduce(((e,s)=>!1===t[s.propertyKey]?e:{...e,[s.propertyKey]:Xo(s.typeCtor)}),{});for(const{propertyKey:t,typeCtor:r}of e.builtins){const e=Xo(r);s[t]=e}return s}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:Xo(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const s={};for(const r in t){const i=t[r],n=e[r];if(n){if("float"!==i.type&&"vec2"!==i.type&&"vec3"!==i.type&&"vec4"!==i.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${i.type}`);s[r]=i.divide(new pn(n))}else s[r]=i}return s}_injectComputePackPrecisionFactor(t,e){const s={},r=new Map;for(const t in this.computeAttributes)for(const e of this.computeAttributes[t]??[])r.set(e,t);for(const i in t){const n=t[i],o=r.get(i);if(!o)continue;const a=e[o];if(a){if("float"!==n.type&&"vec2"!==n.type&&"vec3"!==n.type&&"vec4"!==n.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${n.type}`);s[i]=n.divide(new pn(a))}else s[i]=n}return s}_hydrateFragmentInput(t){const e={};for(const s in t)e[s]=t[s];for(const{propertyKey:t,typeCtor:s}of ra.builtins){const r=Xo(s);e[t]=r}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:s,propertyKey:r}of t.builtins)e.set(r,s);return e}_getFragmentInputBuiltins(t){const e=t.constructor,s=new Map;for(const t of e.builtins??[])s.set(t.propertyKey,t.builtin);return s}_createShaderBuilder(t,e){const s=new Ai;return this._insertDebugInfo(s),t.insertVertexShader(s),e.insertFragmentShader(s),s}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}function aa(t){const e=Dn(12.9898),s=Dn(78.233),r=Dn(43758.5453);return lo(yo(go(co(t,Ln(e,s)),Dn(3.14))).multiply(r))}function ha(t){return Jn(t,Dn(1e-30))}function ca(t,e){const s=Dn(2**e);return go(function(t){return Vn("floor",t)}(t.divide(s)),Dn(2))}function la(t,e){return ca(t,e+B.U5)}class ua extends na{getVisualVariableData(t){if(!this._vvData){const e=this.getAttributeDataCoords(t);this._vvData=bo(this.visualVariableData,e).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(t){if(!this._uv){const e=function(t){const e=ca(t.z,7),s=Dn(1).subtract(e),r=t.xyz.subtract(((...t)=>new gn(...t))(0,0,Dn(128)));return s.multiply(t).add(e.multiply(r))}(t),s=this.size,r=Rn(e.x),i=Rn(e.y).multiply(Rn(256)),n=Rn(e.z).multiply(Rn(256)).multiply(Rn(256)),o=Dn(r.add(i).add(n)),a=go(o,s),h=o.subtract(a).divide(s);this._uv=new fn(a,h).add(.5).divide(s)}return this._uv}getFilterData(t){const e=this.getAttributeDataCoords(t);return bo(this.filterFlags,e).setDebugName("storage0")}getAnimationData(t){const e=this.getAttributeDataCoords(t);return bo(this.animation,e).setDebugName("storage1")}getVVData(t){return this.getVisualVariableData(t)}getDataDrivenData0(t){const e=this.getAttributeDataCoords(t);return bo(this.dataDriven0,e).setDebugName("storage30")}getDataDrivenData1(t){const e=this.getAttributeDataCoords(t);return bo(this.dataDriven1,e).setDebugName("storage31")}getDataDrivenData2(t){const e=this.getAttributeDataCoords(t);return bo(this.dataDriven2,e).setDebugName("storage32")}getGPGPUData(t){const e=this.getAttributeDataCoords(t);return bo(this.gpgpu,e).setDebugName("storage4")}getLocalTimeOrigin(t){const e=this.getAttributeDataCoords(t);return bo(this.localTimeOrigin,e).x.setDebugName("storage5")}getFilterFlags(t){return(0,n.A)("webgl-ignores-sampler-precision")?function(t){return Vn("ceil",t)}(this.getFilterData(t).x.multiply(Dn(255))):this.getFilterData(t).x.multiply(Dn(255))}getLabelVisibility(t){const e=this.getFilterData(t).y.multiply(255);return new pn(1).subtract(e)}getAnimationValue(t){return this.getAnimationData(t).x}getSizeValue(t){return this.getVisualVariableData(t).x}getColorValue(t){return this.getVisualVariableData(t).y}getOpacityValue(t){return this.getVisualVariableData(t).z}getRotationValue(t){return this.getVisualVariableData(t).w}}(0,P._)([Qo(_n)],ua.prototype,"filterFlags",void 0),(0,P._)([Qo(_n)],ua.prototype,"animation",void 0),(0,P._)([Qo(_n)],ua.prototype,"gpgpu",void 0),(0,P._)([Qo(_n)],ua.prototype,"localTimeOrigin",void 0),(0,P._)([Qo(_n)],ua.prototype,"visualVariableData",void 0),(0,P._)([Qo(_n)],ua.prototype,"dataDriven0",void 0),(0,P._)([Qo(_n)],ua.prototype,"dataDriven1",void 0),(0,P._)([Qo(_n)],ua.prototype,"dataDriven2",void 0),(0,P._)([Qo(pn)],ua.prototype,"size",void 0);class da extends na{}(0,P._)([Qo(pn)],da.prototype,"activeReasons",void 0),(0,P._)([Qo(pn)],da.prototype,"highlightAll",void 0);class _a extends na{}(0,P._)([Qo(fn)],_a.prototype,"position",void 0),(0,P._)([Qo(pn)],_a.prototype,"distance",void 0),(0,P._)([Qo(pn)],_a.prototype,"smallSymbolDistance",void 0),(0,P._)([Qo(pn)],_a.prototype,"smallSymbolSizeThreshold",void 0);class pa extends na{}(0,P._)([Qo(En)],pa.prototype,"displayViewScreenMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"displayViewMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"displayMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"viewMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"tileMat3",void 0),(0,P._)([Qo(pn)],pa.prototype,"displayZoomFactor",void 0),(0,P._)([Qo(pn)],pa.prototype,"requiredZoomFactor",void 0),(0,P._)([Qo(fn)],pa.prototype,"tileOffset",void 0),(0,P._)([Qo(pn)],pa.prototype,"currentScale",void 0),(0,P._)([Qo(pn)],pa.prototype,"currentZoom",void 0),(0,P._)([Qo(pn)],pa.prototype,"metersPerSRUnit",void 0),(0,P._)([Qo(pn)],pa.prototype,"rotation",void 0),(0,P._)([Qo(pn)],pa.prototype,"pixelRatio",void 0);class fa extends ea{}(0,P._)([Ho(0,gn)],fa.prototype,"id",void 0),(0,P._)([Ho(1,pn)],fa.prototype,"bitset",void 0),(0,P._)([Ho(2,fn)],fa.prototype,"pos",void 0);class ga extends sa{}(0,P._)([Ho(14,fn)],ga.prototype,"nextPos1",void 0),(0,P._)([Ho(15,fn)],ga.prototype,"nextPos2",void 0);class ma extends ra{}class ya extends oa{clip(t,e){let s=new pn(0);const r=this.storage.getFilterFlags(t);if(s=s.add(Dn(2).multiply(Dn(1).subtract(la(r,0)))),this.inside?s=s.add(Dn(2).multiply(Dn(1).subtract(la(r,1)))):this.outside?s=s.add(Dn(2).multiply(la(r,1))):this.highlight&&(s=s.add(Dn(2).multiply(Dn(1).subtract(this._checkHighlight(r))))),null!=e){const t=new pn(1).subtract(xo(e.x,this.view.currentZoom)),r=xo(e.y,this.view.currentZoom);s=s.add(new pn(2).multiply(t.add(r)))}return s}getFragmentOutput(t,e,s=new pn(1/255)){const r=new ia;return r.glFragColor=this._maybeWriteHittest(e)??this._maybeHighlight(t,s)??t,r}_maybeHighlight(t,e){return this.highlight?new mn(t.rgb,xo(e,t.a)):null}_checkHighlight(t){let e=this._checkHighlightBit(t,0);for(let s=1;s<B.U5;s++)e=e.add(this._checkHighlightBit(t,s));return xo(new pn(.1),e.add(this.highlight.highlightAll))}_checkHighlightBit(t,e){return function(t,e){return ca(t,e)}(t,e).multiply(ca(this.highlight.activeReasons,e))}maybeRunHittest(t,e,s){if(null==this.hittestRequest)return null;let r=Xn(eo(this.hittest(t,e,s),this.hittestRequest.distance),new pn(2),new pn(0));const i=function(t){return t.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(t.id));r=r.add(this.clip(t.id,t.zoomRange));const n=new mn(new pn(1/255),0,0,0);return{glPointSize:new pn(1),glPosition:new mn(i,r,1),color:n}}_maybeWriteHittest(t){return null!=this.hittestRequest?t.color:null}}function xa(t,e,s){const r=s.subtract(e),i=ao((n=t.subtract(e),o=r,co(n,function(t){return Vn("normalize",t)}(o))).divide(uo(r)),new pn(0),new pn(1));var n,o;return function(t,e){return qn("distance",t,e,pn)}(t,e.add(i.multiply(s.subtract(e))))}function ba(t,e,s,r){return Jn(function(t){const e=function(t){return Vn("abs",t)}(t);return xo(e.x.add(e.y).add(e.z),new pn(1.05))}(function(t,e,s,r){const i=new En(s.x.multiply(r.y).subtract(r.x.multiply(s.y)),r.x.multiply(e.y).subtract(e.x.multiply(r.y)),e.x.multiply(s.y).subtract(s.x.multiply(e.y)),s.y.subtract(r.y),r.y.subtract(e.y),e.y.subtract(s.y),r.x.subtract(s.x),e.x.subtract(r.x),s.x.subtract(e.x)),n=e.x.multiply(s.y.subtract(r.y)),o=s.x.multiply(r.y.subtract(e.y)),a=r.x.multiply(e.y.subtract(s.y)),h=n.add(o).add(a);return new pn(1).divide(h).multiply(i.multiply(new gn(1,t)))}(t,e,s,r)),new pn(1))}function wa(t){return t.distance.add(1)}function va(t,e,s){const{viewMat3:r,tileMat3:i}=t.view,n=r.multiply(i),o=n.multiply(new gn(e.pos,1)),a=n.multiply(new gn(s.nextPos1,1)),h=n.multiply(new gn(s.nextPos2,1));return function(t,e,s,r){const i=function(t,e){return t.x.multiply(e.y).subtract(e.x.multiply(t.y))}(s.subtract(e),r.subtract(e)),n=io(function(t,e){return Un("<",t,e,vn)}(i,new pn(.05)),eo(i,new pn(-.05)));return $n([io(mo(n),ba(t.xy,e,s,r)),new pn(-1)],[!0,()=>{const i=xa(t,e,s),n=xa(t,s,r),o=xa(t,r,e);return po(po(i,n),o)}])}(t.hittestRequest.position,o.xy,a.xy,h.xy)}(0,P._)([Jo],ya.prototype,"inside",void 0),(0,P._)([Jo],ya.prototype,"outside",void 0),(0,P._)([Ko(da)],ya.prototype,"highlight",void 0),(0,P._)([Qo(ua)],ya.prototype,"storage",void 0),(0,P._)([Qo(pa)],ya.prototype,"view",void 0),(0,P._)([Ko(_a)],ya.prototype,"hittestRequest",void 0);class Sa extends na{getColor(t,e,s){return $n([ro(ha(t),s),e],[to(t,this.values.first()),this.colors.first()],[so(t,this.values.last()),this.colors.last()],[!0,()=>{const e=this.values.findIndex((e=>eo(e,t))),s=this.values.get(e),r=e.subtract(1),i=this.values.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.colors.get(r),this.colors.get(e),n)}])}}(0,P._)([Qo(un.ofType(mn,8))],Sa.prototype,"colors",void 0),(0,P._)([Qo(un.ofType(pn,8))],Sa.prototype,"values",void 0);class Ia extends na{getOpacity(t){return $n([ha(t),new pn(1)],[to(t,this.opacityValues.first()),this.opacities.first()],[so(t,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const e=this.opacityValues.findIndex((e=>eo(e,t))),s=this.opacityValues.get(e),r=e.subtract(1),i=this.opacityValues.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.opacities.get(r),this.opacities.get(e),n)}])}}function Ma(t){return null!=t.visualVariableSizeMinMaxValue||null!=t.visualVariableSizeScaleStops||null!=t.visualVariableSizeStops||null!=t.visualVariableSizeUnitValue}function Pa(t,e,s,r=new vn(!1)){if(null==t.visualVariableColor)return s;const i=t.storage.getColorValue(e);return t.visualVariableColor.getColor(i,s,r)}function Ta(t,e){if(null==t.visualVariableOpacity)return new pn(1);const s=t.storage.getOpacityValue(e);return t.visualVariableOpacity.getOpacity(s)}(0,P._)([Qo(un.ofType(pn,8))],Ia.prototype,"opacities",void 0),(0,P._)([Qo(un.ofType(pn,8))],Ia.prototype,"opacityValues",void 0);class Aa extends fa{}(0,P._)([Ho(3,mn)],Aa.prototype,"color",void 0),(0,P._)([Ho(4,fn)],Aa.prototype,"zoomRange",void 0);class Ca extends ya{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Ta(this,t.id),r=Pa(this,t.id,t.color).multiply(s),i=this.view.displayViewScreenMat3.multiply(new gn(t.pos.xy,1)),n=this.clip(t.id,t.zoomRange);return{glPosition:new mn(i.xy,n,1),color:r,...this.maybeRunHittest(t,e,null)}}fragment(t){return this.getFragmentOutput(t.color,t,new pn(0))}hittest(t,e){return va(this,t,e)}}(0,P._)([Ko(Sa)],Ca.prototype,"visualVariableColor",void 0),(0,P._)([Ko(Ia)],Ca.prototype,"visualVariableOpacity",void 0),(0,P._)([(0,P.a)(0,Zo(Aa)),(0,P.a)(1,Zo(ga))],Ca.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(ma))],Ca.prototype,"fragment",null);class ka extends na{getPatternOffsetAtTileOrigin(t,e=new pn(0),s=new pn(1)){const r=new fn(16777216).divide(t);let i=t.multiply(lo(this.maxIntsToLocalOrigin.multiply(r))).add(this.tileOffsetFromLocalOrigin).subtract(new pn(.5).multiply(t));return i=new fn(i.x.multiply(s).subtract(i.y.multiply(e)),i.x.multiply(e).add(i.y.multiply(s))),go(i,t)}}(0,P._)([Qo(fn)],ka.prototype,"tileOffsetFromLocalOrigin",void 0),(0,P._)([Qo(fn)],ka.prototype,"maxIntsToLocalOrigin",void 0);class Fa extends na{}(0,P._)([Qo(fn)],Fa.prototype,"size",void 0),(0,P._)([Qo(_n)],Fa.prototype,"texture",void 0);class Ea extends Aa{}function za(t,e){const s=t.view.requiredZoomFactor,r=new fn(e.width,e.height),i=r.multiply(e.scale).multiply(s),n=e.angle.multiply(Mr),o=yo(n),a=ho(n),h=function(t,e,s,r,i){const n=Jn(ca(i,2),Dn(1)),o=function(t){return co(t,new mn(...[255/256,255/65536,255/16777216,255/4294967296]))}(new mn(t,0));return Xn(n,Nn(r.divide(e.x),s.divide(e.y),0,jn(s.divide(e.x)),r.divide(e.y),0,aa(Ln(o,0)),aa(Ln(0,o)),1),Nn(r.divide(e.x),s.divide(e.y),0,jn(s.divide(e.x)),r.divide(e.y),0,0,0,1))}(e.id,i,o,a,e.bitset),c=t.localTileOffset.getPatternOffsetAtTileOrigin(r,o,a),l=s.multiply(e.scale).multiply(e.offset.subtract(c)).divide(i),u=new gn(e.pos,1),d=h.multiply(u).xy.subtract(l),_=e.tlbr.divide(t.mosaicInfo.size.xyxy);let p=ca(e.bitset,4);return null!=t.visualVariableColor&&(p=Xn(ha(t.storage.getColorValue(e.id)),new pn(0),p)),{tileTextureCoord:d,tlbr:_,sampleAlphaOnly:p}}function Oa(t,e){const s=go(e.tileTextureCoord,new pn(1)),r=fo(e.tlbr.xy,e.tlbr.zw,s);let i=bo(t.mosaicInfo.texture,r);return i=Xn(eo(e.sampleAlphaOnly,new pn(.5)),i.aaaa,i),e.color.multiply(i)}(0,P._)([Ho(5,mn)],Ea.prototype,"tlbr",void 0),(0,P._)([Ho(6,pn)],Ea.prototype,"width",void 0),(0,P._)([Ho(7,pn)],Ea.prototype,"height",void 0),(0,P._)([Ho(8,fn)],Ea.prototype,"offset",void 0),(0,P._)([Ho(9,fn)],Ea.prototype,"scale",void 0),(0,P._)([Ho(10,pn)],Ea.prototype,"angle",void 0);class Ra extends Ca{vertex(t,e){return{...super.vertex(t,e),...za(this,t)}}fragment(t){const e=Oa(this,t);return this.getFragmentOutput(e,t,new pn(0))}}(0,P._)([Qo(Fa)],Ra.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],Ra.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(Ea)),(0,P.a)(1,Zo(ga))],Ra.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(class extends ma{}))],Ra.prototype,"fragment",null);class Da extends na{getSize(t,e){const s=this.minMaxValueAndSize.xy,r=this.minMaxValueAndSize.zw;return Xn(ha(t),e,(()=>{const e=ao(t.subtract(s.x).divide(s.y.subtract(s.x)),new pn(0),new pn(1));return r.x.add(e.multiply(r.y.subtract(r.x)))}))}}(0,P._)([Qo(mn)],Da.prototype,"minMaxValueAndSize",void 0);class La extends na{getSizeForViewScale(t){return $n([to(t,this.values.first()),this.sizes.first()],[so(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>eo(e,t))),s=this.values.get(e),r=e.subtract(1),i=this.values.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.sizes.get(r),this.sizes.get(e),n)}])}}(0,P._)([Qo(un.ofType(pn,8))],La.prototype,"sizes",void 0),(0,P._)([Qo(un.ofType(pn,8))],La.prototype,"values",void 0);class Na extends na{getSize(t,e){const s=$n([ha(t),e],[to(t,this.values.first()),this.sizes.first()],[so(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>eo(e,t))),s=this.values.get(e),r=e.subtract(1),i=this.values.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.sizes.get(r),this.sizes.get(e),n)}]);return Xn(ha(s),e,s)}}(0,P._)([Qo(un.ofType(pn,8))],Na.prototype,"sizes",void 0),(0,P._)([Qo(un.ofType(pn,8))],Na.prototype,"values",void 0);class Ba extends na{getSize(t,e){return Xn(ha(t),e,t.multiply(this.unitValueToPixelsRatio))}}(0,P._)([Qo(pn)],Ba.prototype,"unitValueToPixelsRatio",void 0);class Ga extends fa{}(0,P._)([Ho(3,mn)],Ga.prototype,"color",void 0),(0,P._)([Ho(4,fn)],Ga.prototype,"offset",void 0),(0,P._)([Ho(5,fn)],Ga.prototype,"normal",void 0),(0,P._)([Ho(6,pn)],Ga.prototype,"halfWidth",void 0),(0,P._)([Ho(7,pn)],Ga.prototype,"referenceHalfWidth",void 0),(0,P._)([Ho(8,fn)],Ga.prototype,"zoomRange",void 0);class Ua extends ma{}class Va extends na{}function qa(t){return _o(new pn(1.1).multiply(xo(t,new pn(1))),new pn(1))}function Wa(t,e){const{id:s,offset:r,pos:i,normal:n,zoomRange:o}=e,{displayViewScreenMat3:a,displayViewMat3:h}=t.view,c=Pa(t,s,e.color),l=Ta(t,s),u=function(t,e){const{id:s,halfWidth:r,referenceHalfWidth:i}=e;if(Ma(t)){const e=function(t,e,s){if(Ma(t)){const r=t.storage.getSizeValue(e);return t.visualVariableSizeMinMaxValue?.getSize(r,s)??t.visualVariableSizeScaleStops?.getSizeForViewScale(t.view.currentScale)??t.visualVariableSizeStops?.getSize(r,s)??t.visualVariableSizeUnitValue?.getSize(r,s)}return s}(t,s,new pn(2).multiply(i));return new pn(.5).multiply(r.divide(_o(i,new pn(1e-5)))).multiply(e)}return r}(t,e),d=new pn(.5).multiply(t.antialiasingControls.antialiasing),_=_o(u.add(d),new pn(.45)).add(new pn(.1).multiply(d)),p=qa(_).multiply(_).multiply(r),f=h.multiply(new gn(p,new pn(0))),g=a.multiply(new gn(i,new pn(1))).add(f),m=new pn(2).multiply(xo(u,new pn(0))).add(t.clip(s,o)),y=new mn(g.xy,m,1);return{color:c,opacity:l,halfWidth:_,normal:n,scaledOffset:p,scaledHalfWidth:u,glPosition:new mn(y.xy,m,1)}}function ja(t,e){const{opacity:s,color:r}=t,i=function(t,e){const{halfWidth:s,normal:r}=t,i=qa(s),n=uo(r).multiply(s);return ao(i.multiply(s.subtract(n)).divide(e.add(i).subtract(new pn(1))),new pn(0),new pn(1))}(t,e);return s.multiply(r).multiply(i)}(0,P._)([Qo(pn)],Va.prototype,"antialiasing",void 0),(0,P._)([Qo(pn)],Va.prototype,"blur",void 0);class Ya extends ya{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Wa(this,t);return{...s,...this.maybeRunHittest(t,e,s.halfWidth)}}fragment(t){const e=ja(t,this.antialiasingControls.blur);return this.getFragmentOutput(e,t)}hittest(t,e,s){const{viewMat3:r,tileMat3:i}=this.view,n=r.multiply(i),o=n.multiply(new gn(t.pos,1)),a=n.multiply(new gn(e.nextPos1,1)),h=n.multiply(new gn(e.nextPos2,1)),{distance:c,smallSymbolDistance:l,smallSymbolSizeThreshold:u}=this.hittestRequest,d=xo(s,u.multiply(.5)).multiply(c.subtract(l)),_=this.hittestRequest.position;return po(xa(_,o.xy,a.xy),xa(_,o.xy,h.xy)).subtract(s).add(d)}}(0,P._)([Qo(Va)],Ya.prototype,"antialiasingControls",void 0),(0,P._)([Ko(Sa)],Ya.prototype,"visualVariableColor",void 0),(0,P._)([Ko(Ia)],Ya.prototype,"visualVariableOpacity",void 0),(0,P._)([Ko(Da)],Ya.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([Ko(La)],Ya.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([Ko(Na)],Ya.prototype,"visualVariableSizeStops",void 0),(0,P._)([Ko(Ba)],Ya.prototype,"visualVariableSizeUnitValue",void 0),(0,P._)([(0,P.a)(0,Zo(Ga)),(0,P.a)(1,Zo(ga))],Ya.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(Ua))],Ya.prototype,"fragment",null);class Xa extends fa{}(0,P._)([Ho(3,fn)],Xa.prototype,"offset",void 0),(0,P._)([Ho(4,mn)],Xa.prototype,"color",void 0),(0,P._)([Ho(5,fn)],Xa.prototype,"normal",void 0),(0,P._)([Ho(6,pn)],Xa.prototype,"halfWidth",void 0),(0,P._)([Ho(7,pn)],Xa.prototype,"referenceHalfWidth",void 0),(0,P._)([Ho(8,fn)],Xa.prototype,"zoomRange",void 0);class $a extends Ua{}function Ha(t,e,s){const{id:r,bitset:i}=e,n=ca(i,0),o=eo(n,new pn(.5)),a=Wa(t,e),h=Xn(o,a.halfWidth,new pn(0)),c=Ta(t,r),l=Pa(t,r,e.color),u=Xn(o,e.color,l.multiply(c)),d=t.view.displayViewScreenMat3.multiply(new gn(e.pos.xy,1)),_=t.clip(e.id),p=new mn(d.xy,_,1),f=Xn(o,a.glPosition,p),g=s&&t.maybeRunHittest(e,s,o);return{isOutline:n,color:u,opacity:new pn(1),halfWidth:h,normal:a.normal,glPosition:f,...g}}class Za extends ya{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,P._)([Qo(Va)],Za.prototype,"antialiasingControls",void 0),(0,P._)([Ko(Sa)],Za.prototype,"visualVariableColor",void 0),(0,P._)([Ko(Ia)],Za.prototype,"visualVariableOpacity",void 0),(0,P._)([Ko(Da)],Za.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([Ko(La)],Za.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([Ko(Na)],Za.prototype,"visualVariableSizeStops",void 0),(0,P._)([Ko(Ba)],Za.prototype,"visualVariableSizeUnitValue",void 0);class Qa extends Za{vertex(t,e){return Ha(this,t,e)}fragment(t){const{color:e,isOutline:s}=t,r=eo(s,new pn(.5)),i=Xn(r,ja(t,this.antialiasingControls.blur),e),n=Xn(r,new pn(1/255),new pn(0));return this.getFragmentOutput(i,t,n)}hittest(t,e,s){return Xn(s,wa(this.hittestRequest),va(this,t,e))}}(0,P._)([(0,P.a)(0,Zo(Xa)),(0,P.a)(1,Zo(ga))],Qa.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo($a))],Qa.prototype,"fragment",null);class Ka extends Aa{}function Ja(t,e){const s=e.tlbr.xy,r=e.tlbr.zw,i=r.x.subtract(s.x),n=s.y.subtract(r.y),o=new fn(i,n).multiply(e.inverseRasterizationScale),a=o.multiply(t.view.requiredZoomFactor),h=function(t){const e=new pn(1),s=new pn(0);return new En(e.divide(t.x),s.divide(t.y),0,jn(s.divide(t.x)),e.divide(t.y),0,0,0,1)}(a),c=t.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),l=new gn(e.pos,1);return{tileTextureCoord:h.multiply(l).xy.subtract(c),tlbr:e.tlbr.divide(t.mosaicInfo.size.xyxy)}}function th(t,e){const s=go(t.tileTextureCoord,new pn(1)),r=fo(t.tlbr.xy,t.tlbr.zw,s),i=bo(e.texture,r);return t.color.multiply(i)}(0,P._)([Ho(5,mn)],Ka.prototype,"tlbr",void 0),(0,P._)([Ho(6,pn)],Ka.prototype,"inverseRasterizationScale",void 0);class eh extends Ca{vertex(t,e){return{...super.vertex(t,e),...Ja(this,t)}}fragment(t){const e=th(t,this.mosaicInfo);return this.getFragmentOutput(e,t,new pn(0))}}(0,P._)([Qo(Fa)],eh.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],eh.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(Ka)),(0,P.a)(1,Zo(ga))],eh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(class extends ma{}))],eh.prototype,"fragment",null);class sh extends Xa{}(0,P._)([Ho(9,mn)],sh.prototype,"tlbr",void 0),(0,P._)([Ho(10,pn)],sh.prototype,"inverseRasterizationScale",void 0);class rh extends $a{}class ih extends Qa{vertex(t,e){return{...Ha(this,t,e),...Ja(this,t)}}fragment(t){const{isOutline:e}=t,s=eo(e,new pn(.5)),r=Xn(s,ja(t,this.antialiasingControls.blur),th(t,this.mosaicInfo)),i=Xn(s,new pn(1/255),new pn(0));return this.getFragmentOutput(r,t,i)}}(0,P._)([Qo(Fa)],ih.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],ih.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(sh)),(0,P.a)(1,Zo(ga))],ih.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(rh))],ih.prototype,"fragment",null);const nh=1/16;class oh extends fa{}(0,P._)([Ho(3,mn)],oh.prototype,"color",void 0),(0,P._)([Ho(4,mn)],oh.prototype,"tlbr",void 0),(0,P._)([Ho(5,pn)],oh.prototype,"angle",void 0),(0,P._)([Ho(6,pn)],oh.prototype,"aux1",void 0),(0,P._)([Ho(7,pn)],oh.prototype,"aux2",void 0),(0,P._)([Ho(8,fn)],oh.prototype,"aux3",void 0),(0,P._)([Ho(9,fn)],oh.prototype,"aux4",void 0),(0,P._)([Ho(10,fn)],oh.prototype,"zoomRange",void 0);class ah extends Za{vertex(t,e){const{aux1:s,aux2:r,aux3:i,aux4:n}=t,o={...t,width:s,height:r,offset:i,scale:n.multiply(nh)},a=Ha(this,{...t,halfWidth:s,referenceHalfWidth:r,offset:i,normal:n.subtract(128).multiply(nh)}),h=za(this,o),c=eo(a.isOutline,new pn(.5));return{...a,...h,...this.maybeRunHittest(t,e,c)}}fragment(t){const{isOutline:e}=t,s=eo(e,new pn(.5)),r=Xn(s,ja(t,this.antialiasingControls.blur),Oa(this,t)),i=Xn(s,new pn(1/255),new pn(0));return this.getFragmentOutput(r,t,i)}hittest(t,e,s){return Xn(s,wa(this.hittestRequest),va(this,t,e))}}(0,P._)([Qo(Fa)],ah.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],ah.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(oh)),(0,P.a)(1,Zo(ga))],ah.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(class extends rh{}))],ah.prototype,"fragment",null);const hh=pi,ch=vi,lh={createComputedParams:t=>t,optionalAttributes:hh.optionalAttributes,attributes:{...hh.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>_i(t)},aux1:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).width},aux2:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).height},aux3:{count:2,type:dt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),(0,l.Lz)(e)]},aux4:{count:2,type:dt.pe.UNSIGNED_BYTE,pack:({scaleX:t,scaleY:e})=>[16*t,16*e]}}},uh={createComputedParams:t=>t,optionalAttributes:hh.optionalAttributes,attributes:{...hh.attributes,color:ch.attributes.color,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>Et([[0,!0]])},aux1:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.width)},aux2:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.referenceWidth)},aux3:{count:2,type:dt.pe.HALF_FLOAT,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[t,e]},aux4:{count:2,type:dt.pe.UNSIGNED_BYTE,packTessellation:({normalX:t,normalY:e})=>[16*t+128,16*e+128]}}};class dh extends Si{constructor(){super(...arguments),this.vertexSpec=uh}}class _h extends Ii{constructor(){super(...arguments),this.vertexSpec=lh}_createOutlineWriter(t,e,s,r){return new dh(t,e,s,r)}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),this._lineMeshWriter.writeLineVertices(t,Yt.fromOptimizedCIM(i,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}class ph{constructor(t,e){this._size=t,this._sizeUnits=e,this._relativeSize=null}get relativeSize(){return this._relativeSize??=this.calculateRelativeSize(),this._relativeSize}calculateRelativeSize(){if(this._sizeUnits===Ct.OW.Relative){const t=Math.min(this._size/100,1);return[t,t]}return this.calculateRelativeSizeFromAbsolute()}}class fh extends ph{constructor(t,e,s,r){super(e,s),this.rotationMatrix00=1,this.rotationMatrix01=0,this.rotationMatrix10=0,this.rotationMatrix11=1,this.bounds={xmin:1/0,ymin:1/0,xmax:-1/0,ymax:-1/0},this.rotationMatrix00=Math.cos(r),this.rotationMatrix01=-Math.sin(r),this.rotationMatrix10=-this.rotationMatrix01,this.rotationMatrix11=this.rotationMatrix00;const{bounds:i,rotationMatrix00:n,rotationMatrix01:o,rotationMatrix10:a,rotationMatrix11:h}=this;t.forEachVertex(((t,e)=>{const s=t*n+e*o,r=t*a+e*h;i.xmin=Math.min(i.xmin,s),i.ymin=Math.min(i.ymin,r),i.xmax=Math.max(i.xmax,s),i.ymax=Math.max(i.ymax,r)})),this.center=[(i.xmin+i.xmax)/2,(i.ymin+i.ymax)/2]}}class gh extends fh{constructor(t,e,s,r){super(t,e,s,r),this.method="linear"}getRelativePosition(t,e){const{rotationMatrix00:s,rotationMatrix01:r,bounds:i}=this,{xmin:n,xmax:o}=i;return[(t*s+e*r-n)/(o-n),0]}calculateRelativeSizeFromAbsolute(){const{_size:t,bounds:e}=this,{xmin:s,xmax:r}=e;return[(0,l.Lz)(t)/(r-s),0]}}class mh extends fh{constructor(t,e,s,r){super(t,e,s,r),this.method="rectangular"}getRelativePosition(t,e){const{bounds:s,center:r,rotationMatrix00:i,rotationMatrix01:n,rotationMatrix10:o,rotationMatrix11:a}=this,h=t*o+e*a,c=t*i+e*n-r[0],l=h-r[1];return[c*(2/(s.xmax-s.xmin)),-l*(2/(s.ymax-s.ymin))]}calculateRelativeSizeFromAbsolute(){const{_size:t,bounds:e}=this,{xmin:s,ymin:r,xmax:i,ymax:n}=e;return[(0,l.Lz)(2*t)/(i-s),(0,l.Lz)(2*t)/(n-r)]}}class yh extends fh{constructor(t,e,s){super(t,e,s,0),this.method="circular";const{xmin:r,xmax:i,ymin:n,ymax:o}=this.bounds,a=i-r,h=o-n;this.radius=Math.sqrt(a*a+h*h)/2}getRelativePosition(t,e){const{center:s,radius:r}=this;return[(t-s[0])/r,-(e-s[1])/r]}calculateRelativeSizeFromAbsolute(){const{_size:t}=this;return[(0,l.Lz)(t)/this.radius,0]}}function xh(t,e){if(null==t)return null;const s=(0,ks.kU)(e.angle),r=e.gradientSize,i=e.gradientSizeUnits;switch(e.gradientMethod.toLowerCase()){case"linear":return new gh(t,r,i,s);case"rectangular":return new mh(t,r,i,s);case"circular":return new yh(t,r,i);default:return E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.fill.GradientSizeHelper").errorOnce(`Gradient fill method "${e.gradientMethod}" currently unsupported.`),null}}const bh={createComputedParams:t=>t,optionalAttributes:hi.optionalAttributes,attributes:{...hi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({gradientSizeUnits:t,gradientType:e})=>{let s=0;return t===Ct.OW.Absolute&&(s|=Ft(0)),"discrete"===e.toLowerCase()&&(s|=Ft(1)),s}},tlbr:{count:4,type:dt.pe.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM+B.MZ,n=e.y+B.hM;return[i,n,i+s-2*B.MZ,n+r]}},relativePosition:{count:2,type:dt.pe.HALF_FLOAT,packTessellation:({gradientStats:t},e,s,r)=>t?.getRelativePosition(s,r)??[0,0]},relativeGradientSize:{count:2,type:dt.pe.HALF_FLOAT,packTessellation:({gradientStats:t})=>t?.relativeSize??[1,1]},gradientMethod:{count:1,type:dt.pe.UNSIGNED_BYTE,pack:({gradientMethod:t})=>{switch(t.toLowerCase()){case"rectangular":return 1;case"circular":return 2;default:return 0}}}}};class wh extends ni{constructor(){super(...arguments),this.vertexSpec=bh}get _preventEffectClipping(){return!0}createTesselationParams(t){return{gradientStats:xh(t.readGeometryForDisplay(),this.evaluatedMeshParams)}}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),t.recordEnd()}}const vh={optionalAttributes:li.optionalAttributes,createComputedParams:t=>t,attributes:{...li.attributes,...wi.attributes}},Sh={optionalAttributes:li.optionalAttributes,createComputedParams:t=>t,attributes:{...li.attributes,...vi.attributes}};class Ih extends Si{constructor(){super(...arguments),this.vertexSpec=Sh}}class Mh extends Ii{constructor(){super(...arguments),this.vertexSpec=vh}_createOutlineWriter(t,e,s,r){return new Ih(t,e,s,r)}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),this._lineMeshWriter.writeLineVertices(t,Yt.fromOptimizedCIM(i,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}const Ph={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},offset:{type:dt.pe.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};class Th extends br{constructor(){super(...arguments),this.vertexSpec=Ph}_write(t,e){t.recordStart(this.instanceId,this.attributeLayout);const s=e.getDisplayId();if("esriGeometryPoint"===e.geometryType){const r=e.readXForDisplay(),i=e.readYForDisplay();this._writeQuad(t,s,r,i)}else if("esriGeometryMultipoint"===e.geometryType){const r=e.readGeometryForDisplay();r?.forEachVertex(((e,r)=>{e>=0&&e<=512&&r>=0&&r<=512&&this._writeQuad(t,s,e,r)}))}t.recordEnd()}_writeQuad(t,e,s,r){const i=t.vertexCount();this._writeVertex(t,e,s,r),t.indexWrite(i+0),t.indexWrite(i+1),t.indexWrite(i+2),t.indexWrite(i+1),t.indexWrite(i+3),t.indexWrite(i+2)}}var Ah=s(48163),Ch=s(90708);const kh=8388607,Fh=t=>t&kh;class Eh{constructor(t,e,s,r,i,n,o,a,h=[]){this.entityTexel=t,this.anchorX=e,this.anchorY=s,this.directionX=r,this.directionY=i,this.maxScale=n,this.minScale=o,this.referenceBounds=a,this.bounds=h}serialize(t){t.push(this.entityTexel),t.writeF32(this.anchorX),t.writeF32(this.anchorY),t.writeF32(this.directionX),t.writeF32(this.directionY),t.writeF32(this.maxScale),t.writeF32(this.minScale),null===this.referenceBounds?(t.writeF32(0),t.writeF32(0),t.writeF32(0)):(t.writeF32(this.referenceBounds.size),t.writeF32(this.referenceBounds.offsetX),t.writeF32(this.referenceBounds.offsetY)),j(t,this.bounds)}static deserialize(t){const e=t.readInt32(),s=t.readF32(),r=t.readF32(),i=t.readF32(),n=t.readF32(),o=t.readF32(),a=t.readF32(),h=t.readF32(),c=t.readF32(),l=t.readF32(),u=Y(t,Hs)??[];return new Eh(e,s,r,i,n,o,a,{size:h,offsetX:c,offsetY:l},u)}}const zh=1024;function Oh(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function Rh(t,e){return Math.sqrt(t*t+e*e)}function Dh(t){const e=Rh(t[0],t[1]);t[0]/=e,t[1]/=e}function Lh(t,e){return Rh(t[0]-e[0],t[1]-e[1])}function Nh(t){return t.length-1}function Bh(t,e,s=1){let[r,i]=function(t,e){return t[e+1]}(t,e);return[r,i]=[Math.round(r),Math.round(i)],Math.sqrt(r*r+i*i)*s}class Gh{constructor(t,e,s,r,i){this._segments=t,this._index=e,this._distance=s,this._xStart=r,this._yStart=i,this._done=!1}static create(t){return new Gh(t,0,0,t[0][0],t[0][1])}clone(){return new Gh(this._segments,this._index,this._distance,this.xStart,this.yStart)}equals(t){return this._index===t._index||t._index===this._index-1&&(0===this._distance||1===t._distance)||t._index===this._index+1&&(1===this._distance||0===t._distance)}leq(t){return this._index<t._index||this._index===t._index&&this._distance<=t._distance}geq(t){return this._index>t._index||this._index===t._index&&this._distance>=t._distance}get _segment(){return this._segments[this._index+1]}get angle(){const t=this.dy,e=(0*t+-1*-this.dx)/(1*this.length);let s=Math.acos(e);return t>0&&(s=2*Math.PI-s),s}get xStart(){return this._xStart}get yStart(){return this._yStart}get x(){return this.xStart+this.distance*this.dx}get y(){return this.yStart+this.distance*this.dy}get dx(){return this._segment[0]}get dy(){return this._segment[1]}get xMidpoint(){return this.xStart+.5*this.dx}get yMidpoint(){return this.yStart+.5*this.dy}get xEnd(){return this.xStart+this.dx}get yEnd(){return this.yStart+this.dy}get length(){const{dx:t,dy:e}=this;return Math.sqrt(t*t+e*e)}get remainingLength(){return this.length*(1-this._distance)}get backwardLength(){return this.length*this._distance}get distance(){return this._distance}get done(){return this._done}hasPrev(){return this._index-1>=0}hasNext(){return this._index+1<Nh(this._segments)}next(){return this.hasNext()?(this._xStart+=this.dx,this._yStart+=this.dy,this._distance=0,this._index+=1,this):null}prev(){return this.hasPrev()?(this._index-=1,this._xStart-=this.dx,this._yStart-=this.dy,this._distance=1,this):(this._done=!0,null)}_seekBackwards(t,e){const s=this.backwardLength;if(t<=s)return this._distance=(s-t)/this.length,this;let r=this.backwardLength;for(;this.prev();){if(r+this.length>t)return this._seekBackwards(t-r);r+=this.length}return this._distance=0,e?this:null}seek(t,e=!1){if(t<0)return this._seekBackwards(Math.abs(t),e);if(t<=this.remainingLength)return this._distance=(this.backwardLength+t)/this.length,this;let s=this.remainingLength;for(;this.next();){if(s+this.length>t)return this.seek(t-s,e);s+=this.length}return this._distance=1,e?this:null}}function Uh(t,e,s,r=!0){const i=function(t){let e=0;for(let s=0;s<Nh(t);s++)e+=Bh(t,s);return e}(t),n=Gh.create(t),o=i/2;if(!r)return n.seek(o),void(Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),0,o+0*e,i));const a=Math.max((i-e)/2,0),h=Math.floor(a/e),c=o-h*e;n.seek(c);for(let t=-h;t<=h;t++)Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),t,o+t*e,i),n.seek(e)}function Vh(t,e){const s=e;for(let e=0;e<t.length;e++){let r=t[e];qh(r,s);const i=[];i.push(r[0]);for(let t=1;t<r.length;t++){const[e,s]=r[t-1],[n,o]=r[t],a=n-e,h=o-s;i.push([a,h])}t[e]=i,r=i}return t}function qh(t,e){const s=1e-6;if(e<=0)return;const r=t.length;if(r<3)return;const i=[];let n=0;i.push(0);for(let e=1;e<r;e++)n+=Lh(t[e],t[e-1]),i.push(n);e=Math.min(e,.2*n);const o=[];o.push(t[0][0]),o.push(t[0][1]);const a=t[r-1][0],h=t[r-1][1],c=Oh([0,0],t[0],t[1]);Dh(c),t[0][0]+=e*c[0],t[0][1]+=e*c[1],Oh(c,t[r-1],t[r-2]),Dh(c),t[r-1][0]+=e*c[0],t[r-1][1]+=e*c[1];for(let t=1;t<r;t++)i[t]+=e;i[r-1]+=e;const l=.5*e;for(let n=1;n<r-1;n++){let a=0,h=0,c=0;for(let r=n-1;r>=0&&!(i[r+1]<i[n]-l);r--){const o=l+i[r+1]-i[n],u=i[r+1]-i[r],d=i[n]-i[r]<l?1:o/u;if(Math.abs(d)<s)break;const _=d*d,p=d*o-.5*_*u,f=d*u/e,g=t[r+1],m=t[r][0]-g[0],y=t[r][1]-g[1];a+=f/p*(g[0]*d*o+.5*_*(o*m-u*g[0])-_*d*u*m/3),h+=f/p*(g[1]*d*o+.5*_*(o*y-u*g[1])-_*d*u*y/3),c+=f}for(let o=n+1;o<r&&!(i[o-1]>i[n]+l);o++){const r=l-i[o-1]+i[n],u=i[o]-i[o-1],d=i[o]-i[n]<l?1:r/u;if(Math.abs(d)<s)break;const _=d*d,p=d*r-.5*_*u,f=d*u/e,g=t[o-1],m=t[o][0]-g[0],y=t[o][1]-g[1];a+=f/p*(g[0]*d*r+.5*_*(r*m-u*g[0])-_*d*u*m/3),h+=f/p*(g[1]*d*r+.5*_*(r*y-u*g[1])-_*d*u*y/3),c+=f}o.push(a/c),o.push(h/c)}o.push(a),o.push(h);for(let e=0,s=0;e<r;e++)t[e][0]=o[s++],t[e][1]=o[s++]}class Wh{static getPlacement(t,e,s,r,i,n){const o=function(t){if(!t)return null;switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":return $e.local();case"CIMMarkerPlacementAtExtremities":return Ze.local();case"CIMMarkerPlacementAtRatioPositions":return Ke.local();case"CIMMarkerPlacementInsidePolygon":return rs.local();case"CIMMarkerPlacementOnLine":return os.local();case"CIMMarkerPlacementOnVertices":return hs.local();case"CIMMarkerPlacementPolygonCenter":return Ts.local()}return null}(s);return o?(-1===e&&t.invertY(),o.execute(t,s,r,i,n)):null}}class jh{constructor(t){const{offsetX:e,offsetY:s,postAngle:r,fontSize:i,haloSize:n,outlineSize:o,scaleFactor:a,transforms:h}=t;if(this.offsetX=e,this.offsetY=s,this.postAngle=r,this.fontSize=Math.min(i,96),this.haloSize=n??0,this.outlineSize=o??0,this.transforms=h,h&&h.infos.length>1){const t=(0,Te.zb)(i,r,!1,e,s,h,!1);this.fontSize=Math.min(t.size,96);const n=t.size/i;this.haloSize*=n,this.outlineSize*=n,this.postAngle=t.rotation,this.offsetX=t.offsetX,this.offsetY=t.offsetY}a&&(this.fontSize*=a,this.offsetX*=a,this.offsetY*=a)}}const Yh=[4,4],Xh=[16,4],$h={topLeft:Xh,topRight:Xh,bottomLeft:Xh,bottomRight:Xh},Hh=[4,2],Zh=[4,6],Qh={topLeft:Hh,topRight:Hh,bottomLeft:Zh,bottomRight:Zh},Kh={topLeft:Hh,topRight:Zh,bottomLeft:Hh,bottomRight:Zh},Jh={topLeft:Zh,topRight:Zh,bottomLeft:Yh,bottomRight:Yh},tc={topLeft:Yh,topRight:Yh,bottomLeft:Zh,bottomRight:Zh},ec={topLeft:Zh,topRight:Yh,bottomLeft:Zh,bottomRight:Yh},sc={topLeft:Yh,topRight:Zh,bottomLeft:Yh,bottomRight:Zh},rc={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:dt.pe.UNSIGNED_SHORT,count:2,packPrecisionFactor:B.fq,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||28]},clipAngle:{type:dt.pe.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>nc(t||0)},referenceSymbol:{type:dt.pe.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,e)=>{const s=t.isLineLabel||!t.referenceBounds,r=function(t){switch(t){case qs.Right:case"right":return-1;case qs.Center:case"center":return 0;case qs.Left:case"left":return 1;default:return console.debug(`Found invalid horizontal alignment ${t}`),0}}(s?"center":e.horizontalAlignment),i=function(t){switch(t){case Ws.Top:case"top":return 1;case Ws.Center:case"middle":return 0;case Ws.Bottom:case Ws.Baseline:case"baseline":case"bottom":return-1;default:return console.debug(`Found invalid vertical alignment ${t}`),0}}(s?"middle":e.verticalAlignment),{offsetX:n,offsetY:o,size:a}=s?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[(0,l.Lz)(n),-(0,l.Lz)(o),Math.round((0,l.Lz)(a)),r+1<<2|i+1]}}},attributes:{pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>Et([[0,t],[3,!!e]])},offset:{type:dt.pe.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:r,topRight:i}=t;return[r,i,e,s]}}},textureUV:{type:dt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:r,topRight:i}=t;return[r,i,e,s]}}},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:dt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>Math.round((0,l.Lz)(t))},referenceSize:{type:dt.pe.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:e})=>Math.round((0,l.Lz)(e??t))},outlineColor:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>zt(t)},haloColor:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>zt(t)},outlineAndHaloSize:{type:dt.pe.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:e})=>[Math.round((0,l.Lz)(t)),Math.round((0,l.Lz)(e))]}}};class ic extends br{constructor(){super(...arguments),this.vertexSpec=rc,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new jh(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,s){const r=this._getShaping();if(!r)return;const i=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,r,s);if(s?.nextPath())return s.nextPoint(),this._writeGlyphs(t,i,s.x,s.y,r,0);if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[n,o]=s.coords;return this._writeGlyphs(t,i,n,o,r,0)}if("esriGeometryMultipoint"===e.geometryType){const s=e.readGeometryForDisplay();return void s?.forEachVertex(((e,s)=>this._writeGlyphs(t,i,e,s,r,0)))}const n=e.readXForDisplay(),o=e.readYForDisplay();return this._writeGlyphs(t,i,n,o,r,0)}_writePlacedTextMarkers(t,e,s,r){const i=r??Yt.fromFeatureSetReaderCIM(e);if(!i)return;const n=Wh.getPlacement(i,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,ur());if(!n)return;const o=e.getDisplayId();let a=n.next();for(;null!=a;){const e=a.tx,r=-a.ty,i=-a.getAngle();this._writeGlyphs(t,o,e,r,s,i),a=n.next()}}_getShaping(t){const e=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const r=(0,l.Lz)(e.fontSize),i=(0,l.Lz)(e.offsetX),n=(0,l.Lz)(e.offsetY),o=(0,ks.qE)((0,l.Lz)(s.lineWidth),B.GR,B.cp),a=B.DY*(0,ks.qE)(s.lineHeightRatio,.25,4);return function(t,e){const s=e.scale,r=new Array,{glyphs:i,isRightToLeft:n}=t,o=function(t,e,s){const r=new Array,i=1/s.scale,n=s.maxLineWidth*i,o=e?t.length-1:0,a=e?-1:t.length,h=e?-1:1;let c=o,l=0,u=0,d=c,_=d,p=0,f=1/0,g=0;for(;c!==a;){const{code:e,metrics:s}=t[c],i=Math.abs(s.top);if(sr(e)||rr(e)||(f=Math.min(f,i),g=Math.max(g,i+s.height)),sr(e))c!==o&&(r.push(new er(t,d,c-h,l,f===1/0?0:f,g)),f=1/0,g=0),l=0,d=c+h,_=c+h,u=0;else if(rr(e))_=c+h,u=0,p=s.advance,l+=s.advance;else if(l>n){if(_!==d){const e=_-2*h;l-=p,r.push(new er(t,d,e,l-u,f,g)),f=1/0,g=0,d=_,l=u}else r.push(new er(t,d,c-h,l,f,g)),f=1/0,g=0,d=c,_=c,l=0;l+=s.advance,u+=s.advance}else l+=s.advance,u+=s.advance;c+=h}const m=new er(t,d,c-h,l,f,g);return m.start>=0&&m.end<t.length&&r.push(m),r}(i,n,e),a=o.length?function(t,e){let s=0;for(let e=0;e<t.length;e++){const{width:r}=t[e];s=Math.max(r,s)}const r="underline"===e.decoration?4:0,i=t[0].yMin;return{x:0,y:i,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+r-i,width:s}}(o,e):{x:0,y:0,height:0,width:0},h=Ys(e.horizontalAlignment),c=Xs(e.verticalAlignment),l=c===Ws.Baseline?1:0,u=l?0:c-1,d=(1-l)*-a.y+u*(a.height/2)+-22*(l?1:0);for(let n=0;n<o.length;n++){const{start:a,end:c,width:l}=o[n];let u=-1*(h+1)*(l/2)-3;const _=(t.isRightToLeft?o.length-1-n:n)*e.lineHeight+d-3;o[n].startX=u,o[n].startY=_;for(let t=a;t<=c;t++){const e=i[t];if(sr(e.code))continue;const n=new Qs(u+e.metrics.left,_-e.metrics.top,e,s);u+=e.metrics.advance,r.push(n)}}return new tr(r,o,e)}(s.glyphs,{scale:r/B.eG,angle:e.postAngle,xOffset:i,yOffset:n,horizontalAlignment:s.horizontalAlignment,verticalAlignment:t||s.verticalAlignment,maxLineWidth:o,lineHeight:a,decoration:s.decoration,borderLineSizePx:(0,l.Lz)(s.boxBorderLineSize),hasBackground:!!s.boxBackgroundColor,useCIMAngleBehavior:s.useCIMAngleBehavior})}_writeGlyphs(t,e,s,r,i,n,o,a){const h=this.evaluatedMeshParams,c=this._textMeshTransformProps,u=(0,l.Lz)(c.fontSize),d=c.haloSize,_=c.outlineSize,p=(0,l.Lz)(c.offsetX),f=(0,l.Lz)(c.offsetY),[g,m]=kt(h.scaleInfo,this.getTileInfo());0!==n&&i.setRotation(n);const y=i.bounds,x=s+y.x+p,b=r+y.y-f,w=2*(h.minPixelBuffer?h.minPixelBuffer/u:1),v=Math.max(y.width,y.height)*w;i.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),t.recordBounds(x,b,v,v),this._writeTextBox(t,e,s,r,i.textBox,o,a),t.recordEnd());for(const n of i.glyphs){t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(x,b,v,v);const{texcoords:i,offsets:c}=n;this._writeQuad(t,e,s,r,{texcoords:i,offsets:c,fontSize:u,haloSize:d,outlineSize:_,color:zt(h.color),isBackground:!1,referenceBounds:o,minZoom:g,maxZoom:m,...a}),t.recordEnd()}0!==n&&i.setRotation(-n)}_writeTextBox(t,e,s,r,i,n,o){const a=this.evaluatedMeshParams,{fontSize:h,haloSize:c,outlineSize:l}=this._textMeshTransformProps,{boxBackgroundColor:u,boxBorderLineColor:d}=a,_={isBackground:!0,fontSize:h,haloSize:c,outlineSize:l,referenceBounds:n,...o};u&&(this._writeQuad(t,e,s,r,{texcoords:$h,offsets:i.main,color:zt(u),..._}),d||(this._writeQuad(t,e,s,r,{texcoords:Jh,offsets:i.top,color:zt(u),..._}),this._writeQuad(t,e,s,r,{texcoords:tc,offsets:i.bot,color:zt(u),..._}),this._writeQuad(t,e,s,r,{texcoords:ec,offsets:i.left,color:zt(u),..._}),this._writeQuad(t,e,s,r,{texcoords:sc,offsets:i.right,color:zt(u),..._}))),d&&(this._writeQuad(t,e,s,r,{texcoords:Qh,offsets:i.top,color:zt(d),..._}),this._writeQuad(t,e,s,r,{texcoords:Qh,offsets:i.bot,color:zt(d),..._}),this._writeQuad(t,e,s,r,{texcoords:Kh,offsets:i.left,color:zt(d),..._}),this._writeQuad(t,e,s,r,{texcoords:Kh,offsets:i.right,color:zt(d),..._}))}_writeQuad(t,e,s,r,i){const n=t.vertexCount();this._writeVertex(t,e,s,r,i),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}}const nc=t=>Math.round(t*(254/360)),oc=(0,A.Bj)((t=>{let e=0;if(0===t)return 1/0;for(;!(t%2);)e++,t/=2;return e}));class ac extends ic{constructor(){super(...arguments),this._zoomLevel=0}_write(t,e,s,r){if(this._zoomLevel=r||0,null!=s)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(e.geometryType){case"esriGeometryPoint":{const s=e.readXForDisplay(),r=e.readYForDisplay();this._writePoint(t,s,r,e);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const s=e.readCentroidForDisplay();if(!s)return;const[r,i]=s.coords;this._writePoint(t,r,i,e);break}case"esriGeometryPolyline":this._writeLines(t,e)}}_createLineLabelMetric(t,e,s,r){const i=Fh(t),n="right"===this.evaluatedMeshParams.horizontalAlignment?-1:1,o="bottom"===this.evaluatedMeshParams.verticalAlignment?-1:1,a=this.evaluatedMeshParams.scaleInfo?.maxScale??0,h=this.evaluatedMeshParams.scaleInfo?.minScale??0;return new Eh(i,e,s,n,o,a,h,r??null)}_writePoint(t,e,s,r){const i=this._getShaping();if(!i)return;const n=r.getDisplayId(),o=Ys(this.evaluatedMeshParams.horizontalAlignment),a=Xs(this.evaluatedMeshParams.verticalAlignment),h=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,l=Fh(r.getDisplayId()),u=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};t.metricStart(new Eh(l,e,s,o,a,h,c,u)),this._writeGlyphs(t,n,e,s,i,0,u),t.metricBoxWrite(i.boundsT),t.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const t of this._references){const e=t.getBoundsInfo();if(e)return e}return null}_writeLines(t,e){const{scaleInfo:s,verticalAlignment:r}=this.evaluatedMeshParams,i=this.evaluatedMeshParams.repeatLabelDistance||128,n=this._getShaping("middle");if(!n)return;const o=(t,e,s,r)=>this._placeSubdivGlyphs(t,e,s,r),a=(n.bounds.width+i)/2;this._current={out:t,id:e.getDisplayId(),shaping:n,zoomRange:kt(s,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(e,o,a):this._writeCenterAlong(e,o,a)}_writeAboveAndBelowAlong(t,e,s){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:i}=this._current,n=i.bounds.halfHeight,o=t.readGeometryForDisplay();if(!o)return;const a=new jt.A;(0,Ch.kz)(a,o,!1,!1,"esriGeometryPolyline",1);const h=hc(new jt.A,a,n),c=hc(new jt.A,a,-n),l=(0,Ch.zv)(c,"esriGeometryPolyline",!1,!1),u=Vh((0,Ch.zv)(h,"esriGeometryPolyline",!1,!1).paths,i.bounds.width),d=Vh(l.paths,i.bounds.width);this._current.offsetDirection="above";for(const t of u)Uh(t,s,e,!!r);this._current.offsetDirection="below";for(const t of d)Uh(t,s,e,!!r)}_writeCenterAlong(t,e,s){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:i}=this._current,n=Vh(t.readLegacyGeometryForDisplay().paths,i.bounds.width);for(const t of n)Uh(t,s,e,!!r)}_placeSubdivGlyphs(t,e,s,r){const{allowOverrun:i,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],h=oc(e),c=this._current.shaping.bounds.width/2,l=Math.sqrt(o||128)/2,u=Math.min(s,r-s),d=this._current.shaping.isMultiline?28:Math.log2(u/(l+c/2)),_=0===e?d:Math.min(h,d),p=Math.max(a,this._zoomLevel+1-_),f=this._zoomLevel-p,g=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===e&&this._placeStraight(t,p):i&&f<0?this._placeStraightAlong(t,a):"parallel"===n?this._placeStraightAlong(t,p):"curved"===n&&this._placeCurved(t,p,g)}_placeStraight(t,e){const{out:s,id:r,shaping:i,referenceBounds:n}=this._current,{x:o,y:a}=t;s.metricStart(this._createLineLabelMetric(r,o,a)),s.metricBoxWrite(i.boundsT);const h=t.angle*(180/Math.PI)%360,c=(t.angle*(180/Math.PI)+180)%360;this._writeGlyphs(s,r,o,a,i,0,n,{clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:e}),this._writeGlyphs(s,r,o,a,i,0,n,{clipAngle:c,mapAligned:!0,isLineLabel:!0,minZoom:e}),s.metricEnd()}_placeCurved(t,e,s){const{out:r,id:i}=this._current;r.metricStart(this._createLineLabelMetric(i,t.x,t.y));const n=t.clone(),o=t.angle*(180/Math.PI)%360,a=(t.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(n,e,1,o),this._placeBack(t,n,e,s,1,o),this._placeForward(t,n,e,s,1,o)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(n,e,0,a),this._placeBack(t,n,e,s,0,a),this._placeForward(t,n,e,s,0,a)),r.metricEnd()}_placeStraightAlong(t,e){const{out:s,id:r,shaping:i,zoomRange:n,referenceBounds:o}=this._current,{boxBorderLineColor:a,boxBackgroundColor:h}=this.evaluatedMeshParams,c=t.clone(),u=t.angle*(180/Math.PI)%360,d=(t.angle*(180/Math.PI)+180)%360,_=i.glyphs.length>0&&!(!a&&!h);if(s.metricStart(this._createLineLabelMetric(r,t.x,t.y)),_){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),c=Ds(Gs(),-t.angle),_={minZoom:a,maxZoom:h,clipAngle:u,mapAligned:!0,isLineLabel:!0},p=(0,l.Lz)(this.evaluatedMeshParams.offsetX),f=(0,l.Lz)(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e=(0,js.fA)(p,-1*f),[n,a]=i.shapeBackground(Rs(Gs(),c,e));s.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding);const h=2*Math.max(n.width,n.height);s.recordBounds(t.x+n.x,t.y+n.y,h,h),this._writeTextBox(s,r,t.x,t.y,a,o,_),s.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e=(0,js.fA)(p,f),[n,a]=i.shapeBackground(Rs(Gs(),c,e));_.clipAngle=d,s.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding);const h=2*Math.max(n.width,n.height);s.recordBounds(t.x+n.x,t.y+n.y,h,h),this._writeTextBox(s,r,t.x,t.y,a,o,_),s.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(c,e,1,u,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(c,e,0,d,!0),s.metricEnd()}_placeBack(t,e,s,r,i,n){const o=t.clone();let a=t.backwardLength+0;for(;o.prev()&&!(a>=r);)this._placeOnSegment(o,e,a,s,-1,i,n),a+=o.length+0}_placeForward(t,e,s,r,i,n){const o=t.clone();let a=t.remainingLength+0;for(;o.next()&&!(a>=r);)this._placeOnSegment(o,e,a,s,1,i,n),a+=o.length+0}_placeFirst(t,e,s,r,i=!1){const{out:n,id:o,shaping:a,zoomRange:h,referenceBounds:c}=this._current,l=a.glyphs;for(const u of l){const l=u.x>a.bounds.x?s:1-s,d=l*t.remainingLength+(1-l)*t.backwardLength,_=Math.abs(u.x+u.width/2-a.bounds.x),p=Math.max(0,this._zoomLevel+Math.log2(_/(d+0))),f=Math.max(e,i?0:p);u.maxZoom=Math.min(h[1],28),u.angle=t.angle+(1-s)*Math.PI,u.minZoom=Math.max(h[0],f),this._writeLineGlyph(n,o,t.x,t.y,a.bounds,u,r,c,!0),(s||this._current.offsetDirection)&&this._isVisible(u.minZoom,u.maxZoom)&&n.metricBoxWrite(u.bounds)}}_placeOnSegment(t,e,s,r,i,n,o){const{out:a,id:h,shaping:c,referenceBounds:l}=this._current,u=c.glyphs,d=t.dx/t.length,_=t.dy/t.length,p={x:t.x+s*-i*d,y:t.y+s*-i*_};for(const e of u){const u=e.x>c.bounds.x?n:1-n;if(!(u&&1===i||!u&&-1===i))continue;const d=Math.abs(e.x+e.width/2-c.bounds.x),_=Math.max(0,this._zoomLevel+Math.log2(d/s)-.1),f=Math.max(r,this._zoomLevel+Math.log2(d/(s+t.length+0)));0!==_&&(e.angle=t.angle+(1-n)*Math.PI,e.minZoom=f,e.maxZoom=_,this._writeLineGlyph(a,h,p.x,p.y,c.bounds,e,o,l,!0),(n||this._current.offsetDirection)&&this._isVisible(e.minZoom,e.maxZoom)&&a.metricBoxWrite(e.bounds))}}_writeLineGlyph(t,e,s,r,i,n,o,a,h){const c=s+i.x,l=r+i.y,u=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(i.width,i.height)*u;t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(c,l,d,d);const{texcoords:_,offsets:p}=n,{fontSize:f,haloSize:g,outlineSize:m}=this._textMeshTransformProps;this._writeQuad(t,e,s,r,{texcoords:_,offsets:p,fontSize:f,haloSize:g,outlineSize:m,color:zt(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],n.minZoom),maxZoom:Math.min(this._current.zoomRange[1],n.maxZoom),clipAngle:o,mapAligned:h,isLineLabel:!0}),t.recordEnd()}_isVisible(t,e){const s=Math.floor(this._zoomLevel*B.fq)/B.fq;return t<=s&&s<=e}}function hc(t,e,s){const{coords:r,lengths:i}=e,n=(0,Ah.vt)(),o=(0,Ah.vt)(),a=(0,Ah.vt)(),h=(0,Ah.vt)(),c=(0,Ah.vt)(),l=(0,Ah.vt)();let u=0;for(let e=0;e<i.length;e++){const d=i[e];for(let e=0;e<d;e++){const i=2*(e+u-1),_=2*(e+u),p=2*(e+u+1);e>0?(0,O.hZ)(n,r[i],r[i+1]):(0,O.hZ)(n,0,0),(0,O.hZ)(o,r[_],r[_+1]),e<d-1?(0,O.hZ)(a,r[p],r[p+1]):(0,O.hZ)(a,0,0),0===e?(0,O.hZ)(h,0,0):((0,O.jb)(h,o,n),(0,O.S8)(h,h),(0,O.hZ)(h,h[1],-h[0])),e===d-1?(0,O.hZ)(c,0,0):((0,O.jb)(c,a,o),(0,O.S8)(c,c),(0,O.hZ)(c,c[1],-c[0])),(0,O.WQ)(l,h,c),(0,O.S8)(l,l);const f=l[0]*c[0]+l[1]*c[1];0!==f&&(0,O.hs)(l,l,f),(0,O.hs)(l,l,s),t.coords.push(o[0]+l[0],o[1]+l[1])}t.lengths.push(d),u+=d}return t}const cc={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({gradientMethod:t,gradientSizeUnits:e,gradientType:s})=>Et([[0,"alongline"===t.toLowerCase()],[1,e===Ct.OW.Absolute],[2,"discrete"===s.toLowerCase()]])},tlbr:{type:dt.pe.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM+B.MZ,n=e.y+B.hM;return[i,n,i+s-2*B.MZ,n+r]}},accumulatedDistance:{type:dt.pe.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},gradientSize:{type:dt.pe.HALF_FLOAT,count:1,pack:({gradientSize:t,gradientSizeUnits:e})=>e===Ct.OW.Relative?t/100:(0,l.Lz)(t)},totalLength:{type:dt.pe.HALF_FLOAT,count:1,packTessellation:({pathLength:t})=>t},segmentDirection:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]}}};class lc extends bi{get _preventEffectClipping(){return!0}constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=cc,this._tessellationOptions.textured=!0}_write(t,e,s){const r=s??Yt.fromFeatureSetReaderCIM(e);if(!r)return;const{sprite:i}=this.evaluatedMeshParams;this._writeGeometry(t,e,r,i?.textureBinding)}}const uc={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:t,shouldScaleDash:e,isSDF:s})=>Et([[4,t],[2,e],[3,s]])},tlbr:{type:dt.pe.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM,n=e.y+B.hM;return[i,n,i+s,n+r]}},accumulatedDistance:{type:dt.pe.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},segmentDirection:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]},offsetAlongLine:{type:dt.pe.HALF_FLOAT,count:1,pack:({offsetAlongLine:t})=>(0,l.Lz)(t)},capType:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({capType:t})=>{switch(t){case Ct.uT.Butt:case"butt":return 0;case Ct.uT.Square:case"square":return 1;case Ct.uT.Round:case"round":return 2;default:return 0}}}}};class dc extends bi{constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=uc,this._tessellationOptions.textured=!0}_write(t,e,s){const r=s??Yt.fromFeatureSetReaderCIM(e);if(!r)return;const{sprite:i}=this.evaluatedMeshParams;this._writeGeometry(t,e,r,i?.textureBinding)}}class _c{static from(t){return"width"in t?this.fromSimpleMeshParams(t):this.fromComplexMeshParams(t)}static fromSimpleMeshParams(t){const e=new _c(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects),{type:s,width:r,height:i,angle:n,alignment:o,outlineSize:a,referenceSize:h,sprite:c,overrideOutlineColor:u}=t;return e.rawWidth=(0,l.Lz)(r),e.rawHeight=(0,l.Lz)(i),e.angle=n,e.alignment=o,e.outlineSize=(0,l.Lz)(a),e.referenceSize=(0,l.Lz)(h),e.overrideOutlineColor=u,e.offsetX=(0,l.Lz)(t.offsetX),e.offsetY=(0,l.Lz)(t.offsetY),"simple"!==s||c.sdf||(e.rawWidth=c.width,e.rawHeight=c.height),e._computeSize(t,!1),e}static fromComplexMeshParams(t){const e=new _c(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects);let{alignment:s,transforms:r,size:i,scaleX:n,anchorX:o,anchorY:a,angle:h,colorLocked:c,frameHeight:u,widthRatio:d,offsetX:_,offsetY:p,outlineSize:f,referenceSize:g,scaleFactor:m,sizeRatio:y,isAbsoluteAnchorPoint:x,rotateClockwise:b,scaleSymbolsProportionally:w,sprite:v}=t;if(r&&r.infos.length>0){const t=(0,Te.zb)(i,h,b,_,p,r);i=t.size,h=t.rotation,_=t.offsetX,p=t.offsetY,b=!1}m&&(i*=m,_*=m,p*=m);const S=n*(v.width/v.height);e.alignment=s,e.rawHeight=(0,l.Lz)(i),e.rawWidth=e.rawHeight*S,e.referenceSize=(0,l.Lz)(g),e.sizeRatio=y,e.sdfDecodeCoeff=(v.sdfDecodeCoeff??1)*y,e.angle=h,e.rotateClockwise=b,e.anchorX=o,e.anchorY=a,e.offsetX=(0,l.Lz)(_),e.offsetY=(0,l.Lz)(p),x&&i&&(v.sdf?e.anchorX=o/(i*d):e.anchorX=o/(i*S),e.anchorY=a/i);const I=w&&u?i/u:1;return e.outlineSize=0===f||isNaN(f)?0:(0,l.Lz)(f)*I,e.scaleSymbolsProportionally=w,e.colorLocked=c,e._computeSize(t,!0),e}constructor(t,e,s,r,i,n,o){this.sprite=t,this.color=e,this.outlineColor=s,this.minPixelBuffer=r,this.placement=i,this.scaleInfo=n,this.effects=o,this.rawWidth=0,this.rawHeight=0,this.angle=0,this.outlineSize=0,this.referenceSize=0,this.sizeRatio=1,this.sdfDecodeCoeff=1,this.alignment=Ct.C1.SCREEN,this.scaleSymbolsProportionally=!1,this.overrideOutlineColor=!1,this.colorLocked=!1,this.anchorX=0,this.anchorY=0,this.computedWidth=0,this.computedHeight=0,this.texXmin=0,this.texYmin=0,this.texXmax=0,this.texYmax=0,this.offsetX=0,this.offsetY=0,this.rotateClockwise=!0}get boundsInfo(){return{size:Math.max(this.computedHeight,this.computedWidth),offsetX:this.offsetX,offsetY:this.offsetY}}_computeSize(t,e){const{sprite:s,hasSizeVV:r}=t,i=!!s.sdf,n=s.sdfPaddingRatio??.5,{rawWidth:o,rawHeight:a,sizeRatio:h,outlineSize:c}=this;let l=o*h,u=a*h,d=0,_=0;if(i){const t=1/(1-n);if(l*=t,u*=t,r)this.computedWidth=l,this.computedHeight=u;else{const t=e&&o>a?l:o,r=a,i=c+2;this.computedWidth=Math.min(t+i,l),this.computedHeight=Math.min(r+i,u);const n=Math.max(s.width,s.height)/Math.max(l,u);d=(this.computedWidth-l)*n,_=(this.computedHeight-u)*n}}else this.computedWidth=l*(s.rect.width/s.width),this.computedHeight=u*(s.rect.height/s.height),d=2*B.hM,_=2*B.hM;const p=s.rect.x+B.hM-d/2,f=s.rect.y+B.hM-_/2,g=p+s.width+d,m=f+s.height+_;this.texXmin=pc(p),this.texYmin=pc(f),this.texXmax=fc(g),this.texYmax=fc(m),this.computedWidth*=(this.texXmax-this.texXmin)/(g-p),this.computedHeight*=(this.texYmax-this.texYmin)/(m-f),this.anchorX*=l/this.computedWidth,this.anchorY*=u/this.computedHeight}}function pc(t,e=1e-7){const s=Math.ceil(t);return s-t<e?s:Math.floor(t)}function fc(t,e=1e-7){const s=Math.floor(t);return t-s<e?s:Math.ceil(t)}const gc=128/Math.PI;const mc={createComputedParams:t=>_c.from(t),optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({sprite:t,alignment:e,scaleSymbolsProportionally:s,overrideOutlineColor:r,colorLocked:i})=>{let n=0;return t.sdf&&(n|=Ft(Dt)),e===Ct.C1.MAP&&(n|=Ft(Lt)),s&&(n|=Ft(Nt)),r&&(n|=Ft(Bt)),i&&(n|=Ft(Gt)),n}},offset:{type:dt.pe.HALF_FLOAT,count:2,packAlternating:{count:4,pack:({angle:t,computedWidth:e,computedHeight:s,anchorX:r,anchorY:i,offsetX:n,offsetY:o,rotateClockwise:a})=>{const h=function(t,e,s,r,i=!1){const n=Gs(),o=i?1:-1;return Es(n),(e||s)&&Rs(n,n,[e,-s]),r&&Os(n,n,.017453292519944444*o*-r),n}(0,n,o,-t,a),c=-(.5+r)*e,l=-(.5-i)*s,u=[c,l],d=[c+e,l],_=[c,l+s],p=[c+e,l+s];return(0,O.l0)(u,u,h),(0,O.l0)(d,d,h),(0,O.l0)(_,_,h),(0,O.l0)(p,p,h),[u,d,_,p]}}},textureUV:{type:dt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:t,texXmin:e,texYmax:s,texYmin:r})=>[[e,r],[t,r],[e,s],[t,s]]}},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)},outlineColor:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>zt(t)},sizing:{type:dt.pe.UNSIGNED_BYTE,count:4,pack:({rawWidth:t,rawHeight:e,outlineSize:s,referenceSize:r})=>[Ot(Math.max(t,e),128),Ot(s,128),Ot(r,128),0]},placementAngle:{type:dt.pe.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:t})=>function(t){return function(t){return t%=256,Math.abs(t>=0?t:t+256)}(t*gc)}(t)},sdfDecodeCoeff:{type:dt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sdfDecodeCoeff:t})=>t}}};class yc extends br{constructor(){super(...arguments),this.vertexSpec=mc}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(t,e,s){const r=this.evaluatedMeshParams.sprite?.textureBinding,i=e.getDisplayId();t.recordStart(this.instanceId,this.attributeLayout,r);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),h=-this.evaluatedMeshParams.anchorX*this.evaluatedMeshParams.computedWidth,c=this.evaluatedMeshParams.anchorY*this.evaluatedMeshParams.computedHeight,l=this.evaluatedMeshParams.offsetX+h,u=-this.evaluatedMeshParams.offsetY+c;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(t,e,s,o,a);else if(s?.nextPath()){s.nextPoint();const e=s.x,r=s.y;t.recordBounds(e+l,r+u,o,a),this._writeQuad(t,i,e,r)}else if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[r,n]=s.coords;t.recordBounds(r+l,n+u,o,a),this._writeQuad(t,i,r,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),r=e.readYForDisplay();t.recordBounds(s+l,r+u,o,a),this._writeQuad(t,i,s,r)}else{const s=e.readGeometryForDisplay();s?.forEachVertex(((e,s)=>{t.recordBounds(e+l,s+u,o,a),Math.abs(e)>zh||Math.abs(s)>zh||this._writeQuad(t,i,e,s)}))}t.recordEnd()}_writePlacedMarkers(t,e,s,r,i){const n=s??Yt.fromFeatureSetReaderCIM(e)?.clone();if(!n)return;const o=Wh.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,ur());if(!o)return;const a=e.getDisplayId();let h=o.next();const c=this.evaluatedMeshParams.offsetX,u=-this.evaluatedMeshParams.offsetY;for(;null!=h;){const e=h.tx,s=-h.ty;if(Math.abs(e)>zh||Math.abs(s)>zh){h=o.next();continue}const n=-h.getAngle();t.recordBounds(e+c,s+u,r,i),this._writeQuad(t,a,e,s,n),h=o.next()}}_writeQuad(t,e,s,r,i){const n=t.vertexCount(),o=null==i?null:{placementAngle:i};this._writeVertex(t,e,s,r,o),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}}var xc=s(4576),bc=s(71386);function wc(t,e){let s;if("string"==typeof t)s=(0,lt.Wm)(t+`-seed(${e})`);else{let r=12;s=t^e;do{s=107*(s>>8^s)+r|0}while(0!=--r)}return(1+s/(1<<31))/2}function vc(t){return Math.floor(wc(t,Sc)*Ic)}const Sc=53290320,Ic=10;var Mc;!function(t){t.Local="Local",t.Global="Global"}(Mc||(Mc={}));class Pc{generateSource(t){const e=[];for(let s=1;s<this.length;s++)e.push(`vec4 atom${s} = texture(${t.animationTexture}, (pointer + 0.5) / size);`),e.push("pointer.x += 1.0;");for(let t=0;t<this.ins;t++)e.push("top--;"),e.push(`vec4 in${this.ins-t-1} = stack[top];`);for(let t=0;t<this.outs;t++)e.push(`vec4 out${t};`);const{microcode:s}=this;for(const t of s)e.push(t);for(let t=0;t<this.outs;t++)e.push(`stack[top] = out${t};`),e.push("top++;"),e.push(`if (top >= ${Oc}) { top = ${Oc-1}; }`);return e}}let Tc=128;function Ac(t){return[`float duration = clamp(${t.duration}, 0.05, 3600.0);`,`float startTimeOffset = ${t.startTimeOffset};`,`float repeatDelay = ${t.repeatDelay};`,`float timeOriginSelector = ${t.timeOriginSelector};`,`float repeatType = ${t.repeatType};`,`float easing = ${t.easing};`,`float playAnimation = ${t.playAnimation} * (1.0 - step(0.0, -${t.duration}));`,`float reverseAnimation = ${t.reverseAnimation};`,"float time = globalTime - (timeOriginSelector == 1.0 ? localTimeOrigin : 0.0);","time *= playAnimation;","time *= 1.0 - reverseAnimation * 2.0;","float period = duration + repeatDelay;","time += reverseAnimation == 1.0 ? (period - startTimeOffset - 0.001) : startTimeOffset + 0.001;","float omega = time / period;","float oi = floor(omega);","omega = repeatType == 1.0 || repeatType == 3.0 ? omega - oi : omega;","float of = omega * period;","of = (clamp(of, reverseAnimation * repeatDelay, period - (1.0 - reverseAnimation) * repeatDelay) - reverseAnimation * repeatDelay) / duration;","of = easing == 2.0 ? pow(of, 3.0) : of;","of = easing == 3.0 ? 1.0 - pow(1.0 - of, 3.0) : of;","of = easing == 4.0 ? of < 0.5 ? 4.0 * pow(of, 3.0) : 1.0 - pow(-2.0 * of + 2.0, 3.0) / 2.0 : of;","bool oscillate = repeatType == 3.0 && mod(oi, 2.0) == 1.0;",`${t.out} = oscillate ? 1.0 - of : of;`]}const Cc={Linear:1,EaseIn:2,EaseOut:3,EaseInOut:4},kc={Loop:1,None:2,Oscillate:3},Fc={Local:1,Global:2};function Ec(t){const e=Cc[t.easing],s=kc[t.repeatType],r=Fc[t.timeOriginSelector];return[[t.duration,t.startTimeOffset,t.repeatDelay,r],[s,e,t.playAnimation,t.reverseAnimation]]}const zc={scalar:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=1,this.ins=0,this.outs=1,this.microcode=["out0 = vec4(atom0.y, atom0.y, atom0.y, atom0.y);"]}encode(t){return[[this.opcode,t,0,0]]}},vector3:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=1,this.ins=0,this.outs=1,this.microcode=["out0 = vec4(atom0.yzw, 0.0);"]}encode(t){return[[this.opcode,t[0]||0,t[1]||0,t[2]||0]]}},vector4:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=2,this.ins=0,this.outs=1,this.microcode=["out0 = atom1;"]}encode(t){return[[this.opcode,0,0,0],t]}},animatedTransform:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=10,this.ins=1,this.outs=1,this.microcode=["vec2 fromTranslation = atom1.xy;","vec2 toTranslation = atom1.zw;","float fromRotation = atom2.x;","float toRotation = atom2.y;","float fromScale = atom2.z;","float toScale = atom2.w;","bool relativeTranslation = atom9.x == 1.0;","bool absoluteScale = atom9.y == 1.0;","vec2 translationMultiplier = relativeTranslation ? pixelDimensions : vec2(1.0, 1.0);","float scaleDivisor = absoluteScale ? pixelDimensions.y : 1.0;","float fTranslation;","{",...Ac({duration:"atom3.x",startTimeOffset:"atom3.y",repeatDelay:"atom3.z",timeOriginSelector:"atom3.w",repeatType:"atom4.x",easing:"atom4.y",playAnimation:"atom4.z",reverseAnimation:"atom4.w",out:"fTranslation"}),"}","float fRotation;","{",...Ac({duration:"atom5.x",startTimeOffset:"atom5.y",repeatDelay:"atom5.z",timeOriginSelector:"atom5.w",repeatType:"atom6.x",easing:"atom6.y",playAnimation:"atom6.z",reverseAnimation:"atom6.w",out:"fRotation"}),"}","float fScale;","{",...Ac({duration:"atom7.x",startTimeOffset:"atom7.y",repeatDelay:"atom7.z",timeOriginSelector:"atom7.w",repeatType:"atom8.x",easing:"atom8.y",playAnimation:"atom8.z",reverseAnimation:"atom8.w",out:"fScale"}),"}","vec2 aTranslation = mix(fromTranslation, toTranslation, fTranslation);","float aRotation = mix(fromRotation, toRotation, fRotation);","float aScale = mix(fromScale, toScale, fScale);","vec2 pTranslation = in0.xy;","float pRotation = in0.z;","float pScale = in0.w;","aTranslation *= translationMultiplier;","aScale /= scaleDivisor;","float rotation = pRotation + aRotation;","float scale = pScale * aScale;","float sin1 = sin(pRotation);","float cos1 = cos(pRotation);","float s1 = pScale;","float x1 = pTranslation.x;","float y1 = pTranslation.y;","float x2 = aTranslation.x;","float y2 = aTranslation.y;","\n vec2 translation = vec2(\n cos1 * s1 * x2 - sin1 * s1 * y2 + x1,\n sin1 * s1 * x2 + cos1 * s1 * y2 + y1\n );\n ","out0 = vec4(translation, rotation, scale);"]}encode(t){return[[this.opcode,0,0,0],[t.translation.from[0],t.translation.from[1],t.translation.to[0],t.translation.to[1]],[t.rotation.from,t.rotation.to,t.scale.from,t.scale.to],...Ec(t.translation.timing),...Ec(t.rotation.timing),...Ec(t.scale.timing),[t.relativeTranslation?1:0,t.absoluteScale?1:0,0,0]]}},animatedColor:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=7,this.ins=1,this.outs=1,this.microcode=["float fromOpacity = atom0.y;","float toOpacity = atom0.z;","vec4 fromColor = atom1;","vec4 toColor = atom2;","float fColor;","{",...Ac({duration:"atom3.x",startTimeOffset:"atom3.y",repeatDelay:"atom3.z",timeOriginSelector:"atom3.w",repeatType:"atom4.x",easing:"atom4.y",playAnimation:"atom4.z",reverseAnimation:"atom4.w",out:"fColor"}),"}","float fOpacity;","{",...Ac({duration:"atom5.x",startTimeOffset:"atom5.y",repeatDelay:"atom5.z",timeOriginSelector:"atom5.w",repeatType:"atom6.x",easing:"atom6.y",playAnimation:"atom6.z",reverseAnimation:"atom6.w",out:"fOpacity"}),"}","vec4 aColor = mix(fromColor, toColor, fColor);","aColor.a *= mix(fromOpacity, toOpacity, fOpacity);","vec4 pColor = in0;","out0 = aColor * pColor;"]}encode(t){return[[this.opcode,t.opacity.from,t.opacity.to,0],[t.color.from[0],t.color.from[1],t.color.from[2],t.color.from[3]],[t.color.to[0],t.color.to[1],t.color.to[2],t.color.to[3]],...Ec(t.color.timing),...Ec(t.opacity.timing)]}},ret:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=1,this.ins=0,this.outs=0,this.microcode=["break;"]}encode(){return[[this.opcode,0,0,0]]}}},Oc=4;function Rc(t){return t instanceof Dc?t:"object"==typeof t&&"type"in t?Gc[t.type].hydrate(t):new Lc(t)}class Dc{constructor(t){this.inputs=t}encode(){const t=[];for(const e of this.inputs)t.push(...e.encode());return t.push(...this.instructions),t}}class Lc extends Dc{constructor(t){super([]),this.value=t}simplify(){return this}get instructions(){if(Array.isArray(this.value)){const[t,e,s,r]=this.value;return null!=r?zc.vector4.encode([t,e||0,s||0,r]):zc.vector3.encode([t,e||0,s||0])}return zc.scalar.encode(this.value)}}class Nc extends Dc{constructor(t,e){super([e]),this._config=t,this._parent=e}static hydrate(t){return new Nc(t,Rc(t.parent))}simplify(){if(this._config.relativeTranslation||this._config.absoluteScale)return this;const t=this._parent.simplify();if(!(t instanceof Lc))return this;const[e,s,r,i]=t.value,n=this._config.translation.from[0],o=this._config.translation.from[1],a=this._config.rotation.from,h=this._config.scale.from;if(n===this._config.translation.to[0]&&o===this._config.translation.to[1]&&a===this._config.rotation.to&&h===this._config.scale.to){const t=r+a,c=i*h,l=Math.sin(r),u=Math.cos(r);return new Lc([u*i*n-l*i*o+e,l*i*n+u*i*o+s,t,c])}return new Nc(this._config,t)}get instructions(){return zc.animatedTransform.encode(this._config)}}class Bc extends Dc{constructor(t,e){super([e]),this._config=t,this._parent=e}static hydrate(t){return new Bc(t,Rc(t.parent))}simplify(){const t=this._parent.simplify();if(!(t instanceof Lc))return this;const[e,s,r,i]=t.value,n=this._config.color.from[0],o=this._config.color.from[1],a=this._config.color.from[2];let h=this._config.color.from[3];const c=this._config.opacity.from;return n===this._config.color.to[0]&&o===this._config.color.to[1]&&a===this._config.color.to[2]&&h===this._config.color.to[3]&&c===this._config.opacity.to?(h*=c,new Lc([e*n,s*o,r*a,i*h])):new Bc(this._config,t)}get instructions(){return zc.animatedColor.encode(this._config)}}const Gc={AnimatedTransform:Nc,AnimatedColor:Bc};function Uc(t){return qc(t.map((t=>jc(t))).map((t=>Rc(t).simplify())))}function Vc(t){const e=[];return e.push(t.transform),e.push(t.fromColor),e.push(t.toColor),e.push(t.colorMix),e.push(t.toOpacity),e.push(t.opacityMix),e}function qc(t){const e=[],s=[];let r=0;for(const i of t){const n=[...i.encode(),...zc.ret.encode()];e.push([r+t.length,0,0,0]),s.push(...n),r+=n.length}return[...e,...s]}async function Wc(t,e){const s=t;let r;if("number"==typeof s||"string"==typeof s||"boolean"==typeof s)r=s;else if(Array.isArray(s))r=await Promise.all(s.map((t=>Wc(t,e))));else if("object"==typeof s)if("valueExpressionInfo"in s){const{valueExpressionInfo:t}=s,{expression:i}=t;r={...s,computed:await e.createComputedField({expression:i})}}else{r={};for(const t in s)r[t]=await Wc(s[t],e)}return r}function jc(t,e,s){const r=t;let i;if("number"==typeof r||"string"==typeof r||"boolean"==typeof r)i=r;else if(Array.isArray(r))i=r.map((t=>jc(t,e,s)));else if("object"==typeof r)if("type"in r&&null!=r.type&&"Process"===r.type)switch(r.op){case"ArcadeColor":{const t=jc(r.value,e,s);Xc(Array.isArray(t)&&4===t.length),i=[t[0]/255,t[1]/255,t[2]/255,t[3]]}break;case"Transparency":{const t=jc(r.value,e,s);Xc("number"==typeof t),i=1-t/100}break;case"Divide":{const t=jc(r.left,e,s);Xc("number"==typeof t);const n=jc(r.right,e,s);Xc("number"==typeof n),i=t/n}break;case"Random":{const t=jc(r.seed,e,s),n=jc(r.min,e,s),o=jc(r.max,e,s);i=n+wc(vc(e.getObjectId()||0),t)*(o-n)}}else if("computed"in r)i=function(t){if(!("computed"in t))return t;let r=t.computed.readWithDefault(e,s,[255*t.defaultValue[0],255*t.defaultValue[1],255*t.defaultValue[2],t.defaultValue[3]]);if("string"==typeof r){const t=At.A.fromString(r);t&&(r=[t.r,t.g,t.b,t.a])}return r}(r);else{i={};for(const t in r)i[t]=jc(r[t],e,s)}return i}function*Yc(t){const e=t;if(Array.isArray(e))for(const t of e)yield*Yc(t);else if("object"==typeof e)if("type"in e&&null!=e.type&&"Process"===e.type)switch(e.op){case"ArcadeColor":case"Transparency":yield*Yc(e.value);break;case"Divide":yield*Yc(e.left),yield*Yc(e.right);break;case"Random":yield*Yc(e.seed),yield*Yc(e.min),yield*Yc(e.max)}else if("computed"in e)yield e.computed;else for(const t in e)yield*Yc(e[t])}function Xc(t){if(!t)throw new Error("Assertion failed.")}class $c{destroy(){}}class Hc extends $c{constructor(t){super(),this._value=t}resize(t){}read(t,e){return this._value}readWithDefault(t,e,s){return this._value}hasArcadeDependency(t){return!1}}async function Zc(t,e,s=!1){const{defaultValue:r,valueExpressionInfo:i,value:n}=e;if(i){const{expression:n}=i,o=await t.createComputedField({expression:n},s);return o?{...e,computed:o,defaultValue:r}:null}return{...e,computed:new Hc(n),defaultValue:r}}async function Qc(t,e){const{valueExpressionInfo:s}=e,{expression:r}=s,i=await t.createComputedField({expression:r});return i?{...e,computed:i}:null}function Kc(t){return"object"==typeof t&&null!=t&&(!(!("valueExpressionInfo"in t)||!t.valueExpressionInfo)||"type"in t&&"Process"===t.type&&"op"in t&&"Random"===t.op)}function Jc(t){if(Array.isArray(t))for(const e of t)if(Jc(e))return!0;if("object"==typeof t){if(Kc(t))return!0;for(const e in t)if(Jc(t[e]))return!0}return!1}class tl{static async create(t,e,s){const r={},i=new Map,n=new Map,o=new Map,a=new Map,h=new Map,c=new Map;for(const l in s){const u=s[l];if(null!=u&&"object"==typeof u)if(Array.isArray(u)){if("object"==typeof u[0])throw new Error(`InternalError: Cannot handle ${l}. Nested array params are not supported`);r[l]=u}else if("valueExpressionInfo"in u){if(u.value){r[l]=u.value;continue}const e=await Qc(t,u);if(!e){r[l]=u.defaultValue;continue}i.set(l,e),r[l]=null}else switch(u.type){case"cim-effect-infos":if(u.effectInfos.some((t=>t.overrides.length))){n.set(l,{effects:await Promise.all(u.effectInfos.map((async e=>{const s=e.overrides.map((e=>Zc(t,e)));return{effect:e.effect,compiledOverrides:(await Promise.all(s)).filter(xc.Ru)}})))});break}r[l]=u.effectInfos.map((t=>t.effect));break;case"cim-marker-placement-param":u.overrides.length&&o.set(l,{placementInfo:u,compiledOverrides:(await Promise.all(u.overrides.map((e=>Zc(t,e))))).filter(xc.Ru)}),r[l]=u.placement;break;case"text-rasterization-param":{if(u.overrides.length){const e=u.overrides.map((e=>Zc(t,e,u.useLegacyLabelEvaluationRules)));a.set(l,{compiledOverrides:(await Promise.all(e)).filter(xc.Ru),rasterizationParam:u,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:u.resource};r[l]=await e.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(u.overrides.length){const e=u.overrides.map((e=>Zc(t,e)));a.set(l,{compiledOverrides:(await Promise.all(e)).filter(xc.Ru),rasterizationParam:u,objectIdToResourceId:new Map});continue}if("animated"===u.resource.type){a.set(l,{compiledOverrides:[],rasterizationParam:u,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:u.resource};r[l]=await e.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=u;if(Jc(e)){const s={compiledMarkerInfos:[]};await Promise.all(e.map((async e=>{const r={props:{}};for(const s in e)if(Kc(e[s])){const i=await Qc(t,e[s]);r.compiledExpressionMap||(r.compiledExpressionMap=new Map);const n=r.compiledExpressionMap;i&&n.set(s,i)}else r.props[s]=e[s];s.compiledMarkerInfos.push(r)}))),h.set(l,s)}else r[l]={type:"cim-marker-transform-info",infos:e};break}case"animation-params":{const{params:s}=u,i=Vc(s);if(Jc(i)){const e=await Promise.all(i.map((e=>Wc(e,t))));c.set(l,{params:e,propertyIdToResourceId:new Map,key:l})}else{const t=Uc(i),s=await e.fetchResourceImmediate({type:"animation-info",resource:t});null!=s&&"sprite"===s.type&&(r[l]={dataRow:s.rect.y,dataColumn:s.rect.x})}break}default:r[l]=u}else r[l]=u}return new tl(s,r,i,n,o,a,h,c)}constructor(t,e,s,r,i,n,o,a){this.inputMeshParams=t,this._resolvedMeshParams=e,this._dynamicProperties=s,this._dynamicEffectProperties=r,this._dynamicPlacementProperties=i,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this._dynamicAsyncAnimations=a,this.evaluator=t=>t,this._arcadeDependencies=new Set;for(const t of this._expressions())(0,bc.QY)(this._arcadeDependencies,t)}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size||this._dynamicAsyncAnimations.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(t,e,s){for(const i of this._dynamicAsyncProperties.values()){const n=(0,Vt.o8)(i.rasterizationParam.resource);"animated"===i.rasterizationParam.resource.type&&i.rasterizationParam.resource.randomizeStartTime&&(n.primitiveName="__RESERVED__PRIMITIVE__NAME__",n.startGroup=vc(e.getObjectId()||0));for(const{primitiveName:t,propertyName:o,computed:a,defaultValue:h,valueExpressionInfo:c}of i.compiledOverrides)try{fr(n,"animated"===i.rasterizationParam.resource.type?n.primitiveName:t,o,a,e,s,h)}catch(e){E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new r.A("invalid-arcade-expression",`Encountered an error when evaluating the arcade expression '${c?.expression}' (primitive: '${t}', property: '${o}')`,e))}const o=t.enqueueRequest({type:"cim-rasterization-info",resource:n});i.objectIdToResourceId.set(e.getObjectId(),o)}for(const r of this._dynamicAsyncAnimations.values()){const i=r.params.map((t=>jc(t,e,s))).map(Rc).map((t=>t.simplify())),n=qc(i),o=t.enqueueRequest({type:"animation-info",resource:n});r.propertyIdToResourceId.set(e.getObjectId()+"."+r.key,o)}}evaluateMeshParams(t,e,s){for(const[t,r]of this._dynamicProperties.entries())this._resolvedMeshParams[t]=r.computed.readWithDefault(e,s,r.defaultValue);for(const[t,r]of this._dynamicPlacementProperties.entries())for(const{computed:i,defaultValue:n,propertyName:o}of r.compiledOverrides){const a=i.readWithDefault(e,s,n);r.placementInfo.placement[o]=a,this._resolvedMeshParams[t]=r.placementInfo.placement}for(const[t,r]of this._dynamicEffectProperties.entries())for(const i of r.effects){for(const{computed:t,defaultValue:r,propertyName:n}of i.compiledOverrides){const o=t.readWithDefault(e,s,r);i.effect[n]=o}this._resolvedMeshParams[t]=r.effects.map((t=>t.effect))}for(const[t,r]of this._dynamicTransformProperties.entries()){const i={type:"cim-marker-transform-info",infos:[]};for(const t of r.compiledMarkerInfos){const r={...t.props};if(t.compiledExpressionMap)for(const[i,n]of t.compiledExpressionMap){const t=n.computed.readWithDefault(e,s,n.defaultValue);r[i]="number"==typeof t||"boolean"==typeof t?t:n.defaultValue}i.infos.push(r)}this._resolvedMeshParams[t]=i}for(const[s,r]of this._dynamicAsyncProperties.entries()){const i=r.objectIdToResourceId.get(e.getObjectId());if(null==i)continue;const n=t.getResource(i);this._resolvedMeshParams[s]=n}for(const[s,r]of this._dynamicAsyncAnimations.entries()){const i=r.propertyIdToResourceId.get(e.getObjectId()+"."+s);if(null==i)continue;const n=t.getResource(i);this._resolvedMeshParams[s]={dataRow:n.rect.y,dataColumn:n.rect.x}}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}hasArcadeDependency(t){return this._arcadeDependencies.has(t)}*_expressions(){for(const t of this._dynamicProperties.values())yield t.computed;for(const t of this._dynamicEffectProperties.values())for(const e of t.effects)for(const t of e.compiledOverrides)yield t.computed;for(const t of this._dynamicPlacementProperties.values())for(const e of t.compiledOverrides)yield e.computed;for(const t of this._dynamicAsyncProperties.values())for(const e of t.compiledOverrides)yield e.computed;for(const t of this._dynamicTransformProperties.values())for(const e of t.compiledMarkerInfos)if(null!=e.compiledExpressionMap)for(const t of e.compiledExpressionMap.values())yield t.computed;for(const t of this._dynamicAsyncAnimations.values())for(const e of t.params)yield*Yc(e)}}const el={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:dt.pe.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},offset:{type:dt.pe.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:t})=>{const e=(0,l.Lz)(t),s=-e/2,r=-e/2;return[[s,r],[s+e,r],[s,r+e],[s+e,r+e]]}}},texCoords:{type:dt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:dt.pe.UNSIGNED_BYTE,count:2,pack:({size:t})=>[t,t]},referenceSize:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({size:t})=>(0,l.Lz)(t)},zoomRange:{type:dt.pe.UNSIGNED_BYTE,count:2,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}}};class sl extends br{constructor(){super(...arguments),this.vertexSpec=el}_write(t,e){const s=e.getDisplayId(),r=this.evaluatedMeshParams.minPixelBuffer,i=Math.max((0,l.Lz)(this.evaluatedMeshParams.size),r);let n,o;if("esriGeometryPoint"===e.geometryType)n=e.readXForDisplay(),o=e.readYForDisplay();else{const t=e.readCentroidForDisplay();if(!t)return;n=t?.coords[0],o=t?.coords[1]}t.recordStart(this.instanceId,this.attributeLayout),t.recordBounds(n,o,i,i);const a=t.vertexCount();this._writeVertex(t,s,n,o),t.indexWrite(a+0),t.indexWrite(a+1),t.indexWrite(a+2),t.indexWrite(a+1),t.indexWrite(a+3),t.indexWrite(a+2),t.recordEnd()}}class rl{async createMeshWriter(t,e,s,r){const i=this._getMeshWriter(r.techniqueType),n=await tl.create(t,e,r.inputParams),o=new i(r.id,n,r.optionalAttributes,s);return await o.loadDependencies(),o}_getMeshWriter(t){switch(t){case Pt.Fill:return ci;case Pt.DotDensity:return ai;case Pt.ComplexFill:return fi;case Pt.PatternFill:return ui;case Pt.GradientFill:return wh;case Pt.OutlineFill:return Ii;case Pt.PatternOutlineFill:return Mh;case Pt.ComplexOutlineFill:return _h;case Pt.Marker:return yc;case Pt.PieChart:return sl;case Pt.Text:return ic;case Pt.Line:return bi;case Pt.TexturedLine:return dc;case Pt.GradientStroke:return lc;case Pt.Heatmap:return Th;case Pt.Label:return ac;case Pt.AnimatedMarker:return Pr;default:throw new Error("Internal Error: Mesh writer not in the registry")}}}class il{constructor(t,e,s,r){this.storage=t,this.proxy=e,this.viewParams=s,this.registry=r}async createMeshWriters(t){const e=t.map((t=>this.registry.createMeshWriter(this.storage,this.proxy,this.viewParams,t)));return Promise.all(e)}}class nl{constructor(t){this._outstandingMessages=[],this._queue=new R.e({concurrency:t.concurrency,process:e=>t.process(e)})}async push(t){if(t.end)return await Promise.all(this._outstandingMessages),await this._queue.push(t),void(this._outstandingMessages=[]);const e=this._queue.push(t);return this._outstandingMessages.push(e),e}}var ol=s(43334),al=s(31464),hl=s(95466);class cl{static async create(t,e){if("count"===e.statisticType){const t=new Hc(1);return new cl(e.name,e.alias,e.type,e.statisticType,t)}const s=await t.createComputedField({expression:e.onStatisticExpression?.expression,field:e.onStatisticField});return new cl(e.name,e.alias,e.type,e.statisticType,s)}constructor(t,e,s,r,i){this.name=t,this.alias=e,this.type=s,this.statisticType=r,this.computed=i}}var ll=s(65529),ul=s(70328),dl=s(37730),_l=s(19730);class pl{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class fl{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}get isAggregate(){return!1}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(t){}hasArcadeDependency(t){return!1}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}afterUpdateChunks(){}}class gl extends fl{constructor(t,e,s,r){super(t,e),this.spatialReference=s,this.aggregateFields=r,this._arcadeDependencies=new Set,this.events=new ll.A,this.featureAdapter=dl.T;for(const t of r)(0,bc.QY)(this._arcadeDependencies,t.computed)}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new _l.do({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}get isAggregate(){return!0}removeChunks(t){}hasArcadeDependency(t){return this._arcadeDependencies.has(t)}forEach(t){return this.forEachAggregateWorldSpace(t)}forEachInBounds(t,e){}forEachBounds(t,e){const s=(0,ul.vt)();for(const r of t){const t=(0,Ch.jQ)(s,r.geometry,!1,!1);t&&e(t)}}}class ml{constructor(t,e,s,r,i){this.subscription=t,this.reader=e,this.clear=s,this.end=r,this.debugInfo=i,this.type="append"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"append",clear:this.clear,id:this.id,append:t,end:this.end,debugInfo:this.debugInfo,subscriptionVesrion:this.subscription.version,version:e,attributeEpoch:s}}}class yl{constructor(t,e,s,r,i){this.subscription=t,this.reader=e,this.remove=s,this.end=r,this.debugInfo=i,this.type="update"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"update",id:this.id,modify:t,debugInfo:this.debugInfo,remove:this.remove,version:e,subscriptionVesrion:this.subscription.version,end:this.end,attributeEpoch:s}}}class xl extends $c{constructor(t){super(),this._field=t}resize(t){throw new Error("Method not implemented.")}read(t,e){return t.readAttribute(this._field)}readWithDefault(t,e){return t.readAttribute(this._field)}hasArcadeDependency(t){return!1}}function bl(t,e,s){if(null==t)return null;const r=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;try{return t.evaluate({...s,$feature:r},t.services)}catch(t){return E.A.getLogger("esri.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",t),null}}function wl(t){return null==t||t===1/0||t===-1/0||"number"==typeof t&&isNaN(t)}function vl(t,e,s,r){if(null==t)return null!=r?r:null;const i=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;const n=t.evaluate({...s,$feature:i},t.services);return wl(n)?null!=r?r:null:n}class Sl extends $c{static async create(t,e){const s=await(0,bc.Ad)(t,e.spatialReference,e.fields),r=(0,lt.Wm)(t);return new Sl(s,r)}constructor(t,e){super(),this._compiled=t,this._cacheKey=e}resize(t){}read(t,e){return this.hasArcadeDependency("scale")||"system"!==e.$view.timeZone?bl(this._compiled,t,e):this._readCached(t,e)}readWithDefault(t,e,s){return this.hasArcadeDependency("scale")||"system"!==e.$view.timeZone?vl(this._compiled,t,e,s):this._readWithDefaultCached(t,e,s)}hasArcadeDependency(t){return this._compiled?.references(t)??!1}_getCacheKey(t){if(!this._compiled?.references("timeProperties"))return this._cacheKey;const{currentStart:e,currentEnd:s}=t.$view.timeProperties;return this._cacheKey+function(t,e){const s=43758.5453*Math.sin(12.9898*t+78.233*e);return s-Math.floor(s)}(e??1,s??1)}_readCached(t,e){if(t.setCache(this._getCacheKey(e)),t.hasCachedValue())return t.getCachedValue();const s=bl(this._compiled,t,e);return t.setCachedValue(s),s}_readWithDefaultCached(t,e,s){if(t.setCache(this._getCacheKey(e)),t.hasCachedValue())return t.getCachedValue();const r=vl(this._compiled,t,e,s);return t.setCachedValue(r),r}}var Il=s(97770),Ml=s(18047),Pl=s(68463),Tl=s(30524),Al=s(32730);class Cl extends $c{static async create(t,e){const s=(0,Al.lc)(t);return new Cl((t=>s.replaceAll(/{[^}]*}/g,(e=>{const s=e.slice(1,-1),r=t.metadata.fieldsIndex.get(s);if(null==r)return e;const i=t.readAttribute(s);return null==i?"":function(t,e){if(null==t)return"";const s=e.domain;if(s)if("codedValue"===s.type||"coded-value"===s.type){const e=t;for(const t of s.codedValues)if(t.code===e)return t.name}else if("range"===s.type){const{max:r,min:i}=(0,Pl.A5)(e),n=+t;if(null!=i&&null!=r&&i<=n&&n<=r)return s.name}let r=t;return(0,Tl.vE)(e)?r=(0,Il.Yq)(r,(0,Il.J2)("short-date")):(0,Tl.WA)(e)&&(r=(0,Ml.ZV)(+r)),r||""}(i,r)}))))}constructor(t){super(),this._evaluator=t}resize(t){}read(t,e){return this._evaluator(t)}readWithDefault(t,e,s){const r=this._evaluator(t);return wl(r)?s:r}hasArcadeDependency(t){return!1}}class kl extends $c{constructor(t,e){super(),this._field=t,this._normalizationInfo=e}resize(t){throw new Error("Method not implemented.")}read(t,e){return this._readNormalized(t)}readWithDefault(t,e){return this._readNormalized(t)}hasArcadeDependency(t){return!1}_readNormalized(t){const e=t.readAttribute(this._field);if(null==e)return null;const{normalizationField:s,normalizationTotal:r,normalizationType:i}=this._normalizationInfo,n=t.readAttribute(s);switch(i??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?e/n:void 0:null;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return r?e/r*100:null}}}class Fl{static fromBuffer(t,e){return new Fl(t,e)}static create(t,e=4294967295){const s=new Uint32Array(Math.ceil(t/32));return new Fl(s,e)}constructor(t,e){this._mask=0,this._buf=t,this._mask=e}_getIndex(t){return Math.floor(t/32)}has(t){const e=this._mask&t;return!!(this._buf[this._getIndex(e)]&1<<e%32)}hasRange(t,e){let s=t,r=e;for(;s%32&&s!==r;){if(this.has(s))return!0;s++}for(;r%32&&s!==r;){if(this.has(s))return!0;r--}if(s===r)return!1;for(let t=s/32;t!==r/32;t++)if(this._buf[t])return!0;return!1}set(t){const e=this._mask&t,s=this._getIndex(e),r=1<<e%32;this._buf[s]|=r}setRange(t,e){let s=t,r=e;for(;s%32&&s!==r;)this.set(s++);for(;r%32&&s!==r;)this.set(r--);if(s!==r)for(let t=s/32;t!==r/32;t++)this._buf[t]=4294967295}unset(t){const e=this._mask&t,s=this._getIndex(e),r=1<<e%32;this._buf[s]&=4294967295^r}resize(t){const e=this._buf,s=new Uint32Array(Math.ceil(t/32));s.set(e),this._buf=s}or(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=t._buf[e];return this}and(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=t._buf[e];return this}xor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=t._buf[e];return this}ior(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=~t._buf[e];return this}iand(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=~t._buf[e];return this}ixor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=~t._buf[e];return this}any(){for(let t=0;t<this._buf.length;t++)if(this._buf[t])return!0;return!1}copy(t){for(let e=0;e<this._buf.length;e++)this._buf[e]=t._buf[e];return this}clone(){return new Fl(this._buf.slice(),this._mask)}clear(){for(let t=0;t<this._buf.length;t++)this._buf[t]=0;return this}forEachSet(t){for(let e=0;e<this._buf.length;e++){let s=this._buf[e],r=32*e;if(s)for(;s;)1&s&&t(r),s>>>=1,r++}}countSet(){let t=0;return this.forEachSet((e=>{t++})),t}}var El=s(39516);const zl=()=>E.A.getLogger("esri.views.2d.layers.features.support.whereUtils"),Ol={getAttribute:(t,e)=>t.readAttribute(e)};async function Rl(t,e){try{const s=await(0,El.G)(t,e);if(!s.isStandardized){const t=new r.A("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",s);zl().error(t)}return e=>{const r=e.readArcadeFeature();try{return s.testFeature(r,Ol)}catch(e){return zl().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),!0}}}catch(e){return zl().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),t=>!0}}const Dl=()=>E.A.getLogger("esri.views.2d.layers.features.support.ComputedAttributeStorage"),Ll=4294967295;function Nl(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(s)}class Bl{constructor(t){this._numerics=[],this._strings=[],this._allocatedSize=256,this._bitsets=[],this._instanceIds=[],this._bounds=[],this._dirtyBitset=this.getBitset(this.createBitset()),this.compilationOptions=t}createBitset(){const t=this._bitsets.length;return this._bitsets.push(Fl.create(this._allocatedSize,kh)),t+1}async createComputedField(t,e=!1){if(t.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return e?await Cl.create(t.expression,this.compilationOptions):await Sl.create(t.expression,this.compilationOptions)}catch(e){const s=new r.A("featurelayer","Failed to compile arcade expression",{error:e,expression:t.expression});return Dl().error(s),null}if(t.normalizationType||t.normalizationField)return new kl(t.field,t);if(t.field)return new xl(t.field);const s=new r.A("featurelayer","Unable to create computed field. No expression or field found",{info:t});return Dl().error(s),null}async createWhereClause(t){return t?Rl(t,this.compilationOptions.fields):null}getBitset(t){return this._bitsets[t-1]}getComputedNumeric(t,e){return this.getComputedNumericAtIndex(t&kh,0)}setComputedNumeric(t,e,s){return this.setComputedNumericAtIndex(t&kh,s,0)}getComputedString(t,e){return this.getComputedStringAtIndex(t&kh,0)}setComputedString(t,e,s){return this.setComputedStringAtIndex(t&kh,0,s)}getComputedNumericAtIndex(t,e){const s=t&kh;return this._ensureNumeric(e,s),this._numerics[e][s]}setComputedNumericAtIndex(t,e,s){const r=t&kh;this._ensureNumeric(e,r),this._numerics[e][r]=s}getPackedChunkId(t){const e=t&kh;return this._ensureInstanceId(e),this._instanceIds[e]}setPackedChunkId(t,e){const s=t&kh;this._ensureInstanceId(s),this._instanceIds[s]=e}getComputedStringAtIndex(t,e){const s=t&kh;return this._ensureString(e,s),this._strings[e][s]}setComputedStringAtIndex(t,e,s){const r=t&kh;this._ensureString(e,r),this._strings[e][r]=s}getXMin(t){return this._bounds[4*(t&kh)]}getYMin(t){return this._bounds[4*(t&kh)+1]}getXMax(t){return this._bounds[4*(t&kh)+2]}getYMax(t){return this._bounds[4*(t&kh)+3]}setBounds(t,e,s=!1){const r=t&kh;if(!s&&!this._dirtyBitset.has(t))return this._bounds[4*r]!==Ll;this._dirtyBitset.unset(t);const i=e.readGeometryWorldSpace();if(Nl(this._bounds,4*r+4,0),!i||!i.coords.length)return this._bounds[4*r]=Ll,this._bounds[4*r+1]=Ll,this._bounds[4*r+2]=Ll,this._bounds[4*r+3]=Ll,!1;let n=1/0,o=1/0,a=-1/0,h=-1/0;return i.forEachVertex(((t,e)=>{n=Math.min(n,t),o=Math.min(o,e),a=Math.max(a,t),h=Math.max(h,e)})),this._bounds[4*r]=n,this._bounds[4*r+1]=o,this._bounds[4*r+2]=a,this._bounds[4*r+3]=h,!0}getBounds(t,e){const s=this.getXMin(e),r=this.getYMin(e),i=this.getXMax(e),n=this.getYMax(e);return(0,ul.BI)(t,s,r,i,n),s!==Ll}_ensureNumeric(t,e){this._numerics[t]||(this._numerics[t]=[]),Nl(this._numerics[t],e,0)}_ensureInstanceId(t){Nl(this._instanceIds,t,0)}_ensureString(t,e){this._strings[t]||(this._strings[t]=[]),Nl(this._strings[t],e,null)}}var Gl=s(58727),Ul=s(62660),Vl=s(86420),ql=s(61956);class Wl{getObjectId(t){return t.getObjectId()}getAttributes(t){return t.readAttributes()}getAttribute(t,e){return t.readAttribute(e)}getAttributeAsTimestamp(t,e){return t.readAttributeAsTimestamp(e)}cloneWithGeometry(t,e){return t}getGeometry(t){return t.readGeometryWorldSpace()}getCentroid(t,e){return t.readCentroidForDisplay()}}Wl.Shared=new Wl;class jl{constructor(t){this._geometryBounds=(0,N.vt)(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new jl(t);return await e.update(t.filterJSON,t.spatialReference),e}get hash(){return this._hash}check(t){return this._applyFilter(t)}clear(){const t=this._resetAllHiddenIds();return this.update(),{show:t,hide:[]}}invalidate(){this._idToVisibility.forEach(((t,e)=>{this._idToVisibility.set(e,0)}))}setKnownIds(t){for(const e of t)this._idToVisibility.set(e,1)}setTrue(t){const e=[],s=[],r=new Set(t);return this._idToVisibility.forEach(((t,i)=>{const n=!!(1&this._idToVisibility.get(i)),o=r.has(i);!n&&o?e.push(i):n&&!o&&s.push(i),this._idToVisibility.set(i,o?3:0)})),{show:e,hide:s}}createQuery(){const{geometry:t,spatialRel:e,where:s,timeExtent:r,objectIds:i}=this;return ql.A.fromJSON({geometry:t,spatialRel:e,where:s,timeExtent:r,objectIds:i})}async update(t,e){this._hash=JSON.stringify(t);const s=await(0,Gl.T2)(t,null,e);await Promise.all([this._setGeometryFilter(s),this._setIdFilter(s),this._setAttributeFilter(s),this._setTimeFilter(s)])}async _setAttributeFilter(t){if(!t?.where)return this._clause=null,void(this.where=null);this._clause=await Rl(t.where,this._serviceInfo.fieldsIndex),this.where=t.where}_setIdFilter(t){this._idsToShow=t?.objectIds&&new Set(t.objectIds),this._idsToHide=t?.hiddenIds&&new Set(t.hiddenIds),this.objectIds=t?.objectIds}async _setGeometryFilter(t){if(!t?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const e=t.geometry,s=t.spatialRel??"esriSpatialRelIntersects",r=await(0,Ul.xt)(s,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,Ue.Rg)(this._geometryBounds,e),this._spatialQueryOperator=r,this.geometry=e,this.spatialRel=s}_setTimeFilter(t){if(this.timeExtent=this._timeOperator=null,t?.timeExtent)if(this._serviceInfo.timeInfo)this.timeExtent=t.timeExtent,this._timeOperator=(0,Vl.I)(this._serviceInfo.timeInfo,t.timeExtent,Wl.Shared);else{const e=new r.A("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",t.timeExtent);E.A.getLogger("esri.views.2d.layers.features.controllers.FeatureFilter").error(e)}}_applyFilter(t){return this._filterByGeometry(t)&&this._filterById(t)&&this._filterByTime(t)&&this._filterByExpression(t)}_filterByExpression(t){return!this.where||this._clause(t)}_filterById(t){return(!this._idsToHide?.size||!this._idsToHide.has(t.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(t.getObjectId()))}_filterByGeometry(t){if(!this.geometry)return!0;const e=t.readGeometryWorldSpace();return!!e&&this._spatialQueryOperator(e)}_filterByTime(t){return null==this._timeOperator||this._timeOperator(t)}_resetAllHiddenIds(){const t=[];return this._idToVisibility.forEach(((e,s)=>{1&e||(this._idToVisibility.set(s,1),t.push(s))})),t}}class Yl{static minimal(t,e,s=[]){return new Yl({geometryType:t,fieldsIndex:new hl.A(s).toJSON(),objectIdField:e,subtypes:null,subtypeField:null,types:null,globalIdField:null,spatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null})}static createFeature(t){return new Yl(t)}constructor(t){this._options=t,this._fieldsIndex=hl.A.fromJSON(t.fieldsIndex),t.spatialReference&&(this._spatialReference=q.A.fromJSON(t.spatialReference)),this._arcadeSchema={fields:this.fieldsIndex.fields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,objectIdField:this.objectIdField,globalIdField:this._options.globalIdField,spatialReference:this._spatialReference,timeInfo:this._options.timeInfo,typeIdField:this._options.typeIdField??void 0,types:this._options.types??void 0,subtypeField:this._options.subtypeField,subtypes:this._options.subtypes??void 0}}get fieldsIndex(){return this._fieldsIndex}get geometryType(){return"esriGeometryMultiPatch"===this._options.geometryType?"esriGeometryPolygon":this._options.geometryType}get serviceGeometryType(){return this._options.geometryType}get subtypeField(){return this._options.subtypeField}get timeInfo(){return this._options.timeInfo}get objectIdField(){return this._options.objectIdField}get globalIdField(){return this._options.globalIdField}get arcadeSchema(){return this._arcadeSchema}get spatialReference(){return this._spatialReference}get timeReferenceUnknownClient(){return this._options.timeReferenceUnknownClient}}var Xl=s(66131),$l=s(44729),Hl=s(15032),Zl=s(27647),Ql=s(56400);class Kl{constructor(t){this._valid=Fl.create(t),this._data=new Array(t)}has(t){return this._valid.has(t)}set(t,e){this._valid.set(t),this._data[t]=e}get(t){return this._data[t]}}const Jl=(0,n.A)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],tu=Jl[0],eu=Jl[1],su=Jl[2],ru=Jl[3],iu=(0,n.A)("featurelayer-simplify-payload-size-factors")??[1,2,4],nu=iu[0],ou=iu[1],au=iu[2],hu=(0,n.A)("featurelayer-simplify-mobile-factor")??2,cu=(0,n.A)("esri-mobile"),lu=4294967295;class uu{constructor(t){this.metadata=t,this.type="FeatureSetReader",this._overrides=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}destroy(){}[Symbol.dispose](){this.destroy()}getAreaSimplificationThreshold(t,e){let s=1;const r=cu?hu:1;e>4e6?s=au*r:e>1e6?s=ou*r:e>5e5?s=nu*r:e>1e5&&(s=r);let i=0;return t>4e3?i=ru*s:t>2e3?i=su*s:t>100?i=eu:t>15&&(i=tu),i}getBounds(t){if(function(t,e){if(!(t.length>e))for(;t.length<=e;)t.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===lu)return!1;if(0===this.getBoundsXMin()){const e=this.readGeometryWorldSpace();if(!e)return this.setBoundsXMin(lu),!1;let s=1/0,r=1/0,i=-1/0,n=-1/0;return e.forEachVertex(((t,e)=>{s=Math.min(s,t),r=Math.min(r,e),i=Math.max(i,t),n=Math.max(n,e)})),this.setBoundsXMin(s),this.setBoundsYMin(r),this.setBoundsXMax(i),this.setBoundsYMax(n),(0,ul.BI)(t,s,r,i,n),!0}const e=this.getBoundsXMin(),s=this.getBoundsYMin(),r=this.getBoundsXMax(),i=this.getBoundsYMax();return(0,ul.BI)(t,e,s,r,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(t){this._boundsBuffer[4*this.getIndex()]=t}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(t){this._boundsBuffer[4*this.getIndex()+1]=t}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(t){this._boundsBuffer[4*this.getIndex()+2]=t}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(t){this._boundsBuffer[4*this.getIndex()+3]=t}readAttributeAsTimestamp(t){const e=this.readAttribute(t);return"string"==typeof e?new Date(e).getTime():"number"==typeof e||null==e?e:null}readAttribute(t,e=!1){const s=this._readAttribute(t,e);if(void 0!==s)return s;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(t,e);if(void 0!==r)return r}}readAttributes(){const t=this._readAttributes();for(const e of this._joined){e.setIndex(this.getIndex());const s=e._readAttributes();for(const e of Object.keys(s))t[e]=s[e]}return t}joinAttributes(t){this._joined.push(t)}registerOverrides(t){this._overrides=t}readOptimizedFeatureWorldSpace(){const t=this.readGeometryWorldSpace(),e=this.readAttributes(),s=this.readCentroidWorldSpace();return new ol.Om(t,e,s,this.getObjectId(),this.getDisplayId())}readLegacyFeatureForDisplay(){const t=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyFeatureWorldSpace(){const t=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyGeometryForDisplay(){const t=this.readGeometryForDisplay();return(0,Ch.zv)(t,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const t=this._readX(),e=this.getInTransform();return null==e?t:t*e.scale[0]+e.translate[0]}readYWorldSpace(){const t=this._readY(),e=this.getInTransform();return null==e?t:e.translate[1]-t*e.scale[1]}readGeometryForDisplay(){const t=this._readGeometryDeltaDecoded(!0);if(!t){const t=this._createGeometryFromServerCentroid();return t?t.deltaDecode():null}return t}readGeometryForDisplayTransformed(t){const e=this.readGeometryForDisplay(),s=new jt.A;return(0,Ch.Nl)(s,e,this.hasZ,this.hasM,this.geometryType,t),s.deltaDecode()}readGeometryWorldSpace(){let t=this._readGeometry();if(t||(t=this._createGeometryFromServerCentroid()),!t)return null;const e=t.clone(),s=this.getInTransform();return null!=s&&(0,Ch.Ch)(e,e,this.hasZ,this.hasM,s),e}readCentroidForDisplay(){const t=this.readGeometryForDisplay();return t?this._computeDisplayCentroid(t):this._readServerCentroid()}readCentroidWorldSpace(){const t=this.readGeometryForDisplay(),e=t?this._computeDisplayCentroid(t):this._readServerCentroid();if(!e)return null;const s=e.clone(),r=this.getInTransform();return null!=r&&(0,Ch.Ch)(s,s,this.hasZ,this.hasM,r),s}setCache(t){let e=this._caches.get(t);null==e&&(e=new Kl(this.getSize()),this._caches.set(t,e)),this._activeCache=e}setCachedValue(t){this._activeCache.set(this.getIndex(),t)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(t){const e=this._readGeometry(t);return"esriGeometryPoint"!==this.geometryType&&e&&this.getInTransform()?e.deltaDecode():e}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(t){this._contextTimeZone=t}readArcadeFeature(){return this}hasField(t){return this.fields.has(t)||this._joined.some((e=>e.hasField(t)))}geometry(){const t=this.readGeometryWorldSpace(),e=(0,Ch.zv)(t,this.geometryType,this.hasZ,this.hasM),s=(0,Wt.rS)(e);if(s){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");s.spatialReference=this.metadata.spatialReference}return s}autocastArcadeDate(t,e){return e&&e instanceof Date?this.isUnknownDateTimeField(t)?Xl.lY.unknownDateJSToArcadeDate(e):Xl.lY.dateJSAndZoneToArcadeDate(e,this.contextTimeZone??Ql.qU):e}isUnknownDateTimeField(t){return this.metadata.fieldsIndex.getTimeZone(t)===Ql.L5}field(t){let e=this.fields.get(t);if(e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return $l.n.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Hl.k.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Xl.lY.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const s of this._joined)if(s.setIndex(this.getIndex()),e=s.fields.get(t),e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return $l.n.fromReader(s._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Hl.k.fromReader(s._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Xl.lY.fromReaderAsTimeStampOffset(s._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,s._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(t,e){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((t=>t.name))}castToText(t=!1){if(!t)return JSON.stringify(this.readLegacyFeatureForDisplay());const e=this.readLegacyFeatureForDisplay();if(!e)return JSON.stringify(null);const s={geometry:e.geometry,attributes:{...e.attributes??{}}};for(const t in s.attributes){const e=s.attributes[t];e instanceof Date&&(s.attributes[t]=e.getTime())}return JSON.stringify(s)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(t=null){return{attributes:this._readAttributes(),geometry:!0===t?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(t=null,e=null){return Promise.resolve(this.castAsJson(e))}_getExists(){if(this._overrides){const t=this.getObjectId();return!this._overrides.hasOverride(t)}return!0}_computeDisplayCentroid(t){if(null==this.getInTransform())return(0,Zl.Q)(new jt.A,t,this.hasM,this.hasZ);const e=Yt.fromOptimized(t,this.geometryType);e.yFactor*=-1;const s=_s(e);return s?(s[1]*=-1,new jt.A([],s)):null}copyInto(t){t._joined=this._joined,t._overrides=this._overrides,t._objectIdToIndex=this._objectIdToIndex,t._boundsBuffer=this._boundsBuffer,t._activeCache=this._activeCache,t._caches=this._caches,t._contextTimeZone=this._contextTimeZone}_readLegacyGeometryWorldSpace(){const t=this.readGeometryWorldSpace();return(0,Ch.zv)(t,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const t=this._readServerCentroid();if(!t)return null;const[e,s]=t.coords;return this._createQuantizedExtrudedGeometry(e,s)}_createQuantizedExtrudedGeometry(t,e){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(t,e):this._createQuantizedExtrudedQuad(t,e)}_createQuantizedExtrudedQuad(t,e){return new jt.A([5],[t-1,e,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(t,e){return new jt.A([2],[t-1,e+1,1,-1])}}class du extends uu{static fromFeatures(t,e){const{objectIdField:s,geometryType:r}=e,i=(0,Ch.Di)([],t,r,!1,!1,s);for(let e=0;e<i.length;e++)i[e].displayId=t[e].displayId;return du.fromOptimizedFeatures(i,e)}static fromFeatureSet(t,e){const s=(0,Ch.q3)(t,e.objectIdField);return du.fromOptimizedFeatureSet(s,e)}static fromOptimizedFeatureSet(t,e){const s=du.fromOptimizedFeatures(t.features,e);return s._exceededTransferLimit=t.exceededTransferLimit,s._transform=t.transform,s._fieldsIndex=new hl.A(t.fields),s}static fromOptimizedFeatures(t,e,s){const r=new du(t,e);return r._fieldsIndex=e.fieldsIndex,r._transform=s,r}static empty(t){return new du([],t)}constructor(t,e){super(e),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=e.geometryType,this._features=t}get fields(){return this._fieldsIndex}get geometryType(){return this._geometryType}get hasFeatures(){return!!this._features.length}get hasNext(){return this._featureIndex+1<this._features.length}get exceededTransferLimit(){return this._exceededTransferLimit}get hasZ(){return!1}get hasM(){return!1}get _current(){return this._features[this._featureIndex]}get usedMemory(){return this._current.usedMemory}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let t="";for(const e in this._current.attributes)t+=this._current.attributes[e];return t}getIndex(){return this._featureIndex}setIndex(t){this._featureIndex=t}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(t){this._current.displayId=t}copy(){const t=new du(this._features,this.metadata);return this.copyInto(t),t}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return(0,ol.N3)(this._current)?(0,Ch.Rk)(this._current.geometry,2):0}_readX(){return(0,ol.N3)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,ol.N3)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,ol.N3)(this._current)?this._current.geometry??null:null}_readServerCentroid(){return this._current.centroid}_readAttribute(t,e){if(!this._fieldsIndex){const e=this._current.attributes[t];if(void 0!==e)return e;const s=t.toLowerCase();for(const t in this._current.attributes)if(t.toLowerCase()===s)return this._current.attributes[t];return}const s=this._fieldsIndex.get(t);if(!s)return;const r=this._current.attributes[s.name];return null==r?r:e&&this.fields.isDateField(t)?new Date(r):r}_readAttributes(){return this._current.attributes}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._transform=this._transform,t._fieldsIndex=this._fieldsIndex}}class _u extends pl{constructor(t,e){super(t),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=e}reset(){this.destroy(),this.done=!1}destroy(){const t=this.subscription.tile.key.level;for(const e of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${e}.${t}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const e=t.clone();e.geometry&&(0,Ch.Ch)(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}class pu extends gl{static async create(t,e,s,r,i){const n=new Bl({spatialReference:e}),o=await Promise.all(t.fields.map((async t=>cl.create(n,t)))),a=t.featureFilter?await jl.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:e,filterJSON:t.featureFilter}):null;return"geohash"===t.index.type&&await(0,al.Nk)(e,q.A.WGS84),new pu(t,a,i,o,e,s,r)}constructor(t,e,s,r,i,n,o){super(n,o,i,r),this._schema=t,this._featureFilter=e,this._arcadeContextInfo=s,this._metadata=Yl.createFeature({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fieldsIndex:new hl.A(t.fields).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(t){return new _u(t,this._attributeStore)}async*applyOverrideUpdate(t){for(const t of this._sendStates.values()){t.reset();const e=new ml(t.subscription,du.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(t,e,s){const r=new Map(t.map((t=>[e(t),t]))),i=[];for(const t of this._sendStates.values())for(const e of t.featuresWorldSpace()){const{objectId:t,displayId:n}=e,o=r.get(t);if(null!=o){const e=s(n,o,t);i.push(e),r.delete(t)}}return i}getDisplayFeatures(t){const e=new Set(t),s=new Set,r=[];for(const t of this._sendStates.values())for(const i of t.featuresWorldSpace())e.has(i.displayId)&&!s.has(i.objectId)&&(i.geometry&&r.push({...(0,Ch.oN)(i,this._metadata.geometryType,!1,!1),displayId:i.displayId}),s.add(i.objectId));return{features:[],aggregates:r}}getFeatureObjectIdsForAggregate(t){for(const e of this._sendStates.values())for(const s of e.bins.values())if(s.id===t)return Array.from(s.containedObjectIds);return[]}async*updateChunks(){for(const t of this._sendStates.values())yield*this._update(t,this._source)}forEachAggregateWorldSpace(t){const e=new Set;for(const s of this._sendStates.values())for(const r of s.featuresWorldSpace())e.has(r.objectId)||(t(r),e.add(r.objectId))}_createIndexOptions(t){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:t.scale};case"grid":{const e=this._schema.index.fixedBinLevel,s=null!=e?t.tileInfoView.getLODInfoAt(e).scale:t.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:s}}}}async*_update(t,e){const{handledChunks:s,subscription:r,bins:i,featureCache:n}=t,o=r.tile;if(t.done)return;for(const r of e.chunks()){if(s.has(r.chunkId))continue;s.add(r.chunkId);const e=r.queryInfo;if("tileId"in e){const t=new p.A(e.tileId);if(t.level!==o.level||t.world!==o.key.world)continue}r.getAggregateIndex(this._createIndexOptions(t.tile)).putBounded(i,t.tile.extent,t.tile.resolution)}const a=[],h=r.tile.transform,c=r.tile.key.level;for(const t of i.values()){let e=n.get(t.id);if(e)e.attributes=t.getAttributes();else{const s=t.getGeometry(this.spatialReference,h);e=new ol.Om(s,t.getAttributes(),null,t.id),s||(e.centroid=t.getGeometricCentroid(this.spatialReference,h)),e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${c}`),n.set(t.id,e)}a.push(e)}this.events.emit("changed"),t.done=!e.updateTracking.updating;const l=du.fromOptimizedFeatures(a,this._metadata,h),u=l.getCursor(),d=t.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo);for(;u.next();)this._attributeStore.setAttributeData(u.getDisplayId(),u,d);const _=new yl(t.subscription,l,[],t.done,{});yield _}}class fu{constructor(t){this._statistics=t}get statistics(){return this._statistics}}const gu=Math.PI/180;class mu{static create(t){return new mu(t.map((t=>function(t){switch(t.statisticType){case"min":return new xu(t);case"max":return new bu(t);case"avg":return new vu(t);case"avg_angle":return new Su(t);case"sum":case"count":return new wu(t);case"mode":return new Iu(t)}}(t))))}constructor(t){this._statistics=t}values(){return this._statistics.values()}insert(t,e){for(const s of this._statistics)s.insert(t,e)}merge(t){for(let e=0;e<this._statistics.length;e++){const s=this._statistics[e],r=t._statistics[e];if(s.field.name!==r.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");s.merge(r)}}clone(){return new mu(this._statistics.map((t=>t.clone())))}}class yu{constructor(t){this.field=t}insert(t,e){if(!this.field.computed)return;const s=this.field.computed.read(t,e);wl(s)||this._insertValue(s)}}class xu extends yu{constructor(){super(...arguments),this.type="min",this.value=Number.MAX_VALUE}_insertValue(t){this.value=Math.min(this.value,t)}merge(t){this.value=Math.min(this.value,t.value)}clone(){const t=new xu(this.field);return t.value=this.value,t}}class bu extends yu{constructor(){super(...arguments),this.type="max",this.value=Number.MIN_VALUE}_insertValue(t){this.value=Math.max(this.value,t)}merge(t){this.value=Math.max(this.value,t.value)}clone(){const t=new bu(this.field);return t.value=this.value,t}}class wu extends yu{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(t){this.value+=t}merge(t){this.value+=t.value}clone(){const t=new wu(this.field);return t.value=this.value,t}}class vu extends yu{constructor(){super(...arguments),this.type="avg",this._total=0,this._count=0}get value(){return this._total/this._count}_insertValue(t){this._total+=t,this._count+=1}merge(t){this._total+=t._total,this._count+=t._count}clone(){const t=new vu(this.field);return t._total=this._total,t._count=this._count,t}}class Su extends yu{constructor(){super(...arguments),this.type="avg_angle",this._x=0,this._y=0,this._count=0}get value(){const t=this._x/this._count,e=this._y/this._count,s=180/Math.PI;return Math.atan2(e,t)*s}_insertValue(t){this._x=this._x+Math.cos(t*gu),this._y=this._y+Math.sin(t*gu),this._count+=1}merge(t){this._x+=t._x,this._y+=t._y,this._count+=t._count}clone(){const t=new Su(this.field);return t._x=this._x,t._y=this._y,t._count=this._count,t}}class Iu extends yu{constructor(){super(...arguments),this._frequencies=new Map}get value(){let t,e=0;for(const[s,r]of this._frequencies.entries())r>e&&(e=r,t=s);return t}_insertValue(t){const e=this._frequencies.get(t);null!=e?this._frequencies.set(t,e+1):this._frequencies.set(t,1)}merge(t){for(const[e,s]of t._frequencies.entries()){const t=this._frequencies.get(e);null!=t?this._frequencies.set(e,t+s):this._frequencies.set(e,s)}}clone(){const t=new Iu(this.field);return t._frequencies=new Map(this._frequencies),t}}class Mu extends fu{static createId(t,e){return`${t}.${e}`}static create(t,e,s,r){return new Mu(t,e,mu.create(s),r)}constructor(t,e,s,r){super(s),this.gridX=t,this.gridY=e,this._worldUnitsPerCell=r,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return Mu.createId(this.gridX,this.gridY)}get containedObjectIds(){return this._objectIds}get count(){return this._count}get firstObjectId(){return this._objectIds.values().next().value}get centroidXWorld(){return this._xWorldTotal/this._count}get centroidYWorld(){return this._yWorldTotal/this._count}clone(){const t=new Mu(this.gridX,this.gridY,this._statistics.clone(),this._worldUnitsPerCell);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._firstFeatureAttributes=this._firstFeatureAttributes,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,r){0===this._count?this._firstFeatureAttributes=t.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=s,this._yWorldTotal+=r,this._statistics.insert(t,e),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._firstFeatureAttributes=t._firstFeatureAttributes,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroidX(t){return null==t?this.centroidXWorld:(0,Ch.IE)(t,this.centroidXWorld)}getCentroidY(t){return null==t?this.centroidYWorld:(0,Ch.B2)(t,this.centroidYWorld)}getGeometry(t,e){const s=this.gridX*this._worldUnitsPerCell,r=this.gridY*this._worldUnitsPerCell,i=new jt.A([4],[s,r,s+this._worldUnitsPerCell,r,s+this._worldUnitsPerCell,r+this._worldUnitsPerCell,s,r+this._worldUnitsPerCell]);if(null!=e){const t=new jt.A;return(0,Ch.Nl)(t,i,!1,!1,"esriGeometryPolygon",e)}return i}getCentroid(t){const e=new jt.A([],[this.centroidXWorld,this.centroidYWorld]);if(null!=t){const s=new jt.A;return(0,Ch.Nl)(s,e,!1,!1,"esriGeometryPoint",t)}return e}getGeometricCentroid(t,e){const s=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,r=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,i=new jt.A([],[s,r]);if(null!=e){const t=new jt.A;return(0,Ch.Nl)(t,i,!1,!1,"esriGeometryPoint",e)}return i}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return null!=this._firstFeatureAttributes?{...t,...this._firstFeatureAttributes}:t}}var Pu=s(83047);function Tu(t,{timeZone:e,timeExtent:s}){return{$view:{scale:t,timeZone:e,timeProperties:{currentStart:s?.start,currentEnd:s?.end}}}}class Au{constructor(t){this._options=t}insert(t,e){const s=t.getCursor(),{arcadeContextInfo:r,scale:i}=this._options,n=Tu(i,r);for(;s.next();)this._insertFeature(s,n,e)}_insertFeature(t,e,s){const{featureFilter:r}=this._options;if(null!==r&&!r.check(t))return;let i=0,n=0;if("esriGeometryPoint"===t.geometryType)i=t.readXWorldSpace(),n=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,r]=e.coords;if(s<0||s>B.CQ||r<0||r>B.CQ)return}const e=t.readCentroidWorldSpace();if(null==e)return;i=e.coords[0],n=e.coords[1]}this._insert(t,i,n,e)}}function Cu(t,e){return(0,Pu.GA)(t)*Pu.dy*96/e}class ku extends Au{constructor(t){super(t),this._cells=new Map,this._pixelsPerMapUnit=Cu(t.spatialReference,t.scale)}put(t){for(const e of this._cells.values()){const s=t.get(e.id);s?s.merge(e):t.set(e.id,e.clone())}}putBounded(t,e,s){const r=[e.xmin,e.ymin,e.xmax,e.ymax],[i,n,o,a]=r,h=Math.floor(i*this._pixelsPerMapUnit/this._options.cellSize),c=Math.floor(n*this._pixelsPerMapUnit/this._options.cellSize),l=Math.ceil(o*this._pixelsPerMapUnit/this._options.cellSize),u=Math.ceil(a*this._pixelsPerMapUnit/this._options.cellSize);for(let e=c;e<=u;e++)for(let s=h;s<=l;s++){const r=`${s}.${e}`,i=this._cells.get(r);if(!i)continue;const n=t.get(i.id);n?i&&!t.has(i.id)&&n.merge(i):t.set(i.id,i.clone())}}_insert(t,e,s,r){const i=e*this._pixelsPerMapUnit,n=s*this._pixelsPerMapUnit,o=Math.floor(i/this._options.cellSize),a=Math.floor(n/this._options.cellSize);this._getCellOrCreate(o,a).insert(t,r,e,s)}_getCellOrCreate(t,e){const s=Mu.createId(t,e);let r=this._cells.get(s);if(!r){const i=1*this._options.cellSize/this._pixelsPerMapUnit;r=Mu.create(t,e,this._options.fields,i),this._cells.set(s,r)}return r}}class Fu{constructor(t,e){this.inner=t,this.displayId=e}}class Eu extends pl{constructor(t){super(t),this.didSend=!1,this.done=!1}}class zu{constructor(t,e,s,r,i){this._level=t,this._scale=e,this._indexOptions=s,this._clusterRadius=r,this._store=i,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const t of this._clusters.values())this._store.releaseDisplayIdForObjectId(t.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const t of this._clusters.values()){const e=t.inner.getCentroid(null),s=new ol.Om(e,t.inner.getAttributes(),null,t.inner.id,t.displayId);yield s}}clusters(){return this._clusters.values()}updateChunks(t,e){let s=!1;for(const e of t){const t=e.queryInfo;"tileId"in t&&new p.A(t.tileId).level!==this._level||this._handledChunks.has(e.normalizedChunkId)||(this._handledChunks.add(e.normalizedChunkId),s=!0,e.getAggregateIndex({...this._indexOptions,scale:this._scale}).put(this._cells))}const r={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},i=Cu(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:t}of e){const e=t.tile.bounds,s=Math.floor(e[0]*i/n),o=Math.floor(e[1]*i/n),a=Math.ceil(e[2]*i/n),h=Math.ceil(e[3]*i/n);r.xMin=Math.min(r.xMin,s),r.yMin=Math.min(r.yMin,o),r.xMax=Math.max(r.xMax,a),r.yMax=Math.max(r.yMax,h)}return null!=this._lastCellBounds&&r.xMin===this._lastCellBounds.xMin&&r.yMin===this._lastCellBounds.yMin&&r.yMin===this._lastCellBounds.yMin&&r.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=r),s&&this._clusterCells(r),s}async updateStatistics(t){let e=!1;for(const t of this._clusters.values())t.inner.count>1&&(e=this._updateAggregateStatistics(this._statistics,t.inner)||e);if(e){const e=Array.from(this._statistics.entries()).map((([t,e])=>({fieldName:t,minValue:e.minValue,maxValue:e.maxValue})));await t.container.updateStatistics(this._level,e)}}createAggregateFeatures(t,e){const s=t.subscription,r=[],i=s.tile.transform;for(const t of this._clusters.values()){let e=t.inner.getCentroidX(i);const n=t.inner.getCentroidY(i),o=s.tile.lod,a=o.wrap?o.worldSize[0]:null,h=1===t.inner.count?t.inner.firstObjectId:t.inner.id,c=t.displayId;if(null!=a)if(1===a){const s=new jt.A([],[e,n]),i=new ol.Om(s,t.inner.getAttributes(),null,h,c);i.geometry.coords[0]-=B.CQ,r.push(i);const o=new jt.A([],[e,n]),a=new ol.Om(o,t.inner.getAttributes(),null,h,c);a.geometry.coords[0]+=B.CQ,r.push(a)}else e>B.CQ+B.CQ/2?e-=a*B.CQ:e<-B.CQ/2&&(e+=a*B.CQ);if(e<B.CQ+128&&e>=-128&&n<B.CQ+128&&n>=-128){const s=new jt.A([],[e,n]),i=new ol.Om(s,t.inner.getAttributes(),null,h,c);r.push(i)}}return du.fromOptimizedFeatures(r,e,s.tile.transform)}_clusterCells(t){let e=Array.from(this._cells.values());e=e.sort(((t,e)=>e.count-t.count));const s=[];for(const t of this._clusters.values())s.push(t.inner.id);this._clusters.clear();const r=this._clusterRadius*(1/Cu(this._indexOptions.spatialReference,this._scale)),i=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const s of e){if(n.has(s.id))continue;if(s.gridX<t.xMin||s.gridX>t.xMax||s.gridY<t.yMin||s.gridY>t.yMax)continue;const e=this._store.createDisplayIdForObjectId(s.id),o=new Fu(s.clone(),e);n.add(s.id),this._clusters.set(s.id,o);const a=s.centroidXWorld,h=s.centroidYWorld;for(let t=s.gridY-i;t<=s.gridY+i;t++)for(let e=s.gridX-i;e<=s.gridX+i;e++){if(t===s.gridY&&e===s.gridX)continue;const i=this._cells.get(Mu.createId(e,t));if(!i||n.has(i.id))continue;const c=Math.abs(i.centroidXWorld-a),l=Math.abs(i.centroidYWorld-h);c<r&&l<r&&(o.inner.merge(i),n.add(i.id))}}for(const t of s)this._store.releaseDisplayIdForObjectId(t)}_updateAggregateStatistics(t,e){let s=!1;for(const r of e.statistics.values()){if("esriFieldTypeString"===r.field.type)continue;const e=r.value,i=r.field,n=t.get(i.name);if(n){const{minValue:t,maxValue:r}=n,i=Math.min(n.minValue,e),o=Math.max(n.maxValue,e);t===i&&r===o||(n.minValue=i,n.maxValue=o,s=!0)}else t.set(i.name,{minValue:e,maxValue:e}),s=!0}return s}}class Ou extends gl{static async create(t,e,s,r,i,n){const o=new Bl({spatialReference:s}),a={type:"grid",fields:await Promise.all(e.fields.map((async t=>cl.create(o,t)))),spatialReference:s,featureFilter:e.featureFilter?await jl.create({geometryType:r.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:r.metadata.timeInfo,fieldsIndex:r.metadata.fieldsIndex,spatialReference:s,filterJSON:e.featureFilter}):null,cellSize:e.clusterRadius/4,arcadeContextInfo:n};return new Ou(t,e.clusterRadius,a,e.fields,r,i)}constructor(t,e,s,r,i,n){super(i,n,s.spatialReference,s.fields),this._connection=t,this._clusterRadius=e,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=Yl.createFeature({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fieldsIndex:new hl.A([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:i.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear()}onSubscribe(t){super.onSubscribe(t),this._requiredLevel=t.tile.level,this._requiredScale=t.tile.scale}createState(t){return new Eu(t)}async*applyOverrideUpdate(t){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(t,e,s){const r=new Map(t.map((t=>[e(t),t]))),i=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.clusters()){const e=r.get(t.inner.id);if(null==e){if(1===t.inner.count){const{firstObjectId:e}=t.inner,n=e?r.get(e):null;if(null!=n){const o=s(t.displayId,n,e);i.push(o),r.delete(e)}}}else{const n=s(t.displayId,e,t.inner.id);i.push(n),r.delete(t.inner.id)}}return i}getDisplayFeatures(t){const e=new Set(t),s=new Set,r=[],i=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.aggregatesWorldSpace())if(e.has(t.displayId)&&!s.has(t.displayId)){const e=(0,Ch.oN)(t,this._metadata.geometryType,!1,!1);if(s.add(t.displayId),1===e.attributes.cluster_count){r.push({...e,displayId:t.displayId});continue}i.push({...e,displayId:t.displayId})}return{features:r,aggregates:i}}getFeatureObjectIdsForAggregate(t){const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.clusters())if(s.inner.id===t)return Array.from(s.inner.containedObjectIds);return[]}async*updateChunks(){const t=this._source.chunks();if(!t.length)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter((t=>t.subscription.tile.level===this._requiredLevel));if(e.updateChunks(t,s)||!this._source.updateTracking.updating)for(const t of s)t.subscription.tile.level===this._requiredLevel&&(t.didSend=!1,t.done=!1);const r=Array.from(this._sendStates.values()).filter((t=>t.done)).map((t=>t.subscription.tile.key)),i=new Set(r);for(const t of this._sendStates.values()){if(this._source.updateTracking.updating){if(r.some((e=>e.containsChild(t.subscription.tile.key))))continue;if(t.subscription.tile.key.getChildKeys().every((t=>i.has(t))))continue}t.didSend||t.subscription.tile.level!==this._requiredLevel||(t.didSend=!0,yield*this._update(t,e,this._source))}await e.updateStatistics(this._connection)}forEachAggregateWorldSpace(t){if(null==this._requiredLevel||null==this._requiredScale)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.aggregatesWorldSpace())t(s)}_getClusterState(t,e){if(null==t||null==e)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(e);return s||(s=new zu(t,e,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(e,s)),s}async*_update(t,e,s){if(t.done)return;const r=e.createAggregateFeatures(t,this._metadata);this.events.emit("changed"),t.done=!s.updateTracking.updating;const i=r.getCursor(),n=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.arcadeContextInfo);for(;i.next();)this._attributeStore.setAttributeData(i.getDisplayId(),i,n);const o=new ml(t.subscription,r,!0,t.done,{});yield o}}var Ru=s(11006);function Du(t,e){if(!(this instanceof Du))return new Du(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&("function"==typeof e?this.toBBox=e:this._initFormat(e)),this.clear()}function Lu(t,e,s){if(!s)return e.indexOf(t);for(var r=0;r<e.length;r++)if(s(t,e[r]))return r;return-1}function Nu(t,e){Bu(t,0,t.children.length,e,t)}function Bu(t,e,s,r,i){i||(i=Hu(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var n,o=e;o<s;o++)n=t.children[o],Gu(i,t.leaf?r(n):n);return i}function Gu(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Uu(t,e){return t.minX-e.minX}function Vu(t,e){return t.minY-e.minY}function qu(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Wu(t){return t.maxX-t.minX+(t.maxY-t.minY)}function ju(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Yu(t,e){var s=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),n=Math.min(t.maxY,e.maxY);return Math.max(0,i-s)*Math.max(0,n-r)}function Xu(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function $u(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Hu(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Zu(t,e,s,r,i){for(var n,o=[e,s];o.length;)(s=o.pop())-(e=o.pop())<=r||(n=e+Math.ceil((s-e)/r/2)*r,(0,Ru.q)(t,n,e,s,i),o.push(e,n,n,s))}Du.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,s=[],r=this.toBBox;if(!$u(t,e))return s;for(var i,n,o,a,h=[];e;){for(i=0,n=e.children.length;i<n;i++)o=e.children[i],$u(t,a=e.leaf?r(o):o)&&(e.leaf?s.push(o):Xu(t,a)?this._all(o,s):h.push(o));e=h.pop()}return s},collides:function(t){var e=this.data,s=this.toBBox;if(!$u(t,e))return!1;for(var r,i,n,o,a=[];e;){for(r=0,i=e.children.length;r<i;r++)if(n=e.children[r],$u(t,o=e.leaf?s(n):n)){if(e.leaf||Xu(t,o))return!0;a.push(n)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,s=t.length;e<s;e++)this.insert(t[e]);return this}var r=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var i=this.data;this.data=r,r=i}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},insert:function(t){return null!=t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Hu([]),this},remove:function(t,e){if(null==t)return this;for(var s,r,i,n,o=this.data,a=this.toBBox(t),h=[],c=[];o||h.length;){if(o||(o=h.pop(),r=h[h.length-1],s=c.pop(),n=!0),o.leaf&&-1!==(i=Lu(t,o.children,e)))return o.children.splice(i,1),h.push(o),this._condense(h),this;n||o.leaf||!Xu(o,a)?r?(s++,o=r.children[s],n=!1):o=null:(h.push(o),c.push(s),s=0,r=o,o=o.children[0])}return this},toBBox:function(t){return t},compareMinX:Uu,compareMinY:Vu,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var s=[];t;)t.leaf?e.push.apply(e,t.children):s.push.apply(s,t.children),t=s.pop();return e},_build:function(t,e,s,r){var i,n=s-e+1,o=this._maxEntries;if(n<=o)return Nu(i=Hu(t.slice(e,s+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,r-1))),(i=Hu([])).leaf=!1,i.height=r;var a,h,c,l,u=Math.ceil(n/o),d=u*Math.ceil(Math.sqrt(o));for(Zu(t,e,s,d,this.compareMinX),a=e;a<=s;a+=d)for(Zu(t,a,c=Math.min(a+d-1,s),u,this.compareMinY),h=a;h<=c;h+=u)l=Math.min(h+u-1,c),i.children.push(this._build(t,h,l,r-1));return Nu(i,this.toBBox),i},_chooseSubtree:function(t,e,s,r){for(var i,n,o,a,h,c,l,u;r.push(e),!e.leaf&&r.length-1!==s;){for(l=u=1/0,i=0,n=e.children.length;i<n;i++)h=qu(o=e.children[i]),(c=ju(t,o)-h)<u?(u=c,l=h<l?h:l,a=o):c===u&&h<l&&(l=h,a=o);e=a||e.children[0]}return e},_insert:function(t,e,s){var r=this.toBBox,i=s?t:r(t),n=[],o=this._chooseSubtree(i,this.data,e,n);for(o.children.push(t),Gu(o,i);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(i,n,e)},_split:function(t,e){var s=t[e],r=s.children.length,i=this._minEntries;this._chooseSplitAxis(s,i,r);var n=this._chooseSplitIndex(s,i,r),o=Hu(s.children.splice(n,s.children.length-n));o.height=s.height,o.leaf=s.leaf,Nu(s,this.toBBox),Nu(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(s,o)},_splitRoot:function(t,e){this.data=Hu([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Nu(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,s){var r,i,n,o,a,h,c,l;for(h=c=1/0,r=e;r<=s-e;r++)o=Yu(i=Bu(t,0,r,this.toBBox),n=Bu(t,r,s,this.toBBox)),a=qu(i)+qu(n),o<h?(h=o,l=r,c=a<c?a:c):o===h&&a<c&&(c=a,l=r);return l},_chooseSplitAxis:function(t,e,s){var r=t.leaf?this.compareMinX:Uu,i=t.leaf?this.compareMinY:Vu;this._allDistMargin(t,e,s,r)<this._allDistMargin(t,e,s,i)&&t.children.sort(r)},_allDistMargin:function(t,e,s,r){t.children.sort(r);var i,n,o=this.toBBox,a=Bu(t,0,e,o),h=Bu(t,s-e,s,o),c=Wu(a)+Wu(h);for(i=e;i<s-e;i++)n=t.children[i],Gu(a,t.leaf?o(n):n),c+=Wu(a);for(i=s-e-1;i>=e;i--)n=t.children[i],Gu(h,t.leaf?o(n):n),c+=Wu(h);return c},_adjustParentBBoxes:function(t,e,s){for(var r=s;r>=0;r--)Gu(e[r],t)},_condense:function(t){for(var e,s=t.length-1;s>=0;s--)0===t[s].children.length?s>0?(e=t[s-1].children).splice(e.indexOf(t[s]),1):this.clear():Nu(t[s],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}};class Qu{static fromReader(t){const e=[],s=t.copy(),r=(0,ul.vt)();for(;s.next();)s.getBounds(r)&&e.push(s.getIndex());const i=Du(9,(t=>(s.setIndex(t),{minX:s.getBoundsXMin(),minY:s.getBoundsYMin(),maxX:s.getBoundsXMax(),maxY:s.getBoundsYMax()})));return i.load(e),new Qu(i)}constructor(t){this._index=t}search(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this._index.search(e)}}var Ku=s(79258);function Ju(t,e,s,r){if(r.isWebMercator){const r=(0,ks.KJ)(t/Ku.$O.radius),i=r-360*Math.floor((r+180)/360),n=[0,0];return td(n,0,(0,ks.KJ)(Math.PI/2-2*Math.atan(Math.exp(-e/Ku.$O.radius))),i,s),n}const i=(0,al.Cv)({x:t,y:e},r,q.A.WGS84);if(!i)return null;const n=[0,0];return td(n,0,i.y,i.x,s),n}function td(t,e,s,r,i){i%2&&(i+=1);let n=0,o=0,a=-90,h=90,c=-180,l=180;for(let t=0;t<i/2;t++){for(let e=0;e<5;e++){const s=(c+l)/2,i=r>s?1:0;n|=i<<29-(e+5*t),c=(1-i)*c+i*s,l=(1-i)*s+i*l}for(let e=0;e<5;e++){const r=(a+h)/2,i=s>r?1:0;o|=i<<29-(e+5*t),a=(1-i)*a+i*r,h=(1-i)*r+i*h}}t[2*e]=n,t[2*e+1]=o}new Float64Array(2),new Float64Array(2);class ed extends fu{static create(t,e,s,r){const i=mu.create(t),n=new Array(32);for(let t=0;t<n.length;t++)n[t]=null;return new ed(i,e,s,r,n)}constructor(t,e,s,r,i){super(t),this.xNode=e,this.yNode=s,this.depth=r,this.children=i,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}get id(){return`${this.xNode}.${this.yNode}`}get containedObjectIds(){return this._objectIds}get count(){return this._count}clone(){const t=new ed(this._statistics.clone(),this.xNode,this.yNode,this.depth,this.children);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._xGeohashTotal=this._xGeohashTotal,t._yGeohashTotal=this._yGeohashTotal,t.next=this.next,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,r,i,n){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=s,this._xGeohashTotal+=r,this._yGeohashTotal+=i,this._statistics.insert(t,n),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._xGeohashTotal+=t._xWorldTotal,this._yGeohashTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroid(t){throw new Error("getCentroid not supported for GeohashNode")}getGeometry(t,e){const s=this._getLngLatBounds(),[r,i,n,o]=s,a=(0,al.Cv)({rings:[[[r,i],[r,o],[n,o],[n,i],[r,i]]]},q.A.WGS84,t),h=(0,Ch.Ye)(new jt.A,a,!1,!1);return null!=e?(0,Ch.Nl)(new jt.A,h,!1,!1,"esriGeometryPolygon",e,!1,!1):h}getGeometricCentroid(t,e){const s=this._getLngLatBounds(),[r,i,n,o]=s,a=(0,al.Cv)({x:(r+n)/2,y:(i+o)/2},q.A.WGS84,t),h=(0,Ch.qN)(new jt.A,a);return null!=e?(0,Ch.Nl)(new jt.A,h,!1,!1,"esriGeometryPoint",e,!1,!1):h}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return t.aggregateCount=this._count,t}find(t,e,s,r,i,n){if(r>=s)return this;const o=1-r%2,a=3*o+2*(1-o),h=2*o+3*(1-o),c=30-i-a,l=30-n-h,u=((t&7*o+3*(1-o)<<c)>>c)+((e&3*o+7*(1-o)<<l)>>l)*(8*o+4*(1-o)),d=this.children[u];return null==d?null:d.find(t,e,s,r+1,i+a,n+h)}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),r=30-(3*e+2*s),i=30-(2*e+3*s);return function(t,e){let s=-90,r=90,i=-180,n=180;for(let o=0;o<e;o++){const e=Math.ceil((o+1)/2),a=Math.floor((o+1)/2),h=1-o%2,c=30-(3*e+2*a),l=30-(2*e+3*a),u=2*h+3*(1-h),d=(7*h+3*(1-h)<<c&t.geohashX)>>c,_=(3*h+7*(1-h)<<l&t.geohashY)>>l;for(let t=3*h+2*(1-h)-1;t>=0;t--){const e=(i+n)/2,s=d&1<<t?1:0;i=(1-s)*i+s*e,n=(1-s)*e+s*n}for(let t=u-1;t>=0;t--){const e=(s+r)/2,i=_&1<<t?1:0;s=(1-i)*s+i*e,r=(1-i)*e+i*r}}return[i,s,n,r]}({geohashX:this.xNode<<r,geohashY:this.yNode<<i},this.depth)}}class sd{constructor(t){this._fields=t,this._size=0,this._depth=0,this._root=ed.create(this._fields,0,0,0)}destroy(){}get size(){return this._size}get depth(){return this._depth}find(t,e,s){return this._root.find(t,e,s,0,0,0)}insert(t,e,s,r,i,n,o){let a=this._root,h=0,c=0,l=0;for(;null!==a;){if(a.insert(t,e,s,r,i,o),h>=n)return;const u=Math.ceil((h+1)/2),d=Math.floor((h+1)/2),_=1-h%2,p=30-(3*u+2*d),f=30-(2*u+3*d),g=(r&7*_+3*(1-_)<<p)>>p,m=(i&3*_+7*(1-_)<<f)>>f,y=g+m*(8*_+4*(1-_));c=c<<3*_+2*(1-_)|g,l=l<<2*_+3*(1-_)|m,null==a.children[y]&&(a.children[y]=ed.create(this._fields,c,l,h+1),this._depth=Math.max(this._depth,h+1),this._size+=1),h+=1,a=a.children[y]}}putBins(t,e){for(const s of this.getNodes(e)){const e=t.get(s.id);e?e.merge(s):t.set(s.id,s.clone())}}getNodes(t){const e=[],{geohashBounds:s,level:r}=t;let i=this._root;for(;null!==i;){const t=i.depth,n=i.xNode,o=i.yNode;if(t>=r){e.push(i),i=i.next;continue}const a=Math.ceil((t+1)/2),h=Math.floor((t+1)/2),c=1-t%2,l=30-(3*a+2*h),u=30-(2*a+3*h),d=~((1<<l)-1),_=~((1<<u)-1),p=(s.xLL&d)>>l,f=(s.yLL&_)>>u,g=(s.xTR&d)>>l,m=(s.yTR&_)>>u,y=n<<3*c+2*(1-c),x=o<<2*c+3*(1-c),b=y+8*c+4*(1-c),w=x+4*c+8*(1-c),v=Math.max(y,p),S=Math.max(x,f),I=Math.min(b,g),M=Math.min(w,m);let P=null,T=null;for(let t=S;t<=M;t++)for(let e=v;e<=I;e++){const s=e-y+(t-x)*(8*c+4*(1-c)),r=i.children[s];r&&(P||(P=r,P.next=i.next),T&&(T.next=r),T=r,r.next=i.next)}i=P||i.next}return e}}class rd extends Au{constructor(t){super(t),this._tree=new sd(this._options.fields)}put(t){throw new Error("Geohash tree does not support put")}putBounded(t,e,s){const{geohashLevel:r,spatialReference:i}=this._options,n=function(t,e,s,r){const i=[t.xmin,t.ymin,t.xmax,t.ymax],n=ir.A.fromExtent((0,N.w1)(i,r)),o=(0,al.Cv)(n,r,q.A.WGS84,{densificationStep:64*e});if(!o)return null;const a=(0,Ch.Ye)(new jt.A,o,!1,!1),h=a.coords.filter(((t,e)=>!(e%2))),c=a.coords.filter(((t,e)=>e%2)),l=Math.min(...h),u=Math.min(...c),d=Math.max(...h),_=Math.max(...c),p=Ju(l,u,s,q.A.WGS84),f=Ju(d,_,s,q.A.WGS84);return p&&f?{bounds:i,geohashBounds:{xLL:p[0],yLL:p[1],xTR:f[0],yTR:f[1]},level:s}:null}(e,s,r,i);null!=n&&this._tree.putBins(t,n)}_insert(t,e,s,r){const{geohashLevel:i,spatialReference:n}=this._options,o=Ju(e,s,i,n);o&&this._tree.insert(t,e,s,o[0],o[1],i,r)}}var id=s(69397);class nd extends uu{static from(t,e){return new nd(t.copy(),e)}constructor(t,e){super(t.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=t,this._indices=e,this._isPoint="esriGeometryPoint"===t.geometryType}setTransformForDisplay(t){const e=this._reader.getInTransform();if(null==e){const[e,s]=t.scale,[r,i]=t.translate;return this._displayTranslationX=-r/e,this._displayScaleX=1/e,this._displayTranslationY=i/s,this._displayScaleY=1/-s,void(this._displayTransform=t)}const[s,r]=e.scale,[i,n]=e.translate,[o,a]=t.scale,[h,c]=t.translate;if(this._displayScaleX=s/o,this._displayTranslationX=(i-h)/o,this._displayScaleY=r/a,this._displayTranslationY=(-n+c)/a,!this._isPoint&&e)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=t}getInTransform(){return this._reader.getInTransform()}get fields(){return this._reader.fields}get hasNext(){return this._currentIndex+1<this._indices.length}getSize(){return this._indices.length}getCursor(){return this.copy()}copy(){const t=new nd(this._reader.copy(),this._indices);return t._currentIndex=this._currentIndex,t._displayTransform=this._displayTransform,t._displayTranslationX=this._displayTranslationX,t._displayTranslationY=this._displayTranslationY,t._displayScaleX=this._displayScaleX,t._displayScaleY=this._displayScaleY,t}get contextTimeZone(){return this._reader.contextTimeZone}set contextTimeZone(t){this._reader.contextTimeZone=t}get usedMemory(){return id.qK+this._reader.usedMemory}_nextIndex(){return++this._currentIndex<this._indices.length&&(this._reader.setIndex(this._indices[this._currentIndex]),!0)}next(){for(;this._nextIndex()&&!this._reader._getExists(););return this._currentIndex<this._indices.length}readXForDisplay(){return this._reader.readXForDisplay()*this._displayScaleX+this._displayTranslationX}readYForDisplay(){return this._reader.readYForDisplay()*this._displayScaleY+this._displayTranslationY}readGeometryForDisplay(){return this._displayTransform?this._reader.readGeometryForDisplayTransformed(this._displayTransform):this._reader.readGeometryForDisplay()}readCentroidForDisplay(){const t=this._reader.readCentroidForDisplay()?.clone();if(t){const[e,s]=t.coords;t.coords[0]=e*this._displayScaleX+this._displayTranslationX,t.coords[1]=s*this._displayScaleY+this._displayTranslationY}return t}get geometryType(){return this._reader.geometryType}get hasFeatures(){return this._reader.hasFeatures}get exceededTransferLimit(){return this._reader.exceededTransferLimit}get hasZ(){return this._reader.hasZ}get hasM(){return this._reader.hasM}readAttribute(t,e=!1){return this._reader.readAttribute(t,e)}readAttributes(){return this._reader.readAttributes()}joinAttributes(t){return this._reader.joinAttributes(t)}getBounds(t){return this._reader.getBounds(t)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(t){return this._reader.setDisplayId(t)}setIndex(t){return this._reader.setIndex(t)}getIndex(){return this._reader.getIndex()}readXWorldSpace(){return this._reader.readXWorldSpace()}readYWorldSpace(){return this._reader.readYWorldSpace()}_readX(){return this._reader.readXForDisplay()}_readY(){return this._reader.readYForDisplay()}_readServerCentroid(){return this._reader._readServerCentroid()}readLegacyFeatureForDisplay(){const t=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyGeometryForDisplay(){const t=this.readGeometryForDisplay();return(0,Ch.zv)(t,this.geometryType,!1,!1)}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(t,e){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}_readAttributes(){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}readArcadeFeature(){return this._reader.readArcadeFeature()}geometry(){return this._reader.geometry()}field(t){return this._reader.field(t)}hasField(t){return this._reader.hasField(t)}setField(t,e){return this._reader.setField(t,e)}keys(){return this._reader.keys()}castToText(t=!1){return this._reader.castToText(t)}}class od{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._aggregateIndex=null,this._aggregateIndexHash=null,this._spatialIndex=null}registerOverrides(t){this.reader.registerOverrides(t),this.invalidate()}queryFeaturesInBounds(t){const e=this._getSpatialIndex().search(t);return nd.from(this.reader,e)}getAggregateIndex(t){const e=JSON.stringify(t);if(e!==this._aggregateIndexHash){switch(this._aggregateIndexHash=e,t.type){case"grid":this._aggregateIndex=new ku(t);break;case"geohash":this._aggregateIndex=new rd(t)}this._aggregateIndex.insert(this.reader,this.isTiled)}return this._aggregateIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=Qu.fromReader(this.reader)),this._spatialIndex}}class ad{constructor(){this.modified=[],this.removed=[]}modify(t){this.modified.push(t)}remove(t){this.removed.push(t)}get isEmpty(){return 0===this.modified.length&&0===this.removed.length}}class hd extends od{constructor(t){super(),this._reader=t,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(t,e){const s=du.fromOptimizedFeatures(t,e);return new hd(s)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(t){if(!this._reader.getSize())return null;const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class cd{constructor(t,e){this.inner=t,this.isWeak=e,this.lastWeak=null}}class ld{constructor(){this._overrides=new Map,this._update=new ad}hasOverride(t){return this._overrides.has(t)}onChunkInsert(t){if(this._overrides.size){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),s=this._overrides.get(t);s?.lastWeak&&(s.lastWeak=null),s?.isWeak&&(this._overrides.delete(t),this._update.remove(t),this.invalidate())}}t.registerOverrides(this)}apply(t,e){const{updateWeak:s,removeWeak:r,update:i,remove:n,release:o}=t.commands;this.invalidate();for(const t of s)this._overrides.set(t.objectId,new cd(t,!0)),this._update.modify(t);for(const t of i){const e=new cd(t,!1),s=this._overrides.get(t.objectId);s?.isWeak&&(e.lastWeak=s),this._overrides.set(t.objectId,e),this._update.modify(t)}for(const t of r)this._overrides.set(t,new cd(null,!0)),this._update.remove(t);for(const t of n){const e=new cd(null,!1),s=this._overrides.get(t);s?.isWeak&&(e.lastWeak=s),this._overrides.set(t,e),this._update.remove(t)}if(o.length){const t=new Set;for(const e of o){const s=this._overrides.get(e);s?.lastWeak?this._overrides.set(e,s.lastWeak):s&&!s.isWeak&&(this._overrides.delete(e),t.add(e))}e.forEachUnsafe((e=>{const s=e.getObjectId();t.has(s)&&(this._update.modify(e.readOptimizedFeatureWorldSpace()),t.delete(s))}));for(const e of t.values())this._update.remove(e)}}takeOverrideUpdate(){const t=this._update;return t.isEmpty?null:(this._update=new ad,t)}asChunk(t){if(!this._chunk){const e=[];for(const t of this._overrides.values())null!=t.inner&&e.push(t.inner);this._chunk=hd.fromFeatures(e,t)}return this._chunk}invalidate(){this._chunk=null}}class ud extends pl{}class dd extends fl{constructor(t,e,s){super(t,e),this._arcadeContextInfo=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const t of this._source.chunks())this._cleanupChunkIds(t)}invalidateAttributeData(t){this.handledChunksForAttributeData.clear(),this._arcadeContextInfo=t,this._evalOptions=Tu(this._evalOptions.$view.scale,t)}onSubscribe(t){super.onSubscribe(t),this._evalOptions=t.tile.createArcadeEvaluationOptions(this._arcadeContextInfo)}createState(t){return new ud(t)}get aggregateQueryEngine(){return null}displayMap(t,e,s){const r=new Map(t.map((t=>[e(t),t]))),i=[];for(const t of this._source.chunks()){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),o=r.get(t);if(null!=o){const e=s(n,o,t);i.push(e),r.delete(t)}}}return i}getDisplayFeatures(t){const e=new Set(t),s=new Set,r=[];for(const t of this._source.chunks()){const i=t.reader.getCursor();for(;i.next();){const t=i.getObjectId(),n=i.getDisplayId();e.has(n)&&!s.has(t)&&(r.push({...i.readLegacyFeatureWorldSpace(),displayId:n}),s.add(t))}}return{features:r,aggregates:[]}}async*applyOverrideUpdate(t){const e=[];for(const s of t.modified){const t=this._attributeStore.createDisplayIdForObjectId(s.objectId);s.displayId=t,e.push(t)}const s=du.fromOptimizedFeatures(t.modified,this._source.metadata).getCursor();for(;s.next();)this._attributeStore.setAttributeData(s.getDisplayId(),s,this._evalOptions);const r=[];for(const e of t.removed){const t=this._attributeStore.getDisplayIdForObjectId(e);null!=t&&r.push(t)}(0,n.A)("esri-2d-update-debug")&&console.debug("FeatureUpdateStrategy.applyLocalEdit",{message:t,modifiedDisplayIds:e,removedDisplayIds:r});const i=hd.fromFeatures(t.modified,this._source.metadata);this.handledChunks.add(i.chunkId),this.handledChunksForAttributeData.add(i.chunkId),this.handledChunksForIdCreation.add(i.chunkId);for(const t of this._sendStates.values())t.handledChunks.add(i.chunkId),yield new yl(t.subscription,null,e,!1,i.queryInfo);for(const t of this._sendStates.values()){const e=i.getTileReader(t.subscription.tile);yield new yl(t.subscription,e,r,!1,i.queryInfo)}for(const e of t.removed)this._attributeStore.releaseDisplayIdForObjectId(e)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const t of this._sendStates.values())yield*this._update(t)}}removeChunks(t){for(const e of t)this.handledChunks.delete(e.chunkId),this.handledChunksForAttributeData.delete(e.chunkId),this._cleanupChunkIds(e)}afterUpdateChunks(){for(const t of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(t);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(t){if(this.handledChunksForIdCreation.has(t.chunkId)){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(t):this._attributeStore.releaseDisplayIdForObjectId(t)}this.handledChunksForIdCreation.delete(t.chunkId)}}async _updateAttributeData(){for(const t of this._source.chunks()){const{chunkId:e,reader:s}=t;if(!this.handledChunksForIdCreation.has(e)){this.handledChunksForIdCreation.add(e);const t=s.getCursor();for(;t.next();){const e=this._attributeStore.createDisplayIdForObjectId(t.getObjectId());t.setDisplayId(e)}}}for(const t of this._source.chunks())if(!this.handledChunksForAttributeData.has(t.chunkId)){this.handledChunksForAttributeData.add(t.chunkId);const e=t.reader.getCursor();for(;e.next();){const t=e.getDisplayId();this._attributeStore.setAttributeData(t,e,this._evalOptions)}}}*_update(t){const{subscription:e,handledChunks:s}=t;for(const r of this._source.chunks()){const{chunkId:i}=r;if(s.has(i))continue;s.add(i);const n=r.getTileReader(e.tile);n&&(yield new ml(t.subscription,n,!1,r.end,r.queryInfo))}}}class _d{constructor(t){this.data=t,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class pd{constructor(){this._freeIdsGenerationA=[],this._freeIdsGenerationB=[],this._idCounter=1,this._freeIds=this._freeIdsGenerationA,this._objectIdToDisplayId=new Map}createIdForObjectId(t){let e=this._objectIdToDisplayId.get(t);return e?e.increment():(e=new _d((0|this._getFreeId())>>>0),e.increment(),this._objectIdToDisplayId.set(t,e)),e.data}releaseIdForObjectId(t){const e=this._objectIdToDisplayId.get(t);e&&(e.decrement(),e.empty()&&(this._objectIdToDisplayId.delete(t),this._freeIds.push(e.data)))}getDisplayIdForObjectId(t){const e=this._objectIdToDisplayId.get(t);return null!=e?e.data:null}releaseAll(){for(const t of this._objectIdToDisplayId.values())this._freeIds.push(t.data);this._objectIdToDisplayId.clear()}incrementGeneration(){this._freeIds=this._freeIds===this._freeIdsGenerationA?this._freeIdsGenerationB:this._freeIdsGenerationA}_getFreeId(){return this._freeIds.length?this._freeIds.pop():this._idCounter++}}const fd=()=>E.A.getLogger("esri.views.layers.2d.features.support.AttributeStore"),gd=(fd(),()=>null),md=(0,n.A)("esri-shared-array-buffer");(0,n.A)("esri-atomics");class yd{constructor(t,e,s){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:r,layout:i,textureOnly:n}=e;this.textureOnly=n||!1,this.pixelType=r,this.layout=i,this._resetRange(),this.size=t,this.isLocal=s,n||(this.data=this._initData(r,t))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(t,e){const s=this.data;for(let r=0;r<this.size*this.size;r++)s[r*this.texelSize+t]&=~e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(t,e){const s=this.data;for(let r=0;r<this.size*this.size;r++)s[r*this.texelSize+t]|=255&e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(t,e,s){const r=this.data;for(const i of s)r[i*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)}setComponentTexel(t,e,s){this.data[s*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}unsetComponentTexel(t,e,s){this.data[s*this.texelSize+t]&=~e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}getData(t,e){const s=Fh(t);return this.data[s*this.texelSize+e]}setData(t,e,s){const r=Fh(t),i=1<<e;this.layout&i?null!=this.data&&(this.data[r*this.texelSize+e]=s,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)):fd().error("mapview-attributes-store","Tried to set a value for a texel's readonly component")}expand(t){if(this.size=t,!this.textureOnly){const e=this._initData(this.pixelType,t),s=this.data;e.set(s),this.data=e}}toMessage(){const t=this.dirtyStart,e=this.dirtyEnd,s=this.texelSize;if(t>e)return null;this._resetRange();const r=!this.isLocal,i=this.pixelType,n=this.layout,o=this.data;return{start:t,end:e,data:r&&o.slice(t*s,(e+1)*s)||null,pixelType:i,layout:n}}_initData(t,e){const s=ArrayBuffer,i=function(t){switch(t){case dt.ld.UNSIGNED_BYTE:return Uint8Array;case dt.ld.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case dt.ld.FLOAT:return Float32Array;default:return void E.A.getLogger("esri.views.2d.engine.webgl.Utils").error(new r.A("webgl-utils",`Unable to handle type ${t}`))}}(t),n=new i(new s(e*e*4*i.BYTES_PER_ELEMENT));for(let t=0;t<n.length;t+=4)n[t+1]=255;return n}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}}class xd{constructor(t){this._client=t,this._filters=[],this._blocks=new Array,this._attributeComputeInfo=null,this._abortController=new AbortController,this._size=B.TB,this._idsToHighlight=new Map,this._arcadeDependencies=new Set,this._initialized=!1,this.version=0,this._idGenerator=new pd,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const t=dt.ld.FLOAT;gd(`Creating AttributeStore ${md?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:dt.ld.UNSIGNED_BYTE,layout:1},{pixelType:dt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:dt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:dt.ld.FLOAT,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(t){return this._idGenerator.createIdForObjectId(t)}releaseDisplayIdForObjectId(t){return this._idGenerator.releaseIdForObjectId(t)}getDisplayIdForObjectId(t){return this._idGenerator.getDisplayIdForObjectId(t)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}hasArcadeDependency(t){return this._arcadeDependencies.has(t)}releaseAllIds(){this._idGenerator.releaseAll()}async update(t,e,s,r,i=0){const o=(0,V.Ui)(this._schema,t);if(this.version=i,o&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${i}] AttributeStore.update`,{changed:o}),this._schema=t,this._attributeComputeInfo=null,this._initialize(),null!=t))if(s&&(this._filters=await Promise.all(t.filters.map((t=>t?jl.create({geometryType:s.geometryType,hasM:!1,hasZ:!1,timeInfo:s.timeInfo,fieldsIndex:s.fieldsIndex,spatialReference:r??s.spatialReference,filterJSON:t}):null)))),"subtype"!==t.type)this._attributeComputeInfo={isSubtype:!1,map:new Map},await Promise.all(t.bindings.map((async t=>{const s=await this._bind(e,t);this._updateReferences(s)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:t.subtypeField,map:new Map};for(const s in t.bindings){const r=t.bindings[s];await Promise.all(r.map((async t=>{const r=await this._bind(e,t,parseInt(s,10));this._updateReferences(r)})))}}}setHighlight(t,e){const s=this._getBlock(0);s.unsetComponentAllTexels(0,(1<<B.U5)-1);for(const{displayId:e,highlightFlags:r}of t){if(null==e)continue;const t=Fh(e);s.setComponent(0,r,[t])}this._idsToHighlight.clear();for(const{objectId:e,highlightFlags:s}of t)this._idsToHighlight.set(e,s);for(const{objectId:t,highlightFlags:s}of e)this._idsToHighlight.set(t,s)}setData(t,e,s,r){const i=Fh(t);this._ensureSizeForTexel(i),this._getBlock(e).setData(t,s,r)}getData(t,e,s){return this._getBlock(e).getData(t,s)}getHighlightFlags(t){return this._idsToHighlight.get(t)||0}unsetAttributeData(t){const e=Fh(t);this._getBlock(0).setData(e,0,0)}setAttributeData(t,e,s){const r=Fh(t);this._ensureSizeForTexel(r),this._getBlock(0).setData(r,0,this.getFilterFlags(e));const i=this._attributeComputeInfo;let n=null;i&&(n=i.isSubtype?i.map.get(e.readAttribute(i.subtypeField)):i.map,n?.size&&n.forEach(((t,i)=>{const n=1*i%4,o=Math.floor(1*i/4),a=this._getBlock(o+B.dV.VV);let h=t.field?.read(e,s);t.valueRepresentation&&(h=function(t,e){if(!t||!e)return t;switch(e){case"radius":case"distance":return 2*t;case"diameter":case"width":return t;case"area":return Math.sqrt(t)}return t}(h,t.valueRepresentation)),(null===h||isNaN(h)||h===1/0||h===-1/0)&&(h=1e-30),a.setData(r,n,h)})))}get epoch(){return this._epoch}sendUpdates(){const t=this._blocks.map((t=>null!=t?t.toMessage():null)),e=this._getInitArgs();(0,n.A)("esri-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.start"),this._client.update({initArgs:e,blockData:t,version:this.version,sendUpdateEpoch:this._epoch}),this._epoch+=1,(0,n.A)("esri-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.end")}_ensureSizeForTexel(t){for(;t>=this._size*this._size;)if(this._expand())return}async _bind(t,e,s){const r=await t.createComputedField(e),{valueRepresentation:i}=e,n=this._attributeComputeInfo;if(n.isSubtype){const t=n.map.get(s)??new Map;t.set(e.binding,{field:r,valueRepresentation:i}),n.map.set(s,t)}else n.map.set(e.binding,{field:r,valueRepresentation:i});return r}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(B.dV.Animation),this._getBlock(B.dV.GPGPU),this._getBlock(B.dV.LocalTimeOrigin),{blockSize:this._size,blockDescriptors:this._blocks.map((t=>null!=t?{textureOnly:t.textureOnly,buffer:t.buffer,pixelType:t.pixelType}:null))})}_getBlock(t){const e=this._blocks[t];if(null!=e)return e;gd(`Initializing AttributeBlock at index ${t}`);const s=new yd(this._size,this._blockDescriptors[t],this._client.isLocal);return this._blocks[t]=s,this._initialized=!1,s}_expand(){if(this._size<this._schema.capabilities.maxTextureSize){const t=this._size<<=1;gd("Expanding block size to",t,this._blocks);for(const e of this._blocks)e?.expand(t);return this._initialized=!1,this._size=t,0}return fd().error(new r.A("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}_updateReferences(t){(0,bc.QY)(this._arcadeDependencies,t)}isVisible(t){return!!(this._getBlock(0).getData(t,0)&1<<B.U5)}getFilterFlags(t){let e=0;for(let s=0;s<this._filters.length;s++){const r=!!(1<<s),i=this._filters[s];e|=(!r||null==i||i.check(t)?1:0)<<s}let s=0;if(this._idsToHighlight.size){const e=t.getObjectId();s=this.getHighlightFlags(e)}return e<<B.U5|s}}class bd{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._registry=new rl,this._proxy=new Mt({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new xd({isLocal:!1,update:t=>(0,u.oV)(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destroy(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getDisplayIds(t){const e={};return this._strategy?(this._strategy.displayMap(t,(t=>t),((t,s,r)=>{e[r]=t})),e):e}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,e,s,r,i){const o=t.processor,a=(0,U.i8)(this._schema?.storage,o.storage),h=(0,U.i8)(this._schema?.mesh.properties,o.mesh.properties),c=(0,U.i8)(this._schema?.mesh.factory,o.mesh.factory),l=(0,U.i8)(this._schema?.mesh.strategy,o.mesh.strategy),u=function(t,e){const s=[];return t?.timeExtent?.start===e.timeExtent?.start&&t?.timeExtent?.end===e.timeExtent?.end||s.push("timeProperties"),s}(this._schema?.expressionProperties,o.expressionProperties),d=u.some((t=>this._attributeStore.hasArcadeDependency(t))),_=u.some((t=>this._factory?.hasArcadeDependency(t)??!1)),p=u.some((t=>this._strategy?.hasArcadeDependency(t)))||this._strategy?.isAggregate&&d,f=_||p,g=h||c||l;if(!(a||g||_||d||p||r))return;(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:(0,V.Ui)(this._schema,o),schema:o}),this._schema=o;const m=q.A.fromJSON(this._source.service.outSpatialReference),y=new Bl({fields:this._source.metadata.fieldsIndex,spatialReference:m});if((a||g||d)&&(await this._attributeStore.update(o.storage,y,this._source.metadata,m,e),this._strategy?.invalidateAttributeData(wd(o))),!r&&!g&&!f)return;(l||h||f)&&await this._updateStrategy(o.mesh.strategy,m,i,wd(o)),this._updateSortKey(y,"sortKey"in o.mesh.properties?o.mesh.properties.sortKey:null);const x=new il(y,this._proxy,s,this._registry);return(c||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await ct.create(x,o.mesh.factory)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)}async applyOverrideUpdate(t){if(!this._strategy)return;const e=this._strategy.applyOverrideUpdate(t);for await(const t of e)try{await this._process(t)}catch(t){}}async updateChunks(){await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],s=new Map;for await(const r of t){let t=s.get(r.id);null==t&&(t=new nl({concurrency:16,process:t=>this._process(t)}),s.set(r.id,t));const i=t.push(r).catch((t=>(0,a.jH)(t)));e.push(i)}try{await Promise.all(e)}catch(t){}(0,n.A)("esri-2d-update-debug")&&console.log("SendUpdates"),this._attributeStore.sendUpdates(),(0,n.A)("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,r){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new dd(this._source,this._attributeStore,r);break;case"binning":this._strategy=await pu.create(t,e,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await Ou.create(this._connection,t,e,this._source,this._attributeStore,r)}for(const t of s)this._strategy.onSubscribe(t)}async _updateSortKey(t,e){if(this._sortInfo=(0,C.pR)(this._sortInfo?.computed),null!=e){const s=e.byRenderer?null:await t.createComputedField(e);this._sortInfo={...e,computed:s}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if((0,n.A)("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),(0,a.Te)(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(wd(this._schema))),r=e.tile.tileInfoView.getLODInfoAt(e.tile.key),{message:i,transferList:o}=s.serialize(r),h={objectIdMap:null,inner:t.createMessage(i,this._version,this._attributeStore.epoch)};if(this._schema?.mesh.properties.returnMeshObjectId){h.objectIdMap={};const e=t.reader?.getCursor();if(e)for(;e.next();)h.objectIdMap[e.getDisplayId()]=e.getObjectId()}if((0,a.Te)(e.signal),await this._connection.container.onMessage(h,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),(0,n.A)("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(wd(this._schema));for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,r=t.reader?.getCursor(),i=r?.getSize()??0,n=s.tileInfoView.tileInfo.isWrappable,o=s.tileInfoView.tileInfo.spatialReference.isWGS84,a=new J(s.key,this._strategy.enablePixelBuffering,n,o,i);if(!r)return a;const h=s.createArcadeEvaluationOptions(wd(this._schema));for(;r.next();){const t=this._getSortKeyValue(r,e);a.entityStart(r.getDisplayId(),t),this._factory.write(a,this._proxy,r,h,s.level),a.entityEnd()}return a}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,n=i?this._factory.getSortKey(t,e):s?.read(t,e);return null==n||isNaN(n)?0:n*("asc"===r?-1:1)}}function wd(t){const{timeZone:e}=t?.mesh.properties??{},{timeExtent:s}=t?.expressionProperties??{};return{timeZone:e,timeExtent:s}}var vd=s(78888),Sd=s(80893);class Id{static from(t){let e=0,s=0,r=0;return t.forEach((t=>{const i=t._readGeometry();i&&(s+=i.isPoint?1:i.lengths.reduce(((t,e)=>t+e),0),r+=i.isPoint?1:i.lengths.length,e+=1)})),new Id(e,s,r)}constructor(t,e,s){this.featureCount=t,this.vertexCount=e,this.ringCount=s}toJSON(){return{featureCount:this.featureCount,ringCount:this.featureCount,vertexCount:this.featureCount}}}var Md=s(60694),Pd=s(79677);class Td{static fromSchema(t,e,s){const r="feature"===e.type?e.mutable.dataFilter.queryScaleRanges:[];return new Td(function(t,e,s){const r=t.orderByFields??s.objectIdField+" ASC",i=t.source,n={returnCentroid:!(null!==i&&"object"==typeof i&&"path"in i&&(0,Md.Wo)(i.path))&&"esriGeometryPolygon"===s.serviceGeometryType,returnGeometry:!0,timeReferenceUnknownClient:s.timeReferenceUnknownClient??void 0,outSpatialReference:q.A.fromJSON(t.outSpatialReference),orderByFields:"memory"===t.type?[]:[r],where:e.mutable.dataFilter.definitionExpression??"1=1",outFields:e.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===s.serviceGeometryType?"xyFootprint":null};if("feature"===e.type){const{gdbVersion:t,historicMoment:s,timeExtent:r}=e.mutable.dataFilter;return{...n,gdbVersion:t,historicMoment:s?new Date(s):null,timeExtent:r?Pd.A.fromJSON(r):null,outFields:e.mutable.availableFields}}return n}(t,e,s),r,s.subtypeField,e.mutable.dataFilter.customParameters,s.geometryType,t.queryMetadata)}constructor(t,e,s,r,i,n){this._queryParams=t,this._queryScaleRanges=e,this._subtypeField=s,this._customParameters=r,this._geometryType=i,this._queryMetadata=n}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const t=this._queryMetadata.supportsMaxRecordCountFactor?4:null,e=(this._queryMetadata.maxRecordCount??8e3)*(t??1);return Math.min(8e3,e)}updateHistoricMoment(t){this._queryParams.historicMoment=t}updateFields(t){this._queryParams.outFields=t}createPatchFieldsQuery(t,e){if(!e.getSize())return null;const s=t.clone();if("*"===this._queryParams.outFields[0]){if("*"===(s.outFields??[])[0])return null;s.outFields=this._queryParams.outFields}else{const t=new Set(this._queryParams.outFields),r=[];for(const s of t)e.hasField(s)||r.push(s);if(0===r.length)return null;s.outFields=r}return s.returnGeometry=!1,s.returnCentroid=!1,s.quantizationParameters=null,s.cacheHint=!0,{inner:s,customParameters:this._customParameters}}createQuery(t={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new ql.A({...this._queryParams,...t}),customParameters:this._customParameters}}createTileQuery(t,e){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const s=this.createQuery(e),r=s.inner;if(this._queryScaleRanges.length){const e=this._queryScaleRanges.filter((e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale))).map((t=>t.subtypeCode));if(e.length){const t=`${this._subtypeField} IN (${e})`;r.where=(0,El.m)(r.where,t)}}if(r.quantizationParameters=e.quantizationParameters??t.getQuantizationParameters(),r.resultType="tile",r.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(r.maxAllowableOffset=t.resolution*(0,n.A)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(r.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(r.maxAllowableOffset*=(0,n.A)("feature-polyline-generalization-factor"))),r.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,r.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(r.maxRecordCountFactor=4),(0,n.A)("esri-tiles-debug")){const e=t.id.replaceAll("/",".");s.customParameters=s.customParameters?{...s.customParameters,tileId:e}:{tileId:e}}return s}createPagedTileQuery(t,e){const s=this.pageSize;return this.createTileQuery(t,{start:s*e,num:s,returnExceededLimitFeatures:!0})}createPagedQuery(t){const e=this.pageSize;return this.createQuery({start:e*t,num:e,returnExceededLimitFeatures:!0,maxRecordCountFactor:4})}}let Ad=class extends T.A{constructor(t){super(),this._connection=t,this._enabledEventTypes=new Set,this._updateInfo={websocket:0,client:0},this._lastTime=performance.now(),this._queuedCommands=[],this.addHandles([(0,c.wB)((()=>this._strategy?.connectionStatus??"disconnected"),(t=>{this._layerView.setProperty({propertyName:"pipelineConnectionStatus",value:t})}),{initial:!0}),(0,c.wB)((()=>this._strategy?.errorString||null),(t=>this._layerView.setProperty({propertyName:"pipelineErrorString",value:t})),{initial:!0})])}destroy(){this._strategy=null,this.removeAllHandles()}get _layerView(){return this._connection.layerView}set strategy(t){null==this._strategy&&this._resetUpdateInfo(performance.now());const e="event-handles";this.removeHandles(e),null!=t&&(this.addHandles([t.events.on("data-received",(t=>this._onFeature(t))),t.events.on("message-received",(t=>this._onWebSocketMessage(t))),t.events.on("features-updated",(t=>this._onUpdate(t))),t.events.on("tick",(()=>this._onTick()))],e),this._queuedCommands.forEach((e=>e(t))),this._queuedCommands=[]),this._strategy=t}updateCustomParameters(t){null!=t&&this._callOrEnqueue((e=>e.updateCustomParameters(t)))}sendMessageToSocket(t){this._callOrEnqueue((e=>e.sendMessageToSocket(t)))}sendMessageToClient(t){this._callOrEnqueue((e=>e.sendMessageToClient(t)))}enableEvent(t,e){e?this._enabledEventTypes.add(t):this._enabledEventTypes.delete(t)}disconnect(){this._strategy?.disconnect()}connect(){this._strategy?.connect()}clear(){this._strategy?.clear()}_onWebSocketMessage(t){this._enabledEventTypes.has("message-received")&&this._layerView.emitEvent({name:"message-received",event:t})}_onFeature(t){this._updateInfo.websocket++,this._enabledEventTypes.has("data-received")&&this._layerView.emitEvent({name:"data-received",event:{attributes:t.attributes,centroid:t.centroid,geometry:t.geometry}})}_onUpdate(t){this._updateInfo.client+=t}_onTick(){const t=performance.now(),e=t-this._lastTime;if(e>2500){const s=Math.round(this._updateInfo.client/(e/1e3)),r=Math.round(this._updateInfo.websocket/(e/1e3));this._resetUpdateInfo(t),this._layerView.emitEvent({name:"update-rate",event:{client:s,websocket:r}})}}_resetUpdateInfo(t){this._lastTime=t,this._updateInfo.client=0,this._updateInfo.websocket=0}_callOrEnqueue(t){null!=this._strategy?t(this._strategy):this._queuedCommands.push(t)}};(0,P._)([(0,F.MZ)()],Ad.prototype,"_strategy",void 0),Ad=(0,P._)([(0,z.$)("esri.views.2d.layers.features.sources.StreamMessenger")],Ad);class Cd{constructor(t){this._store=t,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}unsafeSetQueryHistoricMoment(t){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(t){throw new Error("InternalError: LoadStrategy does not support fetching")}async addParquetFile(t){throw new Error("InternalError: LoadStrategy does not support loading blobs")}}var kd=s(10382),Fd=s(62577),Ed=s(75321),zd=s(51624),Od=s(53655);const Rd=268435455;class Dd{constructor(){this.hasFeatures=!1,this.exceededTransferLimit=!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}}const Ld=268435455,Nd=128e3,Bd={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(Nd),decoded:new Int32Array(Nd)}};function Gd(t){return t<=Bd.small.delta.length?Bd.small:(t<=Bd.large.delta.length||(Bd.large.delta=new Int32Array(Math.round(1.25*t)),Bd.large.decoded=new Int32Array(Math.round(1.25*t))),Bd.large)}function Ud(t){for(;t.next();){if(1===t.tag())return t.getMessage();t.skip()}return null}function Vd(t,e,s,r,i,n){return.5*Math.abs(t*r+s*n+i*e-t*n-s*e-i*r)}function qd(t,e,s,r,i){return!!t&&0==e*i-r*s&&e*r+s*i>0}class Wd extends uu{static fromBuffer(t,e,s=!1){const i=e.geometryType,n=function(t){try{const e=2,s=new zd.A(new Uint8Array(t),new DataView(t));for(;s.next();){if(s.tag()===e)return Ud(s.getMessage());s.skip()}}catch(t){const e=new r.A("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:t});E.A.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(e)}return null}(t),o=function(t,e,s=!1){const i=t.asUnsafe(),n=i.pos(),o=new Dd;let a=0,h=0,c=null,l=null,u=null,d=!1;const _=[];for(;i.next();)switch(i.tag()){case 1:c=i.getString();break;case 3:l=i.getString();break;case 12:u=i.processMessage(Od.ae);break;case 9:if(o.exceededTransferLimit=i.getBool(),o.exceededTransferLimit){o.offsets.geometry=s?new Float64Array(8e3):new Int32Array(8e3),o.centroid=s?new Float64Array(16e3):new Int32Array(16e3);for(let t=0;t<o.centroid.length;t++)o.centroid[t]=Rd}break;case 13:{const t=i.processMessage(Od.cn);t.index=a++,_.push(t);break}case 15:{const t=i.getLength(),r=i.pos()+t;if(!o.exceededTransferLimit){const t=o.offsets.geometry,e=o.centroid;t.push(0),e.push(Rd),e.push(Rd)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=s?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=h*a;for(;i.pos()<r&&i.next();)switch(i.tag()){case 1:{d?o.offsets.attributes[n++]=i.pos():o.offsets.attributes.push(i.pos());const t=i.getLength();i.skipLen(t);break}case 2:if(e){const t=i.getLength(),e=i.pos()+t;for(;i.pos()<e&&i.next();)switch(i.tag()){case 3:{i.getUInt32();const t=i.getSInt64(),e=i.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:i.skip()}}else{o.offsets.geometry[h]=i.pos();const t=i.getLength();o.vertexCount+=t,i.skipLen(t)}break;case 4:{const t=i.getLength(),e=i.pos()+t;for(;i.pos()<e&&i.next();)switch(i.tag()){case 3:{i.getUInt32();const t=i.getSInt64(),e=i.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:i.skip()}break}default:i.skip()}h++,o.hasFeatures=!0;break}default:i.skip()}const p=c||l;if(!p)throw new r.A("FeatureSet has no objectId or globalId field name");return o.fields=new hl.A(_),o.featureCount=h,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(p)?.index,o.transform=u,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),i.move(n),o}(n,"esriGeometryPoint"===i,s);return new Wd(n,o,e)}constructor(t,e,s){super(s),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0},this._parseCaches=new Array,this._geometryType=s.geometryType,this._reader=t,this._header=e,this._hasNext=e.hasFeatures,this._isPoints="esriGeometryPoint"===s.geometryType}get _size(){return this._header.featureCount}get fields(){return this._header.fields}get geometryType(){return this._geometryType}get hasZ(){return!1}get hasM(){return!1}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}getSize(){return this._size}getInTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(t){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._featureIndex=t}getAttributeHash(){let t="";for(const e of this._header.fields.fields)t+=this._readAttributeAtIndex(e.index)+".";return t}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(t){this._header.displayIds[this._featureIndex]=t}readGeometryArea(){return this._cache.area||this._readGeometry(!0),this._cache.area}copy(){const t=this._reader.clone(),e=new Wd(t,this._header,this.metadata);return this.copyInto(e),e}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}get usedMemory(){return id.qK+(this._cache.geometry?.usedMemory??0)}_readX(){return this._header.centroid[2*this._featureIndex]}_readY(){return this._header.centroid[2*this._featureIndex+1]}_readServerCentroid(){const t=this._header.centroid[2*this._featureIndex],e=this._header.centroid[2*this._featureIndex+1];return t===Ld?null:new jt.A([],[t,e])}_readGeometry(t=!1){if(void 0===this._cache.geometry){let e=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===Ld)return null;const t=this._header.centroid[2*this._featureIndex],s=this._header.centroid[2*this._featureIndex+1];e=new jt.A([],[t,s])}else{const s=this._header.offsets.geometry[this._featureIndex],r=this._reader;if(0===s)return null;r.move(s);try{e=t?this._parseGeometryForDisplay(r):this._parseGeometry(r)}catch(t){return null}}return 0===e?.coords.length&&(e=null),this._cache.geometry=e,e}return this._cache.geometry}_readAttribute(t,e){const s=this._header.fields.get(t);if(null==s)return;const r=this._readAttributeAtIndex(s.index),i=this._header.fields.isDateField(s.name);return e?null==r?r:i?new Date(r):r:r}_readAttributes(){const t={};for(const e of this._header.fields.fields)t[e.name]=this._readAttributeAtIndex(e.index);return t}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._featureOffset=this._featureOffset,t._hasNext=this._hasNext,t._parseCaches=this._parseCaches}_readAttributeAtIndex(t){let e=this._parseCaches[t];if(e||(e=new Kl(this.getSize()),this._parseCaches[t]=e),e.has(this._featureIndex))return e.get(this._featureIndex);const s=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+t],r=this._reader;r.move(s);const i=function(t){const e=t.getLength(),s=t.pos()+e;for(;t.pos()<s&&t.next();)switch(t.tag()){case 1:return t.getString();case 2:return t.getFloat();case 3:return t.getDouble();case 4:return t.getSInt32();case 5:return t.getUInt32();case 6:return t.getInt64();case 7:return t.getUInt64();case 8:return t.getSInt64();case 9:return t.getBool();default:return t.skip(),null}return null}(r);return e.set(this._featureIndex,i),i}_readGeometryDeltaDecoded(t=!1){if(void 0===this._cache.unquantGeometry){const e=this._readGeometry(t);if(!e)return this._cache.unquantGeometry=void 0,null;if(!this.getInTransform())return this._cache.unquantGeometry=e,e;const s=Gd(e.coords.length).decoded,r=e.clone(s),i=r.coords;let n=0;for(const t of r.lengths){for(let e=1;e<t;e++){const t=2*(n+e),s=2*(n+e-1);i[t]+=i[s],i[t+1]+=i[s+1]}n+=t}return this._cache.unquantGeometry=r,r}return this._cache.unquantGeometry}_parseGeometry(t){const e=t.asUnsafe(),s=e.getLength(),r=e.pos()+s,i=[],n=[];for(;e.pos()<r&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;)n.push(e.getUInt32());break}case 3:{const t=e.getUInt32(),s=e.pos()+t;for(i.push(e.getSInt64()),i.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();e.pos()<s;)i.push(e.getSInt64()),i.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();break}default:e.skip()}return new jt.A(n,i)}_parseGeometryForDisplay(t){const e=t.asUnsafe(),s=e.getLength(),r=e.pos()+s,i=[],n=[];let o=0,a=0,h=null,c=0;const l="esriGeometryPolygon"===this.geometryType,u="esriGeometryPolyline"===this.geometryType,d=l||u;for(;e.pos()<r&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;){const t=e.getUInt32();i.push(t),o+=t}h=Gd(2*o).delta;break}case 3:{e.getUInt32();const t=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,C.Lw)(h);for(const s of i)if(a+t*s>h.length)for(let t=0;t<s;t++)e.getSInt32(),e.getSInt32(),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();else if(l){const t=this.getAreaSimplificationThreshold(s,this._header.vertexCount);let r=2,i=1;const o=!1;let l=e.getSInt32(),u=e.getSInt32();h[a++]=l,h[a++]=u,this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();let _=e.getSInt32(),p=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();r<s;){let s=e.getSInt32(),n=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const o=l+_,f=u+p;Vd(l,u,o,f,o+s,f+n)>=t?(c+=-.5*(o-l)*(f+u),i>1&&qd(d,h[a-2],h[a-1],_,p)?(h[a-2]+=_,h[a-1]+=p):(h[a++]=_,h[a++]=p,i++),l=o,u=f):(s+=_,n+=p),_=s,p=n,r++}i<3||o?a-=2*i:(c+=-.5*(l+_-l)*(u+p+u),qd(d,h[a-2],h[a-1],_,p)?(h[a-2]+=_,h[a-1]+=p,n.push(i)):(h[a++]=_,h[a++]=p,n.push(++i)))}else{let t=0,r=e.getSInt32(),i=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),h[a++]=r,h[a++]=i,t+=1;for(let n=1;n<s;n++){const s=e.getSInt32(),o=e.getSInt32(),l=r+s,u=i+o;c+=-.5*(l-r)*(u+i),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),n>2&&qd(d,h[a-2],h[a-1],s,o)?(h[a-2]+=s,h[a-1]+=o):(h[a++]=s,h[a++]=o,t+=1),r=l,i=u}n.push(t)}break}default:e.skip()}return this._cache.area=c,n.length?new jt.A(n,h):null!=h?this._createQuantizedExtrudedGeometry(h[0],h[1]):null}}class jd{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}class Yd extends jd{constructor(t,e){super(t,e),this._portsOpen=async function(t){const e=new kd.A;return await e.open(t,{}),e}(t.source).then((t=>this.client=t))}destroy(){this.client.close(),this.client=null}async executeQuery(t,e){await this._portsOpen;const s=await this.client.invoke("queryFeatures",t.toJSON(),e);return du.fromFeatureSet(s,this._metadata)}}class Xd extends jd{async executeQuery(t,e){const{data:s}=await(0,Sd.kS)(this.service.source,t,e),r=!t.quantizationParameters;return Wd.fromBuffer(s,this._metadata,r)}}class $d extends jd{async executeQuery(t,e){const{source:s,queryMetadata:r}=this.service;if(null!=t.quantizationParameters&&!r.supportsQuantization){const r=t.clone(),i=(0,Fd.VV)(r.quantizationParameters);r.quantizationParameters=null;const{data:n}=await(0,Sd.eW)(s,r,this._metadata.spatialReference,e),o=(0,Ch.q3)(n,this._metadata.objectIdField);return(0,Ch.jH)(i,o),du.fromOptimizedFeatureSet(o,this._metadata)}const{data:i}=await(0,Sd.eW)(s,t,this._metadata.spatialReference,e);return"esriGeometryPoint"===this._metadata.geometryType&&(i.features=i.features?.filter((t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0}))),du.fromFeatureSet(i,this._metadata)}}class Hd extends jd{async executeQuery(t,e){if(t.quantizationParameters&&!this.service.queryMetadata.supportsQuantization){const s=t.clone(),r=(0,Fd.VV)(s.quantizationParameters);s.quantizationParameters=null;const i=await(0,Ed.I)(this.service.source,t,e);return(0,Ch.jH)(r,i),du.fromOptimizedFeatureSet(i,this._metadata)}const s=await(0,Ed.I)(this.service.source,t,e);return du.fromOptimizedFeatureSet(s,this._metadata)}}class Zd extends Cd{constructor(t,e,s,r,i){super(s),this._serviceInfo=t,this._queryInfo=e,this._metadata=r,this._connection=i,this._queue=new R.e({concurrency:16,process:async t=>{const e={signal:t.options?.signal,query:t.query.customParameters};return this._adapter.executeQuery(t.query.inner,e)}}),this._adapter=function(t,e){switch(t.type){case"memory":return new Yd(t,e);case"ogc":return new Hd(t,e);case"feature-service":return t.queryMetadata.supportsFormatPBF&&(0,n.A)("featurelayer-pbf")?new Xd(t,e):new $d(t,e)}}(t,r)}unsafeSetQueryHistoricMoment(t){this._queryInfo.updateHistoricMoment(t)}async updateFields(t){this._queryInfo.updateFields(t);const e=Array.from(this._store.chunks()).map((async t=>{const e=ql.A.fromJSON(t.queryInfo.queryJSON);if(e)try{return await this._tryUpdateFields(t.reader,e),null}catch(t){return t}})),s=(await Promise.all(e)).filter((t=>t));if(s.length)throw new r.A("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async queryByObjectId(t){if(0===t.length)return du.empty(this._metadata);const e=this._queryInfo.createQuery({objectIds:t});return this._fetch(e)}async _fetch(t,e){const s=await this._enqueue(t,e);return await this._tryUpdateFields(s,t.inner),s}async _tryUpdateFields(t,e){const s=this._queryInfo.createPatchFieldsQuery(e,t);if(!s)return;const r=await this._enqueue(s,this._options);t.joinAttributes(r)}async _enqueue(t,e){return this._connection.onEvent({type:"fetchStart"}),this._queue.push({query:t,options:e}).finally((()=>{this._connection.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class Qd extends Zd{constructor(){super(...arguments),this._chunksById=new Map}unload(t){this._removeChunks(t.tile)}_addChunk(t){const e=t.tile.id;this._chunksById.has(e)||this._chunksById.set(e,[]);const s=t.size();(s||t.first||t.end)&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] ATileLoadStrategy.addChunk [count=${s}]`),this._chunksById.get(e).push(t),this._store.insert(t))}_removeChunks(t){const e=this._chunksById.get(t.key.id)??[];for(const s of e)(0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t.key.id}] Chunk[${s.chunkId}] ATileLoadStrategy.removeChunk`),this._store.remove(s);this._chunksById.delete(t.key.id)}}class Kd extends od{constructor(t,e,s,r,i,n){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._sourceTile=r,this._sourceTileDepth=i,this._end=n,this.chunkId=`${this._tile.key.id}.${this._sourceTile?.key.id}${this._end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._sourceTile?.key.normalizedId}${this._end?"e":""}`}get queryInfo(){return{type:"drill-down-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,sourceTileDepth:this._sourceTileDepth,sourceTileId:this._sourceTile?.key.id,size:this.size(),end:this.end}}get first(){return 0===this._sourceTileDepth}get reader(){return this._reader}get end(){return this._end}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class Jd{constructor(t,e){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,this._handles=(0,i.vE)([(0,a.u7)(t.signal,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))])}destroy(){this._controller.abort(),this._handles.remove()}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class t_ extends Qd{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new Jd(t,this._options));const e=this._loadStates.get(t.key.id);let s;try{for await(const s of this._fetchChunkInfos(e,t.tile,0)){const{queryJSON:t,reader:r,sourceTile:i,sourceTileDepth:n,tile:o}=s,h=new Kd(r,t,o,i,n,!1);(0,a.Te)(e.options),this._addChunk(h)}}catch(t){s=t}const r=new Kd(du.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(r),s)throw s}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let r=t.get(e.id);const i=!!r;if(r||(r=await this._fetchChunkInfo(t,e,s),t.set(e.id,r)),r.reader.exceededTransferLimit&&s<(0,n.A)("featurelayer-query-max-depth"))for(const r of e.createChildTiles())yield*this._fetchChunkInfos(t,r,s+1);else i||(yield r)}async _fetchChunkInfo(t,e,s){const r=t.subscription.tile.getQuantizationParameters(),i=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:r});return{reader:await this._fetch(i,t.options),queryJSON:i.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}class e_ extends od{constructor(t,e,s,r,i){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._page=r,this._end=i,this.chunkId=`${this._tile.key.id}.${this._page}${this.end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._page}${this.end?"e":""}`}get queryInfo(){return{type:"paged-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get page(){return this._page}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class s_{constructor(t,e){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,this._handles=(0,i.vE)([(0,a.u7)(t.signal,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))])}destroy(){this._controller.abort(),this._handles.remove()}get pageStart(){let t=-1;for(const e of this._pages.values())t=Math.max(t,e);return t+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(t,e){this._pages.add(t),this._done=this._done||e}}class r_ extends Qd{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new s_(t,this._options));const e=this._loadStates.get(t.key.id);let s;try{await this._fetchPages(e)}catch(t){s=t}const r=new e_(du.empty(this._metadata),null,t.tile,-1,!0);if((0,a.G4)(e.options)||this._addChunk(r),s)throw s}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async _fetchPages(t){let e=0,s=t.pageStart,r=1;for(;e<20&&!t.done;){const i=[];for(let e=0;e<r;e++)i.push(this._fetchChunk(t,s++));const n=await Promise.all(i);for(const e of n)(0!==e.size()||e.first)&&(t.add(e.page,!e.reader.exceededTransferLimit),(0,a.Te)(t.options),this._addChunk(e));e++,r=Math.min(r+1,4)}}async _fetchChunk(t,e){const s=t.subscription.tile,r=this._queryInfo.createPagedTileQuery(s,e),i=await this._fetch(r,t.options);return new e_(i,r.inner.toJSON(),s,e,!1)}}var i_=s(2741);let n_;const o_=new Array(128).fill(void 0);function a_(t){return o_[t]}o_.push(void 0,null,!0,!1);let h_=o_.length;function c_(t){const e=a_(t);return function(t){t<132||(o_[t]=h_,h_=t)}(t),e}function l_(t){h_===o_.length&&o_.push(o_.length+1);const e=h_;return h_=o_[e],o_[e]=t,e}const u_="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&u_.decode();let d_=null;function __(){return null!==d_&&0!==d_.byteLength||(d_=new Uint8Array(n_.memory.buffer)),d_}function p_(t,e){return t>>>=0,u_.decode(__().subarray(t,t+e))}function f_(t,e){return t>>>=0,__().subarray(t/1,t/1+e)}const g_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>{n_.__wbindgen_export_1.get(t.dtor)(t.a,t.b)}));function m_(t,e,s){n_._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h976f7baa817b77e0(t,e,l_(s))}let y_=0;const x_="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},b_="function"==typeof x_.encodeInto?function(t,e){return x_.encodeInto(t,e)}:function(t,e){const s=x_.encode(t);return e.set(s),{read:t.length,written:s.length}};function w_(t,e,s){if(void 0===s){const s=x_.encode(t),r=e(s.length,1)>>>0;return __().subarray(r,r+s.length).set(s),y_=s.length,r}let r=t.length,i=e(r,1)>>>0;const n=__();let o=0;for(;o<r;o++){const e=t.charCodeAt(o);if(e>127)break;n[i+o]=e}if(o!==r){0!==o&&(t=t.slice(o)),i=s(i,r,r=o+3*t.length,1)>>>0;const e=__().subarray(i+o,i+r);o+=b_(t,e).written,i=s(i,r,o,1)>>>0}return y_=o,i}let v_=null;function S_(){return(null===v_||!0===v_.buffer.detached||void 0===v_.buffer.detached&&v_.buffer!==n_.memory.buffer)&&(v_=new DataView(n_.memory.buffer)),v_}function I_(t,e){try{return t.apply(this,e)}catch(t){n_.__wbindgen_exn_store(l_(t))}}let M_=null;let P_=null;function T_(t,e){t>>>=0;const s=S_(),r=[];for(let i=t;i<t+4*e;i+=4)r.push(c_(s.getUint32(i,!0)));return r}let A_=null;function C_(t,e){const s=e(2*t.length,2)>>>0;return(null!==A_&&0!==A_.byteLength||(A_=new Uint16Array(n_.memory.buffer)),A_).set(t,s/2),y_=t.length,s}function k_(t,e,s){const r=w_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),i=y_;return c_(n_.readMetadata(r,i,l_(e),l_(s)))}function F_(t,e){const s=e(1*t.length,1)>>>0;return __().set(t,s/1),y_=t.length,s}function E_(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`);return t.ptr}function z_(t){return null==t}const O_=Object.freeze({Point:0,0:"Point",Polygon:1,1:"Polygon",Polyline:2,2:"Polyline",Multipoint:3,3:"Multipoint"}),R_=["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeBigInteger","esriFieldTypeSingle","esriFieldTypeDouble","esriFieldTypeLong","esriFieldTypeString","esriFieldTypeDate","esriFieldTypeOID","esriFieldTypeGeometry","esriFieldTypeBlob","esriFieldTypeRaster","esriFieldTypeGUID","esriFieldTypeGlobalID","esriFieldTypeXML","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"],D_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_columndescriptor_free(t>>>0,1)));class L_{static __wrap(t){t>>>=0;const e=Object.create(L_.prototype);return e.__wbg_ptr=t,D_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,D_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_columndescriptor_free(t,0)}name(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_name(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}physicalType(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_physicalType(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}logicalType(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_logicalType(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}encodings(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_encodings(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=T_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}pageEncodings(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_pageEncodings(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=T_(t,e).slice(),n_.__wbindgen_free(t,4*e,4)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}numValues(){return n_.columndescriptor_numValues(this.__wbg_ptr)}compression(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_compression(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}compressedSize(){return n_.columndescriptor_compressedSize(this.__wbg_ptr)}uncompressedSize(){return n_.columndescriptor_uncompressedSize(this.__wbg_ptr)}nullCount(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_nullCount(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getBigInt64(s+8,!0);return 0===t?void 0:e}finally{n_.__wbindgen_add_to_stack_pointer(16)}}distinctCount(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_distinctCount(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getBigInt64(s+8,!0);return 0===t?void 0:e}finally{n_.__wbindgen_add_to_stack_pointer(16)}}minValue(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_minValue(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=f_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}maxValue(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_maxValue(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=f_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const N_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_fieldmetadata_free(t>>>0,1)));class B_{static __wrap(t){t>>>=0;const e=Object.create(B_.prototype);return e.__wbg_ptr=t,N_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,N_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_fieldmetadata_free(t,0)}get name(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.fieldmetadata_name(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}get index(){return n_.fieldmetadata_index(this.__wbg_ptr)}get type(){const t=n_.fieldmetadata_esri_type(this.__wbg_ptr);return R_[t]}get physicalType(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.fieldmetadata_physical_type(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}get logicalType(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.fieldmetadata_logical_type(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const G_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_filemetadata_free(t>>>0,1)));class U_{static __wrap(t){t>>>=0;const e=Object.create(U_.prototype);return e.__wbg_ptr=t,G_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,G_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_filemetadata_free(t,0)}version(){return n_.filemetadata_version(this.__wbg_ptr)}numRows(){return n_.filemetadata_numRows(this.__wbg_ptr)>>>0}numFields(){return n_.filemetadata_numFields(this.__wbg_ptr)>>>0}createdBy(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.filemetadata_createdBy(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}keyValueMetadata(t){try{const r=n_.__wbindgen_add_to_stack_pointer(-16),i=w_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),n=y_;n_.filemetadata_keyValueMetadata(r,this.__wbg_ptr,i,n);var e=S_().getInt32(r+0,!0),s=S_().getInt32(r+4,!0);let o;return 0!==e&&(o=p_(e,s).slice(),n_.__wbindgen_free(e,1*s,1)),o}finally{n_.__wbindgen_add_to_stack_pointer(16)}}keys(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.filemetadata_keys(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=T_(t,e).slice(),n_.__wbindgen_free(t,4*e,4)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}getFieldIndex(t){const e=w_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),s=y_,r=n_.filemetadata_getFieldIndex(this.__wbg_ptr,e,s);return 16777215===r?void 0:r}getFieldByIndex(t){const e=n_.filemetadata_getFieldByIndex(this.__wbg_ptr,t);return 0===e?void 0:B_.__wrap(e)}getFields(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.filemetadata_getFields(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=T_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const V_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_geometryinfodescriptor_free(t>>>0,1)));class q_{static __wrap(t){t>>>=0;const e=Object.create(q_.prototype);return e.__wbg_ptr=t,V_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,V_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_geometryinfodescriptor_free(t,0)}get geometryType(){const t=n_.__wbg_get_geometryinfodescriptor_geometryType(this.__wbg_ptr);return 4===t?void 0:t}set geometryType(t){n_.__wbg_set_geometryinfodescriptor_geometryType(this.__wbg_ptr,z_(t)?4:t)}get wkbIndex(){const t=n_.__wbg_get_geometryinfodescriptor_wkbIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set wkbIndex(t){n_.__wbg_set_geometryinfodescriptor_wkbIndex(this.__wbg_ptr,z_(t)?16777215:t)}get lngIndex(){const t=n_.__wbg_get_geometryinfodescriptor_lngIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set lngIndex(t){n_.__wbg_set_geometryinfodescriptor_lngIndex(this.__wbg_ptr,z_(t)?16777215:t)}get latIndex(){const t=n_.__wbg_get_geometryinfodescriptor_latIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set latIndex(t){n_.__wbg_set_geometryinfodescriptor_latIndex(this.__wbg_ptr,z_(t)?16777215:t)}get inWkid(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.__wbg_get_geometryinfodescriptor_inWkid(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);return 0===t?void 0:e>>>0}finally{n_.__wbindgen_add_to_stack_pointer(16)}}set inWkid(t){n_.__wbg_set_geometryinfodescriptor_inWkid(this.__wbg_ptr,!z_(t),z_(t)?0:t)}get outWkid(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.__wbg_get_geometryinfodescriptor_outWkid(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);return 0===t?void 0:e>>>0}finally{n_.__wbindgen_add_to_stack_pointer(16)}}set outWkid(t){n_.__wbg_set_geometryinfodescriptor_outWkid(this.__wbg_ptr,!z_(t),z_(t)?0:t)}static new(){const t=n_.geometryinfodescriptor_new();return q_.__wrap(t)}}const W_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pageencodingdescriptor_free(t>>>0,1)));class j_{static __wrap(t){t>>>=0;const e=Object.create(j_.prototype);return e.__wbg_ptr=t,W_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,W_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pageencodingdescriptor_free(t,0)}pageType(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.pageencodingdescriptor_pageType(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}encoding(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.pageencodingdescriptor_encoding(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}count(){return n_.pageencodingdescriptor_count(this.__wbg_ptr)}}const Y_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_parquetchunk_free(t>>>0,1)));class X_{static __wrap(t){t>>>=0;const e=Object.create(X_.prototype);return e.__wbg_ptr=t,Y_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Y_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_parquetchunk_free(t,0)}size(){return n_.parquetchunk_size(this.__wbg_ptr)>>>0}hasField(t){return 0!==n_.parquetchunk_hasField(this.__wbg_ptr,t)}readX(t){return n_.parquetchunk_readX(this.__wbg_ptr,t)}readY(t){return n_.parquetchunk_readY(this.__wbg_ptr,t)}readCoords(t){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.parquetchunk_readCoords(r,this.__wbg_ptr,t);var e=S_().getInt32(r+0,!0),s=S_().getInt32(r+4,!0);let i;return 0!==e&&(i=function(t,e){return t>>>=0,(null!==M_&&0!==M_.byteLength||(M_=new Float64Array(n_.memory.buffer)),M_).subarray(t/8,t/8+e)}(e,s).slice(),n_.__wbindgen_free(e,8*s,8)),i}finally{n_.__wbindgen_add_to_stack_pointer(16)}}readLengths(t){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.parquetchunk_readLengths(r,this.__wbg_ptr,t);var e=S_().getInt32(r+0,!0),s=S_().getInt32(r+4,!0);let i;return 0!==e&&(i=function(t,e){return t>>>=0,(null!==P_&&0!==P_.byteLength||(P_=new Uint32Array(n_.memory.buffer)),P_).subarray(t/4,t/4+e)}(e,s).slice(),n_.__wbindgen_free(e,4*s,4)),i}finally{n_.__wbindgen_add_to_stack_pointer(16)}}readGeometryTransformed(t,e,s,r,i){const n=n_.parquetchunk_readGeometryTransformed(this.__wbg_ptr,t,e,s,r,i);return 0===n?void 0:Q_.__wrap(n)}boundsXMin(t){return n_.parquetchunk_boundsXMin(this.__wbg_ptr,t)}boundsYMin(t){return n_.parquetchunk_boundsYMin(this.__wbg_ptr,t)}boundsXMax(t){return n_.parquetchunk_boundsXMax(this.__wbg_ptr,t)}boundsYMax(t){return n_.parquetchunk_boundsYMax(this.__wbg_ptr,t)}readAttribute(t,e){return c_(n_.parquetchunk_readAttribute(this.__wbg_ptr,t,e))}}const $_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_parquetfile_free(t>>>0,1)));let H_=class t{static __wrap(e){e>>>=0;const s=Object.create(t.prototype);return s.__wbg_ptr=e,$_.register(s,s.__wbg_ptr,s),s}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,$_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_parquetfile_free(t,0)}metadata(){const t=n_.parquetfile_metadata(this.__wbg_ptr);return U_.__wrap(t)}rowGroups(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.parquetfile_rowGroups(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=T_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}readChunksWithCallback(t,e){const s=C_(t,n_.__wbindgen_malloc),r=y_;return c_(n_.parquetfile_readChunksWithCallback(this.__wbg_ptr,s,r,l_(e)))}readFirstChunk(t){const e=C_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.parquetfile_readFirstChunk(this.__wbg_ptr,e,s))}readAllChunks(t){const e=C_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.parquetfile_readAllChunks(this.__wbg_ptr,e,s))}updateChunks(t){const e=C_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.parquetfile_updateChunks(this.__wbg_ptr,e,s))}};const Z_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_quantizedgeometry_free(t>>>0,1)));class Q_{static __wrap(t){t>>>=0;const e=Object.create(Q_.prototype);return e.__wbg_ptr=t,Z_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Z_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_quantizedgeometry_free(t,0)}readCoordsUnsafe(){return c_(n_.quantizedgeometry_readCoordsUnsafe(this.__wbg_ptr))}readLengthsUnsafe(){return c_(n_.quantizedgeometry_readLengthsUnsafe(this.__wbg_ptr))}}const K_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_rangeproviderjs_free(t>>>0,1)));class J_{static __wrap(t){t>>>=0;const e=Object.create(J_.prototype);return e.__wbg_ptr=t,K_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,K_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_rangeproviderjs_free(t,0)}static new(t,e){const s=n_.rangeproviderjs_new(l_(t),l_(e));return J_.__wrap(s)}static withFetch(){const t=n_.rangeproviderjs_withFetch();return J_.__wrap(t)}}const tp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_rowgroup_free(t>>>0,1)));class ep{static __wrap(t){t>>>=0;const e=Object.create(ep.prototype);return e.__wbg_ptr=t,tp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,tp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_rowgroup_free(t,0)}columns(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.rowgroup_columns(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=T_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}function sp(){const t={wbg:{}};return t.wbg.__wbg_new_abda76e883ba8a5f=function(){return l_(new Error)},t.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const s=w_(a_(e).stack,n_.__wbindgen_malloc,n_.__wbindgen_realloc),r=y_;S_().setInt32(t+4,r,!0),S_().setInt32(t+0,s,!0)},t.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let s,r;try{s=t,r=e,console.error(p_(t,e))}finally{n_.__wbindgen_free(s,r,1)}},t.wbg.__wbindgen_object_drop_ref=function(t){c_(t)},t.wbg.__wbindgen_is_function=function(t){return"function"==typeof a_(t)},t.wbg.__wbg_self_3093d5d1f7bcb682=function(){return I_((function(){return l_(self.self)}),arguments)},t.wbg.__wbg_window_3bcfc4d31bc012f8=function(){return I_((function(){return l_(window.window)}),arguments)},t.wbg.__wbg_globalThis_86b222e13bdf32ed=function(){return I_((function(){return l_(globalThis.globalThis)}),arguments)},t.wbg.__wbg_global_e5a3fe56f8be9485=function(){return I_((function(){return l_(global.global)}),arguments)},t.wbg.__wbindgen_is_undefined=function(t){return void 0===a_(t)},t.wbg.__wbg_newnoargs_76313bd6ff35d0f2=function(t,e){return l_(new Function(p_(t,e)))},t.wbg.__wbindgen_object_clone_ref=function(t){return l_(a_(t))},t.wbg.__wbindgen_number_new=function(t){return l_(t)},t.wbg.__wbindgen_string_new=function(t,e){return l_(p_(t,e))},t.wbg.__wbg_call_1084a111329e68ce=function(){return I_((function(t,e){return l_(a_(t).call(a_(e)))}),arguments)},t.wbg.__wbg_call_89af060b4e1523f2=function(){return I_((function(t,e,s){return l_(a_(t).call(a_(e),a_(s)))}),arguments)},t.wbg.__wbg_call_7de908392845a9a5=function(){return I_((function(t,e,s,r,i){return l_(a_(t).call(a_(e),a_(s),a_(r),a_(i)))}),arguments)},t.wbg.__wbg_valueOf_563b3487b1b116aa=function(t){return a_(t).valueOf()},t.wbg.__wbg_buffer_b7b08af79b0b0974=function(t){return l_(a_(t).buffer)},t.wbg.__wbg_new_b85e72ed1bfd57f9=function(t,e){try{var s={a:t,b:e};return l_(new Promise(((t,e)=>{const r=s.a;s.a=0;try{return function(t,e,s,r){n_.wasm_bindgen__convert__closures__invoke2_mut__h942ec15236fcac1d(t,e,l_(s),l_(r))}(r,s.b,t,e)}finally{s.a=r}})))}finally{s.a=s.b=0}},t.wbg.__wbg_resolve_570458cb99d56a43=function(t){return l_(Promise.resolve(a_(t)))},t.wbg.__wbg_then_95e6edc0f89b73b1=function(t,e){return l_(a_(t).then(a_(e)))},t.wbg.__wbg_then_876bb3c633745cc6=function(t,e,s){return l_(a_(t).then(a_(e),a_(s)))},t.wbg.__wbg_newwithbyteoffsetandlength_b5293b0eedbac651=function(t,e,s){return l_(new Int16Array(a_(t),e>>>0,s>>>0))},t.wbg.__wbg_new_ea1883e1e5e86686=function(t){return l_(new Uint8Array(a_(t)))},t.wbg.__wbg_newwithbyteoffsetandlength_874df3e29cb555f9=function(t,e,s){return l_(new Uint32Array(a_(t),e>>>0,s>>>0))},t.wbg.__wbg_length_8339fcf5d8ecd12e=function(t){return a_(t).length},t.wbg.__wbg_set_d1e79e2388520f18=function(t,e,s){a_(t).set(a_(e),s>>>0)},t.wbg.__wbindgen_throw=function(t,e){throw new Error(p_(t,e))},t.wbg.__wbindgen_memory=function(){return l_(n_.memory)},t.wbg.__wbindgen_array_new=function(){return l_([])},t.wbg.__wbindgen_array_push=function(t,e){a_(t).push(c_(e))},t.wbg.__wbindgen_uint8_array_new=function(t,e){var s=f_(t,e).slice();return n_.__wbindgen_free(t,1*e,1),l_(s)},t.wbg.__wbg_queueMicrotask_48421b3cc9052b68=function(t){return l_(a_(t).queueMicrotask)},t.wbg.__wbindgen_cb_drop=function(t){const e=c_(t).original;return 1==e.cnt--&&(e.a=0,!0)},t.wbg.__wbg_queueMicrotask_12a30234db4045d3=function(t){queueMicrotask(a_(t))},t.wbg.__wbg_parquetchunk_new=function(t){return l_(X_.__wrap(t))},t.wbg.__wbg_parquetfile_new=function(t){return l_(H_.__wrap(t))},t.wbg.__wbg_filemetadata_new=function(t){return l_(U_.__wrap(t))},t.wbg.__wbg_fieldmetadata_new=function(t){return l_(B_.__wrap(t))},t.wbg.__wbg_rowgroup_new=function(t){return l_(ep.__wrap(t))},t.wbg.__wbg_columndescriptor_new=function(t){return l_(L_.__wrap(t))},t.wbg.__wbg_pageencodingdescriptor_new=function(t){return l_(j_.__wrap(t))},t.wbg.__wbindgen_closure_wrapper1461=function(t,e,s){return l_(function(t,e,s,r){const i={a:t,b:e,cnt:1,dtor:75},n=(...t)=>{i.cnt++;const e=i.a;i.a=0;try{return r(e,i.b,...t)}finally{0==--i.cnt?(n_.__wbindgen_export_1.get(i.dtor)(e,i.b),g_.unregister(i)):i.a=e}};return n.original=i,g_.register(n,i,i),n}(t,e,0,m_))},t}function rp(t,e){return n_=t.exports,ip.__wbindgen_wasm_module=e,v_=null,M_=null,A_=null,P_=null,d_=null,n_.__wbindgen_start(),n_}async function ip(t){if(void 0!==n_)return n_;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead"));const e=sp();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s,module:r}=await async function(t,e){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,e)}catch(e){if("application/wasm"==t.headers.get("Content-Type"))throw e;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",e)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,e)}{const s=await WebAssembly.instantiate(t,e);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,e);return rp(s,r)}const np=Object.freeze(Object.defineProperty({__proto__:null,ColumnDescriptor:L_,FieldMetadata:B_,FileMetadata:U_,GeometryInfoDescriptor:q_,GeometryType:O_,PageEncodingDescriptor:j_,ParquetChunk:X_,ParquetFile:H_,QuantizedGeometry:Q_,RangeProviderJs:J_,RowGroup:ep,default:ip,enable_tracing:function(){n_.enable_tracing()},initSync:function(t){if(void 0!==n_)return n_;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module:t}=t):console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=sp();return t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t)),rp(new WebAssembly.Instance(t,e),t)},readFile:function(t,e,s,r,i){const n=w_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),o=y_;E_(r,U_);var a=r.__destroy_into_raw();let h=0;return z_(i)||(E_(i,q_),h=i.__destroy_into_raw()),c_(n_.readFile(n,o,l_(e),l_(s),a,h))},readFileFromBinary:function(t,e){let s=0;z_(t)||(E_(t,q_),s=t.__destroy_into_raw());const r=F_(e,n_.__wbindgen_malloc),i=y_;return c_(n_.readFileFromBinary(s,r,i))},readMetadata:k_,readMetadataFromFile:function(t){const e=F_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.readMetadataFromFile(e,s))}},Symbol.toStringTag,{value:"Module"}));let op=null;async function ap(){return op||(op=async function(){const t=await Promise.resolve().then((()=>np));return await t.default({module_or_path:(0,i_.s)("esri/libs/parquet/pkg/arcgis_parquet_bg.wasm")}),t}()),op}const hp=t=>async function(e,s,r){const i=t(),{data:n}=await(0,vd.A)(e,{responseType:"array-buffer",query:i,headers:{range:`bytes=${s}-${r}`}});return n},cp=t=>async function(e){const s=t(),{data:r}=await(0,vd.A)(e,{responseType:"native",method:"head",query:s}),i=r.headers.get("Content-Length");if(null==i)throw new Error("Unable to parse content length");return parseInt(i,10)};class lp{static async create(t,e){const s=await ap(),r=await s.readMetadata(t,hp(e),cp(e));return lp.fromFileMetadata(r)}static fromFileMetadata(t){const e=[];for(let s=0;s<t.numFields();s++){const r=t.getFieldByIndex(s);e.push({name:r.name,type:r.type,alias:r.name,index:r.index}),r.free()}return new lp(t,e)}constructor(t,e){this._inner=t,this.fields=e}destroy(){this._inner.free()}[Symbol.dispose](){this.destroy()}get size(){return this._inner.numRows()}getFieldIndex(t){return this._inner.getFieldIndex(t)}tryReadGeoMetadata(){const t=this._inner.keyValueMetadata("geo");return null==t?null:JSON.parse(t)}}function up(t,e,s){const r=q_.new();return r.geometryType=function(t){switch(t){case"esriGeometryPoint":return O_.Point;case"esriGeometryPolygon":return O_.Polygon;case"esriGeometryPolyline":return O_.Polyline;case"esriGeometryMultipoint":return O_.Multipoint;default:throw new Error(`InternalError: Found unexpected GeometryType: ${t}`)}}(t.geometryType),"location"===t.type?(r.latIndex=e.getFieldIndex(t.latitudeFieldName),r.lngIndex=e.getFieldIndex(t.longitudeFieldName)):r.wkbIndex=e.getFieldIndex(t.primaryFieldName),r.inWkid=t.spatialReference.wkid,s&&(r.outWkid=s.wkid),r}class dp{static async create(t,e){const s=await ap(),r=hp(e.getCustomParameters),i=cp(e.getCustomParameters),n=await k_(t,r,i),o=up(e.geometryInfo,n,e.outSpatialReference),a=await s.readFile(t,r,i,n,o);return new dp(a,lp.fromFileMetadata(a.metadata()))}static async fromFile(t,e,s){const r=await ap(),i=await r.readMetadataFromFile(t),n=e?up(e,i,s):void 0,o=await r.readFileFromBinary(n,t);return new dp(o,lp.fromFileMetadata(o.metadata()))}constructor(t,e){this.inner=t,this.metadata=e}destroy(){this.inner.free(),this.metadata.destroy()}[Symbol.dispose](){this.destroy()}}class _p extends od{constructor(t,e,s,r){super(),this._reader=t,this._queryJSON=e,this._page=s,this._end=r,this.chunkId=`${this._page}${this.end?"e":""}`,this.normalizedChunkId=this.chunkId}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class pp extends uu{constructor(t,e,s,r,i,n=new Uint32Array(r.size())){super(t),this._fields=e,this._geometryInfo=s,this._inner=r,this._chunkId=i,this._displayIds=n,this._index=-1,this.usedMemory=id.qK,this._size=this._inner.size(),"geometry"===this._geometryInfo.type&&(this._primaryGeometryIndex=this._fields.get(this._geometryInfo.primaryFieldName)?.index),null!=t.objectIdField&&(this._objectIdFieldIndex=this._fields.get(t.objectIdField)?.index),this._chunkId>65535&&console.error("Exceeded max allowed parquet reader size")}destroy(){super.destroy(),this._inner.free()}get fields(){return this._fields}get geometryType(){return this._geometryInfo.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return null}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let t="";for(const e of this.fields.fields)t+=this._readAttribute(e.name,!1)+".";return t}getObjectId(){return null!=this._objectIdFieldIndex?this._inner.readAttribute(this._index,this._objectIdFieldIndex):this._index<<16|this._chunkId}getDisplayId(){return this._displayIds[this._index]}setDisplayId(t){this._displayIds[this._index]=t}setIndex(t){this._index=t}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(t){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(t){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(t){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(t){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){throw new Error("Method not implemented.")}copy(){const t=new pp(this.metadata,this._fields,this._geometryInfo,this._inner,this._chunkId,this._displayIds);return this.copyInto(t),t}copyInto(t){super.copyInto(t),t._index=this._index}readGeometryForDisplayTransformed(t){const[e,s]=t.translate,[r,i]=t.scale,n=this._inner.readGeometryTransformed(this._index,e,s,r,-i);return n?new jt.A(n.readLengthsUnsafe(),n.readCoordsUnsafe()):null}_readGeometry(t){const e=this._inner.readCoords(this._index),s=this._inner.readLengths(this._index);return e&&s?new jt.A(s,e):null}_readX(){return this._readGeometry()?.coords[0]}_readY(){return this._readGeometry()?.coords[1]}_readServerCentroid(){return null}_readAttribute(t,e){const s=this.fields.get(t);if(!s)return;const r=this._inner.readAttribute(this._index,s.index);if(null==r)return r;const i=this.fields.isDateField(s.name);return e?null==r?r:i?new Date(r):r:r}_readAttributes(){const t={};for(const e of this._fields.fields)this._inner.hasField(e.index)&&e.index!==this._primaryGeometryIndex&&(t[e.name]=this._readAttribute(e.name,!1));return null==this._objectIdFieldIndex&&(t.__OBJECTID=this.getObjectId()),t}}class fp extends Cd{constructor(t,e,s,r){super(r),this._service=t,this._metadata=e,this._schema=s,this._chunkId=0,this._files=[],this._availableFields=new Set(s.mutable.availableFields);const{geometryInfo:i}=this._service;"location"===i.type?(this._availableFields.add(i.latitudeFieldName),this._availableFields.add(i.longitudeFieldName)):this._availableFields.add(i.primaryFieldName)}destroy(){for(const t of this._files)t.destroy()}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}async updateFields(t){await this._promise;const e=new Set(t),s=(0,k.iv)(e,this._availableFields);this._availableFields=(0,k.KC)(s,this._availableFields),await Promise.all(this._files.map((t=>{const e=Array.from(s).map((e=>t.metadata.getFieldIndex(e)));return t.inner.updateChunks(new Uint16Array(e))})))}async load(t){return null==this._promise&&(this._promise=this._download()),this._promise}unload(t){}async addParquetFile(t){this._insert(t)}async _insert(t){const e=await dp.create(t,{geometryInfo:this._service.geometryInfo,outSpatialReference:this._service.outSpatialReference,getCustomParameters:()=>this._schema.mutable.dataFilter.customParameters}),{geometryInfo:s}=this._service;(0,a.Te)(this._options);const{fields:r,timeZoneByFieldName:i}=this._service.metadata.fieldsIndex,n=r.map((t=>({...t,index:e.metadata.getFieldIndex(t.name)}))),o=hl.A.fromJSON({fields:n,timeZoneByFieldName:i}),h=new Uint16Array(Array.from(this._availableFields.values()).map((t=>o.get(t)?.index)));await e.inner.readChunksWithCallback(h,(t=>{const e=this._chunkId++,r=new pp(this._metadata,o,s,t,e),i=new _p(r,null,e,!1);this._store.insert(i)})),this._files.push(e)}async _download(){try{await Promise.all(this._service.source.urls.map((t=>this._insert(t))));const t=new _p(du.empty(this._metadata),null,-1,!0);this._store.insert(t)}catch(t){throw console.error(t),t}}}class gp extends Zd{constructor(t,e,s,r,i,n){super(t,e,s,i,n),this._random=new h.A(1e3),this._featureCount=r}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return null==this._promise&&(this._promise=this._downloadPages(this._featureCount)),this._promise}unload(t){}async _downloadPages(t){const e=Math.ceil(t/this._queryInfo.pageSize),s=Array.from({length:e},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),i=await Promise.all(s.map((t=>this._downloadPage(t)))),n=new _p(du.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=i.filter((t=>t));if(o.length)throw new r.A("featurelayer-query","Encountered errors when downloading data",{errors:o})}async _downloadPage(t){try{const e=this._queryInfo.createPagedQuery(t),s=await this._fetch(e,this._options),r=new _p(s,e.inner.toJSON(),t,!1);return(0,a.Te)(this._options),this._store.insert(r),null}catch(t){return t}}}class mp{constructor(t){this.size=0,this._start=0,this.maxSize=t,this._buffer=new Array(t)}get entries(){return this._buffer}enqueue(t){if(this.size===this.maxSize){const e=this._buffer[this._start];return this._buffer[this._start]=t,this._start=(this._start+1)%this.maxSize,e}return this._buffer[(this._start+this.size++)%this.maxSize]=t,null}dequeue(){if(0===this.size)return null;const t=this._buffer[this._start];return this._buffer[this._start]=null,this.size--,this._start=(this._start+1)%this.maxSize,t}peek(){return 0===this.size?null:this._buffer[this._start]}peekLast(){return 0===this.size?null:this._buffer[(this._start+(this.size-1))%this.maxSize]}find(t){if(0===this.size)return null;for(const e of this._buffer)if(null!=e&&t(e))return e;return null}clear(t){let e=this.dequeue();for(;null!=e;)t&&t(e),e=this.dequeue()}}const yp="__esri_timestamp__";class xp{constructor(t,e,s,r,i=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=r,this.store=t,this.objectIdField=e,this.purgeInterval=i,this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}removeById(t){this._removed.push(t)}removeByTrackId(t){const e=this._trackIdToObservations.get(t);if(e)for(const t of e.entries)this._removed.push(t)}add(t){if(this._useGeneratedIds){const e=this._nextId();t.attributes[this.objectIdField]=e,t.objectId=e}else t.objectId=t.attributes[this.objectIdField];const e=t.objectId;if(this._addOrUpdated.set(e,t),this._maxAge=Math.max(this._maxAge,t.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return null==this._trackIdLessObservations&&(this._trackIdLessObservations=new mp(1e5)),void this._trackIdLessObservations.enqueue(e);const s=t.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(s)){const t=null!=this._purgeOptions?.maxObservations?this._purgeOptions.maxObservations:1e3,e=(0,ks.qE)(t,0,1e3);this._trackIdToObservations.set(s,new mp(e))}const r=this._trackIdToObservations.get(s),i=r?.enqueue(e);null!=i&&(this._addOrUpdated.has(i)?this._addOrUpdated.delete(i):this._removed.push(i))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const r=[];if(null!=e)for(const t of e){const e=this.store.removeById(t);null!=e&&r.push(e)}const i=[];if(null!=t){const r=new Set(e??[]);for(const e of t)r.has(e.objectId)||(e.attributes[yp]=s,this.store.add(e),i.push(e))}return!(!i.length&&!r?.length||(this.store.update(i,r),0))}_getToAdd(){if(!this._addOrUpdated.size)return null;const t=new Array(this._addOrUpdated.size);let e=0;return this._addOrUpdated.forEach((s=>t[e++]=s)),this._addOrUpdated.clear(),t}_getToRemove(){const t=this._removed;return this._removed.length?(this._removed=[],t):null}_nextId(){const t=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,t}_purge(t){const e=this._purgeOptions;null!=e&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeByAgeReceived(t,e),this._purgeTracks())}_purgeSomeByDisplayCount(t){if(!t.displayCount)return;let e=this.store.size;if(e>t.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(e>t.displayCount&&s.size){const t=s.dequeue();this._removed.push(t),e--}if(null!=this._trackIdLessObservations){let s=e-t.displayCount;for(;s-- >0;){const t=this._trackIdLessObservations.dequeue();null!=t&&this._removed.push(t)}}}}_purgeByAge(t){const e=this._timeInfo?.startTimeField;if(!t.age||!e)return;const s=60*t.age*1e3,r=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<r&&this._removed.push(t.objectId)}))}_purgeByAgeReceived(t,e){if(!e.ageReceived)return;const s=t-60*e.ageReceived*1e3;this.store.forEach((t=>{t.attributes[yp]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}var bp=s(30624);let wp=class extends T.A{constructor(t){super(t)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,P._)([(0,F.MZ)()],wp.prototype,"connection",void 0),(0,P._)([(0,F.MZ)()],wp.prototype,"connectionStatus",null),(0,P._)([(0,F.MZ)()],wp.prototype,"errorString",null),wp=(0,P._)([(0,z.$)("esri.views.2d.layers.features.sources.StreamConnectionState")],wp);class vp{constructor(t,e){this._metadata=t,this._onUpdate=e,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return du.fromFeatures([...this._objectIdToFeature.values()],this._metadata)}add(t){this._objectIdToFeature.set(t.objectId,t)}forEach(t){this._objectIdToFeature.forEach(t)}removeById(t){const e=this._objectIdToFeature.get(t);return e?(this._objectIdToFeature.delete(t),e):null}clear(){this._objectIdToFeature=new Map}update(t,e){this._onUpdate(t?.length??0)}}class Sp extends od{constructor(t){super(),this._reader=t,this.chunkId="stream-chunk",this.normalizedChunkId="stream-chunk"}get reader(){return this._reader}get first(){return!0}get end(){return!0}get queryInfo(){return{type:"stream",chunkId:this.chunkId,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Ip extends Cd{constructor(t,e,s,r,i){super(s),this._service=t,this._dataFilter=e,this._streamOptions=r,this._metadata=i,this._connectionState=new wp,this._forceRefresh=!1,this.events=new ll.A;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=e;this._stagingStore=new vp(this._metadata,(t=>this.events.emit("features-updated",t))),this._manager=new xp(this._stagingStore,n,o,a),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}async refresh(){const t=null!=this._chunk;this._manager.checkForUpdates()||!t||this._forceRefresh?(this._chunk&&this._store.remove(this._chunk),this._forceRefresh=!1,this._chunk=new Sp(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick")):this.events.emit("tick")}async updateFields(t){throw new Error("Updating available fields not supported for StreamLayer")}async load(t){}unload(t){}disconnect(){this._connection=(0,C.pR)(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:t,spatialReference:e}=this._metadata,{maxReconnectionAttempts:s,maxReconnectionInterval:r,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,bp.createConnection)(this._service.source,e,this._streamOptions.outSR,t,o,n,s,r,a),this._handlesGroup=(0,i.vE)([this._connection.on("data-received",(t=>this._onFeature(t))),this._connection.on("message-received",(t=>this._onWebSocketMessage(t)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(t){this._connection?.updateCustomParameters(t)}sendMessageToSocket(t){this._connection?.sendMessageToSocket(t)}sendMessageToClient(t){this._connection?.sendMessageToClient(t)}_onWebSocketMessage(t){if("type"in t)switch(t.type){case"delete":if(t.objectIds)for(const e of t.objectIds)this._manager.removeById(e);if(t.trackIds)for(const e of t.trackIds)this._manager.removeByTrackId(e);break;case"clear":this.clear()}this.events.emit("message-received",t)}_onFeature(t){try{this._manager.add(t),this.events.emit("data-received",t)}catch(t){}}}class Mp{constructor(t,e){this._onChange=t,this._metadata=e,this._chunks=new Map,this._chunksToRemove=[],this._overrides=new ld,this.events=new ll.A,this.featureAdapter=new Wl}destroy(){this.clear()}clear(){for(const t of this._chunks.values())this._chunksToRemove.push(t);this._chunks.clear()}*chunks(){this._overrides&&(yield this._overrides.asChunk(this._metadata)),yield*this._chunks.values()}insert(t){(0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.insert`),this._overrides.onChunkInsert(t),this._chunks.set(t.chunkId,t),this.events.emit("changed"),this._onChange()}remove(t){(0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.remove`),this._chunks.delete(t.chunkId),this._chunksToRemove.push(t)}cleanupRemovedChunks(){const t=this._chunksToRemove;return this._chunksToRemove=[],t}applyOverride(t){this._overrides.apply(t,this),this.events.emit("changed");for(const t of this._chunks.values())t.invalidate()}takeOverrideUpdate(){return this._overrides.takeOverrideUpdate()}forEach(t){const e=new Set;for(const s of this.chunks()){const r=s.reader.getCursor();for(;r.next();){const s=r.getObjectId();e.has(s)||(t(r.copy()),e.add(s))}}}forEachUnsafe(t){const e=new Set;for(const s of this.chunks()){const r=s.reader.getCursor();for(;r.next();){const s=r.getObjectId();e.has(s)||(t(r),e.add(s))}}}forEachInBounds(t,e){const s=new Set;for(const r of this.chunks()){const i=r.queryFeaturesInBounds(t);for(;i.next();){const t=i.getObjectId();s.has(t)||(e(i.copy()),s.add(t))}}}forEachBounds(t,e){const s=(0,ul.vt)();for(const r of t)r.getBounds(s)&&e(s)}}var Pp=s(32587),Tp=s(79897);let Ap=class extends T.A{constructor(t){super(t),this.debugName="",this._updatingHandles=new Tp.U,this._idToUpdatingState=new Pp.A}get updating(){const t=this._updatingHandles.updating||Array.from(this._idToUpdatingState.values()).some((t=>t));if((0,n.A)("esri-2d-log-updating")){const e=Array.from(this._idToUpdatingState.entries()).map((([t,e])=>`-> ${t}: ${e}`)).join("\n");console.log(`${this.debugName}: Updating: ${t}\n-> Handles: ${this._updatingHandles.updating}\n${e}`)}return t}addUpdateTracking(t,e){const s=(0,c.wB)((()=>e.updating),(e=>this._idToUpdatingState.set(t,e)),{sync:!0});this.addHandles(s)}addPromise(t){return this._updatingHandles.addPromise(t)}};(0,P._)([(0,F.MZ)({constructOnly:!0})],Ap.prototype,"debugName",void 0),(0,P._)([(0,F.MZ)({readOnly:!0})],Ap.prototype,"updating",null),Ap=(0,P._)([(0,z.$)("esri.views.2d.layers.support.UpdateTracking2D")],Ap);class Cp{constructor(t,e,s,r,i){this.service=t,this._aggregateAdapter=e,this._subscriptions=s,this._onChange=r,this._connection=i,this._updateTracking=new Ap({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._metadata=Yl.createFeature(t.metadata),this._store=new Mp(this._onChange,this._metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((t=>t.close()))}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return Id.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:t}=this._schema.mutable,e=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new _l.do({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:t.definitionExpression,availableFields:e})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(t){this._connection.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._connection.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._connection.onEvent({type:"error",tile:t.tile.id,error:e}))),this._updateTracking.addPromise(e))}onResume(t){this._updateTracking.addPromise((0,a.QZ)(this._strategy?.load(t)))}onUnsubscribe(t){this._connection.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}applyOverride(t){this._didInvalidateData=!0,this._store.applyOverride(t)}takeOverrideUpdate(){return this._store.takeOverrideUpdate()}async update(t,e){const s=t.source,r=(0,V.Ui)(this._schema?.mutable,s.mutable);if(!r)return!1;if((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:r}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),(0,V.w2)(r,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if(("feature"===s.type||"parquet"===s.type)&&(0,V.w2)(r,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(e);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(t){this._connection.onEvent({type:"updateFieldsError",error:t})}}return!1}return!(!(0,V.Mj)(r,"dataFilter")&&!(0,V.Mj)(r,"sourceRefreshVersion")||(await this._updateStrategy(e),0))}async addParquetFile(t){this._strategy.addParquetFile(t)}unsafeSetQueryHistoricMoment(t){"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=t,this._strategy.unsafeSetQueryHistoricMoment(new Date(t)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new Ad(this._connection))}async normalizeOverrides(t){const e={historicMoment:t.historicMoment,commands:{updateWeak:t.commands.updateWeak.map(ol.Om.fromJSON),removeWeak:t.commands.removeWeak,update:t.commands.update.map(ol.Om.fromJSON),remove:t.commands.remove,release:t.commands.release}},s=t.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(s);return e.commands.updateWeak.push(...r),e}async _queryOptimizedFeatures(t){if(0===t.length)return[];const e=[],s=(await this._strategy.queryByObjectId(t)).getCursor();for(;s.next();)e.push(s.readOptimizedFeatureWorldSpace());return e}getObjectIdsFromGlobalIds(t){const e=new Set(t),s=this.metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=[];return this._store.forEachUnsafe((t=>{const i=t.readAttribute(s);if(e.has(i)){const e=t.getObjectId();null!=e&&r.push(e)}})),r}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,e={...t.query,f:"json"},s=(await(0,vd.A)(t.path,{query:e,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _createStrategy(){const t="isSourceHosted"in this.service&&this.service.isSourceHosted,e=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=t||e||s;if("stream"===this._schema.type){const t=new Ip(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}if("parquet"===this._schema.type){const t=this.service;return new fp(t,this._metadata,this._schema,this._store)}const i=this.service,n=Td.fromSchema(i,this._schema,this._metadata),o=await this._supportSnapshotMode(i,n);return o?new gp(i,n,this._store,o.featureCount,this.metadata,this._connection):r?new r_(i,n,this._store,this.metadata,this._connection):new t_(i,n,this._store,this.metadata,this._connection)}async _updateStrategy(t){const e=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:e.about});const s=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=e,(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategy`,{strategy:e});const r=Array.from(this._subscriptions.values());if(!r.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(r.map((t=>this._strategy.load(t).then((()=>this._connection.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._connection.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(i);try{s&&await i}catch(t){(0,a.jH)(t)}this._connection.onEvent({type:"updateStrategyEnd"}),(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategyEnd`,{strategy:e})}async _supportSnapshotMode(t,e){const{queryMetadata:s}=t,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const i=t.source,n=e.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,Sd.gW)(i,n.inner,{query:n.customParameters})).data.count,{min:a,max:h}=r.snapshotCountThresholds;return o<=a||r.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}class kp{constructor(t,e){this.tile=t,this.version=e,this._abortController=new AbortController}get key(){return this.tile.key}get signal(){return this._abortController.signal}abort(){this._abortController.abort()}}var Fp=s(98291),Ep=s(27348);class zp{constructor(t,e){this.key=new p.A(0,0,0,0),this.bounds=(0,N.vt)(),this.objectIds=new Set,this.key.set(e);const s=t.getLODInfoAt(this.key);this.tileInfoView=t,this.tileInfoView.getTileBounds(this.bounds,this.key,!0),this.resolution=s.resolution,this.level=s.level,this.scale=s.scale,this.minScale=t.zoomToScale(s.level-1),this.maxScale=t.zoomToScale(s.level+1)}get lod(){return this.tileInfoView.getLODInfoAt(this.key)}get id(){return this.key.id}get extent(){return(0,N.w1)(this.bounds,this.tileInfoView.tileInfo.spatialReference)}get transform(){return{originPosition:"upperLeft",scale:[this.resolution,this.resolution],translate:[this.bounds[0],this.bounds[3]]}}createArcadeEvaluationOptions(t){return Tu(this.scale,t)}createChildTiles(){const t=this.key.getChildKeys(),e=Fp.A.acquire();for(let s=0;s<t.length;s++)e[s]=new zp(this.tileInfoView,t[s]);return e}getQuantizationParameters(){return Ep.A.fromJSON({mode:"view",originPosition:"upperLeft",tolerance:this.resolution,extent:{xmin:this.bounds[0],ymin:this.bounds[1],xmax:this.bounds[2],ymax:this.bounds[3],spatialReference:this.tileInfoView.tileInfo.spatialReference}})}}class Op{constructor(t){this.inner=t,this.resolver=(0,a.Tw)()}}class Rp{constructor(){this._aggregateAdapter={getFeatureObjectIds:t=>this._processor.getFeatureObjectIdsForAggregate(t)},this._subscriptions=new Map,this._updateRequested=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor?.destroy(),this._source?.destroy(),this._handles?.remove(),this._updateOverridesRequest=null,this._tileInfoView=null}onAttach(t){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const e=this._connection,s=d.A.fromJSON(t.tileInfoJSON);this._tileInfoView=new M(s),this._source=new Cp(t.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),e),this._processor=new bd(e,this._source),this._handles=(0,i.vE)([(0,c.wB)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),(0,a.QZ)(this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(t){this._connection=new G(t)}get features(){const t=this._source?.queryEngine;if(!t)throw new r.A("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new r.A("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(t){return this._processor.getDisplayFeatures(t)}getDisplayIds(t){return this._processor.getDisplayIds(t)}getObjectIdsFromGlobalIds(t){return this._source.getObjectIdsFromGlobalIds(t)}async updateSchema(t,e){return(0,n.A)("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new Op({schema:t,version:e}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(t){const e=new Op(t);return this._updateSubscriptionRequests.push(e),this._requestUpdate(),e.resolver.promise}updateHighlight(t){const e=new Op(t);return this._updateHighlightRequests.push(e),this._requestUpdate(),e.resolver.promise}async addParquetFile(t){return this._source.addParquetFile(t)}async onOverride(t){if(null!=this._updateOverridesRequest)throw new r.A("InternalError - Already processing an edit");this._updateOverridesRequest=new Op(t);const e=this._updateOverridesRequest.resolver.promise;return this._requestUpdate(),e}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(t,e){return this.features.executeQuery(t,e)}async queryHeatmapStatistics(t){const e=Math.round((0,l.Lz)(t.radius));let s=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const i="string"==typeof t.fieldOffset,n=t.fieldOffset??0,o=Array.from(this._subscriptions.values()),a=this._source.chunks(),h=e**2,c=3/(Math.PI*h),u=2*e,d=Math.ceil(B.CQ/u);for(const e of o){const o=e.tile,l=new Float64Array(d*d);for(const e of a){const s=e.getTileReader(o);if(!s)continue;const r=s.getCursor();for(;r.next();){let e=1;if(null!=t.field){const s=r.readAttribute(t.field);e=i?-1*+s:+s+n}const s=r.readXForDisplay()/u,o=r.readYForDisplay()/u,a=Math.floor(s),_=Math.floor(o);if(a<0||_<0||a>=d||_>=d)continue;const p=((.5+a-s)*u)**2+((.5+_-o)*u)**2;if(p>h)continue;const f=e*(c*(1-p/h)**2);l[_+a*d]+=f}}for(let t=0;t<l.length;t++)s=Math.min(s,l[t]),r=Math.max(r,l[t])}return{max:r,min:s}}async getSampleFeatures(t){const e=this._source.chunks();if(e.reduce(((t,e)=>t+e.size()),0)<=t.minFeatureCount){if(!this._source.updateTracking.updating){const t=[];return this._source.store.forEachUnsafe((e=>t.push(e.readLegacyFeatureWorldSpace()))),t}return null}const s=new Set,r=[],i=e.map((t=>t.reader.getCursor())),n=new h.A,o=3*t.sampleSize;for(let a=0;a<o&&r.length<t.sampleSize;a++){const t=i[n.getIntRange(0,e.length-1)];if(0===t.getSize())continue;const o=n.getIntRange(0,t.getSize()-1);t.setIndex(o);const a=t.getObjectId();s.has(a)||(s.add(a),r.push(t.readLegacyFeatureWorldSpace()))}return r.length>=t.sampleSize?r:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.d)((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=(0,u.oV)(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(t){const e=t.tileId;if(this._subscriptions.has(e))return;(0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.subscribe`);const s=new zp(this._tileInfoView,e),r=new kp(s,t.version);this._subscriptions.set(e,r),this._source.onSubscribe(r),this._processor.onSubscribe(r)}_unsubscribe(t){const e=this._subscriptions.get(t);e&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.unsubscribe`),e.abort(),this._source.onUnsubscribe(e),this._processor.onUnsubscribe(e),this._subscriptions.delete(e.key.id))}async _doUpdate(){if((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const t=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const e of t)this._doUpdateSubscriptions(e.inner),e.resolver.resolve()}const t=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=t){const{schema:e,version:s}=t.inner;await this._doUpdateSchema(e,s)}const e=this._updateOverridesRequest;if(this._updateOverridesRequest=null,null!=e){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyOverride",e.inner);const t=await this._source.normalizeOverrides(e.inner);null!=t.historicMoment&&this._source.unsafeSetQueryHistoricMoment(t.historicMoment),this._source.applyOverride(t),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.endOverride",e.inner)}if(this._updateHighlightRequests.length){const t=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const e of t)this._processor.updateHighlight(e.inner),e.resolver.resolve()}const s=this._source.cleanupRemovedChunks();this._processor.removeChunks(s);try{const t=this._source.takeOverrideUpdate();null!=t&&this._subscriptions.size&&((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesStart"),await this._processor.applyOverrideUpdate(t),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesEnd")),this._subscriptions.size&&((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(t){(0,a.jH)(t)}null!=e&&e.resolver.resolve(),null!=t&&t.resolver.resolve(),this._updateRequested?((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0})):((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(t,e){(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateStart`,{schema:t});const s={tileInfo:this._tileInfoView?.tileInfo},r=await this._source.update(t,e),i=Array.from(this._subscriptions.values());await this._processor.update(t,e,s,r,i),(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateEnd`)}_doUpdateSubscriptions(t){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",t);for(const e of t.subscribe)this._subscribe(e);for(const e of t.unsubscribe)this._unsubscribe(e)}}},44159:(t,e,s)=>{s.d(e,{A:()=>i});var r=s(93687);class i{static getId(t,e,s,r){return"object"==typeof t?`${t.level}/${t.row}/${t.col}/${t.world}`:`${t}/${e}/${s}/${r}`}constructor(t,e,s,r){this.set(t,e,s,r)}get key(){return this}get id(){return this.toString()}get normalizedId(){return`${this.level}/${this.row}/${this.col}`}set id(t){this.set(t)}get hash(){const t=4095&this.row,e=4095&this.col,s=63&this.level;return(3&this.world)<<30|e<<22|t<<8|s}acquire(t,e,s,r){this.set(t,e,s,r)}contains(t){const e=t.level-this.level;return e>=0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}containsChild(t){const e=t.level-this.level;return e>0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}equals(t){return this.level===t.level&&this.row===t.row&&this.col===t.col&&this.world===t.world}clone(){return new i(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(t,e,s,r){if(null==t)this.level=0,this.row=0,this.col=0,this.world=0;else if("object"==typeof t)this.level=t.level||0,this.row=t.row||0,this.col=t.col||0,this.world=t.world||0;else if("string"==typeof t){const[e,s,r,i]=t.split("/");this.level=parseFloat(e),this.row=parseFloat(s),this.col=parseFloat(r),this.world=parseFloat(i)}else this.level=+t,this.row=+e,this.col=+s,this.world=+r||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new i(this.level-1,this.row>>1,this.col>>1,this.world)}getNormalizedNeighbor(t,e,s){const r=this.clone();return r.col+=t,r.row+=e,s.normalizeKey(r),r}getChildKeys(){const t=this.level+1,e=this.row<<1,s=this.col<<1,r=this.world;return[new i(t,e,s,r),new i(t,e,s+1,r),new i(t,e+1,s,r),new i(t,e+1,s+1,r)]}compareRowMajor(t){return this.row<t.row?-1:this.row>t.row?1:this.col<t.col?-1:this.col>t.col?1:0}}i.pool=new r.A(i,null,null,25,50)},46263:(t,e,s)=>{var r;s.d(e,{c:()=>r}),function(t){t[t.Pass=0]="Pass",t[t.Draw=1]="Draw"}(r||(r={}))},620:(t,e,s)=>{s.d(e,{O_:()=>n,vA:()=>i}),s(48163),s(87317),(0,s(91829).vt)();class r{constructor(t){this.message=t}toString(){return`AssertException: ${this.message}`}}function i(t,e="Assertion"){if(!t){const t=new Error(e).stack;throw new r(`${e} at ${t}`)}}function n(t,e,s,r){let i,n=(s[0]-t[0])/e[0],o=(r[0]-t[0])/e[0];n>o&&(i=n,n=o,o=i);let a=(s[1]-t[1])/e[1],h=(r[1]-t[1])/e[1];if(a>h&&(i=a,a=h,h=i),n>h||a>o)return!1;a>n&&(n=a),h<o&&(o=h);let c=(s[2]-t[2])/e[2],l=(r[2]-t[2])/e[2];return c>l&&(i=c,c=l,l=i),!(n>l||c>o||(l<o&&(o=l),o<0))}},89738:(t,e,s)=>{s.d(e,{e:()=>l}),s(44208);var r=s(97768),i=s(74887),n=s(9775),o=s(32587),a=s(11932),h=s(44794);class c{constructor(t,e){this.item=t,this.controller=e,this.promise=null}}class l{constructor(t){this._schedule=null,this._task=null,this._deferreds=new o.A,this._controllers=new o.A,this._processingItems=new o.A,this._pausedSignal=(0,h.v)(!1),this.concurrency=1,t.concurrency&&(this.concurrency=t.concurrency),this._queue=new n.A(t.peeker),this.process=t.process;const e=t.scheduler;t.priority&&e&&(this._task=e.registerTask(t.priority,this))}destroy(){this.clear(),this._schedule=(0,r.xt)(this._schedule),this._task=(0,r.xt)(this._task)}get updating(){return!!this._task?.updating||this.running}get length(){return this._processingItems.size+this._queue.length}abort(t){const e=this._controllers.get(t);e&&e.abort()}clear(){this._queue.clear();const t=[];this._controllers.forEach((e=>t.push(e))),this._controllers.clear(),t.forEach((t=>t.abort())),this._processingItems.clear(),this._cancelNext()}forEach(t){this._deferreds.forEach(((e,s)=>t(s)))}get(t){const e=this._deferreds.get(t);return e?e.promise:void 0}isOngoing(t){return this._processingItems.has(t)}has(t){return this._deferreds.has(t)}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(t,e){const s=this.get(t);if(s)return s;const r=new AbortController;let n=null;e&&(n=(0,i.u7)(e,(()=>r.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(t),this._queue.remove(t),this._scheduleNext()},a=(0,i.NY)(r.signal,(()=>{const e=this._processingItems.get(t);e&&e.controller.abort(),o(),h.reject((0,i.NK)())})),h=(0,i.Tw)();return this._deferreds.set(t,h),this._controllers.set(t,r),h.promise.then(o,o),this._queue.push(t),this._scheduleNext(),h.promise}last(){return this._queue.last()}lastPromise(){const t=this.last();return t?this.get(t):null}peek(){return this._queue.peek()}popLast(){const t=this._queue.popLast();return t&&(this._deferreds.get(t)?.reject((0,i.NK)()),this._removeItem(t)),t}reset(){const t=Array.from(this._processingItems.values());this._processingItems.clear();for(const e of t)this._queue.push(e.item),e.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const t=[];for(;this._queue.length;)t.push(this._queue.pop());return this.clear(),t}get running(){return!this._pausedSignal.value&&this._queue.length>0&&this._processingItems.size<this.concurrency}runTask(t){for(;!t.done&&this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop()),t.madeProgress()}_removeItem(t){this._deferreds.delete(t),this._controllers.delete(t),this._processingItems.delete(t)}_scheduleNext(){this._task||this._pausedSignal.value||this._schedule||(this._schedule=(0,a._)((()=>{this._schedule=null,this._next()})))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).resolve(e))}_processError(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).reject(e))}_canProcessFulfillment(t){return!!this._deferreds.get(t.item)&&this._processingItems.get(t.item)===t}_process(t){if(null==t)return;let e;const s=new AbortController,r=new c(t,s);this._processingItems.set(t,r);try{e=this.process(t,s.signal)}catch(t){this._processError(r,t)}(0,i.$X)(e)?(r.promise=e,e.then((t=>this._processResult(r,t)),(t=>this._processError(r,t)))):this._processResult(r,e)}get test(){}}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[6020],{40804:(t,e,s)=>{s.d(e,{U:()=>i});var r=s(34727);function i(t,e,s=0){const i=(0,r.qE)(t,0,a);for(let t=0;t<4;t++)e[s+t]=Math.floor(256*h(i*n[t]))}const n=[1,256,65536,16777216],o=[1/256,1/65536,1/16777216,1/4294967296],a=function(t,e=0){let s=0;for(let r=0;r<4;r++)s+=t[e+r]*o[r];return s}(new Uint8ClampedArray([255,255,255,255]));function h(t){return t-Math.floor(t)}},88340:(t,e,s)=>{function r(){return new Float32Array(2)}function i(t,e){const s=new Float32Array(2);return s[0]=t,s[1]=e,s}function n(){return r()}function o(){return i(1,1)}function a(){return i(1,0)}function h(){return i(0,1)}s.d(e,{Un:()=>l,fA:()=>i,uY:()=>c,vt:()=>r});const c=n(),l=o(),u=a(),d=h();Object.freeze(Object.defineProperty({__proto__:null,ONES:l,UNIT_X:u,UNIT_Y:d,ZEROS:c,clone:function(t){const e=new Float32Array(2);return e[0]=t[0],e[1]=t[1],e},create:r,createView:function(t,e){return new Float32Array(t,e,2)},fromValues:i,ones:o,unitX:a,unitY:h,zeros:n},Symbol.toStringTag,{value:"Module"}))},48163:(t,e,s)=>{function r(){return[0,0]}function i(t,e){return[t,e]}function n(){return i(1,1)}function o(){return i(1,0)}function a(){return i(0,1)}s.d(e,{Un:()=>h,fA:()=>i,vt:()=>r});const h=n(),c=o(),l=a();Object.freeze(Object.defineProperty({__proto__:null,ONES:h,UNIT_X:c,UNIT_Y:l,ZEROS:[0,0],clone:function(t){return[t[0],t[1]]},create:r,createView:function(t,e){return new Float64Array(t,e,2)},fromArray:function(t,e=[0,0]){const s=Math.min(2,t.length);for(let r=0;r<s;++r)e[r]=t[r];return e},fromValues:i,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},37585:(t,e,s)=>{s.d(e,{C:()=>i,Cc:()=>g,Io:()=>u,S8:()=>f,WQ:()=>o,e$:()=>y,hZ:()=>n,hs:()=>l,jb:()=>x,l0:()=>m,t2:()=>b});var r=s(34304);function i(t,e){return t[0]=e[0],t[1]=e[1],t}function n(t,e,s){return t[0]=e,t[1]=s,t}function o(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t}function a(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function h(t,e,s){return t[0]=e[0]*s[0],t[1]=e[1]*s[1],t}function c(t,e,s){return t[0]=e[0]/s[0],t[1]=e[1]/s[1],t}function l(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t}function u(t,e){const s=e[0]-t[0],r=e[1]-t[1];return Math.sqrt(s*s+r*r)}function d(t,e){const s=e[0]-t[0],r=e[1]-t[1];return s*s+r*r}function _(t){const e=t[0],s=t[1];return Math.sqrt(e*e+s*s)}function p(t){const e=t[0],s=t[1];return e*e+s*s}function f(t,e){const s=e[0],r=e[1];let i=s*s+r*r;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i),t}function g(t,e,s,r){const i=e[0],n=e[1];return t[0]=i+r*(s[0]-i),t[1]=n+r*(s[1]-n),t}function m(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[2]*i+s[4],t[1]=s[1]*r+s[3]*i+s[5],t}function y(t,e,s,r){const i=e[0]-s[0],n=e[1]-s[1],o=Math.sin(r),a=Math.cos(r);return t[0]=i*a-n*o+s[0],t[1]=i*o+n*a+s[1],t}function b(t,e){return t[0]===e[0]&&t[1]===e[1]}const w=_,x=a,v=h,S=c,I=u,M=d,P=p;Object.freeze(Object.defineProperty({__proto__:null,add:o,angle:function(t,e){const s=t[0],r=t[1],i=e[0],n=e[1];let o=s*s+r*r;o>0&&(o=1/Math.sqrt(o));let a=i*i+n*n;a>0&&(a=1/Math.sqrt(a));const h=(s*i+r*n)*o*a;return h>1?0:h<-1?Math.PI:Math.acos(h)},ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},copy:i,cross:function(t,e,s){const r=e[0]*s[1]-e[1]*s[0];return t[0]=t[1]=0,t[2]=r,t},dist:I,distance:u,div:S,divide:c,dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},equals:function(t,e){const s=t[0],i=t[1],n=e[0],o=e[1],a=(0,r.FD)();return Math.abs(s-n)<=a*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(i-o)<=a*Math.max(1,Math.abs(i),Math.abs(o))},exactEquals:b,floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},inverse:function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},len:w,length:_,lerp:g,max:function(t,e,s){return t[0]=Math.max(e[0],s[0]),t[1]=Math.max(e[1],s[1]),t},min:function(t,e,s){return t[0]=Math.min(e[0],s[0]),t[1]=Math.min(e[1],s[1]),t},mul:v,multiply:h,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},normalize:f,projectAndScale:function(t,e,s,r,i){let n=e[0]-s[0],o=e[1]-s[1];const a=(r[0]*n+r[1]*o)*(i-1);return n=r[0]*a,o=r[1]*a,t[0]=e[0]+n,t[1]=e[1]+o,t},random:function(t,e=1){const s=2*(0,r.Ov)()*Math.PI;return t[0]=Math.cos(s)*e,t[1]=Math.sin(s)*e,t},rotate:y,round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:l,scaleAndAdd:function(t,e,s,r){return t[0]=e[0]+s[0]*r,t[1]=e[1]+s[1]*r,t},set:n,sqrDist:M,sqrLen:P,squaredDistance:d,squaredLength:p,str:function(t){return"vec2("+t[0]+", "+t[1]+")"},sub:x,subtract:a,transformMat2:function(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[2]*i,t[1]=s[1]*r+s[3]*i,t},transformMat2d:m,transformMat3:function(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[3]*i+s[6],t[1]=s[1]*r+s[4]*i+s[7],t},transformMat4:function(t,e,s){const r=e[0],i=e[1];return t[0]=s[0]*r+s[4]*i+s[12],t[1]=s[1]*r+s[5]*i+s[13],t}},Symbol.toStringTag,{value:"Module"}))},79897:(t,e,s)=>{s.d(e,{U:()=>l});var r=s(90237),i=s(69622),n=s(36563),o=s(36708),a=s(11932),h=s(10107),c=s(40608);let l=class extends i.A{constructor(){super(...arguments),this.updating=!1,this._handleId=0,this._scheduleHandleId=0,this._pendingPromises=new Set}destroy(){this.removeAll()}add(t,e,s={}){return this._installWatch(t,e,s,o.wB)}addWhen(t,e,s={}){return this._installWatch(t,e,s,o.z7)}addOnCollectionChange(t,e,{initial:s=!1,final:r=!1}={}){const i=++this._handleId;return this.addHandles([(0,o.on)(t,"after-changes",this._createSyncUpdatingCallback(),o.OH),(0,o.on)(t,"change",e,{onListenerAdd:s?t=>e({added:t.toArray(),removed:[]}):void 0,onListenerRemove:r?t=>e({added:[],removed:t.toArray()}):void 0})],i),(0,n.hA)((()=>this.removeHandles(i)))}addPromise(t){if(null==t)return t;const e=++this._handleId;this.addHandles((0,n.hA)((()=>{this._pendingPromises.delete(t)&&(0!==this._pendingPromises.size||this.hasHandles(u)||this._set("updating",!1))})),e),this._pendingPromises.add(t),this._set("updating",!0);const s=()=>this.removeHandles(e);return t.then(s,s),t}removeAll(){this._pendingPromises.clear(),this.removeAllHandles(),this._set("updating",!1)}_installWatch(t,e,s={},r){const i=++this._handleId;s.sync||this._installSyncUpdatingWatch(t,i);const o=r(t,e,s);return this.addHandles(o,i),(0,n.hA)((()=>this.removeHandles(i)))}_installSyncUpdatingWatch(t,e){const s=this._createSyncUpdatingCallback(),r=(0,o.wB)(t,s,{sync:!0,equals:()=>!1});return this.addHandles(r,e),r}_createSyncUpdatingCallback(){return()=>{this.removeHandles(u),++this._scheduleHandleId;const t=this._scheduleHandleId;this._get("updating")||this._set("updating",!0),this.addHandles((0,a._)((()=>{t===this._scheduleHandleId&&(this._set("updating",this._pendingPromises.size>0),this.removeHandles(u))})),u)}}};(0,r._)([(0,h.MZ)({readOnly:!0})],l.prototype,"updating",void 0),l=(0,r._)([(0,c.$)("esri.core.support.UpdatingHandles")],l);const u=-42},37730:(t,e,s)=>{s.d(e,{T:()=>i});var r=s(43334);const i={getObjectId:t=>t.objectId,getAttributes:t=>t.attributes,getAttribute:(t,e)=>t.attributes[e],cloneWithGeometry:(t,e)=>new r.Om(e,t.attributes,null,t.objectId),getGeometry:t=>t.geometry,getCentroid:(t,e)=>t.ensureCentroid(e)}},30624:(t,e,s)=>{s.r(e),s.d(e,{createConnection:()=>T});var r=s(90237),i=(s(59456),s(78888)),n=s(49186),o=s(53966),a=s(74887),h=s(84952),c=(s(44208),s(87811),s(40608)),l=s(10107),u=s(62815),d=s(65529);let _=class extends d.A.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.A("stream-connection",this.errorString):null}onFeature(t){this.emit("data-received",t)}onMessage(t){this.emit("message-received",t)}};(0,r._)([(0,l.MZ)({readOnly:!0})],_.prototype,"connectionError",null),_=(0,r._)([(0,c.$)("esri.layers.support.StreamConnection")],_);const p=_;var f,g;(g=f||(f={}))[g.CONNECTING=0]="CONNECTING",g[g.OPEN=1]="OPEN",g[g.CLOSING=2]="CLOSING",g[g.CLOSED=3]="CLOSED";let m=class extends p{constructor(t){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:r}=t;this._config=t,this._featureZScaler=(0,u.N)(e,r,s),this._open()}normalizeCtorArgs(){return{}}async _open(){await this._tryCreateWebSocket(),this.destroyed||await this._handshake()}destroy(){super.destroy(),null!=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(null==this._websocket)return"disconnected";switch(this._websocket.readyState){case f.CONNECTING:case f.OPEN:return"connected";case f.CLOSING:case f.CLOSED:return"disconnected"}}sendMessageToSocket(t){null!=this._websocket?this._websocket.send(JSON.stringify(t)):this._outstandingMessages.push(t)}sendMessageToClient(t){this._onMessage(t)}updateCustomParameters(t){this._config.customParameters=t,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(t=this._config.source.path,e=1e3,s=0){try{if(this.destroyed)return;const e=(0,h.a6)(t,this._config.customParameters??{});this._websocket=await this._createWebSocket(e),this.notifyChange("connectionStatus")}catch(r){const i=e/1e3;return this._config.maxReconnectionAttempts&&s>=this._config.maxReconnectionAttempts?(o.A.getLogger(this).error(new n.A("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(o.A.getLogger(this).error(new n.A("websocket-connection",`Failed to connect. Attempting to reconnect in ${i}s`,r)),await(0,a.Pl)(e),this._tryCreateWebSocket(t,Math.min(1.5*e,1e3*this._config.maxReconnectionInterval),s+1))}}_setWebSocketJSONParseHandler(t){t.onmessage=t=>{try{const e=JSON.parse(t.data);this._onMessage(e)}catch(t){return void o.A.getLogger(this).error(new n.A("websocket-connection","Failed to parse message, invalid JSON",{error:t}))}}}_createWebSocket(t){return new Promise(((e,s)=>{const r=new WebSocket(t);r.onopen=()=>{if(r.onopen=null,this.destroyed)return r.onclose=null,void r.close();r.onclose=t=>this._onClose(t),r.onerror=t=>this._onError(t),this._setWebSocketJSONParseHandler(r),e(r)},r.onclose=t=>{r.onopen=r.onclose=null,s(t)}}))}async _handshake(t=1e4){const e=this._websocket;if(null==e)return;const s=(0,a.Tw)(),r=e.onmessage,{filter:i,outFields:h,spatialReference:c}=this._config;return s.timeout(t),e.onmessage=t=>{let a=null;try{a=JSON.parse(t.data)}catch(t){}a&&"object"==typeof a||(o.A.getLogger(this).error(new n.A("websocket-connection","Protocol violation. Handshake failed - malformed message",t.data)),s.reject(),this.destroy()),a.spatialReference?.wkid!==c?.wkid&&(o.A.getLogger(this).error(new n.A("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${c.wkid}`,t.data)),s.reject(),this.destroy()),"json"!==a.format&&(o.A.getLogger(this).error(new n.A("websocket-connection","Protocol violation. Handshake failed - format is not set",t.data)),s.reject(),this.destroy()),i&&a.filter!==i&&o.A.getLogger(this).error(new n.A("websocket-connection","Tried to set filter, but server doesn't support it")),h&&a.outFields!==h&&o.A.getLogger(this).error(new n.A("websocket-connection","Tried to set outFields, but server doesn't support it")),e.onmessage=r;for(const t of this._outstandingMessages)e.send(JSON.stringify(t));this._outstandingMessages=[],s.resolve()},e.send(JSON.stringify({filter:i,outFields:h,format:"json",spatialReference:{wkid:c.wkid}})),s.promise}_onMessage(t){if(this.onMessage(t),"type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}}_onError(t){const e="Encountered an error over WebSocket connection";this._set("errorString",e),o.A.getLogger(this).error("websocket-connection",e)}_onClose(t){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==t.code&&o.A.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${t.code}`),this.destroyed||this._open()}};(0,r._)([(0,l.MZ)()],m.prototype,"connectionStatus",null),(0,r._)([(0,l.MZ)()],m.prototype,"errorString",void 0),m=(0,r._)([(0,c.$)("esri.layers.graphics.sources.connections.WebSocketConnection")],m);var y=s(80893),b=s(61956),w=s(65864),x=s(16930);const v={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends m{constructor(t){super({...v,...t}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const t=await this._fetchServiceDefinition(this._config.source);t.timeInfo.trackIdField||o.A.getLogger(this).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 e=this._fetchWebSocketUrl(t.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(e);const{filter:s,outFields:r}=this._config;this.destroyed||this._setFilter(s,r)}_onMessage(t){if("attributes"in t){let e;try{e=this._enrich(t),null!=this._featureZScaler&&this._featureZScaler(e.geometry)}catch(t){return void o.A.getLogger(this).error(new n.A("geoevent-connection","Failed to parse message",t))}this.onFeature(e)}else this.onMessage(t)}async _fetchServiceDefinition(t){const e={f:"json",...this._config.customParameters},s=(0,i.A)(t.path,{query:e,responseType:"json"}),r=(await s).data;return this._serviceDefinition=r,r}_fetchWebSocketUrl(t,e){const s=t[0],{urls:r,token:i}=s,n=this._inferWebSocketBaseUrl(r);return(0,h.a6)(`${n}/subscribe`,{outSR:""+e.wkid,token:i})}_inferWebSocketBaseUrl(t){if(1===t.length)return t[0];for(const e of t)if(e.includes("wss"))return e;return o.A.getLogger(this).error(new n.A("geoevent-connection","Unable to infer WebSocket url",t)),null}async _setFilter(t,e){const s=this._websocket;if(null==s||null==t&&null==e)return;const r=JSON.stringify({filter:this._serializeFilter(t,e)});let i=!1;const h=(0,a.Tw)();return s.onmessage=t=>{const e=JSON.parse(t.data);e.filter&&(e.error&&(o.A.getLogger(this).error(new n.A("geoevent-connection","Failed to set service filter",e.error)),this._set("errorString",`Could not set service filter - ${e.error}`),h.reject(e.error)),this._setWebSocketJSONParseHandler(s),i=!0,h.resolve())},s.send(r),setTimeout((()=>{i||(this.destroyed||this._websocket!==s||o.A.getLogger(this).error(new n.A("geoevent-connection","Server timed out when setting filter")),h.reject())}),1e4),h.promise}_serializeFilter(t,e){const s={};if(null==t&&null==e)return s;if(t?.geometry)try{const e=(0,w.rS)(t.geometry);if("extent"!==e.type)throw new n.A(`Expected extent but found type ${e.type}`);s.geometry=JSON.stringify(e.shiftCentralMeridian())}catch(t){o.A.getLogger(this).error(new n.A("geoevent-connection","Encountered an error when setting connection geometryDefinition",t))}return t?.where&&"1 = 1"!==t.where&&"1=1"!==t.where&&(s.where=t.where),null!=e&&(s.outFields=e.join(",")),s}_enrich(t){if(!this._relatedFeatures)return t;const e=this._serviceDefinition.relatedFeatures.joinField,s=t.attributes[e],r=this._relatedFeatures.get(s);if(!r)return o.A.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",t),t;const{attributes:i,geometry:a}=r;for(const e in i)t.attributes[e]=i[e];return a&&(t.geometry=a),t.geometry||t.centroid||o.A.getLogger(this).error(new n.A("geoevent-connection","Found malformed feature - no geometry found",t)),t}async _queryBuddyServices(){try{const{relatedFeatures:t,keepLatestArchive:e}=this._serviceDefinition,s=this._queryRelatedFeatures(t),r=this._queryArchive(e);await s;const i=await r;if(!i)return;for(const t of i.features)this.onFeature(this._enrich(t))}catch(t){o.A.getLogger(this).error(new n.A("geoevent-connection","Encountered an error when querying buddy services",{error:t}))}}async _queryRelatedFeatures(t){if(!t)return;const e=await this._queryBuddy(t.featuresUrl);this._addRelatedFeatures(e)}async _queryArchive(t){if(t)return this._queryBuddy(t.featuresUrl)}async _queryBuddy(t){const e=new((await Promise.all([s.e(6131),s.e(8219),s.e(3874),s.e(1147),s.e(13),s.e(5494),s.e(4796),s.e(3029),s.e(4111),s.e(5220),s.e(3600),s.e(812),s.e(655),s.e(1e3)]).then(s.bind(s,13600))).default)({url:t}),{capabilities:r}=await e.load(),i=r.query.supportsMaxRecordCountFactor,n=r.query.supportsPagination,o=r.query.supportsCentroid,a=this._config.maxRecordCountFactor,h=e.capabilities.query.maxRecordCount,c=i?h*a:h,l=new b.A;if(l.outFields=this._config.outFields??["*"],l.where=this._config.filter?.where??"1=1",l.returnGeometry=!0,l.returnExceededLimitFeatures=!0,l.outSpatialReference=x.A.fromJSON(this._config.spatialReference),o&&(l.returnCentroid=!0),i&&(l.maxRecordCountFactor=a),n)return l.num=c,e.destroy(),this._queryPages(t,l);const u=await(0,y.eW)(t,l,this._config.sourceSpatialReference);return e.destroy(),u.data}async _queryPages(t,e,s=[],r=0){e.start=null!=e.num?r*e.num:null;const{data:i}=await(0,y.eW)(t,e,this._config.sourceSpatialReference);return i.exceededTransferLimit&&r<(this._config.maxQueryDepth??0)?(i.features.forEach((t=>s.push(t))),this._queryPages(t,e,s,r+1)):(s.forEach((t=>i.features.push(t))),i)}_addRelatedFeatures(t){const e=new Map,s=t.features,r=this._serviceDefinition.relatedFeatures.joinField;for(const t of s){const s=t.attributes[r];e.set(s,t)}this._relatedFeatures=e}};S=(0,r._)([(0,c.$)("esri.layers.graphics.sources.connections.GeoEventConnection")],S);const I=S;let M=class extends p{constructor(t){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:r}=t;this._featureZScaler=(0,u.N)(e,r,s)}normalizeCtorArgs(){return{}}updateCustomParameters(t){}sendMessageToSocket(t){}sendMessageToClient(t){if("type"in t)switch(t.type){case"features":case"featureResult":for(const e of t.features)null!=this._featureZScaler&&this._featureZScaler(e.geometry),this.onFeature(e)}this.onMessage(t)}};function P(t,e){if(null==t&&null==e)return null;const s={};return null!=e&&(s.geometry=e),null!=t&&(s.where=t),s}function T(t,e,s,r,i,n,o,a,h){const c={source:t,sourceSpatialReference:e,spatialReference:s,geometryType:r,filter:P(i,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:h};return t?t.path.startsWith("wss://")||t.path.startsWith("ws://")?new m(c):new I(c):new M(c)}(0,r._)([(0,l.MZ)()],M.prototype,"connectionStatus",void 0),(0,r._)([(0,l.MZ)()],M.prototype,"errorString",void 0),M=(0,r._)([(0,c.$)("esri.layers.support.ClientSideConnection")],M)},91806:(t,e,s)=>{s.d(e,{A:()=>l});var r,i=s(90237),n=s(25482),o=s(10107),a=s(56507),h=(s(87811),s(44208),s(40608));let c=r=class extends n.A{constructor(t){super(t),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new r({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,i._)([(0,o.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"cols",void 0),(0,i._)([(0,o.MZ)({type:a.jz,json:{write:!0}})],c.prototype,"level",void 0),(0,i._)([(0,o.MZ)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,i._)([(0,o.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"origin",void 0),(0,i._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,i._)([(0,o.MZ)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],c.prototype,"rows",void 0),(0,i._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=r=(0,i._)([(0,h.$)("esri.layers.support.LOD")],c);const l=c},87045:(t,e,s)=>{s.d(e,{A:()=>I});var r,i=s(90237),n=s(66552),o=s(25482),a=s(83047),h=s(10107),c=s(56507),l=(s(87811),s(44208),s(36005)),u=s(40608),d=s(43937),_=s(86738),p=s(16930),f=s(19419),g=s(21325),m=s(28735),y=s(91806),b=s(72802);const w=new n.J({PNG:"png",PNG8:"png8",PNG24:"png24",PNG32:"png32",JPEG:"jpg",JPG:"jpg",DIB:"dib",TIFF:"tiff",EMF:"emf",PS:"ps",PDF:"pdf",GIF:"gif",SVG:"svg",SVGZ:"svgz",Mixed:"mixed",MIXED:"mixed",LERC:"lerc",LERC2D:"lerc2d",RAW:"raw",pbf:"pbf"});let x=r=class extends o.A{static create(t={}){const{resolutionFactor:e=1,scales:s,size:i=256,spatialReference:n=p.A.WebMercator,numLODs:o=24}=t;if(!(0,g.fn)(n)){const t=[];if(s)for(let e=0;e<s.length;e++){const r=s[e];t.push(new y.A({level:e,scale:r,resolution:r}))}else{let e=5e-4;for(let s=o-1;s>=0;s--)t.unshift(new y.A({level:s,scale:e,resolution:e})),e*=2}return new r({dpi:96,lods:t,origin:new _.A(0,0,n),size:[i,i],spatialReference:n})}const h=(0,g.Vp)(n),c=t.origin?new _.A({x:t.origin.x,y:t.origin.y,spatialReference:n}):new _.A(h?{x:h.origin[0],y:h.origin[1],spatialReference:n}:{x:0,y:0,spatialReference:n}),l=1/(39.37*(0,a.GA)(n)*96),u=[];if(s)for(let t=0;t<s.length;t++){const e=s[t],r=e*l;u.push(new y.A({level:t,scale:e,resolution:r}))}else{let t=(0,g.EA)(n)?512/i*591657527.5917094:256/i*591657527.591555;const s=Math.ceil(o/e);u.push(new y.A({level:0,scale:t,resolution:t*l}));for(let r=1;r<s;r++){const s=t/2**e,i=s*l;u.push(new y.A({level:r,scale:s,resolution:i})),t=s}}return new r({dpi:96,lods:u,origin:c,size:[i,i],spatialReference:n})}constructor(t){super(t),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:t,origin:e}=this;if(t&&e){const s=(0,g.Vp)(t);return t.isWrappable&&!!s&&Math.abs(s.origin[0]-e.x)<=s.dx}return!1}readOrigin(t,e){return _.A.fromJSON({spatialReference:e.spatialReference,...t})}set lods(t){let e=0,s=0;const r=[],i=this._levelToLOD={};t&&(e=-1/0,s=1/0,t.forEach((t=>{r.push(t.scale),e=t.scale>e?t.scale:e,s=t.scale<s?t.scale:s,i[t.level]=t}))),this._set("scales",r),this._set("lods",t),this._initializeUpsampleLevels()}readSize(t,e){return[e.cols,e.rows]}writeSize(t,e){e.cols=t[0],e.rows=t[1]}zoomToScale(t){const e=this.scales;if(t<=0)return e[0];if(t>=e.length-1)return e[e.length-1];const s=Math.floor(t),r=s+1;return e[s]/(e[s]/e[r])**(t-s)}scaleToZoom(t){const e=this.scales,s=e.length-1;let r=0;for(;r<s;r++){const s=e[r],i=e[r+1];if(s<=t)return r;if(i===t)return r+1;if(s>t&&i<t)return r+Math.log(s/t)/Math.log(s/i)}return r}tileAt(t,e,s,r){const i=this.lodAt(t);if(!i)return null;let n,o;if("number"==typeof e)n=e,o=s;else if((0,g.aI)(e.spatialReference,this.spatialReference))n=e.x,o=e.y,r=s;else{const t=(0,m.Cv)(e,this.spatialReference);if(null==t)return null;n=t.x,o=t.y,r=s}const a=i.resolution*this.size[0],h=i.resolution*this.size[1];return r||(r=new b.U(null,0,0,0,(0,f.vt)())),r.level=t,r.row=Math.floor((this.origin.y-o)/h+.001),r.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(r),r}updateTileInfo(t,e=r.ExtrapolateOptions.NONE){let s=this.lodAt(t.level);if(!s&&e===r.ExtrapolateOptions.POWER_OF_TWO){const e=this.lods[this.lods.length-1];e.level<t.level&&(s=e)}if(!s)return;const i=t.level-s.level,n=s.resolution*this.size[0]/2**i,o=s.resolution*this.size[1]/2**i;t.id=`${t.level}/${t.row}/${t.col}`,t.extent||(t.extent=(0,f.vt)()),t.extent[0]=this.origin.x+t.col*n,t.extent[1]=this.origin.y-(t.row+1)*o,t.extent[2]=t.extent[0]+n,t.extent[3]=t.extent[1]+o}upsampleTile(t){const e=this._upsampleLevels[t.level];return!(!e||-1===e.parentLevel||(t.level=e.parentLevel,t.row=Math.floor(t.row/e.factor+.001),t.col=Math.floor(t.col/e.factor+.001),this.updateTileInfo(t),0))}getTileBounds(t,e){const s=this.lodAt(e.level);if(null==s)return null;const{resolution:r}=s,i=r*this.size[0],n=r*this.size[1];return t[0]=this.origin.x+e.col*i,t[1]=this.origin.y-(e.row+1)*n,t[2]=t[0]+i,t[3]=t[1]+n,t}lodAt(t){return this._levelToLOD?.[t]??null}clone(){return r.fromJSON(this.write({}))}getCompatibleForVTL(t){if(this.size[0]!==this.size[1]||256===this.size[0]&&512===t)return null;const e=(512===this.size[0]&&256===t?-1:0)+(this.spatialReference.isGeographic?1:0);if(this.size[0]===t&&0===e)return this;const s=[],i=this.lods.length-e;for(let t=0;t<i;t++){const r=t+e,{scale:i,resolution:n}=r>=0?this.lods[r]:{scale:2*this.lods[0].scale,resolution:2*this.lods[0].resolution};s.push(new y.A({level:t,scale:i,resolution:n}))}return new r({size:[t,t],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:s})}_initializeUpsampleLevels(){const t=this.lods;this._upsampleLevels=[];let e=null;for(let s=0;s<t.length;s++){const r=t[s];this._upsampleLevels[r.level]={parentLevel:e?e.level:-1,factor:e?e.resolution/r.resolution:0},e=r}}};var v,S;(0,i._)([(0,h.MZ)({type:Number,json:{write:!0}})],x.prototype,"compressionQuality",void 0),(0,i._)([(0,h.MZ)({type:Number,json:{write:!0}})],x.prototype,"dpi",void 0),(0,i._)([(0,h.MZ)({type:String,json:{read:w.read,write:w.write,origins:{"web-scene":{read:!1,write:!1}}}})],x.prototype,"format",void 0),(0,i._)([(0,h.MZ)({readOnly:!0})],x.prototype,"isWrappable",null),(0,i._)([(0,h.MZ)({type:_.A,json:{write:!0}})],x.prototype,"origin",void 0),(0,i._)([(0,l.w)("origin")],x.prototype,"readOrigin",null),(0,i._)([(0,h.MZ)({type:[y.A],value:null,json:{write:!0}})],x.prototype,"lods",null),(0,i._)([(0,h.MZ)({readOnly:!0})],x.prototype,"scales",void 0),(0,i._)([(0,h.MZ)({cast:t=>Array.isArray(t)?t:"number"==typeof t?[t,t]:[256,256]})],x.prototype,"size",void 0),(0,i._)([(0,l.w)("size",["rows","cols"])],x.prototype,"readSize",null),(0,i._)([(0,d.K)("size",{cols:{type:c.jz},rows:{type:c.jz}})],x.prototype,"writeSize",null),(0,i._)([(0,h.MZ)({type:p.A,json:{write:!0}})],x.prototype,"spatialReference",void 0),x=r=(0,i._)([(0,u.$)("esri.layers.support.TileInfo")],x),v=x||(x={}),(S=v.ExtrapolateOptions||(v.ExtrapolateOptions={}))[S.NONE=0]="NONE",S[S.POWER_OF_TWO=1]="POWER_OF_TWO";const I=x},72802:(t,e,s)=>{s.d(e,{U:()=>r});class r{constructor(t,e,s,r,i=void 0){this.id=t,this.level=e,this.row=s,this.col=r,this.extent=i}}},60694:(t,e,s)=>{s.d(e,{Fi:()=>l,HZ:()=>m,Jf:()=>g,LS:()=>y,Wo:()=>f,bd:()=>b,cr:()=>_,iz:()=>d,qg:()=>u,yG:()=>p});var r=s(84952),i=s(97159);const n={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",knowledgegraphserver:"KnowledgeGraphServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer","3dtilesserver":"3DTilesServer",videoserver:"VideoServer"},o=Object.values(n),a=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),h=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^/\\n]+)\\/(${o.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),c=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function l(t){return a.test(t)}function u(t){if(null==t)return null;const e=(0,r.An)(t),s=e?.path.match(a)||e?.path.match(h);if(!s)return null;const[,i,o,c,l]=s,u=o.indexOf("/");return{title:_(-1!==u?o.slice(u+1):o),serverType:n[c.toLowerCase()],sublayer:null!=l&&""!==l?parseInt(l,10):null,url:{path:i}}}function d(t){const e=(0,r.An)(t).path.match(c);return e?{serviceUrl:e[1],sublayerId:Number(e[2])}:null}function _(t){return(t=t.replaceAll(/\s*[/_]+\s*/g," "))[0].toUpperCase()+t.slice(1)}function p(t,e){const s=[];if(t){const e=u(t);null!=e&&e.title&&s.push(e.title)}if(e){const t=_(e);s.push(t)}if(2===s.length){if(s[0].toLowerCase().includes(s[1].toLowerCase()))return s[0];if(s[1].toLowerCase().includes(s[0].toLowerCase()))return s[1]}return s.join(" - ")}function f(t){let e=(0,r.$z)(t,!0);return!!e&&(e=e.toLowerCase(),e.endsWith(".arcgis.com")&&(e.startsWith("services")||e.startsWith("tiles")||e.startsWith("features")))}function g(t,e){return t?(0,r.UC)((0,r.zi)(t,e)):t}function m(t){let{url:e}=t;if(!e)return{url:e};e=(0,r.zi)(e,t.logger);const s=(0,r.An)(e),i=u(s.path);let n;if(null!=i)null!=i.sublayer&&null==t.layer.layerId&&(n=i.sublayer),e=i.url.path;else if(t.nonStandardUrlAllowed){const t=d(s.path);null!=t&&(e=t.serviceUrl,n=t.sublayerId)}return{url:(0,r.UC)(e),layerId:n}}function y(t,e,s,n,o){(0,i.w)(e,n,"url",o),n.url&&null!=t.layerId&&(n.url=(0,r.fj)(n.url,s,t.layerId.toString()))}function b(t){if(!t)return!1;const e=t.toLowerCase(),s=e.includes("/services/"),r=e.includes("/mapserver/wmsserver"),i=e.includes("/imageserver/wmsserver"),n=e.includes("/wmsserver");return s&&(r||i||n)}},16020:(t,e,s)=>{s.r(e),s.d(e,{default:()=>af});var r=s(49186),i=s(36563),n=s(44208),o=s(26390),a=s(74887),h=s(87811),c=s(36708),l=s(90629),u=s(8341),d=s(87045),_=s(21325),p=s(44159);function f(t,e){return[t,e]}function g(t,e,s){return t[0]=e,t[1]=s,t}const m=new p.A("0/0/0/0");class y{static create(t,e,s=null){const r=(0,_.Vp)(t.spatialReference),i=e.origin||f(t.origin.x,t.origin.y),n=f(t.size[0]*e.resolution,t.size[1]*e.resolution),o=f(-1/0,-1/0),a=f(1/0,1/0),h=f(1/0,1/0);null!=s&&(g(o,Math.max(0,Math.floor((s.xmin-i[0])/n[0])),Math.max(0,Math.floor((i[1]-s.ymax)/n[1]))),g(a,Math.max(0,Math.floor((s.xmax-i[0])/n[0])),Math.max(0,Math.floor((i[1]-s.ymin)/n[1]))),g(h,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:c,rows:l}=e;let u,d,p,m;return!s&&c&&l&&(g(o,c[0],l[0]),g(a,c[1],l[1]),g(h,c[1]-c[0]+1,l[1]-l[0]+1)),t.isWrappable?(u=f(Math.ceil(Math.round((r.valid[1]-r.valid[0])/e.resolution)/t.size[0]),h[1]),d=!0,p=r.origin,m=r.valid):(u=h,d=!1),new y(e.level,e.resolution,e.scale,i,o,a,h,n,u,d,p,m)}constructor(t,e,s,r,i,n,o,a,h,c,l,u){this.level=t,this.resolution=e,this.scale=s,this.origin=r,this.first=i,this.last=n,this.size=o,this.norm=a,this.worldSize=h,this.wrap=c,this._spatialReferenceOrigin=l,this._spatialReferenceValid=u}normalizeCol(t){if(!this.wrap)return t;const e=this.worldSize[0];return t<0?e-1-Math.abs((t+1)%e):t%e}normalizeKey(t){if(!this.wrap)return;const e=this.worldSize[0],s=t.col;s<0?(t.col=s+e,t.world-=1):s>=e&&(t.col=s-e,t.world+=1)}denormalizeCol(t,e){return this.wrap?this.worldSize[0]*e+t:t}getWorldForColumn(t){return this.wrap?Math.floor(t/this.worldSize[0]):0}getFirstColumnForWorld(t){return t*this.worldSize[0]+this.first[0]}getLastColumnForWorld(t){return t*this.worldSize[0]+this.first[0]+this.size[0]-1}getColumnForX(t){return(t-this.origin[0])/this.norm[0]}getXForColumn(t){const e=this.origin[0]+t*this.norm[0],s=this._spatialReferenceOrigin,r=this._spatialReferenceValid;return this.wrap&&s&&r?e===s[0]?r[0]:this.origin[0]===s[0]&&t===this.worldSize[0]?r[1]:e:e}getRowForY(t){return(this.origin[1]-t)/this.norm[1]}getYForRow(t){return this.origin[1]-t*this.norm[1]}getTileBounds(t,e,s=!1){m.set(e);const r=s?m.col:this.denormalizeCol(m.col,m.world),i=m.row;return function(t,e,s,r,i){t[0]=e,t[1]=s,t[2]=r,t[3]=i}(t,this.getXForColumn(r),this.getYForRow(i+1),this.getXForColumn(r+1),this.getYForRow(i)),t}getTileCoords(t,e,s=!1){m.set(e);const r=s?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(t)?g(t,this.getXForColumn(r),this.getYForRow(m.row)):(t.x=this.getXForColumn(r),t.y=this.getYForRow(m.row)),t}}var b=s(93687);class w{constructor(){this.spans=[]}acquire(t){this.lodInfo=t}release(){this.lodInfo=null,this.spans.length=0}*keys(){const t=this.lodInfo;for(const{row:e,colFrom:s,colTo:r}of this.spans)for(let i=s;i<=r;i++){const s=t.getWorldForColumn(i);yield new p.A(t.level,e,t.normalizeCol(i),s)}}forEach(t,e){const{spans:s,lodInfo:r}=this,{level:i}=r;if(0!==s.length)for(const{row:n,colFrom:o,colTo:a}of s)for(let s=o;s<=a;s++)t.call(e,i,n,r.normalizeCol(s),r.getWorldForColumn(s))}}w.pool=new b.A(w);class x{constructor(t,e,s){this.row=t,this.colFrom=e,this.colTo=s}}const v=new p.A("0/0/0/0");class S{static create(t,e){t[1]>e[1]&&([t,e]=[e,t]);const[s,r]=t,[i,n]=e,o=i-s,a=n-r,h=0!==a?o/a:0,c=(Math.ceil(r)-r)*h,l=(Math.floor(r)-r)*h;return new S(s,Math.floor(r),Math.ceil(n),h,o<0?c:l,o<0?l:c,o<0?i:s,o<0?s:i)}constructor(t,e,s,r,i,n,o,a){this.x=t,this.ymin=e,this.ymax=s,this.invM=r,this.leftAdjust=i,this.rightAdjust=n,this.leftBound=o,this.rightBound=a}incrRow(){this.x+=this.invM}getLeftCol(){return Math.max(this.x+this.leftAdjust,this.leftBound)}getRightCol(){return Math.min(this.x+this.rightAdjust,this.rightBound)}}const I=[[0,0],[0,0],[0,0],[0,0]];class M{constructor(t,e=null,s=t.lods[0].level,r=t.lods[t.lods.length-1].level){this.tileInfo=t,this.fullExtent=e,this.scales=[],this._infoByScale={},this._infoByLevel={};const i=t.lods.filter((t=>t.level>=s&&t.level<=r));this.minScale=i[0].scale,this.maxScale=i[i.length-1].scale;const n=this._lodInfos=i.map((s=>y.create(t,s,e)));i.forEach(((t,e)=>{this._infoByLevel[t.level]=n[e],this._infoByScale[t.scale]=n[e],this.scales[e]=t.scale}),this),this._wrap=t.isWrappable}get spatialReference(){return this.tileInfo.spatialReference}getLODInfoAt(t){return this._infoByLevel["number"==typeof t?t:t.level]}getTileBounds(t,e,s=!1){v.set(e);const r=this._infoByLevel[v.level];return r?r.getTileBounds(t,v,s):t}getTileCoords(t,e,s=!1){v.set(e);const r=this._infoByLevel[v.level];return r?r.getTileCoords(t,v,s):t}getTileCoverage(t,e=192,s=!0,r="closest"){if(!s&&(t.scale>this.minScale||t.scale<this.maxScale))return null;const i="closest"===r?this.getClosestInfoForScale(t.scale):this.getSmallestInfoForScale(t.scale),n=w.pool.acquire(i),o=this._wrap;let a,h,c,l=1/0,u=-1/0;const d=n.spans;I[0][0]=I[0][1]=I[1][1]=I[3][0]=-e,I[1][0]=I[2][0]=t.size[0]+e,I[2][1]=I[3][1]=t.size[1]+e;for(const e of I)t.toMap(e,e),e[0]=i.getColumnForX(e[0]),e[1]=i.getRowForY(e[1]);const _=[];let p=3;for(let t=0;t<4;t++){if(I[t][1]===I[p][1]){p=t;continue}const e=S.create(I[t],I[p]);l=Math.min(e.ymin,l),u=Math.max(e.ymax,u),void 0===_[e.ymin]&&(_[e.ymin]=[]),_[e.ymin].push(e),p=t}if(null==l||null==u||u-l>100)return null;let f=[];for(a=l;a<u;){null!=_[a]&&(f=f.concat(_[a])),h=1/0,c=-1/0;for(let t=f.length-1;t>=0;t--){const e=f[t];h=Math.min(h,e.getLeftCol()),c=Math.max(c,e.getRightCol())}if(h=Math.floor(h),c=Math.floor(c),a>=i.first[1]&&a<=i.last[1])if(o)if(i.size[0]<i.worldSize[0]){const t=Math.floor(c/i.worldSize[0]);for(let e=Math.floor(h/i.worldSize[0]);e<=t;e++)d.push(new x(a,Math.max(i.getFirstColumnForWorld(e),h),Math.min(i.getLastColumnForWorld(e),c)))}else d.push(new x(a,h,c));else h>i.last[0]||c<i.first[0]||(h=Math.max(h,i.first[0]),c=Math.min(c,i.last[0]),d.push(new x(a,h,c)));a+=1;for(let t=f.length-1;t>=0;t--){const e=f[t];e.ymax>=a?e.incrRow():f.splice(t,1)}}return n}getTileParentId(t){v.set(t);const e=this._infoByLevel[v.level],s=this._lodInfos.indexOf(e)-1;return s<0?null:(this._getTileIdAtLOD(v,this._lodInfos[s],v),v.id)}getTileResolution(t){const e=this._infoByLevel["object"==typeof t?t.level:t];return e?e.resolution:-1}getTileScale(t){const e=this._infoByLevel[t.level];return e?e.scale:-1}intersects(t,e){v.set(e);const s=this._infoByLevel[v.level],r=t.lodInfo;if(r.resolution>s.resolution){this._getTileIdAtLOD(v,r,v);const e=r.denormalizeCol(v.col,v.world);for(const s of t.spans)if(s.row===v.row&&s.colFrom<=e&&s.colTo>=e)return!0}if(r.resolution<s.resolution){const[e,i,n,o]=t.spans.reduce(((t,e)=>(t[0]=Math.min(t[0],e.row),t[1]=Math.max(t[1],e.row),t[2]=Math.min(t[2],e.colFrom),t[3]=Math.max(t[3],e.colTo),t)),[1/0,-1/0,1/0,-1/0]),a=s.denormalizeCol(v.col,v.world),h=r.getColumnForX(s.getXForColumn(a)),c=r.getRowForY(s.getYForRow(v.row)),l=r.getColumnForX(s.getXForColumn(a+1))-1,u=r.getRowForY(s.getYForRow(v.row+1))-1;return!(h>o||l<n||c>i||u<e)}const i=r.denormalizeCol(v.col,v.world);return t.spans.some((t=>t.row===v.row&&t.colFrom<=i&&t.colTo>=i))}normalizeBounds(t,e,s){if(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],this._wrap){const e=(0,_.Vp)(this.tileInfo.spatialReference),r=-s*(e.valid[1]-e.valid[0]);t[0]+=r,t[2]+=r}return t}getSmallestInfoForScale(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t];if(t>e[0])return this._infoByScale[e[0]];for(let s=1;s<e.length-1;s++)if(t>e[s]+1e-6)return this._infoByScale[e[s-1]];return this._infoByScale[e[e.length-1]]}getClosestInfoForScale(t){const e=this.scales;return this._infoByScale[t]||(t=e.reduce(((e,s)=>Math.abs(s-t)<Math.abs(e-t)?s:e),e[0])),this._infoByScale[t]}scaleToLevel(t){const e=this.scales;if(this._infoByScale[t])return this._infoByScale[t].level;for(let s=e.length-1;s>=0;s--)if(t<e[s])return s===e.length-1?this._infoByScale[e[e.length-1]].level:this._infoByScale[e[s]].level+(e[s]-t)/(e[s]-e[s+1]);return this._infoByScale[e[0]].level}scaleToZoom(t){return this.tileInfo.scaleToZoom(t)}zoomToScale(t){return this.tileInfo.zoomToScale(t)}_getTileIdAtLOD(t,e,s){const r=this._infoByLevel[s.level];return t.set(s),e.resolution<r.resolution?null:(e.resolution===r.resolution||(t.level=e.level,t.col=Math.floor(s.col*r.resolution/e.resolution+.01),t.row=Math.floor(s.row*r.resolution/e.resolution+.01)),t)}}var P=s(90237),T=s(69622),A=s(91869),C=s(97768),k=s(3483),F=s(10107),E=s(53966),z=s(40608),O=s(37585),R=s(89738);const D=[0,0];let L=class extends T.A{constructor(t){super(t),this._keyToItem=new Map,this._tilesByScale=new Map,this.concurrency=6}initialize(){const{concurrency:t,process:e,scheduler:s,priority:r}=this;this._queue=new R.e({concurrency:t,scheduler:s,priority:r,process:(t,s)=>{const r=this._keyToItem.get(t);return e(r,{signal:s})},peeker:t=>this._peek(t)})}destroy(){this.clear(),this._queue=(0,C.pR)(this._queue)}get length(){return this._queue?this._queue.length:0}abort(t){const e="string"==typeof t?t:t.id;this._queue.abort(e)}clear(){this._queue.clear(),this._keyToItem.clear(),this._tilesByScale.clear()}has(t){return"string"==typeof t?this._keyToItem.has(t):this._keyToItem.has(t.id)}pause(){this._queue.pause()}push(t){const e=t.key.id;if(this._queue.has(e))return this._queue.get(e);const s=this._queue.push(e),r=this.tileInfoView.getTileScale(t.key),i=(0,A.tE)(this._tilesByScale,r,(()=>new Set)),n=()=>{i.delete(t.key),0===i.size&&this._tilesByScale.delete(r),this._keyToItem.delete(e)};return i.add(t.key),this._keyToItem.set(e,t),s.then(n,n),s}reset(){this._queue.reset()}resume(){this._queue.resume()}_peek(t){if(!this.state)return t.values().next().value;const e=new Set;for(const s of t)e.add(this._keyToItem.get(s).key);const s=this.state.scale;let r,i=Number.POSITIVE_INFINITY;for(const[t,n]of this._tilesByScale)if((0,k.bw)(n,(t=>e.has(t)))){const e=Math.abs(t-s);e<i&&(r=n,i=e)}return this._getClosestTileKey(r,t).id}_getClosestTileKey(t,e){const s=this.tileInfoView,r=this.state.center;let i,n=Number.POSITIVE_INFINITY;for(const o of t)if(e.has(o.id)){s.getTileCoords(D,o);const t=(0,O.Io)(D,r);t<n&&(n=t,i=o)}return i}};(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"concurrency",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"priority",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"process",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"scheduler",void 0),(0,P._)([(0,F.MZ)()],L.prototype,"state",void 0),(0,P._)([(0,F.MZ)({constructOnly:!0})],L.prototype,"tileInfoView",void 0),L=(0,P._)([(0,z.$)("esri.views.2d.tiling.TileQueue")],L);var N=s(19419);new p.A(0,0,0,0),new Map;var B=s(76213);class G{constructor(t){this._client=t,this.layerView=this._client.createInvokeProxy(""),this.container=this._client.createInvokeProxy("container"),this._eventLog=this._client.createInvokeProxy("eventLog")}onEvent(t){(0,u.oV)(this._eventLog.onEvent(t))}}var U=s(93637),V=s(6797),q=s(16930);class W{constructor(t,e,s,r,i,n,o){this.instanceId=t,this.textureKey=e,this.indexStart=s,this.indexCount=r,this.vertexStart=i,this.vertexCount=n,this.overlaps=o}updateBaseOffsets(t){this.vertexStart+=t.vertexFrom,this.indexStart+=t.indexFrom}clone(){return new W(this.instanceId,this.textureKey,this.indexStart,this.indexCount,this.vertexStart,this.vertexCount,this.overlaps)}static write(t,e,s,r,i,n,o,a){t.push(e),t.push(s),t.push(r),t.push(i),t.push(n),t.push(o),t.push(a)}serialize(t){return t.push(this.instanceId),t.push(this.textureKey),t.push(this.indexStart),t.push(this.indexCount),t.push(this.vertexStart),t.push(this.vertexCount),t.push(this.overlaps),t}static deserialize(t){const e=t.readInt32(),s=t.readInt32(),r=t.readInt32(),i=t.readInt32(),n=t.readInt32(),o=t.readInt32(),a=t.readInt32();return new W(e,s,r,i,n,o,a)}}function j(t,e){if(null!==e){t.push(e.length);for(const s of e)s.serialize(t);return t}t.push(0)}function Y(t,e,s){const r=t.readInt32(),i=new Array(r);for(let r=0;r<i.length;r++)i[r]=e.deserialize(t,s);return i}W.byteSizeHint=7*Uint32Array.BYTES_PER_ELEMENT;class X{constructor(t,e){this.id=t,this.sortKey=e,this.records=[]}serialize(t){return t.push(this.id),t.writeF32(this.sortKey),j(t,this.records),t}static deserialize(t){const e=t.readInt32(),s=t.readF32(),r=new X(e,s);return r.records=Y(t,W)??[],r}}X.byteSizeHint=2*Uint32Array.BYTES_PER_ELEMENT+W.byteSizeHint;class ${get length(){return this._pos}constructor(t,e){this._pos=0;const s=e?this._roundToNearest(e,t.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(s),this._buffer=new t(this._array),this._ctor=t,this._i16View=new Int16Array(this._array)}_roundToNearest(t,e){const s=Math.round(t);return 1===e?s:s+(e-s%e)}_ensureSize(t){if(this._pos+t>=this._buffer.length){const e=this._roundToNearest(1.25*(this._array.byteLength+t*this._buffer.BYTES_PER_ELEMENT),this._buffer.BYTES_PER_ELEMENT),s=new ArrayBuffer(e),r=new this._ctor(s);r.set(this._buffer,0),this._array=s,this._buffer=r,this._i16View=new Int16Array(this._array)}}ensureSize(t){this._ensureSize(t)}writeF32(t){this._ensureSize(1);const e=this._pos;return new Float32Array(this._array,4*this._pos,1)[0]=t,this._pos++,e}push(t){this._ensureSize(1);const e=this._pos;return this._buffer[this._pos++]=t,e}writeFixed(t){this._buffer[this._pos++]=t}setValue(t,e){this._buffer[t]=e}i1616Add(t,e,s){this._i16View[2*t]+=e,this._i16View[2*t+1]+=s}getValue(t){return this._buffer[t]}getValueF32(t){return new Float32Array(this._array,4*t,1)[0]}incr(t){if(this._buffer.length<t)throw new Error("Increment index overflows the target buffer");this._buffer[t]++}decr(t){this._buffer[t]--}writeRegion(t){this._ensureSize(t.length);const e=this._pos;return this._buffer.set(t,this._pos),this._pos+=t.length,e}writeManyFrom(t,e,s){this._ensureSize(s-e);for(let r=e;r!==s;r++)this.writeFixed(t._buffer[r])}buffer(){const t=this._array.slice(0,4*this._pos);return this.destroy(),t}toArray(){return[...this._buffer]}seek(t){this._pos=t}destroy(){this._array=null,this._buffer=null}}class H{constructor(t,e,s=0){const r=6*s*Uint32Array.BYTES_PER_ELEMENT,i=4*s*e.stride,n=e.stride/4,o=e.attributes.find((t=>"pos"===t.name||"position"===t.name));if(!o)throw new Error("InternalError: Unable to find position attribute");this.layout={...e,position:o},this._indices=new $(Uint32Array,r),this._vertices=new $(Uint32Array,i),this._metrics=new $(Uint32Array,0),this._metricCountOffset=this._metrics.push(0),this._strideInt=n,this._instanceId=t}serialize(t){const e=this._indices.buffer(),s=this._vertices.buffer(),r=this._metrics.length?this._metrics.buffer():null;return t.push(e,s),{instanceId:this._instanceId,layout:this.layout,indices:e,vertices:s,metrics:r}}get strideInt(){return this._strideInt}get vertexCount(){return this._vertices.length/this._strideInt}get indexCount(){return this._indices.length}get indexWriter(){return this._indices}get vertexWriter(){return this._vertices}get metricWriter(){return this._metrics}vertexEnsureSize(t){this._vertices.ensureSize(t)}indexEnsureSize(t){this._indices.ensureSize(t)}writeIndex(t){this._indices.push(t)}writeVertex(t){this._vertices.push(t)}writeVertexRegion(t){this._vertices.writeRegion(t)}writeVertexF32(t){this._vertices.writeF32(t)}writeMetric(t){this._metrics.incr(this._metricCountOffset),t.serialize(this._metrics)}}class Z{constructor(t,e=0){this._id=t,this._sizeHint=e,this._entityRecordCountOffset=0,this._entityCountOffset=0,this._entityIdIndex=0,this._entitySortKeyIndex=0,this._didEntityStart=!1,this._instanceIdToVertexData=new Map,this._recordIndexStart=0,this._recordIndexCount=0,this._recordVertexStart=0,this._recordVertexCount=0,this._current={metric:null,writer:null,start:0,sortKey:0,instanceId:0,layoutHash:0,indexStart:0,vertexStart:0,textureKey:0,metricBoxLenPointer:0},this._entities=new $(Uint32Array,this._sizeHint*X.byteSizeHint),this._entityCountOffset=this._entities.push(0)}get id(){return this._id}serialize(){const t=new Array,e=[],s=this._entities.buffer();for(const s of this._instanceIdToVertexData.values())e.push(s.serialize(t));return{message:{data:e,entities:s},transferList:t}}vertexCount(){return this._current.writer?.vertexCount??0}indexCount(){return this._current.writer?.indexCount??0}vertexEnsureSize(t){this._current.writer.vertexEnsureSize(t)}indexEnsureSize(t){this._current.writer.indexEnsureSize(t)}vertexWrite(t){this._current.writer.writeVertex(t)}vertexWriteRegion(t){this._current.writer.writeVertexRegion(t)}vertexWriteF32(t){this._current.writer.writeVertexF32(t)}recordBounds(t,e,s,r){}indexWrite(t){this._current.writer.writeIndex(t)}metricStart(t){this._current.metric=t}metricEnd(){const t=this._current.writer;this._current.metric.bounds.length&&t.writeMetric(this._current.metric)}metricBoxWrite(t){this._current.metric.bounds.push(t)}entityStart(t,e=t){this._entityIdIndex=this._entities.push(t),this._entitySortKeyIndex=this._entities.writeF32(e),this._entityRecordCountOffset=this._entities.push(0),this._didEntityStart=!0}entityRecordCount(){return this._entities.getValue(this._entityRecordCountOffset)}entityEnd(){this._didEntityStart&&(0===this.entityRecordCount()?this._entities.seek(this._entityIdIndex):this._entities.incr(this._entityCountOffset),this._didEntityStart=!1)}recordCount(){return this._entities.getValue(this._entityRecordCountOffset)}recordStart(t,e,s=0){this._current.writer=this._getVertexWriter(t,e),this._current.indexStart=this._current.writer.indexCount,this._current.vertexStart=this._current.writer.vertexCount,this._current.instanceId=t,this._current.layoutHash=e.hash,this._current.textureKey=s}recordEnd(t=0){const e=this._current.vertexStart,s=this._current.writer.vertexCount-e;if(!s)return!1;const r=this._current.indexStart,i=this._current.writer.indexCount-r;return this._recordIndexStart=r,this._recordIndexCount=i,this._recordVertexStart=e,this._recordVertexCount=s,this._entities.incr(this._entityRecordCountOffset),W.write(this._entities,this._current.instanceId,this._current.textureKey,r,i,e,s,t),!0}copyLast(t,e){const s=this._recordVertexStart+this._recordVertexCount;this._entities.incr(this._entityRecordCountOffset),W.write(this._entities,this._current.instanceId,this._current.textureKey,this._recordIndexStart+this._recordIndexCount,this._recordIndexCount,s,this._recordVertexCount,0);const r=this._current.writer.indexWriter,i=this._current.writer.vertexWriter,n=this._recordIndexStart+this._recordIndexCount,o=this._recordVertexCount;for(let t=this._recordIndexStart;t!==n;t++){const e=r.getValue(t);r.push(e+o)}const a=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,h=this._recordVertexStart*a,c=(this._recordVertexStart+this._recordVertexCount)*a;for(let t=h;t!==c;t++){const e=i.getValue(t);i.push(e)}const l=this._current.writer.layout.position,u=l.packPrecisionFactor??1,d=l.offset/Uint32Array.BYTES_PER_ELEMENT,_=t*u,p=e*u;for(let t=s*a;t<=i.length;t+=a)i.i1616Add(t+d,_,p)}copyLastFrom(t,e,s){const r=t._entities.getValue(t._entityIdIndex);if(r!==this._entities.getValue(this._entityIdIndex)){const e=t._entities.getValueF32(t._entitySortKeyIndex);this.entityStart(r,e)}this.recordStart(t._current.instanceId,t._current.writer.layout,t._current.textureKey);const i=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,n=this._current.vertexStart,o=t._current.vertexStart-n,a=this._current.writer.indexWriter,h=this._current.writer.vertexWriter,c=t._current.writer.indexWriter,l=t._current.writer.vertexWriter;for(let e=t._current.indexStart;e!==c.length;e++){const t=c.getValue(e);a.push(t-o)}for(let e=t._current.vertexStart*i;e!==l.length;e++){const t=l.getValue(e);h.push(t)}const u=this._current.writer.layout.position,d=u.packPrecisionFactor??1,_=u.offset/Uint32Array.BYTES_PER_ELEMENT,p=e*d,f=s*d;for(let t=n*i;t<=h.length;t+=i)h.i1616Add(t+_,p,f);this.recordEnd()}_getVertexWriter(t,e){const s=this._instanceIdToVertexData;return s.has(t)||s.set(t,new H(t,e,this._sizeHint)),s.get(t)}}function Q(t){switch(t){case 1:case 8:case 32:return-1;case 2:case 64:return 0;case 4:case 16:case 128:return 1}}function K(t){switch(t){case 1:case 2:case 4:return-1;case 8:case 16:return 0;case 32:case 64:case 128:return 1}}class J{constructor(t,e,s,r,i=0){this.tileKey=t,this._bufferingEnabled=e,this._sizeHint=i,this._meshes={self:new Z(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0;const n=r?1:0;this._copyBufferedDataIntoSelf=s&&this._bufferingEnabled&&t.level===n}get id(){return this.tileKey.id}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(t){this._meshes.self.indexEnsureSize(t)}entityStart(t,e=t){this._currentEntityOverlaps=0,this._meshes.self.entityStart(t,e)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled){if(this._copyBufferedDataIntoSelf)return;for(let t=0;t<8;t++){const e=1<<t;this._currentEntityOverlaps&e&&this._meshes.neighbors[t].entityEnd()}}}recordStart(t,e,s){this._currentRecordOverlaps=0,this._meshes.self.recordStart(t,e,s)}recordEnd(t=0){const e=this._meshes.self.recordEnd(this._currentRecordOverlaps);return e&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):e}recordBounds(t,e,s,r){this._bufferingEnabled&&this._addOverlap(t,e,s,r)}recordCount(){return this._meshes.self.recordCount()}metricStart(t){this._meshes.self.metricStart(t)}metricBoxWrite(t){this._meshes.self.metricBoxWrite(t)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(t){this._meshes.self.vertexWrite(t)}vertexWriteF32(t){this._meshes.self.vertexWriteF32(t)}vertexWriteRegion(t){this._meshes.self.vertexWriteRegion(t)}indexWrite(t){this._meshes.self.indexWrite(t)}serialize(t){const e={message:[],transferList:[]},s=this._meshes.self.serialize();return e.message.push({tileId:this.tileKey.id,...s.message}),e.transferList.push(...s.transferList),this._meshes.neighbors.forEach(((s,r)=>{const i=s.serialize(),n=1<<r,o=Q(n),a=K(n),h=new p.A(this.tileKey).getNormalizedNeighbor(o,a,t);e.message.push({tileId:h.id,...i.message}),e.transferList.push(...i.transferList)})),e}_addOverlap(t,e,s,r){const i=Math.min(B.CQ/2,s),n=Math.min(B.CQ/2,r),o=255^((t<0+i?148:t>=B.CQ-i?41:189)|(e<0+n?224:e>=B.CQ-n?7:231));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let t=0;t<8;t++){const e=1<<t;if(this._currentRecordOverlaps&e){if(this._copyBufferedDataIntoSelf){const t=-Q(e)*B.CQ,s=-K(e)*B.CQ;if(0!==s)continue;this._meshes.self.copyLast(t,s);continue}if(!this._meshes.neighbors[t]){const s=Math.floor(this._sizeHint/16);this._meshes.neighbors[t]=new Z(e,s)}const s=this._meshes.neighbors[t],r=-Q(e)*B.CQ,i=-K(e)*B.CQ;s.copyLastFrom(this._meshes.self,r,i)}}}}class tt{}class et{constructor(){this._defaultResult=null,this._backgroundFillResult=null}static async from(t,e){const s=new et;return s.setDefault(await t.createMeshWriters(e.meshes)),s}size(){return 1}getDefault(){return this._defaultResult}setDefault(t){this._defaultResult=t}getBackgroundFill(){return this._backgroundFillResult}setBackgroundFill(t){this._backgroundFillResult=t}hasArcadeDependency(t){return this._defaultResult?.some((e=>e.hasArcadeDependency(t)))??!1}match(t,e){const s=this.doMatch(t,e)||this.getDefault();if(s&&s.length>0){const t=this.getBackgroundFill();if(t)return[...t,...s]}return s}getSortKey(t,e){return 0}doMatch(t,e){return null}async fetchResources(t,e){}}class st extends et{static async fromDictionaryRenderer(t,e){return new st(t,e)}constructor(t,e){super(),this._context=t,this._schema=e,this._hashToGroup=new Map}get fieldMap(){return this._schema.fieldMap}async fetchResources(t,e){const s=e.getCursor(),r=[];for(;s.next();)r.push(this._updateMeshWriterGroup(t,s));await Promise.all(r)}match(t,e){const s=t.getAttributeHash();return this._hashToGroup.get(s)}async _updateMeshWriterGroup(t,e){const s=e.readLegacyFeatureForDisplay(),r=e.getAttributeHash();if(this._hashToGroup.has(r))return;this._hashToGroup.set(r,null);const i=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:s});if(!i)return;const n=await this._context.createMeshWriters(i.meshes);this._hashToGroup.set(r,n)}}class rt extends et{constructor(t,e){super(),this._intervals=[],this._isMaxInclusive=e,this._field=t}static async fromIntervalSchema(t,e){const s=await t.storage.createComputedField(e),r=new rt(s,e.isMaxInclusive);await Promise.all(e.intervals.map((async e=>{const s=await t.createMeshWriters(e.meshes);r.add(e,s)})));const i=await t.createMeshWriters(e.defaultSymbol);r.setDefault(i);const n=await t.createMeshWriters(e.backgroundFill);return r.setBackgroundFill(n),r}add(t,e){this._intervals.push({interval:t,result:e}),this._intervals.sort(((t,e)=>t.interval.min-e.interval.min))}size(){return super.size()+this._intervals.length}hasArcadeDependency(t){return this._field?.hasArcadeDependency(t)||this._intervals.some((e=>e.result.some((e=>e.hasArcadeDependency(t)))))}doMatch(t,e){const s=this._field?.read(t,e);if(null==s||isNaN(s)||s===1/0||s===-1/0)return null;for(let t=0;t<this._intervals.length;t++){const{interval:e,result:r}=this._intervals[t],i=s>=e.min,n=this._isMaxInclusive?s<=e.max:s<e.max;if(i&&n)return r}return null}}class it extends et{static async fromLabelSchema(t,e){const s=e.classes.map((async e=>{const s=await t.createMeshWriters(e.meshes);return{minScale:e.minScale,maxScale:e.maxScale,meshes:s,expression:null,where:await t.storage.createWhereClause(e.where)}})),r=await Promise.all(s);return new it(r)}constructor(t){super(),this._labels=t}match(t,e){if(!this._labels.length)return null;const s=this._getLabels(e.$view.scale),r=[];for(const e of s)e.where&&!e.where(t)||r.push(...e.meshes);return r}_getLabels(t){return this._labels.filter((e=>this._validForTileScale(e,t)))}_validForTileScale(t,e){const s=e-e/4,r=e+e/2;return(!t.minScale||t.minScale>=s)&&(!t.maxScale||t.maxScale<=r)}}class nt extends et{constructor(t,e){super(),this._defaultSymbolSortKey=0,this._nullResult=null,this._resultsMap=new Map,this._fields=[],this._fields=t,this._separator=e||""}static async fromMatcherSchema(t,e){const s=e.expression?[t.storage.createComputedField({expression:e.expression})]:[e.field?t.storage.createComputedField({field:e.field}):null,e.field2?t.storage.createComputedField({field:e.field2}):null,e.field3?t.storage.createComputedField({field:e.field3}):null],r=(await Promise.all(s)).filter((t=>!!t)),i=new nt(r,e.fieldDelimiter),n=await t.createMeshWriters(e.defaultSymbol);i.setDefault(n);const o=await t.createMeshWriters(e.backgroundFill);return i.setBackgroundFill(o),await Promise.all(e.map.map((async(e,s)=>{const r=await t.createMeshWriters(e.symbol);"<Null>"===e.value?i.setNullResult(r):i.add(e.value,r,s+1)}))),i}setNullResult(t){this._nullResult=t}getSortKey(t,e){const s=this._getValueFromFields(t,e);if(null==s||""===s||"<Null>"===s)return 0;const r=this._resultsMap.get(s.toString());return r?r.sortKey:this._defaultSymbolSortKey}add(t,e,s){this._resultsMap.set(t.toString(),{meshWriters:e,sortKey:s}),this._defaultSymbolSortKey=Math.max(this._defaultSymbolSortKey,s+1)}size(){return super.size()+this._resultsMap.size}hasArcadeDependency(t){return this._fields.some((e=>e.hasArcadeDependency(t)))||[...this._resultsMap.values()].some((e=>e.meshWriters.some((e=>e.hasArcadeDependency(t)))))||this._nullResult?.some((e=>e.hasArcadeDependency(t)))||!1}doMatch(t,e){const s=this._getValueFromFields(t,e);if(null!==this._nullResult&&(null==s||""===s||"<Null>"===s))return this._nullResult;if(null==s)return null;const r=s.toString();return this._resultsMap.get(r)?.meshWriters}_getValueFromFields(t,e){const s=[];for(const r of this._fields){const i=r.read(t,e);null==i||""===i?s.push("<Null>"):s.push(i)}return s.join(this._separator)}}async function ot(t,e){switch(e.type){case"simple":case"heatmap":case"dot-density":case"pie-chart":return et.from(t,e);case"interval":return rt.fromIntervalSchema(t,e);case"dictionary":return st.fromDictionaryRenderer(t,e);case"label":return it.fromLabelSchema(t,e);case"map":return nt.fromMatcherSchema(t,e);case"subtype":return at.fromSubtypes(t,e);case"cluster":return ht.fromClusterSchema(t,e);default:throw new Error("Impl")}}class at extends et{constructor(t,e){super(),this._subMatchers=t,this._subtypeField=e}static async fromSubtypes(t,e){const s=new Map,r=[];for(const i in e.renderers){const n=parseInt(i,10),o=ot(t,e.renderers[i]).then((t=>s.set(n,t)));r.push(o)}return await Promise.all(r),new at(s,e.subtypeField)}match(t,e){const s=t.readAttribute(this._subtypeField),r=this._subMatchers.get(s);return r?r.match(t,e):null}}class ht extends et{static async fromClusterSchema(t,e){const[s,r]=await Promise.all([ot(t,e.feature),ot(t,e.cluster)]);return new ht(s,r)}constructor(t,e){super(),this._featureMatcher=t,this._clusterMatcher=e}match(t,e){return 1===t.readAttribute("cluster_count")?this._featureMatcher.match(t,e):this._clusterMatcher.match(t,e)}}class ct extends tt{static async create(t,e){const s=await ot(t,e.symbology),r=e.labels?await ot(t,e.labels):null;return new ct(s,r)}constructor(t,e){super(),this._symbology=t,this._labels=e}destroy(){}async enqueueMatcherRequests(t,e){await Promise.all([this._symbology.fetchResources(t,e),this._labels?.fetchResources(t,e)])}enqueueWriterRequests(t,e,s){const r=this._symbology.match(e,s);if(r){for(const i of r)i.enqueueRequest(t,e,s);if(this._labels){const r=this._labels.match(e,s);if(!r)return;for(const i of r)i.enqueueRequest(t,e,s)}}}write(t,e,s,r,i){const n=this._symbology.match(s,r);if(n){for(const o of n)o.write(t,e,s,r,i);if(t.entityRecordCount()>=1&&this._labels){const o=this._labels.match(s,r);if(!o)return;for(const a of o)a.setReferences(n),a.write(t,e,s,r,i)}}}getSortKey(t,e){return this._symbology.getSortKey(t,e)}hasArcadeDependency(t){return this._symbology.hasArcadeDependency(t)}}var lt=s(799),ut=s(94656),dt=s(63907),_t=s(48852),pt=s(36421),ft=s(42293);class gt{constructor(t,e){this._context=t,this._descriptor=e,this.type=pt.p.RenderBuffer,this._context.instanceCounter.increment(dt.vt.Renderbuffer,this);const s=this._context.gl;this.glName=s.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:r,height:i,internalFormat:n,multisampled:o}=e;o?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,n,r,i):s.renderbufferStorage(s.RENDERBUFFER,n,r,i),this._context.bindRenderbuffer(null)}get descriptor(){return this._descriptor}get samples(){const t=this._descriptor.samples,e=this._context.parameters.maxSamples;return t?Math.min(t,e):e}get usedMemory(){return(t=this._descriptor).width<=0||t.height<=0||null==t.internalFormat?0:t.width*t.height*(0,ft.IB)(t.internalFormat);var t}resize(t,e){const s=this._descriptor;if(s.width===t&&s.height===e)return;s.width=t,s.height=e;const r=this._context.gl;this._context.bindRenderbuffer(this),s.multisampled?r.renderbufferStorageMultisample(r.RENDERBUFFER,this.samples,s.internalFormat,s.width,s.height):r.renderbufferStorage(r.RENDERBUFFER,s.internalFormat,s.width,s.height),this._context.bindRenderbuffer(null)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(dt.vt.Renderbuffer,this),this._context=null)}}var mt=s(72626);class yt{constructor(t,e,s=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(dt.vt.FramebufferObject,this);const r=bt(e)?e:new mt.g(this._context,e);if(this._colorAttachments.set(dt.Nm.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(dt.Nm.COLOR_ATTACHMENT0),null!=s)if(function(t){return bt(t)||null!=t&&"pixelFormat"in t}(s))this._depthStencilTexture=bt(s)?s:new mt.g(this._context,s),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=function(t){return null!=t&&"type"in t&&t.type===pt.p.RenderBuffer}(s)?s:new gt(this._context,s);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName&&(this._context.gl.deleteFramebuffer(this._glName),this._glName=null),this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(dt.vt.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(dt.Nm.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(dt.Nm.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(dt.Nm.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,s])=>t+s.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&bt(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=dt.Nm.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const s=t.descriptor;this._validateTextureDescriptor(s),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=dt.Nm.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=dt.Nm.COLOR_ATTACHMENT0){const s=this._colorAttachments.get(e);s&&this._framebufferTexture2D(s.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case pt.p.Texture:return this._attachDepthStencilTexture(t);case pt.p.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==dt.Ab.DEPTH_STENCIL&&e.pixelFormat!==dt.Ab.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==dt.ld.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,dt.nI)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;if(t&&this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,dt.nI),this._context.bindFramebuffer(t)}return this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const s=this._context.gl,r=this._getGLAttachmentPoint(e);s.framebufferRenderbuffer(dt.R.FRAMEBUFFER,r,s.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this);const s=this._context.gl,r=this._getGLAttachmentPoint(t.descriptor);s.framebufferRenderbuffer(dt.R.FRAMEBUFFER,r,s.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,s,r,i,n,o){(t<0||e<0||i<0||n<0)&&console.error("Offsets cannot be negative!"),(s<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==dt.Ap.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||t+s>this.width||e+r>this.height||i+s>a.width||n+r>a.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const h=this._context,c=h.bindTexture(o,mt.g.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(mt.g.TEXTURE_UNIT_FOR_UPDATES),h.bindFramebuffer(this),h.gl.copyTexSubImage2D(dt.Ap.TEXTURE_2D,0,i,n,t,e,s,r),h.bindTexture(c,mt.g.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,s,r,i,n,o){(s<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),o||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,s,r,i,n,o)}async readPixelsAsync(t,e,s,r,i,n,o){const{gl:a}=this._context,h=_t.g.createPixelPack(this._context,dt._U.STREAM_READ,o.byteLength);this._context.bindBuffer(h);const c=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),a.readPixels(t,e,s,r,i,n,0),this._context.unbindBuffer(dt.NZ.PIXEL_PACK_BUFFER),this._context.bindFramebuffer(c),await h.getSubDataAsync(o),h.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const s={width:t,height:e};wt(s,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(s.width,s.height))),this._depthStencilTexture?.resize(s.width,s.height),this._initialized&&(wt(s,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(s.width,s.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=dt.R.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const s=e.createFramebuffer();if(e.bindFramebuffer(t,s),this._colorAttachments.forEach(((e,s)=>this._framebufferTexture2D(e.glName,s,xt(e),t))),this._depthStencilBuffer){const s=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,s,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,xt(this._depthStencilTexture),t);(0,ut.en)()&&e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=s,this._initialized=!0}_framebufferTexture2D(t,e=dt.Nm.COLOR_ATTACHMENT0,s=dt.Ap.TEXTURE_2D,r=dt.R.FRAMEBUFFER,i=0){this._context.gl.framebufferTexture2D(r,e,s,t,i)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(dt.R.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=(0,C.WD)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,C.WD)(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==dt.Ap.TEXTURE_2D&&t.target!==dt.Ap.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),wt(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){wt(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case dt.yQ.DEPTH_COMPONENT16:case dt.yQ.DEPTH_COMPONENT24:case dt.yQ.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case dt.yQ.DEPTH24_STENCIL8:case dt.yQ.DEPTH32F_STENCIL8:case dt.yQ.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case dt.yQ.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(t){if(-1===yt._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;yt._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const e=t-dt.Nm.COLOR_ATTACHMENT0;e+1>yt._MAX_COLOR_ATTACHMENTS&&E.A.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${e+1}. Implementation supports up to ${yt._MAX_COLOR_ATTACHMENTS} color attachments`)}}function bt(t){return null!=t&&"type"in t&&t.type===pt.p.Texture}function wt(t,e){const s=Math.max(t.width,t.height);if(s>e){E.A.getLogger("esri.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/s;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function xt(t){return t.descriptor.target===dt.Ap.TEXTURE_CUBE_MAP?dt.Ap.TEXTURE_CUBE_MAP_POSITIVE_X:dt.Ap.TEXTURE_2D}yt._MAX_COLOR_ATTACHMENTS=-1,s(62298);var vt=s(67171);function St(t,e,s){const r=new vt.R(e.width,e.height);return r.dataType=e.dataType,e.depth&&(r.depth=e.depth),e.flipped&&(r.flipped=e.flipped),e.hasMipmap&&(r.hasMipmap=e.hasMipmap),r.internalFormat=e.internalFormat,e.isImmutable&&(r.isImmutable=e.isImmutable),e.isOpaque&&(r.isOpaque=e.isOpaque),e.maxAnisotropy&&(r.maxAnisotropy=e.maxAnisotropy),r.pixelFormat=e.pixelFormat,e.preMultiplyAlpha&&(r.preMultiplyAlpha=e.preMultiplyAlpha),e.samplingMode&&(r.samplingMode=e.samplingMode),e.target&&(r.target=e.target),r.uniform=e.uniform,e.unpackAlignment&&(r.unpackAlignment=e.unpackAlignment),e.wrapMode&&(r.wrapMode=e.wrapMode),new mt.g(t,r,s)}new Map;class It{}class Mt extends It{constructor(t){super(),this._fetcher=t,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destroy(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(t){const e="url"in(r=t.resource)&&"urlHash"in r?{...r,url:""}:r,s=(0,lt.Wm)(JSON.stringify(e));var r;return this._pendingIds.has(s)||(this._pendingIds.add(s),this._pendingRequests.push({...t,resourceId:s})),s}async fetchEnqueuedResources(){const t=this._pendingRequests;if(this._pendingIds.clear(),this._pendingRequests=[],0===t.length)return;const e=await this._fetcher.fetch(t,this._abortOptions);for(let s=0;s<e.length;s++){const r=t[s].resourceId;this._resourceIdToResource.set(r,e[s])}}async fetchResourceImmediate(t){const e=await this._fetcher.fetch([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return e[0]}async fetchDictionaryResourceImmediate(t){const e=await this._fetcher.fetchDictionary([t],this._abortOptions);if(1!==e.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return e[0]}getResource(t){return this._resourceIdToResource.get(t)}}var Pt,Tt;(Tt=Pt||(Pt={}))[Tt.AnimatedMarker=0]="AnimatedMarker",Tt[Tt.Blend=1]="Blend",Tt[Tt.ComplexFill=2]="ComplexFill",Tt[Tt.ComplexOutlineFill=3]="ComplexOutlineFill",Tt[Tt.DotDensity=4]="DotDensity",Tt[Tt.Fill=5]="Fill",Tt[Tt.GradientFill=6]="GradientFill",Tt[Tt.GradientStroke=7]="GradientStroke",Tt[Tt.Grid=8]="Grid",Tt[Tt.Heatmap=9]="Heatmap",Tt[Tt.Label=10]="Label",Tt[Tt.Line=11]="Line",Tt[Tt.Magnifier=12]="Magnifier",Tt[Tt.Marker=13]="Marker",Tt[Tt.OutlineFill=14]="OutlineFill",Tt[Tt.Overlay=15]="Overlay",Tt[Tt.PatternFill=16]="PatternFill",Tt[Tt.PatternOutlineFill=17]="PatternOutlineFill",Tt[Tt.PieChart=18]="PieChart",Tt[Tt.Test=19]="Test",Tt[Tt.Text=20]="Text",Tt[Tt.TexturedLine=21]="TexturedLine",Tt[Tt.Bitmap=22]="Bitmap";var At=s(68197),Ct=s(15294);function kt(t,e){return[!!t?.minScale&&e.scaleToZoom(t.minScale)||0,!!t?.maxScale&&e.scaleToZoom(t.maxScale)||100]}function Ft(t){return 1<<t}function Et(t){let e=0;for(const[s,r]of t)r&&(e|=1<<s);return e}function zt(t){let e;if(!t)return[0,0,0,0];if("string"==typeof t){const s=At.A.fromString(t);if(!s)return E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new r.A("mapview:mesh-processing","Unable to parse string into color",{color:t})),[0,0,0,0];e=s.toArray()}else e=t;const[s,i,n,o]=e;return[s*(o/255),i*(o/255),n*(o/255),o]}function Ot(t,e){return Math.round(Math.min(Math.sqrt(t*e),255))}function Rt(t,e){return Math.round(t*e)/e}const Dt=0,Lt=1,Nt=2,Bt=3,Gt=4,Ut=5;var Vt=s(4718),qt=s(51118),Wt=s(65864),jt=s(92722);class Yt{static fromOptimized(t,e,s=!1,r=!1,i=1){return(new Xt).initialize(t,e,s,r,i)}static fromJSON(t,e=!1,s=!1){const[r,i]=Ht(t);return(new Zt).initialize(r,i,e,s,1)}static fromOptimizedCIM(t,e,s=!1,r=!1,i=1){return(new Qt).initialize(t,e,s,r,i)}static fromJSONCIM(t,e=!1,s=!1,r=1){const[i,n]=Ht(t);return(new Kt).initialize(i,n,e,s,r)}static fromFeatureSetReader(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimized(e,s):null}static fromFeatureSetReaderCIM(t){const e=t.readGeometryForDisplay(),s=t.geometryType;return e&&s?this.fromOptimizedCIM(e,s):null}static createEmptyOptimized(t,e=!1,s=!1,r=1){return(new Xt).initialize(new jt.A,t,e,s,r)}static createEmptyJSON(t,e=!1,s=!1){return(new Zt).initialize([],t,e,s,1)}static createEmptyOptimizedCIM(t,e=!1,s=!1,r=1){return(new Qt).initialize(new jt.A,t,e,s,r)}static createEmptyJSONCIM(t,e=!1,s=!1,r=1){return(new Kt).initialize([],t,e,s,r)}asJSON(){const t=(0,qt.x)(this);return"esriGeometryEnvelope"===this.geometryType?{xmin:t[0][0][0],ymin:t[0][0][1],xmax:t[0][2][0],ymax:t[0][2][1]}:"esriGeometryMultipoint"===this.geometryType?{points:t.flat()}:"esriGeometryPoint"===this.geometryType?{x:t[0][0][0],y:t[0][0][1]}:"esriGeometryPolygon"===this.geometryType?{rings:t}:{paths:t}}getCurrentRingArea(){if(this.pathSize<3)return 0;let t,e,s=0;if(this.seekPathStart(),!this.nextPoint())return 0;t=this.x,e=this.y;const r=t,i=e;for(;this.nextPoint();)s+=(t-this.x)*(e+this.y),t=this.x,e=this.y;return s+=(t-r)*(e+i),-.5*s}invertY(){this.yFactor*=-1}}class Xt extends Yt{constructor(){super(...arguments),this._end=-1}initialize(t,e,s,r,i){return this.hasZ=s,this.hasM=r,this.geometryType=e,this._stride=2+Number(s)+Number(r),this._geometry=t,this._pathIndex=-1,this._pathOffset=0,this._pointOffset=-this._stride,this._end=-1,this.yFactor=i,this}reset(){this.initialize(this._geometry,this.geometryType,this.hasZ,this.hasM,this.yFactor)}seekPath(t){if(t>=0&&t<this.totalSize){if(this._pathIndex<t)for(;this._pathIndex<t&&this.nextPath(););else if(this._pathIndex>t)for(;this._pathIndex>t&&this.prevPath(););return!0}return!1}seekPathStart(){this._pointOffset=this._pathOffset-this._stride}seekPathEnd(){this._pointOffset=this._end}seekInPath(t){const e=this._pathOffset+t*this._stride;return e>=0&&e<this._end&&(this._pointOffset=e,!0)}nextPoint(){return(this._pointOffset+=this._stride)<this._end}prevPoint(){return(this._pointOffset-=this._stride)>=this._pathOffset}nextPath(){return!(this.pathIndex>=this.totalSize-1||(this._pathIndex>=0&&(this._pathOffset+=this._stride*this.pathSize),this._pathIndex++,this._pointOffset=this._pathOffset-this._stride,this._end=this._pointOffset+this._stride+this._stride*this.pathSize,0))}prevPath(){return!(this.pathIndex<=0||(this._pathIndex--,this._end=this._pathOffset,this._pathOffset-=this._stride*this.pathSize,this._pointOffset=this._pathOffset-this._stride,0))}getCurrentPath(){const t=this._end,e=this._geometry.coords,s=this._pathOffset;return(new Xt).initialize(new jt.A([this.pathSize],e.slice(s,t)),this.geometryType,this.hasZ,this.hasM,this.yFactor)}pathLength(){const t=this._end,e=this._stride,s=this._geometry.coords;let r=0;for(let i=this._pathOffset+e;i<t;i+=e){const t=s[i-e],n=s[i-e+1],o=s[i]-t,a=s[i+1]-n;r+=Math.sqrt(o*o+a*a)}return r}startPath(){this._geometry.lengths.push(0)}pushPath(t){this.startPath(),this.pushPoints(t)}pushPoint(t){for(let e=0;e<this._stride;++e)this._geometry.coords.push(t[e]);this._geometry.lengths[this.totalSize-1]++}pushXY(t,e){this._geometry.coords.push(t,e),this._geometry.lengths[this.totalSize-1]++}pushPoints(t){for(const e of t)for(let t=0;t<this._stride;++t)this._geometry.coords.push(e[t]);this._geometry.lengths[this.totalSize-1]+=t.length}pushCursor(t){const e=t.asOptimized();this._geometry.coords.push(...e.coords),this._geometry.lengths.push(...e.lengths)}asOptimized(){const t=this._geometry.clone();if(1!==this.yFactor)for(let e=1;e<t.coords.length;e+=this._stride)t.coords[e]*=this.yFactor;return"esriGeometryPoint"===this.geometryType&&(t.lengths.length=0),t}isClosed(){const t=this._geometry.coords,e=this._pathOffset,s=this._end-this._stride;for(let r=0;r<this._stride;r++)if(t[e+r]!==t[s+r])return!1;return!0}clone(){return(new Xt).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._geometry.isPoint?1:this._geometry.lengths.reduce(((t,e)=>t+e))}get pathSize(){const{lengths:t}=this._geometry;return this._geometry.isPoint?1:this._pathIndex<0||this._pathIndex>t.length-1?0:t[this._pathIndex]}get totalSize(){return this._geometry.isPoint?1:this._geometry.lengths.length}get x(){return this._geometry.coords[this._pointOffset]}set x(t){this._geometry.coords[this._pointOffset]=t}get y(){return this.yFactor*this._geometry.coords[this._pointOffset+1]}set y(t){this._geometry.coords[this._pointOffset+1]=this.yFactor*t}get z(){return this._geometry.coords[this._pointOffset+2]}set z(t){this._geometry.coords[this._pointOffset+2]=t}get m(){const t=this.hasZ?3:2;return this._geometry.coords[this._pointOffset+t]}set m(t){this._geometry.coords[this._pointOffset+3]=t}get pathIndex(){return this._pathIndex}get _coordIndex(){return this._pointOffset/this._stride}}function $t(t){const e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e}function Ht(t){return(0,Wt.Bi)(t)?[t.rings,"esriGeometryPolygon"]:(0,Wt.Rg)(t)?[t.paths,"esriGeometryPolyline"]:(0,Wt.U9)(t)?[[t.points],"esriGeometryMultipoint"]:(0,Wt.ZC)(t)?[[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]],"esriGeometryEnvelope"]:(0,Wt.fT)(t)?[[[$t(t)]],"esriGeometryPoint"]:[[],"esriGeometryPolyline"]}class Zt extends Yt{initialize(t,e,s,r,i){return this._paths=t,this.geometryType=e,this.hasZ=s,this.hasM=r,this._pathIndex=this._pointIndex=-1,this.yFactor=i,this._mIndex=this.hasZ?3:2,this}reset(){this._pathIndex=this._pointIndex=-1}seekPath(t){return this._pathIndex=t,this._pointIndex=-1,t>=0&&t<this.totalSize&&(this._currentPath=this._paths[t],!0)}seekPathStart(){this._pointIndex=-1}seekPathEnd(){this._pointIndex=this._currentPath.length}seekInPath(t){return t>=0&&t<this._currentPath.length&&(this._pointIndex=t,this._currentPoint=this._currentPath[this._pointIndex],!0)}nextPoint(){return this._currentPoint=this._currentPath[++this._pointIndex],this._pointIndex<this._currentPath.length}prevPoint(){return this._currentPoint=this._currentPath[--this._pointIndex],this._pointIndex>=0}nextPath(){return this._pointIndex=-1,this._currentPath=this._paths[++this._pathIndex],this._pathIndex<this.totalSize}prevPath(){return this.pathIndex>0&&(this._pointIndex=-1,this._pathIndex--,this._currentPath=this._paths[this._pathIndex],!0)}pathLength(){const t=this._currentPath.length,e=this._currentPath;let s=0;for(let r=1;r<t;r++){const t=e[r-1],i=e[r],n=t[0],o=t[1],a=i[0]-n,h=i[1]-o;s+=Math.sqrt(a*a+h*h)}return s}startPath(){this._paths.push([])}getCurrentPath(){return(new Zt).initialize([this._currentPath],this.geometryType,this.hasZ,this.hasM,this.yFactor)}pushPath(t){this._paths.push(t)}pushPoint(t){this._paths[this.totalSize-1].push(t)}pushXY(t,e){this._paths[this.totalSize-1].push([t,e])}pushPoints(t){this._paths[this.totalSize-1].push(...t)}pushCursor(t){const e=(0,qt.x)(t);for(const t of e)this.pushPath(t)}asOptimized(){const t=new jt.A;if("esriGeometryPoint"===this.geometryType)t.coords.push(...this._paths[0][0]),t.lengths.length=0;else for(const e of this._paths){for(const s of e)t.coords.push(s[0]),t.coords.push(s[1]*this.yFactor),this.hasZ&&t.coords.push(s[2]),this.hasM&&t.coords.push(s[this._mIndex]);t.lengths.push(e.length)}return t}isClosed(){const t=this._currentPath[0],e=this._currentPath[this._currentPath.length-1];for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}clone(){return(new Zt).initialize((0,Vt.o8)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}get totalPoints(){return this._paths.map((t=>t.length)).reduce(((t,e)=>t+e))}get pathSize(){return this._pathIndex<0||this._pathIndex>this.totalSize-1?-1:this._paths[this._pathIndex].length}get totalSize(){return this._paths.length}get x(){return this._currentPoint[0]}set x(t){this._currentPoint[0]=t}get y(){return this.yFactor*this._currentPoint[1]}set y(t){this._currentPoint[1]=this.yFactor*t}get z(){return this._currentPoint[2]}set z(t){this._currentPoint[2]=t}get m(){return this._currentPoint[this._mIndex]}set m(t){this._currentPoint[this._mIndex]=t}get pathIndex(){return this._pathIndex}}class Qt extends Xt{initialize(t,e,s,r,i){return super.initialize(t,e,s,r,i),this._controlPoints||(this._controlPoints=this._controlPoints=new Array(this.totalSize).fill(void 0).map((t=>new Set))),this}startPath(){super.startPath(),this._controlPoints.push(new Set)}clone(){const t=(new Qt).initialize(this._geometry.clone(),this.geometryType,this.hasZ,this.hasM,this.yFactor);return t._controlPoints=this._controlPoints,t}setControlPoint(){this._controlPoints[this.pathIndex].add(this._coordIndex)}getControlPoint(){return this._controlPoints[this.pathIndex].has(this._coordIndex)}setControlPointAt(t){this._controlPoints[this.pathIndex].add(t)}getControlPointAt(t){return this._controlPoints[this.pathIndex].has(t)}}class Kt extends Zt{initialize(t,e,s,r,i){return super.initialize(t,e,s,r,i)}clone(){return(new Kt).initialize((0,Vt.o8)(this._paths),this.geometryType,this.hasZ,this.hasM,this.yFactor)}setControlPoint(){this._paths[this.pathIndex][this._pointIndex][4]=1}getControlPoint(){return 1===this._paths[this.pathIndex][this._pointIndex][4]}setControlPointAt(t){this._paths[this.pathIndex][t][4]=1}getControlPointAt(t){return 1===this._paths[this.pathIndex][t][4]}}var Jt=s(6774);let te;class ee{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}function se(t,e){te||(te=new Jt.O3(0,0,0,1));const s="esriGeometryPolygon"===t.geometryType,r=s?Jt.dC.Polygon:Jt.dC.LineString,i=s?3:2;let n,o;for(te.reset(r),te.setPixelMargin(e+1),te.setExtent(512);t.nextPath();)if(!(t.pathSize<i)){for(t.nextPoint(),n=t.x,o=-t.y,te.moveTo(n,o);t.nextPoint();)n=t.x,o=-t.y,te.lineTo(n,o);s&&te.close()}const a=te.result(!1);if(a){const e=Yt.createEmptyOptimizedCIM(t.geometryType);for(const t of a){e.startPath();for(const s of t)e.pushXY(s.x,-s.y)}return e.reset(),e}return null}class re{static local(){return null===re.instance&&(re.instance=new re),re.instance}execute(t,e,s,r,i){return new ie(t,e,s)}}re.instance=null;class ie{constructor(t,e,s){this._inputGeometries=t,this._angleTolerance=void 0!==e.angleTolerance?e.angleTolerance:120,this._maxCosAngle=Math.cos((1-Math.abs(this._angleTolerance)/180)*Math.PI)}next(){let t=this._inputGeometries.next();for(;t;){if("esriGeometryPolygon"===t.geometryType)this._isClosed=!0;else if("esriGeometryPolyline"===t.geometryType)this._isClosed=!1;else{if("esriGeometryEnvelope"!==t.geometryType){t=this._inputGeometries.next();continue}if(this._maxCosAngle)return t;this._isClosed=!0}for(;t.nextPath();)this._processPath(t);return t.reset(),t}return null}_processPath(t){if(t.nextPoint()){const e=t.x,s=t.y;let r=e,i=s,n=t.pathSize,o=0,a=0,h=0,c=0,l=0,u=0;this._isClosed&&++n;for(let d=1;t.nextPoint()||d<n;++d){let _,p;this._isClosed&&d===n-1?(_=e,p=s):(_=t.x,p=t.y);const f=_-r,g=p-i,m=Math.sqrt(f*f+g*g);d>1&&m>0&&h>0&&(o*f+a*g)/m/h<=this._maxCosAngle&&t.setControlPointAt(d-1),1===d&&(c=f,l=g,u=m),m>0&&(r=_,i=p,o=f,a=g,h=m)}this._isClosed&&h>0&&u>0&&(o*c+a*l)/u/h<=this._maxCosAngle&&t.setControlPointAt(0)}}}class ne{constructor(){this.setIdentity()}getAngle(){return(null==this.rz||0===this.rz&&1!==this.rzCos&&0!==this.rzSin)&&(this.rz=Math.atan2(this.rzSin,this.rzCos)),this.rz}setIdentity(){this.tx=0,this.ty=0,this.tz=0,this.s=1,this.rx=0,this.ry=0,this.rz=0,this.rzCos=1,this.rzSin=0}setTranslate(t,e){this.tx=t,this.ty=e}setTranslateZ(t){this.tz=t}setRotateCS(t,e){this.rz=void 0,this.rzCos=t,this.rzSin=e}setRotate(t){this.rz=t,this.rzCos=void 0,this.rzSin=void 0}setRotateY(t){this.ry=t}setScale(t){this.s=t}setMeasure(t){this.m=t}}function oe(t,e){t[4]=e}class ae{constructor(t,e=!0,s=!0,r=0){this.isClosed=!1,this.geometryCursor=null,this.geometryCursor=!e&&"esriGeometryPolygon"===t.geometryType||!s&&"esriGeometryPolyline"===t.geometryType?null:t,this.geomUnitsPerPoint=r,this.iterateMultiPath=!1,this.iteratePath=!1,this.internalPlacement=new ne}next(){if(!this.geometryCursor)return null;const t=this.processMultiPath(this.geometryCursor);return this.iterateMultiPath&&t||(this.geometryCursor=null),t}processMultiPath(t){for(;this.iteratePath||t.pathIndex<t.totalSize-1;){this.iteratePath||t.nextPath(),this.iterateMultiPath=!0;const e=this.processPath(t);if(e)return e}return this.iterateMultiPath=!1,null}}class he{constructor(t,e,s,r=0){this.isClosed=!1,this.inputGeometries=t,this.acceptPolygon=e,this.acceptPolyline=s,this.geomUnitsPerPoint=r,this.iteratePath=!1,this.multiPathCursor=null}next(){for(;;){if(!this.multiPathCursor){let t=this.inputGeometries.next();for(;t&&(this.isClosed=this.acceptPolygon&&"esriGeometryPolygon"===t.geometryType||"esriGeometryEnvelope"===t.geometryType,this.multiPathCursor=t,!this.multiPathCursor);)t=this.inputGeometries.next();if(!this.multiPathCursor)return null}for(;this.iteratePath||this.multiPathCursor.nextPath();){this.multiPathCursor.seekPathStart();const t=this.processPath(this.multiPathCursor);if(t)return t}this.multiPathCursor=null}}}const ce=.03;class le{constructor(t=0,e=!1){}isEmpty(t){if(!t.nextPoint())return!0;let e,s,r,i;for(e=t.x,s=t.y;t.nextPoint();e=s,s=i)if(r=t.x,i=t.y,r!==e||i!==s)return t.seekPathStart(),!1;return t.seekPathStart(),!0}normalize(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]);0!==e&&(t[0]/=e,t[1]/=e)}getLength(t,e,s,r){const i=s-t,n=r-e;return Math.sqrt(i*i+n*n)}getSegLength(t){const[[e,s],[r,i]]=t;return this.getLength(e,s,r,i)}getCoord2D(t,e,s,r,i){return[t+(s-t)*i,e+(r-e)*i]}getSegCoord2D(t,e){const[[s,r],[i,n]]=t;return this.getCoord2D(s,r,i,n,e)}getAngle(t,e,s,r,i){const n=s-t,o=r-e;return Math.atan2(o,n)}getAngleCS(t,e,s,r,i){const n=s-t,o=r-e,a=Math.sqrt(n*n+o*o);return a>0?[n/a,o/a]:[1,0]}getSegAngleCS(t,e){const[[s,r],[i,n]]=t;return this.getAngleCS(s,r,i,n,e)}cut(t,e,s,r,i,n){return[i<=0?[t,e]:this.getCoord2D(t,e,s,r,i),n>=1?[s,r]:this.getCoord2D(t,e,s,r,n)]}getSubCurve(t,e,s){const r=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");return this.appendSubCurve(r,t,e,s)?r:null}appendSubCurve(t,e,s,r){t.startPath(),e.seekPathStart();let i=0,n=!0;if(!e.nextPoint())return!1;let o=e.x,a=e.y;for(;e.nextPoint();){const h=this.getLength(o,a,e.x,e.y);if(0!==h){if(n){if(i+h>s){const c=(s-i)/h;let l=1,u=!1;i+h>=r&&(l=(r-i)/h,u=!0);const d=this.cut(o,a,e.x,e.y,c,l);if(d&&t.pushPoints(d),u)break;n=!1}}else{if(i+h>r){const s=this.cut(o,a,e.x,e.y,0,(r-i)/h);s&&t.pushPoint(s[1]);break}t.pushXY(e.x,e.y)}i+=h,o=e.x,a=e.y}else o=e.x,a=e.y}return!0}getCIMPointAlong(t,e){if(!t.nextPoint())return null;let s,r,i,n,o=0;for(s=t.x,r=t.y;t.nextPoint();s=i,r=n){i=t.x,n=t.y;const a=this.getLength(s,r,i,n);if(0!==a){if(o+a>e){const t=(e-o)/a;return this.getCoord2D(s,r,i,n,t)}o+=a}}return null}offset(t,e,s,r,i){if(!t||t.length<2)return null;let n=0,o=t[n++],a=n;for(;n<t.length;){const e=t[n];e[0]===o[0]&&e[1]===o[1]||(n!==a&&(t[a]=t[n]),o=t[a++]),n++}const h=t[0][0]===t[a-1][0]&&t[0][1]===t[a-1][1];if(h&&--a,a<(h?3:2))return null;const c=[];o=h?t[a-1]:null;let l=t[0];for(let i=0;i<a;i++){const n=i===a-1?h?t[0]:null:t[i+1];if(o)if(n){const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t);const i=[l[0]-o[0],l[1]-o[1]];this.normalize(i);const a=i[0]*t[1]-i[1]*t[0],h=i[0]*t[0]+i[1]*t[1];if(0===a&&1===h){l=n;continue}if(a>=0==e<=0){if(h<1){const s=[t[0]-i[0],t[1]-i[1]];this.normalize(s);const n=Math.sqrt((1+h)/2);if(n>1/r){const t=-Math.abs(e)/n;c.push([l[0]-s[0]*t,l[1]-s[1]*t])}}}else switch(s){case Ct.xw.Mitered:{const s=Math.sqrt((1+h)/2);if(s>0&&1/s<r){const r=[t[0]-i[0],t[1]-i[1]];this.normalize(r);const n=Math.abs(e)/s;c.push([l[0]-r[0]*n,l[1]-r[1]*n]);break}}case Ct.xw.Bevelled:c.push([l[0]+i[1]*e,l[1]-i[0]*e]),c.push([l[0]+t[1]*e,l[1]-t[0]*e]);break;case Ct.xw.Rounded:if(h<1){c.push([l[0]+i[1]*e,l[1]-i[0]*e]);const s=Math.floor(2.5*(1-h));if(s>0){const r=1/s;let n=r;for(let o=1;o<s;o++,n+=r){const s=[i[1]*(1-n)+t[1]*n,-i[0]*(1-n)-t[0]*n];this.normalize(s),c.push([l[0]+s[0]*e,l[1]+s[1]*e])}}c.push([l[0]+t[1]*e,l[1]-t[0]*e])}break;case Ct.xw.Square:default:if(a<0)c.push([l[0]+(i[1]+i[0])*e,l[1]+(i[1]-i[0])*e]),c.push([l[0]+(t[1]-t[0])*e,l[1]-(t[0]+t[1])*e]);else{const s=Math.sqrt((1+Math.abs(h))/2),r=[t[0]-i[0],t[1]-i[1]];this.normalize(r);const n=e/s;c.push([l[0]-r[0]*n,l[1]-r[1]*n])}}}else{const t=[l[0]-o[0],l[1]-o[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}else{const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t),c.push([l[0]+t[1]*e,l[1]-t[0]*e])}o=l,l=n}return c.length<(h?3:2)?null:(h&&c.push([c[0][0],c[0][1]]),c)}}const ue=Ct.oF.OpenEnded;class de{static local(){return null===de.instance&&(de.instance=new de),de.instance}execute(t,e,s,r,i){return new _e(t,e,s)}}de.instance=null;class _e extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new le,this._width=(void 0!==e.width?e.width:5)*s,this._arrowType=void 0!==e.geometricEffectArrowType?e.geometricEffectArrowType:void 0!==e.arrowType?e.arrowType:ue,this._offsetFlattenError=ce*s}processPath(t){const e=Yt.createEmptyOptimizedCIM(t.geometryType);switch(this._arrowType){case Ct.oF.OpenEnded:default:this._constructSimpleArrow(e,t,!0);break;case Ct.oF.Block:this._constructSimpleArrow(e,t,!1);break;case Ct.oF.Crossed:this._constructCrossedArrow(e,t)}return e}_constructSimpleArrow(t,e,s){const r=e.pathLength();let i=this._width;r<2*i&&(i=r/2);const n=this._curveHelper.getSubCurve(e,0,r-i);if(!n||!n.nextPath())return;n.seekPathStart();const o=i/2;if(this._curveHelper.isEmpty(n))return;const a=(0,qt.A)(n),h=this._constructOffset(a,-o);if(!h)return;const c=this._constructOffset(a,o);if(!c)return;const l=this._constructArrowBasePoint(h,-o/2);if(!l)return;const u=this._constructArrowBasePoint(c,o/2);if(!u)return;e.seekInPath(e.pathSize-1);const d=[e.x,e.y];t.pushPath(c),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(u),t.nextPoint(),t.setControlPoint(),t.pushPoint(d),t.nextPoint(),t.setControlPoint(),t.pushPoint(l),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.setControlPoint(),s||(t.setControlPointAt(0),t.setControlPointAt(t.pathSize-1),t.pushPoint(c[0])),t.reset()}_constructCrossedArrow(t,e){const s=e.pathLength();let r=this._width;s<3.732050807568877*r&&(r=s/3.732050807568877),e.seekPathStart();const i=this._curveHelper.getSubCurve(e,0,s-2.732050807568877*r);if(!i)return;i.nextPath();const n=r/2;if(this._curveHelper.isEmpty(i))return;const o=(0,qt.A)(i),a=this._constructOffset(o,n);if(!a)return;const h=this._constructOffset(o,-n);if(!h)return;const c=this._curveHelper.getSubCurve(e,0,s-r);if(!c)return;if(c.nextPath(),this._curveHelper.isEmpty(c))return;const l=(0,qt.A)(c),u=this._constructOffset(l,n);if(!u)return;const d=this._constructOffset(l,-n);if(!d)return;const _=u[u.length-1],p=this._constructArrowBasePoint(u,n/2);if(!p)return;const f=d[d.length-1],g=this._constructArrowBasePoint(d,-n/2);if(!g)return;e.seekInPath(e.pathSize-1);const m=[e.x,e.y];t.pushPath(a),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(f),t.nextPoint(),t.setControlPoint(),t.pushPoint(g),t.nextPoint(),t.setControlPoint(),t.pushPoint(m),t.nextPoint(),t.setControlPoint(),t.pushPoint(p),t.nextPoint(),t.setControlPoint(),t.pushPoint(_),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.nextPoint(),t.setControlPoint(),t.reset()}_constructOffset(t,e){return this._curveHelper.offset(t,e,Ct.xw.Rounded,4,this._offsetFlattenError)}_constructArrowBasePoint(t,e){if(!t||t.length<2)return null;const s=t[t.length-2],r=t[t.length-1],i=[r[0]-s[0],r[1]-s[1]];return this._curveHelper.normalize(i),[r[0]+i[1]*e,r[1]-i[0]*e]}}s(59456);class pe{static local(){return null===pe.instance&&(pe.instance=new pe),pe.instance}execute(t,e,s,r,i,n,o){return new fe(t,e,s,r,i,n,o)}}pe.instance=null;class fe{constructor(t,e,s,r,i,n,o){this._preventClipping=o,this._inputGeometries=t,this._tileKey=r,this._geometryEngine=i,this._curveHelper=new le,this._size=(void 0!==e.size?e.size:1)*s,this._maxInflateSize=n*s,this._offsetFlattenError=ce*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._size)return t;if("esriGeometryEnvelope"===t.geometryType)if(this._size>0){const e=Yt.createEmptyOptimizedCIM(t.geometryType),s=(0,qt.x)(t)[0],r=this._curveHelper.offset(s,this._size,Ct.xw.Rounded,4,this._offsetFlattenError);if(r)return e.pushPath(r),e}else if(this._size<0){const e=t.asJSON();if(Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._size>0)return Yt.fromJSONCIM({xmin:e.xmin-this._size,xmax:e.xmax+this._size,ymin:e.ymin-this._size,ymax:e.ymax+this._size})}const e=this._geometryEngine;if(null==e)return null;const s=!this._preventClipping&&this._tileKey?se(t,this._maxInflateSize):t;if(!s)continue;const r=e.buffer(q.A.WebMercator,s.asJSON(),this._size,1);return r?Yt.fromJSONCIM(r):null}return null}}var ge,me,ye=s(95108);class be{static local(){return null===be.instance&&(be.instance=new be),be.instance}execute(t,e,s,r,i){return new we(t,e,s)}}be.instance=null;class we{constructor(t,e,s){this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=e.rule??Ct.uQ.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){const e=this._processGeom((0,qt.x)(t));if(e?.length)return Yt.fromJSONCIM({paths:e})}return null}_clone(t){return[t[0],t[1]]}_mid(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}_mix(t,e,s,r){return[t[0]*e+s[0]*r,t[1]*e+s[1]*r]}_add(t,e){return[t[0]+e[0],t[1]+e[1]]}_add2(t,e,s){return[t[0]+e,t[1]+s]}_sub(t,e){return[t[0]-e[0],t[1]-e[1]]}_dist(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}_norm(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}_normalize(t,e=1){const s=e/this._norm(t);t[0]*=s,t[1]*=s}_leftPerpendicular(t){const e=-t[1],s=t[0];t[0]=e,t[1]=s}_leftPerp(t){return[-t[1],t[0]]}_rightPerpendicular(t){const e=t[1],s=-t[0];t[0]=e,t[1]=s}_rightPerp(t){return[t[1],-t[0]]}_dotProduct(t,e){return t[0]*e[0]+t[1]*e[1]}_crossProduct(t,e){return t[0]*e[1]-t[1]*e[0]}_rotateDirect(t,e,s){const r=t[0]*e-t[1]*s,i=t[0]*s+t[1]*e;t[0]=r,t[1]=i}_makeCtrlPt(t){const e=[t[0],t[1]];return oe(e,1),e}_addAngledTicks(t,e,s,r){const i=this._sub(s,e);this._normalize(i);const n=this._crossProduct(i,this._sub(r,e));let o;o=n>0?this._rightPerp(i):this._leftPerp(i);const a=Math.abs(n)/2,h=[];h.push([e[0]+(o[0]-i[0])*a,e[1]+(o[1]-i[1])*a]),h.push(e),h.push(s),h.push([s[0]+(o[0]+i[0])*a,s[1]+(o[1]+i[1])*a]),t.push(h)}_addBezier2(t,e,s,r,i){if(0==i--)return void t.push(r);const n=this._mid(e,s),o=this._mid(s,r),a=this._mid(n,o);this._addBezier2(t,e,n,a,i),this._addBezier2(t,a,o,r,i)}_addBezier3(t,e,s,r,i,n){if(0==n--)return void t.push(i);const o=this._mid(e,s),a=this._mid(s,r),h=this._mid(r,i),c=this._mid(o,a),l=this._mid(a,h),u=this._mid(c,l);this._addBezier3(t,e,o,c,u,n),this._addBezier3(t,u,l,h,i,n)}_add90DegArc(t,e,s,r,i){const n=i??this._crossProduct(this._sub(s,e),this._sub(r,e))>0,o=this._mid(e,s),a=this._sub(o,e);n?this._leftPerpendicular(a):this._rightPerpendicular(a),o[0]+=a[0],o[1]+=a[1],this._addBezier3(t,e,this._mix(e,.33333,o,.66667),this._mix(s,.33333,o,.66667),s,4)}_addArrow(t,e,s){const r=e[0],i=e[1],n=e[e.length-1],o=this._sub(r,i),a=this._norm(o);this._normalize(o);const h=Math.abs(this._crossProduct(o,this._sub(n,i)));let c=this._dotProduct(o,this._sub(n,i));c<.05*a?c=.05*a:c>.95*a&&(c=.95*a);const l=.5*h,u=this._leftPerp(o),d=[i[0]+o[0]*c,i[1]+o[1]*c],_=e.length-1,p=[];p.push(s?[-u[0],-u[1]]:u);let f=[-o[0],-o[1]];for(let t=1;t<_-1;t++){const s=this._sub(e[t+1],e[t]);this._normalize(s);const r=this._dotProduct(s,f),i=this._crossProduct(s,f),n=Math.sqrt((1+r)/2),o=this._sub(s,f);this._normalize(o),o[0]/=n,o[1]/=n,p.push(i<0?[-o[0],-o[1]]:o),f=s}p.push(this._rightPerp(f));for(let s=p.length-1;s>0;s--)t.push([e[s][0]+p[s][0]*l,e[s][1]+p[s][1]*l]);t.push([d[0]+p[0][0]*l,d[1]+p[0][1]*l]),t.push([d[0]+p[0][0]*h,d[1]+p[0][1]*h]),t.push(r),t.push([d[0]-p[0][0]*h,d[1]-p[0][1]*h]),t.push([d[0]-p[0][0]*l,d[1]-p[0][1]*l]);for(let s=1;s<p.length;s++)t.push([e[s][0]-p[s][0]*l,e[s][1]-p[s][1]*l])}_addDash(t,e,s){const r=this._norm(s)/7;this._normalize(s);let i=[];for(let n=0;n<=7;n++)i.push([e[0]+s[0]*n*r,e[1]+s[1]*n*r]),1&n&&(t.push(i),i=[])}_cp2(t,e,s){return t.length>=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,r){if(t.length>=3)return t[2];const i=this._mix(t[0],1-s,e,s),n=this._sub(e,t[0]);return this._normalize(n),this._rightPerpendicular(n),[i[0]+n[0]*r*this._defaultSize,i[1]+n[1]*r*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),r=this._sub(e,s);this._normalize(r);const i=this._rightPerp(r);return[e,s,[e[0]+(i[0]-r[0])*this._defaultSize,e[1]+(i[1]-r[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let r;if(t.length>=3)r=t[t.length-1];else{const t=this._sub(e,s);this._normalize(t);const i=this._rightPerp(t);r=[e[0]+(i[0]-t[0])*this._defaultSize,e[1]+(i[1]-t[1])*this._defaultSize]}return[s,r]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){const t=s.length>1&&(0,ye.Yl)(s)<this._defaultSize;if(!s||0===s.length||t)continue;const r=s.length;let i=s[0];switch(this._rule){case Ct.uQ.PerpendicularFromFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=[];n.push(r),n.push(this._mid(i,t)),e.push(n);break}case Ct.uQ.ReversedFirstSegment:{const t=this._cp2(s,0,-1);e.push([t,i]);break}case Ct.uQ.PerpendicularToSecondSegment:{if(s.length<3)return[];const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=[];n.push(this._mid(t,r)),n.push(i),e.push(n);break}case Ct.uQ.SecondSegmentWithTicks:{if(s.length<3)return[];const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);let o;o=this._crossProduct(n,this._sub(i,t))>0?this._rightPerp(n):this._leftPerp(n);const a=[];a.push([t[0]+(o[0]-n[0])/3,t[1]+(o[1]-n[1])/3]),a.push(t),a.push(r),a.push([r[0]+(o[0]+n[0])/3,r[1]+(o[1]+n[1])/3]),e.push(a);break}case Ct.uQ.DoublePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push(i),h.push([r[0]+o[0]*a,r[1]+o[1]*a]),e.push(h);const c=[];c.push([r[0]-o[0]*a,r[1]-o[1]*a]),c.push(t),e.push(c);break}case Ct.uQ.OppositeToFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a,r[1]+o[1]*a]),h.push([r[0]-o[0]*a,r[1]-o[1]*a]),e.push(h);break}case Ct.uQ.TriplePerpendicular:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t),o=this._sub(n,r);this._normalize(o);const a=this._crossProduct(o,this._sub(i,r));this._leftPerpendicular(o);const h=[];h.push([r[0]+o[0]*a*.8,r[1]+o[1]*a*.8]),h.push([n[0]+.8*(i[0]-n[0]),n[1]+.8*(i[1]-n[1])]),e.push(h),e.push([r,n]);const c=[];c.push([r[0]-o[0]*a*.8,r[1]-o[1]*a*.8]),c.push([n[0]+.8*(t[0]-n[0]),n[1]+.8*(t[1]-n[1])]),e.push(c);break}case Ct.uQ.HalfCircleFirstSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,4),n=this._mid(i,t);let o=this._sub(t,i);const a=Math.cos(Math.PI/18),h=Math.sin(Math.PI/18),c=Math.sqrt((1+a)/2),l=Math.sqrt((1-a)/2),u=[];let d;this._crossProduct(o,this._sub(r,i))>0?(u.push(i),o=this._sub(i,n),d=t):(u.push(t),o=this._sub(t,n),d=i),this._rotateDirect(o,c,l),o[0]/=c,o[1]/=c;for(let t=1;t<=18;t++)u.push(this._add(n,o)),this._rotateDirect(o,a,h);u.push(d),e.push(u);break}case Ct.uQ.HalfCircleSecondSegment:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,1,-1);let n=this._sub(i,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,t))/2;this._leftPerpendicular(n);const a=[t[0]+n[0]*o,t[1]+n[1]*o];n=this._sub(t,a);const h=Math.cos(Math.PI/18);let c=Math.sin(Math.PI/18);o>0&&(c=-c);const l=[t];for(let t=1;t<=18;t++)this._rotateDirect(n,h,c),l.push(this._add(a,n));e.push(l);break}case Ct.uQ.HalfCircleExtended:{const t=this._cp2(s,0,-2),n=this._cp3(s,t,1,-1);let o;if(r>=4)o=s[3];else{const e=this._sub(i,t);o=this._add(n,e)}const a=this._dist(t,n)/2/.75,h=this._sub(t,i);this._normalize(h,a);const c=this._sub(n,o);this._normalize(c,a);const l=[o,n];e.push(l);const u=[this._clone(n)];this._addBezier3(u,n,this._add(n,c),this._add(t,h),t,4),u.push(i),e.push(u);break}case Ct.uQ.OpenCircle:{const t=this._cp2(s,-2,0),r=this._sub(t,i),n=Math.cos(Math.PI/18),o=-Math.sin(Math.PI/18),a=[t];for(let t=1;t<=33;t++)this._rotateDirect(r,n,o),a.push(this._add(i,r));e.push(a);break}case Ct.uQ.CoverageEdgesWithTicks:{const t=this._cp2(s,0,-1);let n,o;if(r>=3)n=s[2];else{const e=this._sub(t,i),s=this._leftPerp(e);n=[i[0]+s[0]-.25*e[0],i[1]+s[1]-.25*e[1]]}if(r>=4)o=s[3];else{const e=this._mid(i,t),s=this._sub(i,t);this._normalize(s),this._leftPerpendicular(s);const r=this._crossProduct(s,this._sub(n,e));this._rightPerpendicular(s),o=[n[0]+s[0]*r*2,n[1]+s[1]*r*2]}const a=this._sub(t,i);let h,c;h=this._crossProduct(a,this._sub(n,i))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push(n),c.push(i),c.push([i[0]+(h[0]-a[0])/3,i[1]+(h[1]-a[1])/3]),e.push(c),h=this._crossProduct(a,this._sub(o,t))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push([t[0]+(h[0]+a[0])/3,t[1]+(h[1]+a[1])/3]),c.push(t),c.push(o),e.push(c);break}case Ct.uQ.GapExtentWithDoubleTicks:{const t=this._cp2(s,0,2),n=this._cp3(s,t,0,1);let o;if(r>=4)o=s[3];else{const e=this._sub(t,i);o=this._add(n,e)}this._addAngledTicks(e,i,t,this._mid(n,o)),this._addAngledTicks(e,n,o,this._mid(i,t));break}case Ct.uQ.GapExtentMidline:{const t=this._cp2(s,2,0),n=this._cp3(s,t,0,1);let o;if(r>=4)o=s[3];else{const e=this._sub(t,i);o=this._add(n,e)}const a=[];a.push(this._mid(i,n)),a.push(this._mid(t,o)),e.push(a);break}case Ct.uQ.Chevron:{const t=this._cp2(s,-1,-1);let n;if(r>=3)n=s[2];else{const e=this._sub(t,i);this._leftPerpendicular(e),n=this._add(i,e)}e.push([t,this._makeCtrlPt(i),n]);break}case Ct.uQ.PerpendicularWithArc:{const t=this._cp2(s,0,-2),n=this._cp3(s,t,.5,-1),o=this._sub(t,i),a=this._norm(o);o[0]/=a,o[1]/=a;const h=this._crossProduct(o,this._sub(n,i));let c=this._dotProduct(o,this._sub(n,i));c<.05*a?c=.05*a:c>.95*a&&(c=.95*a);const l=[i[0]+o[0]*c,i[1]+o[1]*c];let u=this._leftPerp(o),d=[];if(d.push([l[0]-u[0]*h,l[1]-u[1]*h]),d.push([l[0]+u[0]*h,l[1]+u[1]*h]),e.push(d),r>=4){const t=s[3];let r=this._dotProduct(o,this._sub(t,i));r<.1*a?r=.1*a:r>.9*a&&(r=.9*a);const n=[i[0]+o[0]*r,i[1]+o[1]*r],h=this._crossProduct(o,this._sub(t,i)),c=[];c.push([n[0]-u[0]*h,n[1]-u[1]*h]),c.push([n[0]+u[0]*h,n[1]+u[1]*h]),e.push(c)}const _=[t[0]+u[0]*h,t[1]+u[1]*h];u=this._sub(t,_);const p=Math.cos(Math.PI/18);let f=Math.sin(Math.PI/18);h<0&&(f=-f),d=[i,t];for(let t=1;t<=9;t++)this._rotateDirect(u,p,f),d.push(this._add(_,u));e.push(d);break}case Ct.uQ.ClosedHalfCircle:{const t=this._cp2(s,2,0),r=this._mid(i,t),n=this._sub(t,r),o=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18),h=[i,t];for(let t=1;t<=18;t++)this._rotateDirect(n,o,a),h.push(this._add(r,n));e.push(h);break}case Ct.uQ.TripleParallelExtended:{const t=this._cp2(s,0,-2),r=this._cp3(s,t,1,-2),n=this._mid(i,t),o=this._sub(r,t);this._normalize(o);const a=Math.abs(this._crossProduct(o,this._sub(n,t)))/2,h=this._dist(t,r),c=[t,i];c.push([i[0]+o[0]*h*.5,i[1]+o[1]*h*.5]),e.push(c);const l=[];l.push([n[0]-o[0]*a,n[1]-o[1]*a]),l.push([n[0]+o[0]*h*.375,n[1]+o[1]*h*.375]),oe(l[l.length-1],1),l.push([n[0]+o[0]*h*.75,n[1]+o[1]*h*.75]),e.push(l);const u=[t,r];e.push(u);break}case Ct.uQ.ParallelWithTicks:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(r,t);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n),this._addAngledTicks(e,i,t,r),this._addAngledTicks(e,this._mix(i,1,n,o),this._mix(t,1,n,o),this._mid(i,t));break}case Ct.uQ.Parallel:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._leftPerp(n),a=this._crossProduct(n,this._sub(r,i));let h=[i,t];e.push(h),h=[],h.push([i[0]+o[0]*a,i[1]+o[1]*a]),h.push([t[0]+o[0]*a,t[1]+o[1]*a]),e.push(h);break}case Ct.uQ.PerpendicularToFirstSegment:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._mid(i,t),o=this._sub(t,i);this._normalize(o);const a=this._crossProduct(o,this._sub(r,i));this._leftPerpendicular(o);const h=[];h.push([n[0]-o[0]*a*.25,n[1]-o[1]*a*.25]),h.push([n[0]+o[0]*a*1.25,n[1]+o[1]*a*1.25]),e.push(h);break}case Ct.uQ.ParallelOffset:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);const h=[];h.push([i[0]+n[0]*o,i[1]+n[1]*o]),h.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(h);break}case Ct.uQ.OffsetOpposite:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]-n[0]*o,i[1]-n[1]*o]),a.push([t[0]-n[0]*o,t[1]-n[1]*o]),e.push(a);break}case Ct.uQ.OffsetSame:{const t=this._cp2(s,3,0),r=this._cp3(s,t,.5,-1),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n);const a=[];a.push([i[0]+n[0]*o,i[1]+n[1]*o]),a.push([t[0]+n[0]*o,t[1]+n[1]*o]),e.push(a);break}case Ct.uQ.CircleWithArc:{let t=this._cp2(s,3,0);const n=this._cp3(s,t,.5,-1);let o,a;if(r>=4)o=s[3],a=this._crossProduct(this._sub(o,t),this._sub(n,t))>0;else{o=t,a=this._crossProduct(this._sub(o,i),this._sub(n,i))>0;const e=24*this._geomUnitsPerPoint,s=this._sub(o,i);this._normalize(s,e);const r=Math.sqrt(2)/2;this._rotateDirect(s,r,a?r:-r),t=this._add(i,s)}const h=this._sub(t,i),c=Math.cos(Math.PI/18),l=Math.sin(Math.PI/18),u=[t];for(let t=1;t<=36;t++)this._rotateDirect(h,c,l),u.push(this._add(i,h));this._add90DegArc(u,t,o,n,a),oe(u[u.length-8],1),e.push(u);break}case Ct.uQ.DoubleJog:{let t,n=this._cp2(s,-3,1),o=this._cp3(s,n,-1,-.5);if(r>=4)t=s[3];else{const e=i;i=n,t=o;const s=this._dist(i,e),r=this._dist(t,e);let a=30*this._geomUnitsPerPoint;.5*s<a&&(a=.5*s),.5*r<a&&(a=.5*r),n=this._mix(i,a/s,e,(s-a)/s),o=this._mix(t,a/r,e,(r-a)/r)}const a=this._mid(i,n),h=this._mid(t,o),c=this._dist(i,n),l=this._dist(o,t);let u=Math.min(c,l)/8;u=Math.min(u,24*this._geomUnitsPerPoint);const d=Math.cos(Math.PI/4);let _=this._sub(i,n);this._normalize(_,u),this._crossProduct(_,this._sub(t,n))>0?this._rotateDirect(_,d,-d):this._rotateDirect(_,d,d);let p=[];p.push(n),p.push(this._add(a,_)),p.push(this._sub(a,_)),p.push(i),e.push(p),_=this._sub(t,o),this._normalize(_,u),this._crossProduct(_,this._sub(i,o))<0?this._rotateDirect(_,d,d):this._rotateDirect(_,d,-d),p=[],p.push(o),p.push(this._add(h,_)),p.push(this._sub(h,_)),p.push(t),e.push(p);break}case Ct.uQ.PerpendicularOffset:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o);e.push([a,i]);break}case Ct.uQ.LineExcludingLastSegment:{const t=this._arrowPath(s),r=[];let i=t.length-2;for(;i--;)r.push(t[i]);e.push(r);break}case Ct.uQ.MultivertexArrow:{const t=this._arrowPath(s),r=[];this._addArrow(r,t,!1),e.push(r);break}case Ct.uQ.CrossedArrow:{const t=this._arrowPath(s),r=[];this._addArrow(r,t,!0),e.push(r);break}case Ct.uQ.ChevronArrow:{const[t,r]=this._arrowLastSeg(s),n=10*this._geomUnitsPerPoint,o=this._sub(i,t),a=this._norm(o);this._normalize(o);const h=this._crossProduct(o,this._sub(r,t));let c=this._dotProduct(o,this._sub(r,t));c<.05*a?c=.05*a:c>.95*a-n&&(c=.95*a-n);const l=[t[0]+o[0]*c,t[1]+o[1]*c],u=this._leftPerp(o),d=[];d.push([l[0]+u[0]*h+o[0]*n,l[1]+u[1]*h+o[1]*n]),d.push(i),d.push([l[0]-u[0]*h+o[0]*n,l[1]-u[1]*h+o[1]*n]),e.push(d);break}case Ct.uQ.ChevronArrowOffset:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t),o=this._norm(n);this._normalize(n);const a=this._crossProduct(n,this._sub(r,t));let h=this._dotProduct(n,this._sub(r,t));h<.05*o?h=.05*o:h>.95*o&&(h=.95*o);const c=[t[0]+n[0]*h,t[1]+n[1]*h];this._leftPerpendicular(n);const l=[];l.push([c[0]+n[0]*a*.5,c[1]+n[1]*a*.5]),l.push(this._mid(c,i)),l.push([c[0]-n[0]*a*.5,c[1]-n[1]*a*.5]),e.push(l);break}case Ct.uQ.PartialFirstSegment:{const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t),o=this._norm(n);this._normalize(n);let a=this._dotProduct(n,this._sub(r,t));a<.05*o?a=.05*o:a>.95*o&&(a=.95*o);const h=[t[0]+n[0]*a,t[1]+n[1]*a];e.push([t,h]);break}case Ct.uQ.Arch:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=this._sub(i,t),o=this._mix(r,1,n,.55),a=this._mix(r,1,n,-.55),h=[i];this._addBezier2(h,i,o,r,4),this._addBezier2(h,r,a,t,4),e.push(h);break}case Ct.uQ.CurvedParallelTicks:{const t=this._cp2(s,-4,1),r=this._cp3(s,t,.882353,-1.94),n=this._sub(r,t);this._crossProduct(n,this._sub(i,t))>0?this._rightPerpendicular(n):this._leftPerpendicular(n);const o=[n[0]/8,n[1]/8],a=this._sub(this._mid(t,r),o),h=this._sub(this._mix(t,.75,r,.25),o),c=this._sub(this._mix(t,.25,r,.75),o),l=[t];this._addBezier2(l,t,h,a,3),this._addBezier2(l,a,c,r,3),e.push(l);for(let t=0;t<8;t++){const s=l[2*t+1],r=[this._clone(s)];r.push(this._add(s,[n[0]/4,n[1]/4])),e.push(r)}break}case Ct.uQ.Arc90Degrees:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,1),n=[t];this._add90DegArc(n,t,i,r),e.push(n);break}case Ct.uQ.TipWithPerpendicularAndTicks:{const[t,r]=this._arrowLastSeg(s),n=10*this._geomUnitsPerPoint,o=this._sub(i,t),a=this._norm(o);this._normalize(o);let h=this._crossProduct(o,this._sub(r,t)),c=this._dotProduct(o,this._sub(r,t));c<.05*a?c=.05*a:c>.95*a-n&&(c=.95*a-n);const l=this._leftPerp(o),u=[i[0]-o[0]*n,i[1]-o[1]*n],d=.5*Math.max(a-c-n,n);h=Math.abs(h);const _=[];_.push([u[0]+l[0]*(h+d)-o[0]*d,u[1]+l[1]*(h+d)-o[1]*d]),_.push([u[0]+l[0]*h,u[1]+l[1]*h]),_.push([u[0]-l[0]*h,u[1]-l[1]*h]),_.push([u[0]-l[0]*(h+d)-o[0]*d,u[1]-l[1]*(h+d)-o[1]*d]),e.push(_),e.push([u,i]);break}case Ct.uQ.ConcentricCircles:{const t=this._cp2(s,1,0),n=this._cp3(s,t,2,0),o=Math.cos(Math.PI/18),a=Math.sin(Math.PI/18);let h=this._dist(t,i),c=[h,0],l=[];for(let t=0;t<=36;t++)l.push(this._add(i,c)),this._rotateDirect(c,o,a);if(e.push(l),r>=4){l=[];const t=s[3];h=this._dist(t,i),c=[h,0];for(let t=0;t<=36;t++)l.push(this._add(i,c)),0===t&&(l.push(this._add(i,c)),oe(l[1],1)),this._rotateDirect(c,o,a);e.push(l)}l=[],h=this._dist(n,i),c=[h,0];for(let t=0;t<=36;t++)l.push(this._add(i,c)),this._rotateDirect(c,o,a);e.push(l);break}case Ct.uQ.DoubleJogArrow:{i=this._arrowPath(s)[0];const[t,r]=this._arrowLastSeg(s),n=this._sub(i,t),o=this._norm(n);this._normalize(n);const a=Math.abs(this._crossProduct(n,this._sub(r,i)));let h=Math.abs(this._dotProduct(n,this._sub(r,i)));h<.05*o?h=.05*o:h>.95*o&&(h=.95*o);const c=Math.max(a,h),l=this._leftPerp(n);let u=[];const d=[i[0]-n[0]*h*.5+l[0]*a*.5,i[1]-n[1]*h*.5+l[1]*a*.5];u.push([d[0],d[1]]),d[0]+=n[0]*c*.5+l[0]*c*.4,d[1]+=n[1]*c*.5+l[1]*c*.4,u.push([d[0],d[1]]),d[0]-=l[0]*c*.25,d[1]-=l[1]*c*.25,u.push([d[0],d[1]]),d[0]+=n[0]*c*.5+l[0]*c*.4,d[1]+=n[1]*c*.5+l[1]*c*.4,u.push([d[0],d[1]]),e.push(u),u=[],d[0]=i[0]-n[0]*h*.5-l[0]*a*.5,d[1]=i[1]-n[1]*h*.5-l[1]*a*.5,u.push([d[0],d[1]]),d[0]+=n[0]*c*.5-l[0]*c*.4,d[1]+=n[1]*c*.5-l[1]*c*.4,u.push([d[0],d[1]]),d[0]+=l[0]*c*.25,d[1]+=l[1]*c*.25,u.push([d[0],d[1]]),d[0]+=n[0]*c*.5-l[0]*c*.4,d[1]+=n[1]*c*.5-l[1]*c*.4,u.push([d[0],d[1]]),e.push(u);break}case Ct.uQ.LinkedChevrons:{const t=this._cp2(s,-5,0),r=this._cp3(s,t,-.2,1),n=this._sub(i,t);this._normalize(n);const o=this._leftPerp(n),a=Math.abs(this._crossProduct(n,this._sub(r,t)));e.push([t,i]);const h=[];h.push([i[0]-n[0]*a+o[0]*a,i[1]-n[1]*a+o[1]*a]),h.push(i),h.push([i[0]-n[0]*a-o[0]*a,i[1]-n[1]*a-o[1]*a]),e.push(h),this._addDash(e,t,[-n[0]*a+o[0]*a,-n[1]*a+o[1]*a]),this._addDash(e,t,[-n[0]*a-o[0]*a,-n[1]*a-o[1]*a]);break}case Ct.uQ.SegmentThenHalfCircle:{const t=this._cp2(s,2,0),n=this._cp3(s,t,1.5,0);let o;o=r>=4?s[3]:this._cp3(s,t,1.25,-.5);const a=this._sub(t,i);this._normalize(a);const h=.5*this._dist(t,n),c=this._crossProduct(a,this._sub(o,i))>0,l=Math.cos(Math.PI/18);let u=Math.sin(Math.PI/18);c&&(u=-u);const d=[i,t];a[0]*=h,a[1]*=h;const _=this._add(t,a);a[0]=-a[0],a[1]=-a[1];for(let t=1;t<=18;t++)this._rotateDirect(a,l,u),d.push(this._add(_,a));e.push(d);break}case Ct.uQ.LineWithStraightTicks:{const t=this._cp2(s,-2,1),r=this._cp3(s,t,-1,-.5),n=this._sub(r,t);this._normalize(n);const o=this._dotProduct(n,this._sub(t,i)),a=this._dotProduct(n,this._sub(r,i));let h=[i];h.push([i[0]+n[0]*o,i[1]+n[1]*o]),h.push(t),e.push(h),h=[i],h.push([i[0]+n[0]*a,i[1]+n[1]*a]),h.push(r),e.push(h);break}case Ct.uQ.DoubleCurve:{const t=this._cp2(s,-5,-1),r=this._cp3(s,t,2,0),n=Math.atan2(1,5),o=Math.cos(n),a=Math.sin(n),h=this._sub(t,i),c=this._dist(i,t);this._normalize(h),this._rotateDirect(h,o,-a);const l=[i];l.push([i[0]+h[0]*c*.5,i[1]+h[1]*c*.5]),oe(l[1],1),l.push([i[0]+h[0]*c*.8,i[1]+h[1]*c*.8]),this._addBezier2(l,l[2],[i[0]+h[0]*c,i[1]+h[1]*c],t,3);const u=this._sub(r,t),d=this._dist(t,r);this._normalize(u),this._rotateDirect(u,o,-a),this._addBezier2(l,t,[r[0]-u[0]*d,r[1]-u[1]*d],[r[0]-u[0]*d*.8,r[1]-u[1]*d*.8],3),l.push(r),e.push(l);break}case Ct.uQ.ParallelWithTicksByWidth:{const t=this._cp2(s,0,-1),r=this._cp3(s,t,.5,3),n=this._sub(t,i);this._normalize(n);const o=this._crossProduct(n,this._sub(r,i));this._leftPerpendicular(n),o>0?(this._addAngledTicks(e,i,[i[0]+n[0]*o,i[1]+n[1]*o],t),this._addAngledTicks(e,t,[t[0]+n[0]*o,t[1]+n[1]*o],i)):(this._addAngledTicks(e,[i[0]+n[0]*o,i[1]+n[1]*o],i,t),this._addAngledTicks(e,[t[0]+n[0]*o,t[1]+n[1]*o],i,t));break}case Ct.uQ.EnclosingRoundedRectangle:{const t=this._cp2(s,3,-2),e=[Math.min(i[0],t[0]),Math.max(i[1],t[1])],r=[Math.max(i[0],t[0]),Math.min(i[1],t[1])],n=r[0]-e[0],o=e[1]-r[1],a=Math.min(n,o)/10,h=[];h.push([e[0]+a+.75*(n-2*a),e[1]]),h.push([r[0]-a,e[1]]),this._add90DegArc(h,[r[0]-a,e[1]],[r[0],e[1]-a],[r[0],e[1]]),h.push([r[0],r[1]+a]),this._add90DegArc(h,[r[0],r[1]+a],[r[0]-a,r[1]],r),h.push([e[0]+a,r[1]]),this._add90DegArc(h,[e[0]+a,r[1]],[e[0],r[1]+a],[e[0],r[1]]),h.push([e[0],e[1]-a]),this._add90DegArc(h,[e[0],e[1]-a],[e[0]+a,e[1]],e),h.push([e[0]+a+.75*(n-2*a),e[1]]);break}case Ct.uQ.FullGeometry:default:e.push(s)}}return e}}class xe{static local(){return null===xe.instance&&(xe.instance=new xe),xe.instance}execute(t,e,s,r,i){return new ve(t,e,s)}}xe.instance=null;class ve extends he{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new le,this._beginCut=(void 0!==e.beginCut?e.beginCut:1)*s,this._endCut=(void 0!==e.endCut?e.endCut:1)*s,this._middleCut=(void 0!==e.middleCut?e.middleCut:0)*s,this._invert=void 0!==e.invert&&e.invert,this._beginCut<0&&(this._beginCut=0),this._endCut<0&&(this._endCut=0),this._middleCut<0&&(this._middleCut=0)}processPath(t){const{_beginCut:e,_endCut:s,_middleCut:r}=this,i=t.pathLength(),n=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==e||0!==s||0!==r)if(e+s+r>=i)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else this._curveHelper.appendSubCurve(n,t,0,e),this._curveHelper.appendSubCurve(n,t,.5*(i-r),.5*(i+r)),this._curveHelper.appendSubCurve(n,t,i-s,s)}else if(0===e&&0===s&&0===r)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else e+s+r<i&&(0===r?this._curveHelper.appendSubCurve(n,t,e,i-s):(this._curveHelper.appendSubCurve(n,t,e,.5*(i-r)),this._curveHelper.appendSubCurve(n,t,.5*(i+r),i-s)));return 0===n.totalSize?null:n}}class Se{constructor(){this._values=[],this.extPtGap=0,this.ctrlPtGap=0,this._length=0,this._currentValue=0}isEmpty(){return 0===this._values.length}size(){return this._values.length}init(t,e,s=!0){if(this._setEmpty(),!t||0===t.length)return!1;for(let e=0;e<t.length;e++){let r=Math.abs(t[e]);s&&r<1e-7&&(r=1e-7),this._values.push(r),this._length+=r}return e&&1&t.length&&(this._length*=2),0!==this._length&&(this.ctrlPtGap=this.extPtGap=0,this._currentValue=-1,!0)}scale(t){const e=this._values?this._values.length:0;for(let s=0;s<e;++s)this._values[s]*=t;this._length*=t,this.extPtGap*=t,this.ctrlPtGap*=t}addValue(t){this._length+=t,this._values.push(t)}firstValue(){return this._values[0]}lastValue(){return this._values[this._values.length-1]}nextValue(){return this._currentValue++,this._currentValue===this._values.length&&(this._currentValue=0),this._values[this._currentValue]}reset(){this._currentValue=-1}length(){return this._length}_setEmpty(){this.extPtGap=this.ctrlPtGap=this._length=0,this._currentValue=-1,this._values.length=0}}class Ie{constructor(){this.pt=null,this.ca=0,this.sa=0}}(me=ge||(ge={}))[me.FAIL=0]="FAIL",me[me.END=1]="END",me[me.CONTINUE=2]="CONTINUE";class Me{constructor(){this.reset()}reset(){this.segment=null,this.segmentLength=0,this.abscissa=0,this.isPathEnd=!1,this.isPartEnd=!1}isValid(){return null!==this.segment}copyTo(t){t.segment=this.segment,t.segmentLength=this.segmentLength,t.abscissa=this.abscissa,t.isPathEnd=this.isPathEnd,t.isPartEnd=this.isPartEnd}}class Pe extends le{constructor(t=0,e=!1){super(t,e),this._tolerance=ce,this._currentPosition=new Me}updateTolerance(t){this._tolerance=ce*t}init(t,e,s=!0){return s?(this._patternLength=e.length(),this._partExtPtGap=e.extPtGap,this._partCtrlPtGap=e.ctrlPtGap):(this._patternLength=0,this._partExtPtGap=0,this._partCtrlPtGap=0),this._currentPosition.reset(),this._partSegCount=0,this._pathCursor=t,this._seg=-1,this._setPosAtNextPart()}curPositionIsValid(){return this._currentPosition.isValid()}nextPosition(t,e=ge.FAIL){const s=new Me;return!!this._nextPosition(t,s,null,e)&&(s.copyTo(this._currentPosition),!0)}curPointAndAngle(t){t.pt=this._getPoint(this._currentPosition);const[e,s]=this._getAngleCS(this._currentPosition);t.ca=e,t.sa=s}nextPointAndAngle(t,e,s=ge.FAIL){const r=new Me;if(!this._nextPosition(t,r,null,s))return!1;r.copyTo(this._currentPosition),e.pt=this._getPoint(r);const[i,n]=this._getAngleCS(r);return e.ca=i,e.sa=n,!0}nextCurve(t){if(0===t)return null;const e=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");e.startPath(),e.nextPath();const s=new Me;return this._nextPosition(t,s,e,ge.END)?(s.copyTo(this._currentPosition),e):null}isPathEnd(){return this._currentPosition.isPathEnd}getPathEnd(){return this._currentPosition.segment[1]}getPt(t){return this._pathCursor.seekInPath(t),[this._pathCursor.x,this._pathCursor.y]}getSeg(t){return[this.getPt(t),this.getPt(t+1)]}_nextPosition(t,e,s,r){if(this._currentPosition.isPathEnd)return!1;let i=this._currentPosition.abscissa;for(this._currentPosition.segmentLength>0&&(i/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(0===s.pathSize)if(0===i){const t=e.segment[0];s.pushXY(t[0],t[1])}else s.pushPoint(this.getSegCoord2D(e.segment,i));const t=e.segment[1];s.pushXY(t[0],t[1])}if(i=0,t-=(e.segmentLength-e.abscissa)/this._partLengthRatio,this._partSegCount)e.segment=this._nextSegment(),e.segmentLength=this.getSegLength(e.segment),e.abscissa=0,this._partSegCount--;else{if(!this._setPosAtNextPart())return r!==ge.FAIL&&(e.segmentLength=this.getSegLength(e.segment),e.isPartEnd=!0,r===ge.END?(e.abscissa=e.segmentLength,e.isPathEnd=!0):e.abscissa=e.segmentLength+t,!0);this._currentPosition.copyTo(e)}}if(e.abscissa+=t*this._partLengthRatio,s){0===s.pathSize&&(0===i?s.pushPoint(e.segment[0]):s.pushPoint(this.getSegCoord2D(e.segment,i)));const t=e.abscissa/e.segmentLength;1===t?s.pushPoint(e.segment[1]):s.pushPoint(this.getSegCoord2D(e.segment,t))}return this._partSegCount||Math.abs(e.abscissa-e.segmentLength)<this._tolerance&&(e.isPathEnd=this._partIsLast,e.isPartEnd=!0),!0}_getPoint(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegCoord2D(this._currentPosition.segment,e)}_getAngleCS(t){const e=t.segmentLength<=0?0:t.abscissa/t.segmentLength;return this.getSegAngleCS(this._currentPosition.segment,e)}_setPosAtNextPart(){for(;this._partSegCount;)this._hasNextSegment()&&this._nextSegment(),this._partSegCount--;if(!this._hasNextSegment())return!1;for(this._partLength=0,this._partIsLast=!0,this._partSegCount=0;this._hasNextSegment();)if(this._partLength+=this.getSegLength(this._nextSegment()),this._partSegCount++,this._pathCursor.getControlPointAt(this._getEndPointIndex())){this._partIsLast=!this._hasNextSegment();break}let t=this._partSegCount;for(;t;)this._previousSegment(),--t;this._currentPosition.segment=this._nextSegment(),this._currentPosition.segmentLength=this.getSegLength(this._currentPosition.segment),this._currentPosition.abscissa=0,this._currentPosition.isPathEnd=this._currentPosition.isPartEnd=!1,--this._partSegCount;const e=this._getStartPointIndex();this._ctrlPtBegin=this._pathCursor.getControlPointAt(e);let s=e+this._partSegCount+1;if(s>=this._pathCursor.pathSize&&(s=0),this._ctrlPtEnd=this._pathCursor.getControlPointAt(s),this._patternLength>0){const t=this._ctrlPtBegin?this._partCtrlPtGap:this._partExtPtGap,e=this._ctrlPtEnd?this._partCtrlPtGap:this._partExtPtGap;let s=Math.round((this._partLength-(t+e))/this._patternLength);s<=0&&(s=t+e>0?0:1),this._partLengthRatio=this._partLength/(t+e+s*this._patternLength),this._partLengthRatio<.01&&(this._partLengthRatio=1)}else this._partLengthRatio=1;return!0}_hasNextSegment(){return this._seg<this._pathCursor.pathSize-2}_previousSegment(){return this.getSeg(--this._seg)}_nextSegment(){return this.getSeg(++this._seg)}_getStartPointIndex(){return this._seg}_getEndPointIndex(){return this._seg+1}}var Te=s(93397);class Ae{static local(){return null===Ae.instance&&(Ae.instance=new Ae),Ae.instance}execute(t,e,s,r,i){return new Ce(t,e,s)}}Ae.instance=null;class Ce extends he{constructor(t,e,s){super(t,!0,!0),this._firstCurve=null,this._walker=new Pe,this._walker.updateTolerance(s),this._endings=e.lineDashEnding,this._customDashPos=-(e.offsetAlongLine??0)*s,this._offsetAtEnd=(e.customEndingOffset??0)*s;let r=(0,Te.FH)(e).dashTemplate;null==r&&(r=[]),r.length%2&&(r=[...r,...r]),this._pattern=new Se,this._pattern.init(r,!0),this._pattern.scale(s)}processPath(t){if(0===this._pattern.length()){this.iteratePath=!1;const e=(0,qt.A)(t);return Yt.fromJSONCIM({paths:[e]})}if(!this.iteratePath){let e=!0;switch(this._endings){case Ct.yS.HalfPattern:case Ct.yS.HalfGap:default:this._pattern.extPtGap=0;break;case Ct.yS.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case Ct.yS.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case Ct.yS.NoConstraint:this.isClosed||(e=!1);break;case Ct.yS.Custom:this.isClosed||(this._pattern.extPtGap=.5*this._offsetAtEnd)}const s=t.pathLength();if(this._pattern.isEmpty()||s<.1*this._pattern.length()){const e=(0,qt.A)(t);return Yt.fromJSONCIM({paths:[e]})}if(!this._walker.init(t,this._pattern,e)){const e=(0,qt.A)(t);return Yt.fromJSONCIM({paths:[e]})}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case Ct.yS.HalfPattern:default:t=.5*this._pattern.firstValue();break;case Ct.yS.HalfGap:t=.5*-this._pattern.lastValue();break;case Ct.yS.FullGap:t=-this._pattern.lastValue();break;case Ct.yS.FullPattern:t=0;break;case Ct.yS.NoConstraint:case Ct.yS.Custom:t=-this._customDashPos}let s=t/this._pattern.length();s-=Math.floor(s),t=s*this._pattern.length(),this._pattern.reset(),e=this._pattern.nextValue();let r=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),r=!r;e-=t,r?(this._walker.nextPosition(e),e=this._pattern.nextValue()):this.isClosed&&(this._firstCurve=this._walker.nextCurve(e),e=this._pattern.nextValue(),this._walker.nextPosition(e),e=this._pattern.nextValue())}let s=this._walker.nextCurve(e);if(s)if(this._walker.isPathEnd()){if(this.iteratePath=!1,this._firstCurve){for(this._firstCurve.nextPath();this._firstCurve.nextPoint();)s.pushXY(this._firstCurve.x,this._firstCurve.y);this._firstCurve=null}}else e=this._pattern.nextValue(),!this._walker.nextPosition(e)||this._walker.isPathEnd()?(this.iteratePath=!1,this._firstCurve&&(s.pushCursor(this._firstCurve),this._firstCurve=null)):this.iteratePath=!0;else this.iteratePath=!1,s=this._firstCurve,this._firstCurve=null;return s?.reset(),s}}class ke{static local(){return null===ke.instance&&(ke.instance=new ke),ke.instance}execute(t,e,s,r,i,n,o){return new Fe(t,e,s,r,i,n,o)}}ke.instance=null;class Fe{constructor(t,e,s,r,i,n,o){switch(this._preventClipping=o,this._inputGeometries=t,this._tileKey=r,this._geometryEngine=i,this._maxInflateSize=n*s,this._width=(void 0!==e.width?e.width:2)*s,e.method){case Ct.M1.Mitered:case Ct.M1.Bevelled:case Ct.M1.Rounded:case Ct.M1.TrueBuffer:case Ct.M1.Square:}this._option=e.option}next(){let t;for(;t=this._inputGeometries.next();){if("esriGeometryEnvelope"===t.geometryType&&this._width>0){const e=t.asJSON();return Math.min(e.xmax-e.xmin,e.ymax-e.ymin)-2*this._width<0?t:Yt.fromJSONCIM({paths:[[[e.xmin+this._width,e.ymin+this._width],[e.xmax-this._width,e.ymin+this._width],[e.xmax-this._width,e.ymax-this._width],[e.xmin+this._width,e.ymax-this._width],[e.xmin+this._width,e.ymin+this._width]],[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}if("esriGeometryPolygon"===t.geometryType){if(0===this._width)return t.clone();const e=this._geometryEngine;if(null==e)return null;const s=!this._preventClipping&&this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const r=e.buffer(q.A.WebMercator,s.asJSON(),-this._width,1);if(r)for(const t of r.rings)if(t){s.startPath();for(const e of t.reverse())s.pushXY(e[0],s.yFactor*e[1])}return s}}return null}}class Ee{static local(){return null===Ee.instance&&(Ee.instance=new Ee),Ee.instance}execute(t,e,s,r,i){return new ze(t,e,s)}}Ee.instance=null;class ze extends he{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new le,this._length=(void 0!==e.length?e.length:20)*s,this._angle=void 0!==e.angle?e.angle:225,this._position=void 0!==e.position?e.position:50,this._length<0&&(this._length=-this._length),this._position<20&&(this._position=20),this._position>80&&(this._position=80),this._mirror=!1}processPath(t){const e=Yt.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._curveHelper.isEmpty(t))return null;t.seekInPath(0);const s=t.x,r=t.y;t.seekInPath(t.pathSize-1);const i=t.x,n=t.y,o=[i-s,n-r];this._curveHelper.normalize(o);const a=s+(i-s)*this._position/100,h=r+(n-r)*this._position/100,c=Math.cos((90-this._angle)/180*Math.PI);let l=Math.sin((90-this._angle)/180*Math.PI);this._mirror&&(l=-l),this._mirror=!this._mirror;const u=[a-this._length/2*c,h-this._length/2*l],d=[a+this._length/2*c,h+this._length/2*l];return e.pushPath([[s,r],u,d,[i,n]]),e}}class Oe{static local(){return null===Oe.instance&&(Oe.instance=new Oe),Oe.instance}execute(t,e,s,r,i){return new Re(t,e,s)}}Oe.instance=null;class Re{constructor(t,e,s){this._inputGeometries=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0}next(){let t=this._inputGeometries.next();for(;t;){if(t.totalSize>0)return this._move(t.clone(),this._offsetX,this._offsetY);t=this._inputGeometries.next()}return null}_move(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=t.x+e,t.y=t.y+s;return t.reset(),t}}class De{static local(){return null===De.instance&&(De.instance=new De),De.instance}execute(t,e,s,r,i,n,o){return new Le(t,e,s,r,i,n,o)}}De.instance=null;class Le{constructor(t,e,s,r,i,n,o){this._preventClipping=o,this._inputGeometries=t,this._tileKey=r,this._geometryEngine=i,this._curveHelper=new le,this._offset=(e.offset??1)*s,this._method=e.method,this._maxInflateSize=Math.max(Math.abs(n*s),10),this._option=e.option,this._offsetFlattenError=ce*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._offset)return t.clone();if("esriGeometryEnvelope"===t.geometryType){if(this._method===Ct.xw.Rounded&&this._offset>0){const e=(0,qt.A)(t),s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=Yt.createEmptyOptimizedCIM(t.geometryType);return e.pushPath(s),e}return null}const e=t.asJSON();if((0,Wt.ZC)(e)&&Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._offset>0)return Yt.fromJSONCIM({xmin:e.xmin-this._offset,xmax:e.xmax+this._offset,ymin:e.ymin-this._offset,ymax:e.ymax+this._offset})}const e=this._geometryEngine;if(null==e)continue;const s=!this._preventClipping&&this._tileKey?se(t,this._maxInflateSize):t.clone();if(!s)continue;const r=e.offset(q.A.WebMercator,s.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return r?Yt.fromJSONCIM(r):null}return null}}class Ne{static local(){return null===Ne.instance&&(Ne.instance=new Ne),Ne.instance}execute(t,e,s,r,i){return new Be(t,e,s)}}Ne.instance=null;class Be{constructor(t,e,s){this._inputGeometries=t,this._reverse=void 0===e.reverse||e.reverse}next(){let t=this._inputGeometries.next();for(;t;){if(!this._reverse)return t;if("esriGeometryPolyline"===t.geometryType)return Ge(t.clone());t=this._inputGeometries.next()}return null}}function Ge(t){for(;t.nextPath();)for(let e=0;e<t.pathSize/2;e++){t.seekInPath(e);const s=t.x,r=t.y;t.seekInPath(t.pathSize-e-1);const i=t.x,n=t.y;t.x=s,t.y=r,t.seekInPath(e),t.x=i,t.y=n}return t.reset(),t}var Ue=s(537);class Ve{static local(){return null===Ve.instance&&(Ve.instance=new Ve),Ve.instance}execute(t,e,s,r,i){return new qe(t,e,s)}}Ve.instance=null;class qe{constructor(t,e,s){this._inputGeometries=t,this._rotateAngle=void 0!==e.angle?e.angle*Math.PI/180:0}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._rotateAngle||"esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ue.z8)(t),s=(e[2]+e[0])/2,r=(e[3]+e[1])/2;return t.reset(),this._rotate(t.clone(),s,r)}t=this._inputGeometries.next()}return null}_rotate(t,e,s){const r=Math.cos(this._rotateAngle),i=Math.sin(this._rotateAngle);for(;t.nextPath();)for(;t.nextPoint();){const n=t.x-e,o=t.y-s;t.x=e+n*r-o*i,t.y=s+n*i+o*r}return t.reset(),t}}class We{static local(){return null===We.instance&&(We.instance=new We),We.instance}execute(t,e,s,r,i){return new je(t,e,s)}}We.instance=null;class je{constructor(t,e,s){this._inputGeometries=t,this._xFactor=void 0!==e.xScaleFactor?e.xScaleFactor:1.15,this._yFactor=void 0!==e.yScaleFactor?e.yScaleFactor:1.15}next(){const t=this._inputGeometries.next();if(t){if(1===this._xFactor&&1===this._yFactor)return t;if("esriGeometryPoint"===t.geometryType)return t;if(t.totalSize>0){const e=(0,Ue.z8)(t),s=(e[2]+e[0])/2,r=(e[3]+e[1])/2;return t.reset(),this._scaleCursor(t.clone(),s,r)}}return null}_scaleCursor(t,e,s){for(;t.nextPath();)for(;t.nextPoint();)t.x=e+(t.x-e)*this._xFactor,t.y=s+(t.y-s)*this._yFactor;return t.reset(),t}}class Ye{static local(){return null===Ye.instance&&(Ye.instance=new Ye),Ye.instance}execute(t,e,s,r,i){return new Xe(t,e,s)}}Ye.instance=null;class Xe{constructor(t,e,s){this._inputGeometries=t,this._height=(void 0!==e.amplitude?e.amplitude:2)*s,this._period=(void 0!==e.period?e.period:3)*s,this._style=e.waveform,this._height<=0&&(this._height=Math.abs(this._height)),this._period<=0&&(this._period=Math.abs(this._period)),this._pattern=new Se,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new Pe,this._walker.updateTolerance(s)}next(){let t=this._inputGeometries.next();for(;t;){if(0===this._height||0===this._period)return t;const e=this._processGeom(t);if(e)return e;t=this._inputGeometries.next()}return null}_processGeom(t){const e=Yt.createEmptyOptimizedCIM(t.geometryType);for(;t.nextPath();){e.startPath();const s=t.pathLength();if(this._walker.init(t,this._pattern))switch(this._style){case Ct.WE.Sinus:default:this._constructCurve(e,s,!1);break;case Ct.WE.Square:this._constructSquare(e,s);break;case Ct.WE.Triangle:this._constructTriangle(e,s);break;case Ct.WE.Random:this._constructCurve(e,s,!0)}else for(;t.nextPoint();)e.pushXY(t.x,t.y)}return e}_constructCurve(t,e,s){let r=Math.round(e/this._period);0===r&&(r=1);const i=16*r+1,n=e/r,o=this._period/16,a=1/i,h=2*Math.PI*e/n,c=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),u=2*Math.PI*Math.random(),d=.75-Math.random()/2,_=.75-Math.random()/2,p=new Ie;this._walker.curPointAndAngle(p),t.pushPoint(p.pt);let f=0;for(;;){if(!this._walker.nextPointAndAngle(o,p)){t.pushPoint(this._walker.getPathEnd());break}{const e=f;let r;if(f+=a,s){const t=this._height/2*(1+.3*Math.sin(d*h*e+c));r=t*Math.sin(h*e+l),r+=t*Math.sin(_*h*e+u),r/=2}else r=.5*this._height*Math.sin(.5*h*e);t.pushXY(p.pt[0]-r*p.sa,p.pt[1]+r*p.ca)}}}_constructSquare(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const r=new Ie;this._walker.curPointAndAngle(r);const i=new Ie;if(this._walker.nextPointAndAngle(this._period,i)){const n=new Ie;this._walker.nextPointAndAngle(this._period,n)&&(s?(t.pushPoint(r.pt),s=!1):t.pushPoint(r.pt),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(i.pt[0]+this._height/2*i.sa,i.pt[1]-this._height/2*i.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}_constructTriangle(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const r=new Ie;this._walker.curPointAndAngle(r);const i=new Ie;if(this._walker.nextPointAndAngle(this._period/2,i)){const n=new Ie;this._walker.nextPointAndAngle(this._period,n)&&(this._walker.nextPosition(this._period/2)&&(s?(t.pushPoint(r.pt),s=!1):t.pushPoint(r.pt),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(n.pt[0]+this._height/2*n.sa,n.pt[1]-this._height/2*n.ca)),e=!0)}}if(!e){t.pushPoint(this._walker.getPathEnd());break}}}}class $e{static local(){return null===$e.instance&&($e.instance=new $e),$e.instance}execute(t,e,s,r,i){return new He(t,e,s)}}$e.instance=null;class He extends ae{constructor(t,e,s){super(t),this._geometryWalker=new Pe,this._geometryWalker.updateTolerance(s),this._angleToLine=e.angleToLine??!0,this._offset=(e.offset?e.offset:0)*s,this._originalEndings=e.endings,this._offsetAtEnd=(e.customEndingOffset?e.customEndingOffset:0)*s,this._position=-(e.offsetAlongLine?e.offsetAlongLine:0)*s,this._pattern=new Se,this._pattern.init(e.placementTemplate,!1),this._pattern.scale(s),this._endings=this._originalEndings}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath)e=this._pattern.nextValue();else{this._originalEndings===Ct.e_.WithFullGap&&this.isClosed?this._endings=Ct.e_.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let s,r=!0;switch(this._endings){case Ct.e_.NoConstraint:s=-this._position,s=this._adjustPosition(s),r=!1;break;case Ct.e_.WithHalfGap:default:s=-this._pattern.lastValue()/2;break;case Ct.e_.WithFullGap:s=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case Ct.e_.WithMarkers:s=0;break;case Ct.e_.Custom:s=-this._position,s=this._adjustPosition(s),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,r))return null;this._pattern.reset();let i=0;for(;s>i;)s-=i,i=this._pattern.nextValue();i-=s,e=i,this.iteratePath=!0}const s=new Ie;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===Ct.e_.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===Ct.e_.WithMarkers&&this._geometryWalker.isPathEnd()&&(this.iteratePath=!1,this.isClosed)?null:(this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca),this._angleToLine&&this.internalPlacement.setRotateCS(s.ca,s.sa),this.internalPlacement):(this.iteratePath=!1,null)}_adjustPosition(t){let e=t/this._pattern.length();return e-=Math.floor(e),e*this._pattern.length()}}class Ze{static local(){return null===Ze.instance&&(Ze.instance=new Ze),Ze.instance}execute(t,e,s,r,i){return new Qe(t,e,s)}}Ze.instance=null;class Qe extends ae{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new le,this._placePerPart=e.placePerPart??!1,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._type=e.extremityPlacement,this._position=void 0!==e.offsetAlongLine?e.offsetAlongLine*s:0,this._beginProcessed=!1}processMultiPath(t){return this._placePerPart?super.processMultiPath(t):this.processPath(t)}processPath(t){let e;switch(this._type){case Ct.$2.Both:default:this._beginProcessed?(e=this._atExtremities(t,this._position,!1),this._beginProcessed=!1,this.iterateMultiPath=!1,this.iteratePath=!1):(e=this._atExtremities(t,this._position,!0),this._beginProcessed=!0,this.iterateMultiPath=!0,this.iteratePath=!0);break;case Ct.$2.JustBegin:e=this._atExtremities(t,this._position,!0);break;case Ct.$2.JustEnd:e=this._atExtremities(t,this._position,!1);case Ct.$2.None:}return e}_atExtremities(t,e,s){if(this._placePerPart||(s?t.seekPath(0):t.seekPath(t.totalSize-1)),s||t.seekPathEnd(),s?t.nextPoint():t.prevPoint()){let r=0,[i,n]=[0,0],[o,a]=[t.x,t.y];for(;s?t.nextPoint():t.prevPoint();){i=o,n=a,o=t.x,a=t.y;const s=this._curveHelper.getLength(i,n,o,a);if(r+s>e){const t=(e-r)/s,[h,c]=this._curveHelper.getAngleCS(i,n,o,a,t),l=this._curveHelper.getCoord2D(i,n,o,a,t);return this.internalPlacement.setTranslate(l[0]-this._offset*c,l[1]+this._offset*h),this._angleToLine&&this.internalPlacement.setRotateCS(-h,-c),this.internalPlacement}r+=s}}return null}}class Ke{static local(){return null===Ke.instance&&(Ke.instance=new Ke),Ke.instance}execute(t,e,s,r,i){return new Je(t,e,s)}}Ke.instance=null;class Je extends ae{constructor(t,e,s){super(t),this._walker=new Pe,this._walker.updateTolerance(s),this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._beginGap=void 0!==e.beginPosition?e.beginPosition*s:0,this._endGap=void 0!==e.endPosition?e.endPosition*s:0,this._flipFirst=void 0===e.flipFirst||e.flipFirst,this._pattern=new Se,this._pattern.init(e.positionArray,!1,!1),this._subPathLen=0,this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0}processPath(t){if(this._pattern.isEmpty())return null;let e;if(this.iteratePath){const t=this._pattern.nextValue()*this._subPathLen,s=this._beginGap+t;e=s-this._prevPos,this._prevPos=s}else{if(this._posCount=this._pattern.size(),this._isFirst=!0,this._prevPos=0,this._subPathLen=t.pathLength()-this._beginGap-this._endGap,this._subPathLen<0)return this.iteratePath=!1,null;if(!this._walker.init(t,this._pattern,!1))return null;this._pattern.reset();const s=this._pattern.nextValue()*this._subPathLen,r=this._beginGap+s;e=r-this._prevPos,this._prevPos=r,this.iteratePath=!0}const s=new Ie;if(!this._walker.nextPointAndAngle(e,s,ge.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const r=this._isFirst&&this._flipFirst;let i,n;return this._angleToLine?(i=s.ca,n=s.sa):(i=1,n=0),r&&(i=-i,n=-n),this.internalPlacement.setRotateCS(i,n),this._isFirst=!1,this._posCount--,0===this._posCount&&(this.iteratePath=!1),this.internalPlacement}}const ts=512,es=24,ss=1e-6;class rs{static local(){return null===rs.instance&&(rs.instance=new rs),rs.instance}execute(t,e,s,r,i){return new is(t,e,s,r,i)}}rs.instance=null;class is{constructor(t,e,s,r,i){if(this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,this._currentX=0,this._currentY=0,this._accelerationMap=null,this._testInsidePolygon=!1,this._verticalSubdivision=!0,this._stepX=Math.abs(e.stepX??16)*s,this._stepY=Math.abs(e.stepY??16)*s,this._stepX=Math.round(128*this._stepX)/128,this._stepY=Math.round(128*this._stepY)/128,0!==this._stepX&&0!==this._stepY){if(this._gridType=e.gridType??Ct.Q1.Fixed,this._gridType===Ct.Q1.Random){const t=e.seed??13,s=1;this._randomLCG=new h.A(t*s),this._randomness=(e.randomness??100)/100,this._gridAngle=0,this._shiftOddRows=!1,this._cosAngle=1,this._sinAngle=0,this._offsetX=0,this._offsetY=0,this._buildRandomValues()}else{if(this._randomness=0,this._gridAngle=e.gridAngle??0,this._shiftOddRows=e.shiftOddRows??!1,this._offsetX=(e.offsetX??0)*s,this._offsetY=(e.offsetY??0)*s,this._cosAngle=Math.cos(this._gridAngle/180*Math.PI),this._sinAngle=-Math.sin(this._gridAngle/180*Math.PI),this._stepX)if(this._offsetX<0)for(;this._offsetX<-.5*this._stepX;)this._offsetX+=this._stepX;else for(;this._offsetX>=.5*this._stepX;)this._offsetX-=this._stepX;if(this._stepY)if(this._offsetY<0)for(;this._offsetY<-.5*this._stepY;)this._offsetY+=this._stepY;else for(;this._offsetY>=.5*this._stepY;)this._offsetY-=this._stepY}if(this._graphicOriginX=0,this._graphicOriginY=0,null!=r){const[t,e,s,i]=r.split("/"),n=parseFloat(t),o=parseFloat(e),a=parseFloat(s),h=parseFloat(i);this._graphicOriginX=-(h*2**n+a)*ts,this._graphicOriginY=o*ts,this._testInsidePolygon=!0}this._internalPlacement=new ne,this._calculateMinMax(t),this._geometryCursor=t}}next(){return this._geometryCursor?this._nextInside():null}_buildRandomValues(){if(!is._randValues){is._randValues=[];for(let t=0;t<es;t++)for(let t=0;t<es;t++)is._randValues.push(this._randomLCG.getFloat()),is._randValues.push(this._randomLCG.getFloat())}}_calculateMinMax(t){let e,s,r,i,n,o,a,h,c,l,u,d,_,p;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=h=_=u=Number.MAX_VALUE,c=l=p=d=-Number.MAX_VALUE;const f=1!==this._cosAngle;for(t.reset();t.nextPath();)for(;t.nextPoint();)o=t.x,n=t.y,e=o-this._graphicOriginX-this._offsetX,s=n-this._graphicOriginY-this._offsetY,f?(r=this._cosAngle*e-this._sinAngle*s,i=this._sinAngle*e+this._cosAngle*s):(r=e,i=s),a=Math.min(a,r),c=Math.max(c,r),h=Math.min(h,i),l=Math.max(l,i),u=Math.min(u,n),d=Math.max(d,n),_=Math.min(_,o),p=Math.max(p,o);u=u!==Number.MAX_VALUE?u:-512-this._stepY,d=d!==-Number.MAX_VALUE?d:this._stepY,_=_!==Number.MAX_VALUE?_:-this._stepX,p=p!==-Number.MAX_VALUE?p:ts+this._stepX;const g=d-u,m=p-_;if(this._verticalSubdivision=g>=m,this._polygonMin=this._verticalSubdivision?u:_,this._testInsidePolygon){let t=0-this._graphicOriginX-this._offsetX-this._stepX,e=ts-this._graphicOriginX-this._offsetX+this._stepX,s=-512-this._graphicOriginY-this._offsetY-this._stepY,r=0-this._graphicOriginY-this._offsetY+this._stepY;if(f){const i=[[t,s],[t,r],[e,s],[e,r]];t=s=Number.MAX_VALUE,e=r=-Number.MAX_VALUE;for(const n of i){const i=this._cosAngle*n[0]-this._sinAngle*n[1],o=this._sinAngle*n[0]+this._cosAngle*n[1];t=Math.min(t,i),e=Math.max(e,i),s=Math.min(s,o),r=Math.max(r,o)}}a=a!==Number.MAX_VALUE?Math.max(a,t):t,h=h!==Number.MAX_VALUE?Math.max(h,s):s,c=c!==-Number.MAX_VALUE?Math.min(c,e):e,l=l!==-Number.MAX_VALUE?Math.min(l,r):r}this._xMin=Math.round(a/this._stepX),this._xMax=Math.round(c/this._stepX),this._yMin=Math.round(h/this._stepY),this._yMax=Math.round(l/this._stepY),this._currentX=this._xMax+1,this._currentY=this._yMin-1,this._buildAccelerationMap(t,_,p,u,d)}_buildAccelerationMap(t,e,s,r,i){t.reset();const n=new Map,o=this._verticalSubdivision,a=o?i-r:s-e;let h=Math.ceil(a/10);if(h<=1)return;const c=Math.floor(a/h);let l,u,d,_,p,f,g,m,y,b,w;for(h++,this._delta=c,o?(y=-512-2*this._stepY,b=2*this._stepY,w=r):(y=-2*this._stepX,b=ts+2*this._stepX,w=e);t.nextPath();)if(!(t.pathSize<2)&&t.nextPoint())for(l=t.x,u=t.y;t.nextPoint();l=d,u=_){if(d=t.x,_=t.y,o){if(u===_||u<y&&_<y||u>b&&_>b)continue;p=Math.min(u,_),f=Math.max(u,_)}else{if(l===d||l<y&&d<y||l>b&&d>b)continue;p=Math.min(l,d),f=Math.max(l,d)}for(;p<f;)g=Math.floor((p-w)/c),ns(g,l,u,d,_,n),p+=c;m=Math.floor((f-w)/c),m>g&&ns(m,l,u,d,_,n)}this._accelerationMap=n}_nextInside(){for(;;){if(this._currentX>this._xMax){if(this._currentY++,this._currentY>this._yMax)return null;this._currentX=this._xMin,this._shiftOddRows&&this._currentY%2&&this._currentX--}let t=this._currentX*this._stepX+this._offsetX;this._shiftOddRows&&this._currentY%2&&(t+=.5*this._stepX);const e=this._currentY*this._stepY+this._offsetY;let s,r;if(this._currentX++,this._gridType===Ct.Q1.Random){const i=(this._currentX%es+es)%es,n=(this._currentY%es+es)%es;s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-is._randValues[n*es+i])*2/3,r=this._graphicOriginY+e+this._stepY*this._randomness*(.5-is._randValues[n*es+i+1])*2/3}else s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,r=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e;if(!this._testInsidePolygon||this._isInsidePolygon(s,r,this._geometryCursor))return this._internalPlacement.setTranslate(s,r),this._internalPlacement}}_isInsidePolygon(t,e,s){if(null==this._accelerationMap)return function(t,e,s){let r,i,n,o,a=0;for(t+=ss,e+=ss,s.reset();s.nextPath();)if(s.nextPoint())for(r=s.x,i=s.y;s.nextPoint();r=n,i=o)n=s.x,o=s.y,i>e!=o>e&&((n-r)*(e-i)-(o-i)*(t-r)>0?a++:a--);return 0!==a}(t,e,s);t+=ss,e+=ss;const r=this._verticalSubdivision,i=r?e:t,n=Math.floor((i-this._polygonMin)/this._delta),o=this._accelerationMap.get(n);if(!o)return!1;let a,h,c,l=0;for(const s of o){if(a=s[0],h=s[1],r){if(a[1]>e==h[1]>e)continue;c=(h[0]-a[0])*(e-a[1])-(h[1]-a[1])*(t-a[0])}else{if(a[0]>t==h[0]>t)continue;c=(h[1]-a[1])*(t-a[0])-(h[0]-a[0])*(e-a[1])}c>0?l++:l--}return 0!==l}}function ns(t,e,s,r,i,n){let o=n.get(t);o||(o=[],n.set(t,o)),o.push([[e,s],[r,i]])}class os{static local(){return null===os.instance&&(os.instance=new os),os.instance}execute(t,e,s,r,i){return new as(t,e,s)}}os.instance=null;class as extends ae{constructor(t,e,s){super(t),this._curveHelper=new le,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._relativeTo=e.relativeTo,this._position=void 0!==e.startPointOffset?e.startPointOffset*s:0,this._epsilon=.001*s}processPath(t){const e=this._position;if(this._relativeTo===Ct.ip.SegmentMidpoint){if(this.iteratePath||(this.iteratePath=!0),t.nextPoint()){let[e,s]=[t.x,t.y],[r,i]=[0,0];for(;t.nextPoint();){r=t.x,i=t.y;const n=this._curveHelper.getLength(e,s,r,i);if(n<this._epsilon){e=r,s=i;continue}const o=.5+this._position/n,[a,h]=this._curveHelper.getAngleCS(e,s,r,i,o),c=this._curveHelper.getCoord2D(e,s,r,i,o);return this.internalPlacement.setTranslate(c[0]-this._offset*h,c[1]+this._offset*a),this._angleToLine&&this.internalPlacement.setRotateCS(a,h),this.internalPlacement}}return this.iteratePath=!1,null}const s=this._relativeTo===Ct.ip.LineEnd;return this.onLine(t,e,s)}onLine(t,e,s){let r,i=!1;switch(this._relativeTo){case Ct.ip.LineMiddle:default:t.seekPathStart(),r=t.pathLength()/2+e;break;case Ct.ip.LineBeginning:r=e;break;case Ct.ip.LineEnd:r=e,i=!0}s?t.seekPathEnd():t.seekPathStart();let n=0;if(s?t.prevPoint():t.nextPoint()){let[e,o]=[t.x,t.y],[a,h]=[0,0];for(;s?t.prevPoint():t.nextPoint();){a=t.x,h=t.y;const s=this._curveHelper.getLength(e,o,a,h);if(n+s>r){const t=(r-n)/s,[c,l]=this._curveHelper.getAngleCS(e,o,a,h,t),u=this._curveHelper.getCoord2D(e,o,a,h,t),d=i?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-d*l,u[1]+d*c),this._angleToLine&&(i?this.internalPlacement.setRotateCS(-c,-l):this.internalPlacement.setRotateCS(c,l)),this.internalPlacement}e=a,o=h,n+=s}}return null}}class hs{static local(){return null===hs.instance&&(hs.instance=new hs),hs.instance}execute(t,e,s,r,i){return new cs(t,e,s)}}hs.instance=null;class cs extends ae{constructor(t,e,s){super(t),this._curveHelper=new le,this._angleToLine=void 0===e.angleToLine||e.angleToLine,this._offset=void 0!==e.offset?e.offset*s:0,this._endPoints=void 0===e.placeOnEndPoints||e.placeOnEndPoints,this._controlPoints=void 0===e.placeOnControlPoints||e.placeOnControlPoints,this._regularVertices=void 0===e.placeOnRegularVertices||e.placeOnRegularVertices,this._tags=[],this._tagIterator=0}processPath(t){if(this.iteratePath||(this._preparePath(t),this.iteratePath=!0),this._tagIterator>=this._tags.length)return this._tags.length=0,this._tagIterator=0,this.iteratePath=!1,null;const e=this._tags[this._tagIterator];this._angleToLine&&this.internalPlacement.setRotate(e[2]);let s=e[0],r=e[1];if(0!==this._offset){const t=Math.cos(e[2]),i=Math.sin(e[2]);s-=this._offset*i,r+=this._offset*t}return this.internalPlacement.setTranslate(s,r),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0,t.seekPathStart();const e=t.isClosed();let s=0,r=!1,i=0,n=0;if(t.seekPathStart(),t.nextPoint()){let o=t.x,a=t.y,h=t.getControlPoint(),c=!0,l=t.nextPoint();for(;l;){const u=t.x,d=t.y,_=t.getControlPoint();(this._angleToLine||0!==this._offset)&&(i=this._curveHelper.getAngle(o,a,u,d,0)),c?(c=!1,e?(s=i,r=h):(this._endPoints||this._controlPoints&&h)&&this._tags.push([o,a,i])):h?this._controlPoints&&this._tags.push([o,a,ls(n,i)]):this._regularVertices&&this._tags.push([o,a,ls(n,i)]),(this._angleToLine||0!==this._offset)&&(n=this._curveHelper.getAngle(o,a,u,d,1)),l=t.nextPoint(),l||(e?_||r?this._controlPoints&&this._tags.push([u,d,ls(n,s)]):this._regularVertices&&this._tags.push([u,d,ls(n,s)]):(this._endPoints||this._controlPoints&&_)&&this._tags.push([u,d,n])),o=u,a=d,h=_}}this._tagIterator=0}}function ls(t,e){const s=Math.PI;for(;Math.abs(e-t)>s+2e-15;)e-t>s?e-=2*s:e+=2*s;return(t+e)/2}var us=s(12359),ds=s(12176);function _s(t){if(0===t.totalSize)return null;const e=(0,Ue.z8)(t);if(!e)return null;const s=4*(Math.abs(e[0])+Math.abs(e[2])+Math.abs(e[1])+Math.abs(e[3])+1)*222045e-19;let r=0,i=0;t.reset();for(let e=0;t.nextPath();e++){const s=t.getCurrentRingArea();s>i&&(i=s,r=e)}if(t.seekPath(r),0===t.pathSize)return null;t.seekPathStart();const n=(0,Ue.B$)(t);if(Math.abs(i)<=2*s*s)return[(n[0]+n[2])/2,(n[1]+n[3])/2];t.seekPathStart();const o=(0,us.w2)(t,(0,N.vt)());if(null===o)return null;if(t.totalPoints<4)return o;const a=[[NaN,NaN],[NaN,NaN],[NaN,NaN],[NaN,NaN]],h=[NaN,NaN,NaN,NaN],c=[NaN,NaN,NaN,NaN];let l=!1,u=fs(o,t,!0);0===u.distance&&(l=!0,a[0][0]=o[0],a[0][1]=o[1],u=fs(o,t,!1)),h[0]=u.distance,c[0]=0;const d=[NaN,NaN];let _=!1,p=.25,f=-1,g=NaN;do{if(g=NaN,a[1]=gs(t,Is(n[0],n[2],p),0,e),isNaN(a[1][0])||isNaN(a[1][1])||(u=fs(a[1],t,!1),g=u.distance),!isNaN(g)&&g>s&&ps(a[1],t))_=!0,h[1]=g,c[1]=Ms(a[1],o);else if(!isNaN(g)&&g>f&&(f=g,d[0]=a[1][0],d[1]=a[1][1]),p-=.01,p<.1){if(!(f>=0))break;_=!0,h[1]=f,a[1][0]=d[0],a[1][1]=d[1],c[1]=Ms(a[1],o)}}while(!_);_=!1,p=.5,f=-1;let m=.01,y=1;do{if(g=NaN,a[2]=gs(t,Is(n[0],n[2],p),0,e),isNaN(a[2][0])||isNaN(a[2][1])||(u=fs(a[2],t,!1),g=u.distance),!isNaN(g)&&g>s&&ps(a[2],t))_=!0,h[2]=g,c[2]=Ms(a[2],o);else if(!isNaN(g)&&g>f)f=g,d[0]=a[2][0],d[1]=a[2][1];else if(g>f&&(f=g,d[0]=a[2][0],d[1]=a[2][1]),p=.5+m*y,m+=.01,y*=-1,p<.3||p>.7){if(!(f>=0))break;_=!0,h[2]=f,a[2][0]=d[0],a[2][1]=d[1],c[2]=Ms(a[2],o)}}while(!_);_=!1,p=.75,f=-1;do{if(g=NaN,a[3]=gs(t,Is(n[0],n[2],p),0,e),isNaN(a[3][0])||isNaN(a[3][1])||(u=fs(a[3],t,!1),g=u.distance),!isNaN(g)&&g>s&&ps(a[3],t))_=!0,h[3]=g,c[3]=Ms(a[3],o);else if(g>f&&(f=g,d[0]=a[3][0],d[1]=a[3][1]),p+=.01,p>.9){if(!(f>=0))break;_=!0,h[3]=f,a[3][0]=d[0],a[3][1]=d[1],c[3]=Ms(a[3],o)}}while(!_);const b=[0,1,2,3],w=l?0:1;let x;for(let t=w;t<4;t++)for(let t=w;t<3;t++){const e=c[t],s=c[t+1];Ps(e,s)>0&&(x=b[t],b[t]=b[t+1],b[t+1]=x,c[t]=s,c[t+1]=e)}let v=w,S=0,I=0;for(let t=w;t<4;t++){switch(t){case 0:I=2*h[b[t]];break;case 1:I=1.66666666*h[b[t]];break;case 2:I=1.33333333*h[b[t]];break;case 3:I=h[b[t]]}I>S&&(S=I,v=b[t])}return a[v]}function ps(t,e){let s,r,i,n,o=0;for(e.reset();e.nextPath()&&e.nextPoint();)for(s=e.x,r=e.y;e.nextPoint();s=i,r=n)i=e.x,n=e.y,r>t[1]!=n>t[1]&&((i-s)*(t[1]-r)-(n-r)*(t[0]-s)>0?o++:o--);return 0!==o}function fs(t,e,s){if(s&&ps(t,e))return{coord:t,distance:0};let r=1/0,i=0,n=0,o=[0,0],a=[0,0];const h=[0,0];for(e.reset();e.nextPath()&&e.nextPoint();)if(!(e.pathSize<2))for(o[0]=e.x,o[1]=e.y;e.nextPoint();o=a){a=[e.x,e.y],(0,ye.gR)(h,t,o,a);const s=Ms(t,h);s<r&&(r=s,i=h[0],n=h[1])}return{coord:[i,n],distance:Math.sqrt(r)}}function gs(t,e,s,r){const i=[e,0];let n=1/0,o=1/0,a=!1,h=!1;const c=[[e,r[1]-1],[e,r[3]+1]],l=[0,0],u=[0,0],d=[0,0],_=[[0,0],[0,0]],p=(0,N.vt)();for(t.reset();t.nextPath()&&t.nextPoint();)if(!(t.pathSize<2))for(_[0][0]=t.x,_[0][1]=t.y;t.nextPoint();_[0][0]=_[1][0],_[0][1]=_[1][1]){if(_[1][0]=t.x,_[1][1]=t.y,null===ms(p,_))continue;if(u[0]=c[0][0],u[1]=c[0][1],d[0]=c[1][0],d[1]=c[1][1],0===vs(p,u,d))continue;if(!(0,ds.Ql)(c[0],c[1],_[0],_[1],l))continue;const e=l[1];n>o?e<n&&(n=e,a=!0):e<o&&(o=e,h=!0)}return a&&h?i[1]=(n+o)/2:i[0]=i[1]=NaN,i}function ms(t,e){if(e.length<2)return null;t||(t=(0,N.vt)());const[s,r]=e[0],[i,n]=e[1];return t[0]=Math.min(s,i),t[1]=Math.min(r,n),t[2]=Math.max(s,i),t[3]=Math.max(r,n),t}const ys=1,bs=4,ws=3,xs=12;function vs(t,e,s){let r=Ss(e,t),i=Ss(s,t);const n=t[0],o=t[1],a=t[2],h=t[3];if(r&i)return 0;if(!(r|i))return 4;const c=(r?1:0)|(i?2:0);do{const c=s[0]-e[0],l=s[1]-e[1];if(c>l)r&ws?(r&ys?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),r=Ss(e,t)):i&ws?(i&ys?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),i=Ss(s,t)):r?(r&bs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),r=Ss(e,t)):(i&bs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),i=Ss(s,t));else if(r&xs?(r&bs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),r=Ss(e,t)):i&xs?(i&bs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),i=Ss(s,t)):r?(r&ys?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),r=Ss(e,t)):(i&ys?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),i=Ss(s,t)),r&i)return 0}while(r|i);return c}function Ss(t,e){return(t[0]<e[0]?1:0)|(t[0]>e[2]?1:0)<<1|(t[1]<e[1]?1:0)<<2|(t[1]>e[3]?1:0)<<3}function Is(t,e,s){return t+(e-t)*s}function Ms(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])}function Ps(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;const s=isNaN(t),r=isNaN(e);return s<r?-1:s>r?1:0}class Ts{static local(){return null===Ts.instance&&(Ts.instance=new Ts),Ts.instance}execute(t,e,s,r,i){return new As(t,e,s)}}Ts.instance=null;class As{constructor(t,e,s){this._geometryCursor=t,this._offsetX=void 0!==e.offsetX?e.offsetX*s:0,this._offsetY=void 0!==e.offsetY?e.offsetY*s:0,this._method=void 0!==e.method?e.method:Ct.YI.OnPolygon,this._placementPerPart=void 0!==e.placePerPart&&e.placePerPart,this._internalPlacement=new ne}next(){const t=this._geometryCursor;if(!t)return null;if(!this._placementPerPart)return this._geometryCursor=null,this._polygonCenter(t);for(;t.nextPath();)if(!(t.getCurrentRingArea()<0))return this._polygonCenter(t.getCurrentPath());return this._geometryCursor=null,null}_polygonCenter(t){let e=!1;switch(this._method){case Ct.YI.CenterOfMass:{const s=(0,us.TP)(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case Ct.YI.BoundingBoxCenter:{const s=(0,Ue.z8)(t);s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case Ct.YI.OnPolygon:default:{const s=_s(t);null!==s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function Cs(t){if(!t)return null;switch(t.type){case"CIMGeometricEffectAddControlPoints":return re.local();case"CIMGeometricEffectArrow":return de.local();case"CIMGeometricEffectBuffer":return pe.local();case"CIMGeometricEffectControlMeasureLine":return be.local();case"CIMGeometricEffectCut":return xe.local();case"CIMGeometricEffectDashes":return Ae.local();case"CIMGeometricEffectDonut":return ke.local();case"CIMGeometricEffectJog":return Ee.local();case"CIMGeometricEffectMove":return Oe.local();case"CIMGeometricEffectOffset":return De.local();case"CIMGeometricEffectReverse":return Ne.local();case"CIMGeometricEffectRotate":return Ve.local();case"CIMGeometricEffectScale":return We.local();case"CIMGeometricEffectWave":return Ye.local()}return null}new(s(32488).A),s(11831),s(92602),new Map,new Set;var ks=s(34727);s(28076),s(40804),s(5760);var Fs=s(34304);function Es(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function zs(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1],u=s[2],d=s[3],_=s[4],p=s[5];return t[0]=r*c+n*l,t[1]=i*c+o*l,t[2]=r*u+n*d,t[3]=i*u+o*d,t[4]=r*_+n*p+a,t[5]=i*_+o*p+h,t}function Os(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=Math.sin(s),l=Math.cos(s);return t[0]=r*l+n*c,t[1]=i*l+o*c,t[2]=r*-c+n*l,t[3]=i*-c+o*l,t[4]=a,t[5]=h,t}function Rs(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=r,t[1]=i,t[2]=n,t[3]=o,t[4]=r*c+n*l+a,t[5]=i*c+o*l+h,t}function Ds(t,e){const s=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=s,t[2]=-s,t[3]=r,t[4]=0,t[5]=0,t}function Ls(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t[2]=e[2]-s[2],t[3]=e[3]-s[3],t[4]=e[4]-s[4],t[5]=e[5]-s[5],t}const Ns=zs,Bs=Ls;function Gs(){const t=new Float32Array(6);return t[0]=1,t[3]=1,t}function Us(t,e,s,r){const i=e[r],n=e[r+1];t[r]=s[0]*i+s[2]*n+s[4],t[r+1]=s[1]*i+s[3]*n+s[5]}function Vs(t,e,s,r=0,i=0,n=2){const o=i||e.length/n;for(let i=r;i<o;i++)Us(t,e,s,i*n)}Object.freeze(Object.defineProperty({__proto__:null,add:function(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],t[2]=e[2]+s[2],t[3]=e[3]+s[3],t[4]=e[4]+s[4],t[5]=e[5]+s[5],t},copy:function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},determinant:function(t){return t[0]*t[3]-t[1]*t[2]},equals:function(t,e){const s=t[0],r=t[1],i=t[2],n=t[3],o=t[4],a=t[5],h=e[0],c=e[1],l=e[2],u=e[3],d=e[4],_=e[5],p=(0,Fs.FD)();return Math.abs(s-h)<=p*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(r-c)<=p*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(i-l)<=p*Math.max(1,Math.abs(i),Math.abs(l))&&Math.abs(n-u)<=p*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(o-d)<=p*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-_)<=p*Math.max(1,Math.abs(a),Math.abs(_))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},frob:function(t){return Math.sqrt(t[0]**2+t[1]**2+t[2]**2+t[3]**2+t[4]**2+t[5]**2+1)},fromRotation:Ds,fromScaling:function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},fromTranslation:function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},identity:Es,invert:function(t,e){const s=e[0],r=e[1],i=e[2],n=e[3],o=e[4],a=e[5];let h=s*n-r*i;return h?(h=1/h,t[0]=n*h,t[1]=-r*h,t[2]=-i*h,t[3]=s*h,t[4]=(i*a-n*o)*h,t[5]=(r*o-s*a)*h,t):null},mul:Ns,multiply:zs,multiplyScalar:function(t,e,s){return t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t[3]=e[3]*s,t[4]=e[4]*s,t[5]=e[5]*s,t},multiplyScalarAndAdd:function(t,e,s,r){return t[0]=e[0]+s[0]*r,t[1]=e[1]+s[1]*r,t[2]=e[2]+s[2]*r,t[3]=e[3]+s[3]*r,t[4]=e[4]+s[4]*r,t[5]=e[5]+s[5]*r,t},rotate:Os,scale:function(t,e,s){const r=e[0],i=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=r*c,t[1]=i*c,t[2]=n*l,t[3]=o*l,t[4]=a,t[5]=h,t},set:function(t,e,s,r,i,n,o){return t[0]=e,t[1]=s,t[2]=r,t[3]=i,t[4]=n,t[5]=o,t},str:function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},sub:Bs,subtract:Ls,translate:Rs},Symbol.toStringTag,{value:"Module"})),Object.freeze(Object.defineProperty({__proto__:null,clone:function(t){const e=new Float32Array(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},create:Gs,createView:function(t,e){return new Float32Array(t,e,6)},fromValues:function(t,e,s,r,i,n){const o=new Float32Array(6);return o[0]=t,o[1]=e,o[2]=s,o[3]=r,o[4]=i,o[5]=n,o},transform:Us,transformMany:Vs},Symbol.toStringTag,{value:"Module"}));var qs,Ws,js=s(88340);function Ys(t){if(!t)return qs.Center;switch(t){case"Left":case"left":return qs.Left;case"Right":case"right":return qs.Right;case"Justify":return E.A.getLogger("esri.views.2d.engine.webgl.alignmentUtils").warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),qs.Center;case"Center":case"center":return qs.Center}}function Xs(t){if(!t)return Ws.Center;switch(t){case"Top":case"top":return Ws.Top;case"Center":case"middle":return Ws.Center;case"Baseline":case"baseline":return Ws.Baseline;case"Bottom":case"bottom":return Ws.Bottom}}!function(t){t[t.Left=-1]="Left",t[t.Center=0]="Center",t[t.Right=1]="Right"}(qs||(qs={})),function(t){t[t.Top=1]="Top",t[t.Center=0]="Center",t[t.Bottom=-1]="Bottom",t[t.Baseline=2]="Baseline"}(Ws||(Ws={}));var $s=s(18989);class Hs{constructor(t,e,s,r){this.transformedX=0,this.transformedY=0,this.center=(0,js.fA)(t,e),this.centerT=(0,js.vt)(),this.halfWidth=s/2,this.halfHeight=r/2,this.width=s,this.height=r}get x(){return this.center[0]}get y(){return this.center[1]}get blX(){return this.center[0]+this.halfWidth}get blY(){return this.center[1]+this.halfHeight}get trX(){return this.center[0]-this.halfWidth}get trY(){return this.center[1]-this.halfHeight}get xmin(){return this.x-this.halfWidth}get xmax(){return this.x+this.halfWidth}get ymin(){return this.y-this.halfHeight}get ymax(){return this.y+this.halfHeight}set x(t){this.center[0]=t}set y(t){this.center[1]=t}clone(){return new Hs(this.x,this.y,this.width,this.height)}serialize(t){return t.writeF32(this.center[0]),t.writeF32(this.center[1]),t.push(this.width),t.push(this.height),t}findCollisionDelta(t,e=4){const s=Math.abs(t.centerT[0]-this.centerT[0]),r=Math.abs(t.centerT[1]-this.centerT[1]),i=(t.halfWidth+this.halfWidth+e)/s,n=(t.halfHeight+this.halfHeight+e)/r,o=Math.min(i,n);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),r=Math.max(this.xmax,t.xmax)-e,i=Math.max(this.ymax,t.ymax)-s,n=e+r/2,o=s+i/2;this.width=r,this.height=i,this.halfWidth=r/2,this.halfHeight=i/2,this.x=n,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),r=t.readInt32(),i=t.readInt32();return new Hs(e,s,r,i)}}const Zs=Math.PI/180;class Qs{constructor(t,e,s,r){this._rotationT=Gs(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const i=s.rect,n=new Float32Array(8);t*=r,e*=r;const o=s.code?i.width*r:s.metrics.width,a=s.code?i.height*r:s.metrics.height;this.width=o,this.height=a,n[0]=t,n[1]=e,n[2]=t+o,n[3]=e,n[4]=t,n[5]=e+a,n[6]=t+o,n[7]=e+a,this._data=n,this._setTextureCoords(i),this._scale=r,this._mosaic=s,this.x=t,this.y=e,this.maxOffset=Math.max(t+o,e+a)}get mosaic(){return this._mosaic}set angle(t){this._angle=t,Ds(this._rotationT,-t),this._setOffsets()}get angle(){return this._angle}get xTopLeft(){return this._data[0]}get yTopLeft(){return this._data[1]}get xBottomRight(){return this._data[6]}get yBottomRight(){return this._data[7]}get texcoords(){return this._texcoords}get textureBinding(){return this._mosaic.textureBinding}get offsets(){return this._offsets||this._setOffsets(),this._offsets}get char(){return String.fromCharCode(this._mosaic.code)}get code(){return this._mosaic.code}get bounds(){if(!this._bounds){const{height:t,width:e}=this._mosaic.metrics,s=e*this._scale,r=Math.abs(t)*this._scale,i=new Float32Array(8);i[0]=this.x,i[1]=this.y,i[2]=this.x+s,i[3]=this.y,i[4]=this.x,i[5]=this.y+r,i[6]=this.x+s,i[7]=this.y+r,Vs(i,i,zs(Gs(),this._rotationT,this._transform));let n=1/0,o=1/0,a=-1/0,h=-1/0;for(let t=0;t<4;t++){const e=i[2*t],s=i[2*t+1];n=Math.min(n,e),o=Math.min(o,s),a=Math.max(a,e),h=Math.max(h,s)}const c=a-n,l=h-o,u=n+c/2,d=o+l/2;this._bounds=new Hs(u,d,c,l)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}_setOffsets(){this._offsets||(this._offsets={topLeft:[0,0],topRight:[0,0],bottomLeft:[0,0],bottomRight:[0,0]});const t=zs(Gs(),this._rotationT,this._transform);this._offsets.topLeft[0]=this._data[0],this._offsets.topLeft[1]=this._data[1],this._offsets.topRight[0]=this._data[2],this._offsets.topRight[1]=this._data[3],this._offsets.bottomLeft[0]=this._data[4],this._offsets.bottomLeft[1]=this._data[5],this._offsets.bottomRight[0]=this._data[6],this._offsets.bottomRight[1]=this._data[7],(0,O.l0)(this._offsets.topLeft,this._offsets.topLeft,t),(0,O.l0)(this._offsets.topRight,this._offsets.topRight,t),(0,O.l0)(this._offsets.bottomLeft,this._offsets.bottomLeft,t),(0,O.l0)(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:e,width:s,height:r}){this._texcoords={topLeft:[t,e],topRight:[t+s,e],bottomLeft:[t,e+r],bottomRight:[t+s,e+r]}}}const Ks=(t,e)=>({code:0,page:0,sdf:!0,rect:new $s.A(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function Js(t,e){return t.forEach((t=>(0,O.l0)(t,t,e))),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class tr{constructor(t,e,s){this._rotation=0,this._decorate(t,e,s),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==s.angle,this._transform=this._createGlyphTransform(this.bounds,s),this._borderLineSizePx=s.borderLineSizePx,(s.borderLineSizePx||s.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const e of t)e.setTransform(this._transform)}setRotation(t){if(0===t&&0===this._rotation)return;this._rotation=t;const e=this._transform;zs(e,Ds(Gs(),t),e);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,s){if(!s.decoration||"none"===s.decoration||!t.length)return;const r=s.scale,i="underline"===s.decoration?26:16,n=t[0].textureBinding;for(const s of e){const e=s.startX*r,o=s.startY*r,a=(s.width+s.glyphWidthEnd)*r;t.push(new Qs(e,o+i*r,Ks(a,n),1))}}shapeBackground(t){const e=(1.5+(this._borderLineSizePx||0))/2,s=this._borderLineSizePx?e:0,{xmin:r,ymin:i,xmax:n,ymax:o,x:a,y:h,width:c,height:l}=this.bounds,u=[r-8,i-8],d=[n+8,i-8],_=[r-8,o+8],p=[n+8,o+8],f=Js([[u[0]-e,u[1]-e],[d[0]+e,d[1]-e],[u[0]+s,u[1]+s],[d[0]-s,d[1]+s]],t),g=Js([[_[0]+s,_[1]-s],[p[0]-s,p[1]-s],[_[0]-e,_[1]+e],[p[0]+e,p[1]+e]],t),m=Js([[u[0]-e,u[1]-e],[u[0]+s,u[1]+s],[_[0]-e,_[1]+e],[_[0]+s,_[1]-s]],t),y=Js([[d[0]-s,d[1]+s],[d[0]+e,d[1]-e],[p[0]-s,p[1]-s],[p[0]+e,p[1]+e]],t),b={main:Js([u,d,_,p],t),top:f,bot:g,left:m,right:y};return[new Hs(a,h,c+2*e,l+2*e),b]}get boundsT(){const t=this.bounds,e=(0,O.hZ)((0,js.vt)(),t.x,t.y);if((0,O.l0)(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Hs(e[0],e[1],s,s)}return new Hs(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,r=0,i=0;for(const n of t)e=Math.min(e,n.xTopLeft),s=Math.min(s,n.yTopLeft),r=Math.max(r,n.xBottomRight),i=Math.max(i,n.yBottomRight);const n=r-e,o=i-s;return new Hs(e+n/2,s+o/2,n,o)}_createGlyphTransform(t,e){const s=Zs*e.angle,r=Gs(),i=(0,js.vt)();return Rs(r,r,(0,O.hZ)(i,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?Os(r,r,s):(Rs(r,r,(0,O.hZ)(i,t.x,t.y)),Os(r,r,s),Rs(r,r,(0,O.hZ)(i,-t.x,-t.y))),r}}class er{constructor(t,e,s,r,i,n){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=r,this.yMin=i,this.yMax=n}}const sr=t=>10===t,rr=t=>32===t;var ir=s(39829);Math.PI,s(59868);var nr=s(13195);function or(t){if(!t)return 0;switch(t.type){case"CIMGeometricEffectArrow":return Math.abs(.5*t.width);case"CIMGeometricEffectBuffer":return Math.abs(t.size);case"CIMGeometricEffectControlMeasureLine":return 500;case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(t.length);case"CIMGeometricEffectJog":return Math.abs(.5*t.length);case"CIMGeometricEffectMove":return Math.max(Math.abs((0,Te.$w)(t.offsetX)),Math.abs((0,Te.$w)(t.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(t.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(t.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(t.fromWidth),Math.abs(t.toWidth));case"CIMGeometricEffectWave":return Math.abs(t.amplitude);case"CIMGeometricEffectDonut":return Math.abs(t.width)}}function ar(t){if(!t)return 0;let e=0;for(const s of t)e+=or(s);return e}Math.PI,Math.PI;const hr=96/72;class cr{static executeEffects(t,e,s,r,i){const n=hr,o=ar(t);let a=new ee(e);for(const e of t){const t=Cs(e);t&&(a=t.execute(a,e,n,s,r,o,i))}return a}static applyEffects(t,e,s){if(!t)return e;const r=ar(t);let i,n=new ee(Yt.fromJSONCIM(e));for(const e of t){const t=Cs(e);t&&(n=t.execute(n,e,1,null,s,r,!1))}const o=[];let a=null;for(;i=n.next();)o.push(...(0,qt.x)(i)),a=i.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let lr=null;function ur(){return lr}const dr=new Float32Array(1),_r=new Uint32Array(dr.buffer);function pr(t){const e=function(t){return dr[0]=t,_r[0]}(t),s=e>>>31;let r=e>>>23&255,i=8388607&e;return r-=127,r>15?s<<15|31744:r<-25?0:(r<-14&&(i+=8388608,i/=2**(-14-r),r=-15),r+=15,i/=8192,i=function(t){const e=Math.floor(t),s=t-e;return e<1023&&(s>.5||.5===s&&e%2==1)?e+1:e}(i),s<<15|r<<10|i)}function fr(t,e,s,r,i,n,o){if(t.primitiveName===e){let e=r?.readWithDefault(i,n,t[s]&&o);return"text"===t.type&&(e=e.toString()),void(t[s]=e)}if("type"in t&&null!=t.type){if(t.effects)for(const a of t.effects)fr(a,e,s,r,i,n,o);switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.symbolLayers)for(const a of t.symbolLayers)fr(a,e,s,r,i,n,o);break;case"CIMTextSymbol":t.symbol&&fr(t.symbol,e,s,r,i,n,o);break;case"CIMHatchFill":t.lineSymbol&&fr(t.lineSymbol,e,s,r,i,n,o);break;case"CIMPictureMarker":case"CIMCharacterMarker":case"CIMVectorMarker":if(t.markerPlacement&&fr(t.markerPlacement,e,s,r,i,n,o),"CIMVectorMarker"===t.type&&t.markerGraphics)for(const a of t.markerGraphics)fr(a,e,s,r,i,n,o),fr(a.symbol,e,s,r,i,n,o)}}}function gr(t){const e=t.width;return null!=t.effects?400:Math.max(1.25*e,8)}function mr(t){switch(t){case dt.pe.BYTE:case dt.pe.UNSIGNED_BYTE:return 1;case dt.pe.SHORT:case dt.pe.UNSIGNED_SHORT:case dt.pe.HALF_FLOAT:return 2;case dt.pe.FLOAT:case dt.pe.INT:case dt.pe.UNSIGNED_INT:return 4}}class yr{static fromVertexSpec(t,e){const{attributes:s,optionalAttributes:r}=t;let i,n,o;const a=[];for(const t in s){const e=s[t];"position"===e.pack?i={...e,name:t,offset:0}:"id"===e.pack?n={...e,name:t,offset:4}:"bitset"===t?o={...e,name:t,offset:7}:a.push({...e,name:t})}for(const t in r)if(!0===e[t]){const e=r[t];a.push({...e,name:t})}const h=function(t){const e=[],s=[],r=[];for(const i of t){const t=mr(i.type)*i.count;switch(t%2||t%4||4){case 4:e.push(i);continue;case 2:s.push(i);continue;case 1:r.push(i);continue;default:throw new Error("Found unexpected dataType byte count")}}return e.push(...s),e.push(...r),e}(a),c=[];let l=8,u=1;for(const t of h)c.push({...t,offset:l}),l+=mr(t.type)*t.count,t.packAlternating&&(u=Math.max(t.packAlternating.count,u));const d=Uint32Array.BYTES_PER_ELEMENT,_=l%d;return new yr(i,n,o,c,l+(_?d-_:0),u)}constructor(t,e,s,r,i,n){this.position=t,this.id=e,this.bitset=s,this.standardAttributes=r,this.stride=i,this.packVertexCount=n,r.push(s),this._attributes=[t,e,s,...r]}get attributeLayout(){if(!this._attributeLayout){const t=function(t){const e=t.map((({name:t,count:e,type:s})=>`${t}.${e}.${s}`)).join(",");return(0,lt.Wm)(e)}(this._attributes),e=this._attributes.map((t=>({name:t.name,count:t.count,offset:t.offset,type:t.type,packPrecisionFactor:t.packPrecisionFactor,normalized:t.normalized??!1})));this._attributeLayout={attributes:e,hash:t,stride:this.stride}}return this._attributeLayout}}class br{static fromVertexSpec(t,e){const s=yr.fromVertexSpec(t,e);return new br(s)}constructor(t){this._spec=t,this._packed=new Uint8Array(this._spec.stride*this._spec.packVertexCount),this._packedU32View=new Uint32Array(this._packed.buffer),this._dataView=new DataView(this._packed.buffer)}get attributeLayout(){return this._spec.attributeLayout}get stride(){return this._spec.stride}writeVertex(t,e,s,r,i,n){for(let t=0;t<this._spec.packVertexCount;t++){const o=t*this._spec.stride;this._packPosition(s,r,o),this._packId(e,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const t=a.packTessellation(n,i,s,r);this._pack(t,a,o)}for(const t of this._spec.standardAttributes)if(null!=t.packTessellation){const e=t.packTessellation(n,i,s,r);this._pack(e,t,o)}else if(t.packAlternating?.packTessellation){const e=t.packAlternating.packTessellation(n,i,s,r);for(let s=0;s<this._spec.packVertexCount;s++){const r=e[s];this._pack(r,t,s*this._spec.stride)}}}}t.vertexWriteRegion(this._packedU32View)}pack(t,e){for(const s of this._spec.standardAttributes)if(s.pack&&"string"!=typeof s.pack){const r=s.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++)this._pack(r,s,t*this._spec.stride)}else if(s.packAlternating?.pack){const r=s.packAlternating.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++){const e=r[t];this._pack(e,s,t*this._spec.stride)}}}_packPosition(t,e,s){const{offset:r}=this._spec.position,i=this._spec.position.packPrecisionFactor??1,n=function(t,e){return 65535&t|e<<16}(t*i,e*i);this._dataView.setUint32(s+r,n,!0)}_packId(t,e){const s=t*(this._spec.id.packPrecisionFactor??1),r=4278190080&this._dataView.getUint32(e+this._spec.id.offset,!0);this._dataView.setUint32(e+this._spec.id.offset,s|r,!0)}_pack(t,e,s){!function(t,e,s,r){const i=s.packPrecisionFactor??1;switch(s.type){case dt.pe.BYTE:if(1===s.count)t.setInt8(r+s.offset,e*i);else for(let n=0;n<s.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;t.setInt8(r+s.offset+o,e[n]*i)}break;case dt.pe.UNSIGNED_BYTE:if(1===s.count)t.setUint8(r+s.offset,e*i);else for(let n=0;n<s.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;t.setUint8(r+s.offset+o,e[n]*i)}break;case dt.pe.SHORT:if(1===s.count)t.setInt16(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;t.setInt16(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.UNSIGNED_SHORT:if(1===s.count)t.setUint16(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.INT:if(1===s.count)t.setInt32(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;t.setInt32(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.UNSIGNED_INT:if(1===s.count)t.setUint32(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;t.setUint32(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.FLOAT:if(1===s.count)t.setFloat32(r+s.offset,e*i,!0);else for(let n=0;n<s.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;t.setFloat32(r+s.offset+o,e[n]*i,!0)}break;case dt.pe.HALF_FLOAT:if(1===s.count)t.setUint16(r+s.offset,pr(e*i),!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(r+s.offset+o,pr(e[n]*i),!0)}}}(this._dataView,t,e,s)}}class wr{constructor(t,e,s,r){this._instanceId=t,this._evaluator=e,this._enabledOptionalAttributes=s,this._viewParams=r,this._evaluator.evaluator=t=>this.vertexSpec.createComputedParams(t)}get _vertexPack(){if(!this._cachedVertexPack){const t=br.fromVertexSpec(this.vertexSpec,this._enabledOptionalAttributes);this._evaluator.hasDynamicProperties||t.pack(this._evaluator.evaluatedMeshParams,this._viewParams),this._cachedVertexPack=t}return this._cachedVertexPack}get evaluatedMeshParams(){return this._evaluator.evaluatedMeshParams}get hasEffects(){return!!this.evaluatedMeshParams.effects}get instanceId(){return this._instanceId}get attributeLayout(){return this._vertexPack.attributeLayout}get _preventEffectClipping(){return!1}setReferences(t){this._references=t}getBoundsInfo(){return null}getTileInfo(){return this._viewParams.tileInfo}async loadDependencies(){(function(t){if(!t)return!1;for(const e of t)switch(e.effect.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":case"CIMGeometricEffectDonut":return!0}return!1})(this._evaluator.inputMeshParams.effects?.effectInfos)&&await async function(){lr=await Promise.all([s.e(9930),s.e(3656)]).then(s.bind(s,47559))}()}enqueueRequest(t,e,s){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(t,e,s)}write(t,e,s,r,i){this.ensurePacked(e,s,r);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(t,s,void 0,i);const o=s.readGeometryForDisplay()?.clone();if(!o)return;const a=Yt.fromOptimizedCIM(o,s.geometryType),h=ur();a.invertY();const c=t.id||"",l=cr.executeEffects(n,a,c,h,this._preventEffectClipping);let u;for(;u=l.next();)u.invertY(),this._write(t,s,u,i)}ensurePacked(t,e,s){if(!this._evaluator.hasDynamicProperties)return;const r=this._evaluator.evaluateMeshParams(t,e,s);this._vertexPack.pack(r,this._viewParams)}hasArcadeDependency(t){return this._evaluator.hasArcadeDependency(t)}_writeVertex(t,e,s,r,i){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(t,e,s,r,n,i)}}class xr extends wr{}function vr(t){const{sprite:e,isMapAligned:s,colorLocked:r,scaleSymbolsProportionally:i,isStroke:n}=t;let o=0;return s&&(o|=Ft(Lt)),r&&(o|=Ft(Gt)),e.sdf&&(o|=Ft(Dt)),i&&(o|=Ft(Nt)),n&&(o|=Ft(Ut)),o}var Sr,Ir;(Ir=Sr||(Sr={}))[Ir.Geographic=0]="Geographic",Ir[Ir.Arithmatic=1]="Arithmatic";const Mr=3.14159265359/128;class Pr extends xr{get vertexSpec(){return{createComputedParams:t=>{let{pixelDimensions:e,texelDimensions:s,baseSize:r,referenceSize:i,strokeWidth:n,sizeRatio:o}=t;e||(e=t.sprite.sdf?[0,0]:[t.sprite.width,t.sprite.height]),s||(s=t.sprite.sdf?[0,0]:e),r=(0,l.Lz)(r),i=(0,l.Lz)(i),n=(0,l.Lz)(n);const a=(t.sprite.sdfDecodeCoeff??1)*o;return{...t,pixelDimensions:e,texelDimensions:s,baseSize:r,referenceSize:i,strokeWidth:n,sdfDecodeCoeff:a}},optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:vr},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:1},offset:{type:dt.pe.FLOAT,count:2,packAlternating:{count:4,pack:t=>{const e=t.texelDimensions;return[[-.5*e[0],-.5*e[1]],[.5*e[0],-.5*e[1]],[-.5*e[0],.5*e[1]],[.5*e[0],.5*e[1]]]}}},uv:{type:dt.pe.SHORT,count:2,packPrecisionFactor:1,packAlternating:{count:4,packTessellation:({texXmax:t,texXmin:e,texYmax:s,texYmin:r})=>[[e,r],[t,r],[e,s],[t,s]]}},animationPointerAndBaseSizeAndReferenceSize:{type:dt.pe.UNSIGNED_SHORT,count:4,packPrecisionFactor:1,pack:({animations:t,baseSize:e,referenceSize:s})=>[t.dataColumn,t.dataRow,e,s]},sizing:{type:dt.pe.UNSIGNED_SHORT,count:4,packPrecisionFactor:8,pack:({strokeWidth:t,pixelDimensions:e,baseSize:s,sprite:r,sizeRatio:i})=>{const n=Math.max(s*r.width/r.height,s),o=r.sdfDecodeCoeff*n*i;return[e[0],e[1],t,o]}},angle:{type:dt.pe.BYTE,count:1,packTessellation:({angle:t})=>t}}}}_write(t,e){const s=this.evaluatedMeshParams.sprite,{textureBinding:r}=s;t.recordStart(this.instanceId,this.attributeLayout,r);const i=e.getDisplayId();if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[r,n]=s.coords;this._writeQuad(t,i,r,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),r=e.readYForDisplay();this._writeQuad(t,i,s,r)}else{const s=e.readGeometryForDisplay();if(s){const{angleToLine:e}=this.evaluatedMeshParams;if(e){let e=!0,r=null,n=null;s.forEachVertex(((s,o)=>{if(null!=r&&null!=n){const a=Math.atan2(o-n,s-r)/Mr;e&&(this._writeQuad(t,i,r,n,a),e=!1),this._writeQuad(t,i,s,o,a)}r=s,n=o}))}else s.forEachVertex(((e,s)=>{this._writeQuad(t,i,e,s)}))}}t.recordEnd()}_writeQuad(t,e,s,r,i=0){const n=this.evaluatedMeshParams.sprite,{rect:o}=n,a=o.x+B.hM,h=o.y+B.hM,c=o.x+o.width-B.hM,l=o.y+o.height-B.hM,u=t.vertexCount();t.recordBounds(s,r,64,64);const d={texXmin:a,texYmin:h,texXmax:c,texYmax:l,angle:i};for(let i=0;i<4;i++)this._writeVertex(t,e,s,r,d);t.indexEnsureSize(6),t.indexWrite(u),t.indexWrite(u+1),t.indexWrite(u+2),t.indexWrite(u+1),t.indexWrite(u+3),t.indexWrite(u+2)}}var Tr=s(15585);function Ar(t,e,s,r,i,n,o){Kr=0;const a=(r-s)*n,h=i&&i.length,c=h?(i[0]-s)*n:a;let l,u,d,_,p,f=Cr(e,s,0,0,c,n,!0);if(f&&f.next!==f.prev){if(h&&(f=function(t,e,s,r,i,n){const o=new Array;for(let i=0,a=r.length;i<a;i++){const h=Cr(t,e,0,r[i]*n,i<a-1?r[i+1]*n:s*n,n,!1);h===h.next&&(h.steiner=!0),o.push(Dr(h))}o.sort(jr);for(const t of o)i=Lr(t,i);return i}(e,s,r,i,f,n)),a>80*n){l=d=e[0+s*n],u=_=e[1+s*n];for(let t=n;t<c;t+=n){const r=e[t+s*n],i=e[t+1+s*n];l=Math.min(l,r),u=Math.min(u,i),d=Math.max(d,r),_=Math.max(_,i)}p=Math.max(d-l,_-u),p=0!==p?1/p:0}Fr(f,t,n,l,u,p,o,0)}}function Cr(t,e,s,r,i,n,o){let a;if(o===function(t,e,s,r,i,n){let o=0;for(let s=r,a=i-n;s<i;s+=n)o+=(t[a+e*n]-t[s+e*n])*(t[s+1+e*n]+t[a+1+e*n]),a=s;return o}(t,e,0,r,i,n)>0)for(let s=r;s<i;s+=n)a=Or(s+e*n,t[s+e*n],t[s+1+e*n],a);else for(let s=i-n;s>=r;s-=n)a=Or(s+e*n,t[s+e*n],t[s+1+e*n],a);return a&&Wr(a,a.next)&&(Rr(a),a=a.next),a}function kr(t,e=t){if(!t)return t;let s,r=t;do{if(s=!1,r.steiner||!Wr(r,r.next)&&0!==Br(r.prev,r,r.next))r=r.next;else{if(Rr(r),r=e=r.prev,r===r.next)break;s=!0}}while(s||r!==e);return e}function Fr(t,e,s,r,i,n,o,a){if(!t)return;!a&&n&&(t=Nr(t,r,i,n));let h=t;for(;t.prev!==t.next;){const c=t.prev,l=t.next;if(n?zr(t,r,i,n):Er(t))e.push(c.index/s+o),e.push(t.index/s+o),e.push(l.index/s+o),Rr(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?Fr(t=Yr(t,e,s,o),e,s,r,i,n,o,2):2===a&&Xr(t,e,s,r,i,n,o):Fr(kr(t),e,s,r,i,n,o,1);break}}}function Er(t){const e=t.prev,s=t,r=t.next;if(Br(e,s,r)>=0)return!1;let i=t.next.next;const n=i;let o=0;for(;i!==t.prev&&(0===o||i!==n);){if(o++,Ur(e.x,e.y,s.x,s.y,r.x,r.y,i.x,i.y)&&Br(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function zr(t,e,s,r){const i=t.prev,n=t,o=t.next;if(Br(i,n,o)>=0)return!1;const a=i.x<n.x?i.x<o.x?i.x:o.x:n.x<o.x?n.x:o.x,h=i.y<n.y?i.y<o.y?i.y:o.y:n.y<o.y?n.y:o.y,c=i.x>n.x?i.x>o.x?i.x:o.x:n.x>o.x?n.x:o.x,l=i.y>n.y?i.y>o.y?i.y:o.y:n.y>o.y?n.y:o.y,u=qr(a,h,e,s,r),d=qr(c,l,e,s,r);let _=t.prevZ,p=t.nextZ;for(;_&&_.z>=u&&p&&p.z<=d;){if(_!==t.prev&&_!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Br(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,p!==t.prev&&p!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Br(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;_&&_.z>=u;){if(_!==t.prev&&_!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Br(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;p&&p.z<=d;){if(p!==t.prev&&p!==t.next&&Ur(i.x,i.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Br(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Or(t,e,s,r){const i=Zr.create(t,e,s);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Rr(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Dr(t){let e=t,s=t;do{(e.x<s.x||e.x===s.x&&e.y<s.y)&&(s=e),e=e.next}while(e!==t);return s}function Lr(t,e){const s=function(t,e){let s=e;const r=t.x,i=t.y;let n,o=-1/0;do{if(i<=s.y&&i>=s.next.y&&s.next.y!==s.y){const t=s.x+(i-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=r&&t>o){if(o=t,t===r){if(i===s.y)return s;if(i===s.next.y)return s.next}n=s.x<s.next.x?s:s.next}}s=s.next}while(s!==e);if(!n)return null;if(r===o)return n.prev;const a=n,h=n.x,c=n.y;let l,u=1/0;for(s=n.next;s!==a;)r>=s.x&&s.x>=h&&r!==s.x&&Ur(i<c?r:o,i,h,c,i<c?o:r,i,s.x,s.y)&&(l=Math.abs(i-s.y)/(r-s.x),(l<u||l===u&&s.x>n.x)&&Vr(s,t)&&(n=s,u=l)),s=s.next;return n}(t,e);if(!s)return e;const r=Hr(s,t);return kr(r,r.next),kr(s,s.next)}function Nr(t,e,s,r){let i;for(;i!==t;i=i.next){if(i=i||t,null===i.z&&(i.z=qr(i.x,i.y,e,s,r)),i.prev.next!==i||i.next.prev!==i)return i.prev.next=i,i.next.prev=i,Nr(t,e,s,r);i.prevZ=i.prev,i.nextZ=i.next}return t.prevZ.nextZ=null,t.prevZ=null,function(t){let e,s=1;for(;;){let r,i=t;t=null,e=null;let n=0;for(;i;){n++,r=i;let o=0;for(;o<s&&r;o++)r=r.nextZ;let a=s;for(;o>0||a>0&&r;){let s;0===o?(s=r,r=r.nextZ,a--):0!==a&&r?i.z<=r.z?(s=i,i=i.nextZ,o--):(s=r,r=r.nextZ,a--):(s=i,i=i.nextZ,o--),e?e.nextZ=s:t=s,s.prevZ=e,e=s}i=r}if(e.nextZ=null,s*=2,n<2)return t}}(t)}function Br(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function Gr(t,e,s,r){return!!(Wr(t,e)&&Wr(s,r)||Wr(t,r)&&Wr(s,e))||Br(t,e,s)>0!=Br(t,e,r)>0&&Br(s,r,t)>0!=Br(s,r,e)>0}function Ur(t,e,s,r,i,n,o,a){return(i-o)*(e-a)-(t-o)*(n-a)>=0&&(t-o)*(r-a)-(s-o)*(e-a)>=0&&(s-o)*(n-a)-(i-o)*(r-a)>=0}function Vr(t,e){return Br(t.prev,t,t.next)<0?Br(t,e,t.next)>=0&&Br(t,t.prev,e)>=0:Br(t,e,t.prev)<0||Br(t,t.next,e)<0}function qr(t,e,s,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Wr(t,e){return t.x===e.x&&t.y===e.y}function jr(t,e){return t.x-e.x}function Yr(t,e,s,r){let i=t;do{const n=i.prev,o=i.next.next;!Wr(n,o)&&Gr(n,i,i.next,o)&&Vr(n,o)&&Vr(o,n)&&(e.push(n.index/s+r),e.push(i.index/s+r),e.push(o.index/s+r),Rr(i),Rr(i.next),i=t=o),i=i.next}while(i!==t);return i}function Xr(t,e,s,r,i,n,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.index!==t.index&&$r(a,t)){let h=Hr(a,t);return a=kr(a,a.next),h=kr(h,h.next),Fr(a,e,s,r,i,n,o,0),void Fr(h,e,s,r,i,n,o,0)}t=t.next}a=a.next}while(a!==t)}function $r(t,e){return t.next.index!==e.index&&t.prev.index!==e.index&&!function(t,e){let s=t;do{if(s.index!==t.index&&s.next.index!==t.index&&s.index!==e.index&&s.next.index!==e.index&&Gr(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&Vr(t,e)&&Vr(e,t)&&function(t,e){let s=t,r=!1;const i=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&i<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(r=!r),s=s.next}while(s!==t);return r}(t,e)}function Hr(t,e){const s=Zr.create(t.index,t.x,t.y),r=Zr.create(e.index,e.x,e.y),i=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=i,i.prev=s,r.next=s,s.prev=r,n.next=r,r.prev=n,r}s(83349);class Zr{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(t,e,s){const r=Kr<Qr.length?Qr[Kr++]:new Zr;return r.index=t,r.x=e,r.y=s,r.prev=null,r.next=null,r.z=null,r.prevZ=null,r.nextZ=null,r.steiner=!1,r}}const Qr=[];let Kr=0;for(let t=0;t<8096;t++)Qr.push(new Zr);const Jr=new Jt.O3(0,0,0,1,0),ti=new Jt.O3(0,0,0,1,0);function ei(t,e,s){let r=0;for(let i=1;i<s;i++){const s=t[2*(e+i-1)],n=t[2*(e+i-1)+1];r+=(t[2*(e+i)]-s)*(t[2*(e+i)+1]+n)}return r}function si(t,e,s,r,i){let n=0;for(let o=s;o<r;o+=3){const s=2*(t[o]-i),r=2*(t[o+1]-i),a=2*(t[o+2]-i);n+=Math.abs((e[s]-e[a])*(e[r+1]-e[s+1])-(e[s]-e[r])*(e[a+1]-e[s+1]))}return n}function ri(t,e){if(null==t)return null;if(!function(t,e,s){let r=0;for(let e=0;e<t.lengths.length;e++){const i=t.lengths[e];for(let e=0;e<i;e++){const i=t.coords[2*(e+r)],n=t.coords[2*(e+r)+1];if(i<-128||i>s||n<-128||n>s)return!0}r+=i}return!1}(t,0,B.CQ+128))return t;Jr.setPixelMargin(e),Jr.reset(Jt.dC.Polygon);let s=0;for(let e=0;e<t.lengths.length;e++){const r=t.lengths[e];let i=t.coords[2*(0+s)],n=t.coords[2*(0+s)+1];Jr.moveTo(i,n);for(let e=1;e<r;e++)i=t.coords[2*(e+s)],n=t.coords[2*(e+s)+1],Jr.lineTo(i,n);Jr.close(),s+=r}const r=Jr.result(!1);if(!r)return null;const i=[],n=[];for(const t of r){let e=0;for(const s of t)n.push(s.x),n.push(s.y),e++;i.push(e)}return new jt.A(i,n)}Jr.setExtent(B.CQ),ti.setExtent(B.CQ);const ii=(0,n.A)("featurelayer-fast-triangulation-enabled");class ni extends wr{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,Tr.F)()])}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);i&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,i),t.recordEnd())}_clip(t){return t?ri(t,this.hasEffects?256:8):null}_writeGeometry(t,e,s){const r=s.maxLength>100,i=[],n=this.createTesselationParams(e);if(!r&&ii&&function(t,e){const{coords:s,lengths:r}=e,i=t;let n=0;for(let t=0;t<r.length;){let e=t,o=r[t],a=ei(s,n,o);const h=[];for(;++e<r.length;){const t=r[e],i=ei(s,n+o,t);if(!(i>0))break;a+=i,h.push(n+o),o+=t}const c=i.length;Ar(i,s,n,n+o,h,2,0);const l=si(i,s,c,i.length,0),u=Math.abs(a);if(Math.abs((l-u)/Math.max(1e-7,u))>1e-5)return i.length=0,!1;t=e,n+=o}return!0}(i,s))return void(i.length&&this._writeVertices(t,e,s.coords,n,i));const o=function(t){const{coords:e,lengths:s}=t,{buffer:r}=(0,Tr.l)(e,s);return r}(s);this._writeVertices(t,e,o,n)}_writeVertices(t,e,s,r,i){const n=e.getDisplayId(),o=t.vertexCount(),a=this.hasEffects;let h=0;if(i)for(const e of i){const i=s[2*e],o=s[2*e+1];a&&t.recordBounds(i,o,0,0),this._writeVertex(t,n,i,o,r),h++}else for(let e=0;e<s.length;e+=2){const i=Math.round(s[e]),o=Math.round(s[e+1]);a&&t.recordBounds(i,o,0,0),this._writeVertex(t,n,i,o,r),h++}t.indexEnsureSize(h);for(let e=0;e<h;e++)t.indexWrite(e+o)}}const oi={createComputedParams:t=>t,optionalAttributes:{},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:dt.pe.FLOAT,count:1,packTessellation:({inverseArea:t})=>t}}};class ai extends ni{constructor(){super(...arguments),this.vertexSpec=oi}createTesselationParams(t){return{inverseArea:1/t.readGeometryArea()}}}const hi={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)}}};class ci extends ni{constructor(){super(...arguments),this.vertexSpec=hi}createTesselationParams(t){return null}}const li={createComputedParams:t=>t,optionalAttributes:hi.optionalAttributes,attributes:{...hi.attributes,tlbr:{count:4,type:dt.pe.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM,n=e.y+B.hM;return[i,n,i+s,n+r]}},inverseRasterizationScale:{count:1,type:dt.pe.BYTE,packPrecisionFactor:16,pack:({sprite:t})=>1/t.rasterizationScale}}};class ui extends ci{constructor(){super(...arguments),this.vertexSpec=li}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),t.recordEnd()}}function di(t){const{sprite:e,aspectRatio:s,scaleProportionally:r}=t,i=(0,l.Lz)(t.height),n=i>0?i:e.height;let o=i*s;return o<=0?o=e.width:r&&(o*=e.width/e.height),{width:o,height:n}}function _i(t){const{applyRandomOffset:e,sampleAlphaOnly:s}=t;return Et([[2,e],[4,s]])}const pi={createComputedParams:t=>t,optionalAttributes:li.optionalAttributes,attributes:{...li.attributes,bitset:{count:1,type:dt.pe.UNSIGNED_BYTE,pack:_i},width:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).width},height:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).height},offset:{count:2,type:dt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),-(0,l.Lz)(e)]},scale:{count:2,type:dt.pe.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:t,scaleY:e})=>[t,e]},angle:{count:1,type:dt.pe.UNSIGNED_BYTE,pack:({angle:t})=>(0,nr.wV)(t)}}};class fi extends ui{constructor(){super(...arguments),this.vertexSpec=pi}}var gi=s(83773);class mi{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0,this.pathLength=0}}const yi={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)},offset:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[Rt(t,16),Rt(e,16)]},normal:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:t,normalY:e})=>[Rt(t,16),Rt(e,16)]},halfWidth:{type:dt.pe.HALF_FLOAT,count:1,pack:({width:t})=>(0,l.Lz)(.5*t)},referenceHalfWidth:{type:dt.pe.HALF_FLOAT,count:1,pack:({referenceWidth:t})=>(0,l.Lz)(.5*t)}}};class bi{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0,this.pathLength=0}}class wi extends wr{constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=yi,this._currentWrite=new bi,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new mi,this._initializeTessellator()}writeLineVertices(t,e,s){const r=this._getLines(e);null!=r&&this._writeVertices(t,s,r)}_initializeTessellator(){this._lineTessellator=new gi.i(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(t,e,s){const r=s??Yt.fromFeatureSetReaderCIM(e);r&&this._writeGeometry(t,e,r)}_writeGeometry(t,e,s,r){t.recordStart(this.instanceId,this.attributeLayout,r),this.writeLineVertices(t,s,e),t.recordEnd()}_getLines(t){return function(t,e){ti.setPixelMargin(e);const s=ti,r=-e,i=B.CQ+e;let n=[],o=!1;if(!t.nextPath())return null;let a=t.pathLength(),h=!0;for(;h;){t.seekPathStart();const e=[];if(!t.pathSize)return null;s.reset(Jt.dC.LineString),t.nextPoint();let c=t.x,l=t.y;if(o)s.moveTo(c,l);else{if(c<r||c>i||l<r||l>i){o=!0;continue}e.push({x:c,y:l})}let u=!1;for(;t.nextPoint();)if(c=t.x,l=t.y,o)s.lineTo(c,l);else{if(c<r||c>i||l<r||l>i){u=!0;break}e.push({x:c,y:l})}if(u)o=!0;else{if(o){const t=s.resultWithStarts();if(t)for(const e of t)n.push({...e,pathLength:a})}else n.push({line:e,start:0,pathLength:a});h=t.nextPath(),a=h?t.pathLength():0,o=!1}}return n=n.filter((t=>t.line.length>1)),0===n.length?null:n}(t,gr(this.evaluatedMeshParams))}_writeVertices(t,e,s){const{_currentWrite:r,_tessellationOptions:i,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:h,miterLimit:c,hasSizeVV:u}=n,d=(0,l.Lz)(.5*o);i.halfWidth=d,i.capType=function(t){switch(t){case"butt":case Ct.uT.Butt:return Ct.xR.BUTT;case"round":case Ct.uT.Round:return Ct.xR.ROUND;case"square":case Ct.uT.Square:return Ct.xR.SQUARE}}(a),i.joinType=function(t){switch(t){case"bevel":case Ct.wd.Bevel:return Ct.JO.BEVEL;case"miter":case Ct.wd.Miter:return Ct.JO.MITER;case"round":case Ct.wd.Round:return Ct.JO.ROUND}}(h),i.miterLimit=c;const _=!u;r.out=t,r.id=e.getDisplayId(),r.vertexCount=0,r.indexCount=0,r.vertexFrom=t.vertexCount(),r.vertexBounds=_&&d<B.Gh?0:1;for(const{line:t,start:e,pathLength:n}of s)i.initialDistance=e%65535,r.pathLength=n,this._lineTessellator.tessellate(t,i,_)}_writeTesselatedVertex(t,e,s,r,i,n,o,a,h,c,l){const{out:u,id:d,vertexBounds:_,pathLength:p}=this._currentWrite;return this.hasEffects&&u.recordBounds(t,e,_,_),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=c,this._tessParams.directionX=i,this._tessParams.directionY=n,this._tessParams.distance=l,this._tessParams.pathLength=p,this._writeVertex(u,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,s){const{out:r}=this._currentWrite;r.indexEnsureSize(3),r.indexWrite(t),r.indexWrite(e),r.indexWrite(s),this._currentWrite.indexCount+=3}}const xi={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)}}},vi={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>Et([[0,!0]])},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>zt(t)}}};class Si extends wi{constructor(){super(...arguments),this.vertexSpec=vi}}class Ii extends ci{constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=xi,this._lineMeshWriter=this._createOutlineWriter(t,e,s,r)}_createOutlineWriter(t,e,s,r){return new Si(t,e,s,r)}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);i&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,i),this._lineMeshWriter.writeLineVertices(t,Yt.fromOptimizedCIM(i,"esriGeometryPolyline"),e),t.recordEnd())}_clip(t){return t?ri(t,gr(this.evaluatedMeshParams)):null}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}var Mi=s(46263),Pi=s(620);class Ti{constructor(){this._includedModules=new Map}include(t,e){this._includedModules.has(t)?this._includedModules.get(t):(this._includedModules.set(t,e),t(this.builder,e))}}class Ai extends Ti{constructor(){super(...arguments),this.vertex=new Fi,this.fragment=new Fi,this.attributes=new Ei,this.varyings=new zi,this.extensions=new Oi,this.constants=new Ri}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(t,e=!0){const s=this.extensions.generateSource(t),r=this.attributes.generateSource(t),i=this.varyings.generateSource(t),n="vertex"===t?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),h="vertex"===t?Di:"#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp sampler2D;\n#else\n precision mediump float;\n precision mediump sampler2D;\n#endif\n",c=this.constants.generateSource().concat(n.constants.generateSource());return`${e?"#version 300 es":""}\n${s.join("\n")}\n${h}\n${c.join("\n")}\n${o.join("\n")}\n${r.join("\n")}\n${i.join("\n")}\n${a.join("\n")}`}generateBindPass(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Pass];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Pass];s&&e.set(t.name,s)}));const s=Array.from(e.values()),r=s.length;return(e,i)=>{for(let n=0;n<r;++n)s[n](t,e,i)}}generateBindDraw(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Draw];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[Mi.c.Draw];s&&e.set(t.name,s)}));const s=Array.from(e.values()),r=s.length;return(e,i,n)=>{for(let o=0;o<r;++o)s[o](t,n,e,i)}}}class Ci{constructor(){this._entries=new Map}add(...t){for(const e of t)this._add(e)}get(t){return this._entries.get(t)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new r.A(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else E.A.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder").error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((t=>null!=t.arraySize?`uniform ${t.type} ${t.name}[${t.arraySize}];`:`uniform ${t.type} ${t.name};`))}get entries(){return Array.from(this._entries.values())}}class ki{constructor(){this._entries=new Array}add(t){this._entries.push(t)}generateSource(){return this._entries}}class Fi extends Ti{constructor(){super(...arguments),this.uniforms=new Ci,this.code=new ki,this.constants=new Ri}get builder(){return this}}class Ei{constructor(){this._entries=new Array}add(t,e){this._entries.push([t,e])}generateSource(t){return"fragment"===t?[]:this._entries.map((t=>`in ${t[1]} ${t[0]};`))}}class zi{constructor(){this._entries=new Map}add(t,e){this._entries.has(t)&&(0,Pi.vA)(this._entries.get(t)===e),this._entries.set(t,e)}generateSource(t){const e=new Array;return this._entries.forEach(((s,r)=>e.push("vertex"===t?`out ${s} ${r};`:`in ${s} ${r};`))),e}}class Oi{constructor(){this._entries=new Set}add(t){this._entries.add(t)}generateSource(t){const e="vertex"===t?Oi.ALLOWLIST_VERTEX:Oi.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((t=>e.includes(t))).map((t=>`#extension ${t} : enable`))}}Oi.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],Oi.ALLOWLIST_VERTEX=[];class Ri{constructor(){this._entries=new Set}add(t,e,s){let r="ERROR_CONSTRUCTOR_STRING";switch(e){case"float":r=Ri._numberToFloatStr(s);break;case"int":r=Ri._numberToIntStr(s);break;case"bool":r=s.toString();break;case"vec2":r=`vec2(${Ri._numberToFloatStr(s[0])}, ${Ri._numberToFloatStr(s[1])})`;break;case"vec3":r=`vec3(${Ri._numberToFloatStr(s[0])}, ${Ri._numberToFloatStr(s[1])}, ${Ri._numberToFloatStr(s[2])})`;break;case"vec4":r=`vec4(${Ri._numberToFloatStr(s[0])}, ${Ri._numberToFloatStr(s[1])}, ${Ri._numberToFloatStr(s[2])}, ${Ri._numberToFloatStr(s[3])})`;break;case"ivec2":r=`ivec2(${Ri._numberToIntStr(s[0])}, ${Ri._numberToIntStr(s[1])})`;break;case"ivec3":r=`ivec3(${Ri._numberToIntStr(s[0])}, ${Ri._numberToIntStr(s[1])}, ${Ri._numberToIntStr(s[2])})`;break;case"ivec4":r=`ivec4(${Ri._numberToIntStr(s[0])}, ${Ri._numberToIntStr(s[1])}, ${Ri._numberToIntStr(s[2])}, ${Ri._numberToIntStr(s[3])})`;break;case"mat2":case"mat3":case"mat4":r=`${e}(${Array.prototype.map.call(s,(t=>Ri._numberToFloatStr(t))).join(", ")})`}return this._entries.add(`const ${e} ${t} = ${r};`),this}static _numberToIntStr(t){return t.toFixed(0)}static _numberToFloatStr(t){return Number.isInteger(t)?t.toFixed(1):t.toString()}generateSource(){return Array.from(this._entries)}}const Di="precision highp float;\nprecision highp sampler2D;";function Li(t,e){const s=[];for(s.push(e);s.length;){const e=s.pop();if("object"==typeof e&&!t.has(e.uid)){t.add(e.uid);for(const t of e.children)s.push(t)}}}class Ni{constructor(){this.uid=Ni.NodeCount++,this._debugName=null,this._isMutable=!1,this.isImplicit=!1}get isMutable(){return this._isMutable}setMutable(){return this._isMutable=!0,this}setDebugName(t){return t=function(t){return t.split(" ").map(((t,e)=>e>0?t.charAt(0).toUpperCase()+t.slice(1):t)).join("")}(t),this._debugName=t,this.isImplicit&&this.children[0]instanceof Ni&&this.children[0].setDebugName(t),this}get debugInfo(){return{name:this._debugName??""}}cloneInto(t){t._debugName=this._debugName,t._isMutable=this._isMutable,t.isImplicit=this.isImplicit,t.uid=this.uid}}function Bi(t){return"object"==typeof t?t.clone():t}Ni.NodeCount=0;class Gi extends Ni{constructor(){super(...arguments),this.shaderType="primitive-node"}}class Ui extends Ni{constructor(t){super(),this.child=t,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const t=new Ui(Bi(this.child));return this.cloneInto(t),t}}class Vi extends Ni{constructor(t,e,s){super(),this.property=t,this.target=e,this.returnType=s,this.shaderType="property-access-node"}get children(){const t=[this.target];return"string"!=typeof this.property&&t.push(this.property),t}clone(){const t=new Vi(this.property,Bi(this.target),this.returnType);return this.cloneInto(t),t}}class qi extends Ni{constructor(t,e,s,r){super(),this.x=t,this.y=e,this.target=s,this.returnType=r,this.shaderType="property-access-2d-node"}get children(){return[this.target,this.x,this.y]}clone(){const t=new qi(this.x,this.y,Bi(this.target),this.returnType);return this.cloneInto(t),t}}class Wi extends Ni{constructor(t,e,s){super(),this.condition=t,this.ifTrue=e,this.ifFalse=s,this.shaderType="condition-node"}get children(){return[this.condition,this.ifTrue,this.ifFalse]}clone(){const t=Bi(this.ifTrue),e=this.ifFalse?Bi(this.ifFalse):null,s=new Wi(this.condition,t,e);return this.cloneInto(s),s}}class ji extends Ni{constructor(t,e,s,r){super(),this.captureList=t,this.returnType=e,this.generator=r,this.shaderType="block-node",s&&(this.subgraph=new Ui(s))}get children(){return Object.keys(this.captureList).map((t=>this.captureList[t])).concat(this.subgraph??[])}clone(){const t={};for(const e in this.captureList)t[e]=Bi(this.captureList[e]);const e=new ji(t,this.returnType,this.subgraph?Bi(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(e),e}}class Yi extends Ni{constructor(t,e,s,r,i,n=!1){super(),this.token=t,this._children=e,this.isInfix=s,this.isPropertyAccess=r,this.returnType=i,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const t=new Yi(this.token,this._children.map(Bi),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(t),t}}var Xi,$i,Hi,Zi,Qi,Ki,Ji,tn,en,sn,rn,nn,on,an;function hn(t){return new Proxy(t,{get(e,s){if("constructor"===s)return new Proxy(e.constructor,{construct:(t,e,s)=>hn(new t(...e))});if(s in e)return e[s];if("string"==typeof s){const e=function(t){const e=[["float","vec2","vec3","vec4"],["int","ivec2","ivec3","ivec4"],["uint","uvec2","uvec3","uvec4"],["bool","bvec2","bvec3","bvec4"]];for(const s of e)if(s.includes(t))return s.map((t=>On[t]));throw new Error("Unable to find type family")}(t.type);return Bn(t,s,e[s.length-1])}}})}function cn(t){return new Proxy(t,{construct:(t,e,s)=>hn(new t(...e))})}class ln extends Error{}let un=Xi=class extends Gi{constructor(t,e){super(),this.elementType=t,this.size=e,this.children=[],this.type="array"}clone(){const t=new Xi(this.elementType,this.size);return super.cloneInto(t),t}get(t,e){const s=new Tn(t),r=null!=e?new Tn(e):null;return null!=r?Gn(this,s,r,function(t){switch(t.type){case"bool":case"bvec2":case"bvec3":case"bvec4":return vn;case"float":case"vec2":case"vec3":case"vec4":return pn;case"int":case"ivec2":case"ivec3":case"ivec4":return Tn;case"uint":case"uvec2":case"uvec3":case"uvec4":return yn;default:throw new Error("Unable to handle type")}}(this.elementType.constructor)):Bn(this,s,this.elementType.constructor)}last(){return this.get(this.size-1)}first(){return this.get(0)}findIndex(t,e,s){return function(t,e,s=0,r=t.size){const i=new Tn(s).setMutable().setDebugName("FindIndexIterator"),n=e(t.get(i)).setDebugName("FindIndexPredicate"),o=Yn({iter:i},Tn,n,(({out:t,iter:e,subgraph:s})=>`\n${t} = -1;\n\nfor (; ${e} < ${r}; ${e}++) {\n\n${s.body}\n\n if (${s.varName}) {\n ${t} = ${e};\n break;\n }\n\n}\n`)).setDebugName("FindIndexBlock");return o}(this,t,e,s)}glslFindIndex(t,e,s){return function(t,e,s=0,r=t.size){const i=Yn({array:t},Tn,null,(({out:t,array:i})=>`\n${t} = -1;\nfor (int i = ${s}; i < ${r}; i++) {\n bool condition;\n ${e({array:i,i:"i",out:"condition"})}\n if (condition) {\n ${t} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return i}(this,t,e,s)}static ofType(t,e){const s={construct:(s,r)=>new Xi(new t,e)};return new Proxy(Xi,s)}};un.type="array",un=Xi=(0,P._)([function(t){return new Proxy(t,{construct:(t,e,s)=>function(t){return new Proxy(t,{get(e,s){if(s in e)return e[s];if("string"==typeof s){const e=parseInt(s,10);if(!isNaN(e))return Bn(t,`[${e}]`,t.elementType.constructor)}}})}(new t(...e))})}],un);class dn extends Gi{constructor(t,e,s,r=!1){super(),this.elementType=t,this.xSize=e,this.ySize=s,this.isRowMajor=r,this.children=[],this.type="array-2d"}clone(){const t=new dn(this.elementType,this.xSize,this.ySize,this.isRowMajor);return super.cloneInto(t),t}get size(){return this.xSize*this.ySize}get(t,e){return this.isRowMajor?this._getRowMajor(t,e):this._getColumnMajor(t,e)}_getColumnMajor(t,e){const s=new Tn(t);return Bn(this,new Tn(e).add(s.multiply(this.xSize)),this.elementType.constructor)}_getRowMajor(t,e){const s=new Tn(t),r=new Tn(e);return Bn(this,s.add(r.multiply(this.ySize)),this.elementType.constructor)}static ofType(t,e,s,r=!1){return new Proxy(un,{construct:(i,n)=>new dn(new t,e,s,r)})}}dn.type="array-2d";class _n extends Gi{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const t=new _n;return t.children=this.children.map(Bi),super.cloneInto(t),t}}_n.type="sampler2D";class pn extends Gi{constructor(t){super(),this.type="float",this.children=[t]}clone(){const t=new pn(Bi(this.children[0]));return super.cloneInto(t),t}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}}pn.type="float";let fn=$i=class extends Gi{constructor(t,e){super(),this.type="vec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new $i(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}get 0(){return Bn(this,"[0]",pn)}get 1(){return Bn(this,"[1]",pn)}get 2(){throw new ln}get 3(){throw new ln}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}};fn.type="vec2",fn=$i=(0,P._)([cn],fn);let gn=Hi=class extends Gi{constructor(t,e,s){super(),this.type="vec3",this.children=[t,e,s].filter((t=>null!=t))}get 0(){return Bn(this,"[0]",pn)}get 1(){return Bn(this,"[1]",pn)}get 2(){return Bn(this,"[2]",pn)}get 3(){throw new ln}clone(){const t=new Hi(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}};gn.type="vec3",gn=Hi=(0,P._)([cn],gn);let mn=Zi=class extends Gi{constructor(t,e,s,r){super(),this.type="vec4",this.children=[t,e,s,r].filter((t=>null!=t))}clone(){const t=new Zi(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}get 0(){return Bn(this,"[0]",pn)}get 1(){return Bn(this,"[1]",pn)}get 2(){return Bn(this,"[2]",pn)}get 3(){return Bn(this,"[3]",pn)}multiply(t){return Hn(this,"number"==typeof t?Mn(t,pn):t)}divide(t){return Zn(this,"number"==typeof t?Mn(t,pn):t)}add(t){return Qn(this,"number"==typeof t?Mn(t,pn):t)}subtract(t){return Kn(this,"number"==typeof t?Mn(t,pn):t)}};mn.type="vec4",mn=Zi=(0,P._)([cn],mn);let yn=Qi=class extends Gi{constructor(t){super(),this.type="uint",this.children=[t]}clone(){const t=new Qi(Bi(this.children[0]));return super.cloneInto(t),t}};yn.type="uint",yn=Qi=(0,P._)([cn],yn);let bn=Ki=class extends Gi{constructor(t,e){super(),this.type="uvec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new Ki(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}};bn.type="uvec2",bn=Ki=(0,P._)([cn],bn);let wn=Ji=class extends Gi{constructor(t,e,s){super(),this.type="uvec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new Ji(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}};wn.type="uvec3",wn=Ji=(0,P._)([cn],wn);let xn=tn=class extends Gi{constructor(t,e,s,r){super(),this.type="uvec4",this.children=[t,e,s,r].filter((t=>null!=t))}clone(){const t=new tn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}};xn.type="uvec4",xn=tn=(0,P._)([cn],xn);class vn extends Gi{constructor(t){super(),this.type="bool",this.children=[t]}and(t){return io(this,t)}or(t){return ro(this,t)}clone(){const t=new vn(Bi(this.children[0]));return super.cloneInto(t),t}}vn.type="bool";let Sn=en=class extends Gi{constructor(t,e){super(),this.type="bvec2",this.children=[t,e].filter((t=>null!=t))}all(){return no(this)}any(){return oo(this)}clone(){const t=new en(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}};Sn.type="bvec2",Sn=en=(0,P._)([cn],Sn);let In=sn=class extends Gi{constructor(t,e,s){super(),this.type="bvec3",this.children=[t,e,s].filter((t=>null!=t))}all(){return no(this)}any(){return oo(this)}clone(){const t=new sn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}};function Mn(t,e){return"number"==typeof t?new e(t):t}In.type="bvec3",In=sn=(0,P._)([cn],In);let Pn=rn=class extends Gi{constructor(t,e,s,r){super(),this.type="bvec4",this.children=[t,e,s,r].filter((t=>null!=t))}all(){return no(this)}any(){return oo(this)}clone(){const t=new rn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}};Pn.type="bvec4",Pn=rn=(0,P._)([cn],Pn);class Tn extends Gi{constructor(t){super(),this.type="int",this.children=[t]}multiply(t){return Hn(this,Mn(t,Tn))}add(t){return Qn(this,Mn(t,Tn))}subtract(t){return Kn(this,Mn(t,Tn))}divide(t){return Zn(this,Mn(t,Tn))}clone(){const t=new Tn(Bi(this.children[0]));return super.cloneInto(t),t}}Tn.type="int";let An=nn=class extends Gi{constructor(t,e){super(),this.type="ivec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new nn(Bi(this.children[0]),Bi(this.children[1]));return super.cloneInto(t),t}};An.type="ivec2",An=nn=(0,P._)([cn],An);let Cn=on=class extends Gi{constructor(t,e,s){super(),this.type="ivec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new on(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]));return super.cloneInto(t),t}};Cn.type="ivec3",Cn=on=(0,P._)([cn],Cn);let kn=an=class extends Gi{constructor(t,e,s,r){super(),this.type="ivec4",this.children=[t,e,s,r].filter((t=>null!=t))}clone(){const t=new an(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}};kn.type="ivec4",kn=an=(0,P._)([cn],kn);class Fn extends Gi{constructor(t,e,s,r){super(),this.type="mat2",this.children=[t,e,s,r]}clone(){const t=new Fn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]));return super.cloneInto(t),t}get(t,e){return Gn(this,new Tn(t),new Tn(e),pn)}multiply(t){return Hn(this,t)}}Fn.type="mat2";class En extends Gi{static identity(){return new En(1,0,0,0,1,0,0,0,1)}static fromRotation(t){const e=yo(t),s=ho(t);return new En(s,e,0,jn(e),s,0,0,0,1)}constructor(t,e,s,r,i,n,o,a,h){super(),this.type="mat3",this.children=[t,e,s,r,i,n,o,a,h]}add(t){return Qn(this,t)}multiply(t){return Hn(this,t)}get(t,e){return Gn(this,new Tn(t),new Tn(e),pn)}clone(){const t=new En(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]),Bi(this.children[4]),Bi(this.children[5]),Bi(this.children[6]),Bi(this.children[7]),Bi(this.children[8]));return super.cloneInto(t),t}}En.type="mat3";class zn extends Gi{static identity(){return new zn(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t,e,s,r,i,n,o,a,h,c,l,u,d,_,p,f){super(),this.type="mat4",this.children=[t,e,s,r,i,n,o,a,h,c,l,u,d,_,p,f]}static fromColumns(t,e,s,r){return new zn(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,s.x,s.y,s.z,s.w,r.x,r.y,r.z,r.w)}multiply(t){return Hn(this,t)}get(t,e){return Gn(this,new Tn(t),new Tn(e),pn)}clone(){const t=new zn(Bi(this.children[0]),Bi(this.children[1]),Bi(this.children[2]),Bi(this.children[3]),Bi(this.children[4]),Bi(this.children[5]),Bi(this.children[6]),Bi(this.children[7]),Bi(this.children[8]),Bi(this.children[9]),Bi(this.children[10]),Bi(this.children[11]),Bi(this.children[12]),Bi(this.children[13]),Bi(this.children[14]),Bi(this.children[15]));return super.cloneInto(t),t}}zn.type="mat4";const On={float:pn,vec2:fn,vec3:gn,vec4:mn,int:Tn,ivec2:An,ivec3:Cn,ivec4:kn,uint:yn,uvec2:bn,uvec3:wn,uvec4:xn,bool:vn,bvec2:Sn,bvec3:In,bvec4:Pn},Rn=(...t)=>new Tn(...t),Dn=(...t)=>new pn(...t),Ln=(...t)=>new fn(...t),Nn=(...t)=>new En(...t);function Bn(t,e,s){const r=new s(new Vi(e,t,s));return r.isImplicit=!0,r}function Gn(t,e,s,r){const i=new r(new qi(e,s,t,r));return i.isImplicit=!0,i}function Un(t,e,s,r=null){if(r){const i=new r,n=new r(new Yi(t,[e,s],!0,!1,i));return n.isImplicit=!0,n}if("float"===e.type||"int"===e.type){const r=new s.constructor(new Yi(t,[e,s],!0,!1,s.constructor));return r.isImplicit=!0,r}if(("mat2"===e.type||"mat3"===e.type||"mat4"===e.type)&&"float"!==s.type){const r=new s.constructor(new Yi(t,[e,s],!0,!1,s.constructor));return r.isImplicit=!0,r}const i=new e.constructor(new Yi(t,[e,s],!0,!1,e.constructor));return i.isImplicit=!0,i}function Vn(t,e,s=e.constructor){const r=new s(new Yi(t,[e],!1,!1,s));return r.isImplicit=!0,r}function qn(t,e,s,r=e.constructor){const i=new r(new Yi(t,[e,s],!1,!1,r));return i.isImplicit=!0,i}function Wn(t,e,s,r,i=e.constructor){const n=new i(new Yi(t,[e,s,r],!1,!1,i));return n.isImplicit=!0,n}function jn(t){return Hn(t,Dn(-1))}function Yn(t,e,s,r){return new e(new ji(t,e,s,r))}function Xn(t,e,s){const r="function"==typeof e?e():e,i="function"==typeof s?s():s,n=new r.constructor(new Wi(t,r,i));return n.isImplicit=!0,n}function $n(...t){const e=t.map((([t,e])=>"function"==typeof e?[t,e()]:[t,e])),s=e[0][1].constructor,r=e.findIndex((t=>!0===t[0]));if(-1===r)throw new Error("A cond must have a fallthrough case with `true`/; ");const i=e.slice(0,r),n=e[r][1],o=new s(i.reduceRight(((t,e)=>Xn(e[0],e[1],t)),n));return o.isImplicit=!0,o}function Hn(t,e){return Un("*",t,e)}function Zn(t,e){return Un("/",t,e)}function Qn(t,e){return Un("+",t,e)}function Kn(t,e){return Un("-",t,e)}function Jn(t,e){return Un("==",t,e,vn)}function to(t,e){return Un("<=",t,e,vn)}function eo(t,e){return Un(">",t,e,vn)}function so(t,e){return Un(">=",t,e,vn)}function ro(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Un("||",t,e,vn)}(t,e)),t[0])}function io(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Un("&&",t,e,vn)}(t,e)),t[0])}function no(t){return Vn("all",t,vn)}function oo(t){return Vn("any",t,vn)}function ao(t,e,s){return Wn("clamp",t,e,s,t.constructor)}function ho(t){return Vn("cos",t)}function co(t,e){return qn("dot",t,e,pn)}function lo(t){return Vn("fract",t)}function uo(t){return Vn("length",t,pn)}function _o(t,e){return qn("max",t,e)}function po(t,e){return qn("min",t,e)}function fo(t,e,s){return Wn("mix",t,e,s)}function go(t,e){return qn("mod",t,e)}function mo(t){return"bool"===t.type?Vn("!",t):Vn("not",t)}function yo(t){return Vn("sin",t)}function bo(t,e){return qn("step",t,e,e.constructor)}function wo(t,e){return qn("texture",t,e,mn)}function xo(t,e,s){const r=e.split("\n");for(const e of r)if(e.trim().length){{let e="";null!=s&&(e+=`/*id:${s??"000"}*/ `),t.body+=e.padEnd(14)}t.body+=" ".repeat(t.indent)+e+"\n"}}class vo{write(t){for(const e of t.rootOutputNodes())t.shouldPruneOutputNode(e)||(e.variableName=this._write(t,e.node));return t}_createVarName(t,e){let s="";return"boolean"!=typeof e&&"number"!=typeof e&&e.debugInfo.name&&(s=`${e.debugInfo.name}_`),`${s}v${t.varCount++}`}_write(t,e,s=!1){if("number"==typeof e)return e.toString();if("boolean"==typeof e)return e.toString();let r=t.getEmit(e);if(r)return r;switch(e.shaderType){case"scope-node":r=this._writeScopeNode(t,e);break;case"primitive-node":r=this._writePrimitiveNode(t,e,s);break;case"function-node":r=this._writeFunctionNode(t,e);break;case"property-access-node":r=this._writePropertyAccessNode(t,e);break;case"property-access-2d-node":r=this._writePropertyAccess2DNode(t,e);break;case"text-node":r=e.text;break;case"block-node":r=this._writeBlockNode(t,e);break;case"condition-node":r=this._writeConditionNode(t,e)}return t.setEmit(e,r),r}_writeScopeNode(t,e){const s=new e.child.constructor;s.setDebugName(e.debugInfo.name);const r=this._write(t,s,!0);return xo(t,`{ /*ScopeStart: ${e.uid} ${e.debugInfo.name}*/`),t.indent+=2,xo(t,`${r} = ${this._write(t,e.child)};`),t.indent-=2,xo(t,`} /*ScopeEnd: ${e.uid} ${e.debugInfo.name}*/`),r}_writeConditionNode(t,e){const s=new e.ifTrue.constructor,r=this._write(t,s,!0);xo(t,`if (${this._write(t,e.condition)}) {`),t.indent+=2;const i=t.createSubgraphContext(),n=this._write(i,e.ifTrue);if(t.body+=i.body,n&&xo(t,`${r} = ${n};`),t.indent-=2,xo(t,"}"),e.ifFalse){xo(t,"else {"),t.indent+=2;const s=t.createSubgraphContext(),i=this._write(s,e.ifFalse);t.body+=s.body,i&&xo(t,`${r} = ${i};`),t.indent-=2,xo(t,"}")}return r}_writeBlockNode(t,e){const{captureList:s,generator:r,returnType:i}=e,n={};for(const e in s){if(!s[e])continue;const r=this._write(t,s[e]);n[e]=r}const o=new i,a=this._write(t,o,!0);if(n.out=a,e.subgraph){const s=t.createSubgraphContext(),r=this._write(s,e.subgraph.child),i=s.body;n.subgraph={varName:r,body:i}}const h=r(n);return xo(t,"{\n"),t.indent+=2,xo(t,h),t.indent-=2,xo(t,"}\n"),a}_writePropertyAccessNode(t,e){const s=this._write(t,e.target);return"string"==typeof e.property&&e.property.includes("[")?`${s}${e.property}`:"string"!=typeof e.property?`${s}[${this._write(t,e.property)}]`:`${s}.${e.property}`}_writePropertyAccess2DNode(t,e){return`${this._write(t,e.target)}[${this._write(t,e.x)}][${this._write(t,e.y)}]`}_writeFunctionNode(t,e){const s=e.returnType.type;if(e.isInfix){const[r,i]=e.children.map((e=>this._write(t,e))),n=this._createVarName(t,e);return xo(t,`${s.padEnd(5)} ${n} = ${r} ${e.token} ${i};`,e.uid),n}const r=e.children.map((e=>this._write(t,e))).join(", "),i=this._createVarName(t,e);return xo(t,`${s.padEnd(5)} ${i} = ${e.token}(${r});`,e.uid),i}_writePrimitiveNode(t,e,s=!1){const r=t.getInput(e);if(r)return r.isUsed=!0,r.variableName;const i=1===e.children.length&&e.children[0]?.type===e.type;if(!e.isMutable&&(e.isImplicit||i))return this._write(t,e.children[0]);const n=this._createVarName(t,e);if(s)return xo(t,`${e.type.padEnd(5)} ${n};`,e.uid),n;const o=!e.debugInfo.name&&!e.isMutable;if(o&&"float"===e.type&&"number"==typeof e.children[0])return Number.isInteger(e.children[0])?e.children[0].toFixed(1):e.children[0].toString();if(o&&"int"===e.type&&"number"==typeof e.children[0]&&Number.isInteger(e.children[0]))return e.children[0].toString();const a=e.children.map((e=>this._write(t,e))).join(", ");return"array"===e.type?(xo(t,`${e.type.padEnd(5)} ${n} = [${a}];`,e.uid),n):o?`${e.type}(${a})`:(xo(t,`${e.type.padEnd(5)} ${n} = ${e.type}(${a});`,e.uid),n)}}class So{constructor(t,e,s){this.variableName=t,this.variableInputType=e,this.node=s,this.type="shader-input",this.isUsed=!1}clone(){return new So(this.variableName,this.variableInputType,Bi(this.node))}}class Io{constructor(t,e,s){this.outVariableName=t,this.outVariableType=e,this.node=s,this.type="shader-output"}clone(){const t=new Io(this.outVariableName,this.outVariableType,Bi(this.node));return t.variableName=this.variableName,t}}class Mo{static createVertex(t,e,s,r,i,n){const o=[];for(const e in t){const r=t[e],i=s.get(e);i?o.push(new So(i,"builtin",r)):o.push(new So("a_"+e,"in",r))}for(const t of r){const e=t.uniformHydrated;o.push(new So(t.uniformName,"uniform",e))}const a=[];for(const t in e){const s=e[t];"glPosition"===t?a.push(new Io("gl_Position","builtin",s)):"glPointSize"===t?a.push(new Io("gl_PointSize","builtin",s)):a.push(new Io("v_"+t,"out",s))}return new Mo(o,a,i,n)}static createFragment(t,e,s,r,i,n){const o=[],a=Array.from(i.rootOutputNodes());for(const e in t){const r=t[e],i=s.get(e);if(i){o.push(new So(i,"builtin",r));continue}const n=a.find((t=>t.node===r));n&&o.push(new So(n.outVariableName,"in",r))}for(const t of r){const e=t.uniformHydrated;o.push(new So(t.uniformName,"uniform",e))}const h=[];for(const t in e){const r=e[t],i=s.get(t);"discard"===t?h.push(new Io(null,"discard",r)):i?h.push(new Io(i,"builtin",r)):h.push(new Io(t,"out",r))}return new Mo(o,h,n)}constructor(t,e,s,r){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const e of t)this._inputShaderTypesByNodeUid.set(e.node.uid,e);this._outputShaderTypes=e,this._transformFeedbackBindings=s,this._transformFeedbackNames=new Set(s.map((t=>"v_"+t.propertyKey))),this._usedInFragmentShader=r}shouldPruneOutputNode(t){return!!this._usedInFragmentShader&&"builtin"!==t.outVariableType&&!this._transformFeedbackNames.has(t.outVariableName)&&!this._usedInFragmentShader.has(t.node.uid)}setEmit(t,e){this._nodeEmitMap.set(t.uid,e)}getEmit(t){return this._nodeEmitMap.get(t.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(t){return this._inputShaderTypesByNodeUid.get(t.uid)}*rootOutputNodes(){for(const t of this._outputShaderTypes)yield t}*nodes(){const t=[];for(const e of this._outputShaderTypes.values())t.push(e.node);for(;t.length;){const e=t.pop();"number"!=typeof e&&"boolean"!=typeof e&&t.push(...e.children.filter(Boolean)),yield e}}*nodesOfTypeOrFunction(){for(const t of this.nodes())"number"!=typeof t&&"boolean"!=typeof t&&(yield t)}createSubgraphContext(){const t=this.clone();return t.body="",t.indent=this.indent+2,t._nodeEmitMap=new Map(this._nodeEmitMap),t}clone(){const t=new Mo([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return t._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,t.indent=this.indent,t.body=this.body,t.varCount=this.varCount,t._nodeEmitMap=this._nodeEmitMap,t}insertVertexShader(t){t.vertex.code.add(""),this._insertInputs(t,"vertex"),t.vertex.code.add(""),t.vertex.code.add("// OUTPUTS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this.rootOutputNodes()){const s="builtin"===e.outVariableType;this.shouldPruneOutputNode(e)||(s?t.vertex.code.add(`// ${e.outVariableType.padEnd(7)} ${e.node.type.padEnd(9)} ${e.outVariableName};`):t.vertex.code.add(`${e.outVariableType.padEnd(10)} ${e.node.type.padEnd(9)} ${e.outVariableName};`))}t.vertex.code.add(""),t.vertex.code.add("void main() {"),t.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())this.shouldPruneOutputNode(e)||t.vertex.code.add(` ${e.outVariableName} = ${e.variableName};`);t.vertex.code.add("}")}insertFragmentShader(t){this._insertInputs(t,"fragment"),t.fragment.code.add(""),t.fragment.code.add("// OUTPUTS: "),t.fragment.code.add("// --------------------------------------------------------- ");for(const e of this.rootOutputNodes())"builtin"===e.outVariableType?t.fragment.code.add(`// ${e.outVariableType.padEnd(7)} ${e.node.type.padEnd(9)} ${e.outVariableName};`):t.fragment.code.add(`${e.outVariableType.padEnd(10)} ${e.node.type.padEnd(9)} ${e.outVariableName};`);t.fragment.code.add(""),t.fragment.code.add("void main() {"),t.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const e of this.rootOutputNodes())"discard"===e.outVariableType?(t.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),t.fragment.code.add(` if (${e.variableName}) {`),t.fragment.code.add(" discard;"),t.fragment.code.add(" }"),t.fragment.code.add(" ")):t.fragment.code.add(` ${e.outVariableName} = ${e.variableName};`);t.fragment.code.add("}")}_insertInputs(t,e){t[e].code.add("// INPUTS: "),t[e].code.add("// --------------------------------------------------------- ");for(const s of this.inputs())s.isUsed&&"builtin"!==s.variableInputType&&("array"===s.node.type?t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.elementType.type.padEnd(9)} ${s.variableName}[${s.node.size}];`):"array-2d"===s.node.type?t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.elementType.type.padEnd(9)} ${s.variableName}[${s.node.size}]; // Emulated 2D Array. Not supported by ES3.0`):t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.type.padEnd(9)} ${s.variableName};`))}}const Po=["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"],To=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"],Ao=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],Co=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"];var ko=999,Fo=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Eo(t){return function(t){var e=function(){var t,e,s,r=0,i=0,n=ko,o=[],a=[],h=1,c=0,l=0,u=!1,d=!1,_="";return function(t){return a=[],null!==t?f(t.replace?t.replace(/\r\n/g,"\n"):t):(o.length&&p(o.join("")),n=10,p("(eof)"),a)};function p(t){t.length&&a.push({type:Fo[n],data:t,position:l,line:h,column:c})}function f(e){var o;for(r=0,s=(_+=e).length;t=_[r],r<s;){switch(o=r,n){case 0:r=b();break;case 1:case 2:r=y();break;case 3:r=w();break;case 4:r=S();break;case 11:r=v();break;case 5:r=I();break;case 9999:r=M();break;case 9:r=m();break;case ko:r=g()}o!==r&&("\n"===_[o]?(c=0,++h):++c)}return i+=r,_=_.slice(r),a}function g(){return o=o.length?[]:o,"/"===e&&"*"===t?(l=i+r-1,n=0,e=t,r+1):"/"===e&&"/"===t?(l=i+r-1,n=1,e=t,r+1):"#"===t?(n=2,l=i+r,r):/\s/.test(t)?(n=9,l=i+r,r):(u=/\d/.test(t),d=/[^\w_]/.test(t),l=i+r,n=u?4:d?3:9999,r)}function m(){return/[^\s]/g.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function y(){return"\r"!==t&&"\n"!==t||"\\"===e?(o.push(t),e=t,r+1):(p(o.join("")),n=ko,r)}function b(){return"/"===t&&"*"===e?(o.push(t),p(o.join("")),n=ko,r+1):(o.push(t),e=t,r+1)}function w(){if("."===e&&/\d/.test(t))return n=5,r;if("/"===e&&"*"===t)return n=0,r;if("/"===e&&"/"===t)return n=1,r;if("."===t&&o.length){for(;x(o););return n=5,r}if(";"===t||")"===t||"("===t){if(o.length)for(;x(o););return p(t),n=ko,r+1}var s=2===o.length&&"="!==t;if(/[\w_\d\s]/.test(t)||s){for(;x(o););return n=ko,r}return o.push(t),e=t,r+1}function x(t){for(var e,s,r=0;;){if(e=Ao.indexOf(t.slice(0,t.length+r).join("")),s=Ao[e],-1===e){if(r--+t.length>0)continue;s=t.slice(0,1).join("")}return p(s),l+=s.length,(o=o.slice(s.length)).length}}function v(){return/[^a-fA-F0-9]/.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function S(){return"."===t||/[eE]/.test(t)?(o.push(t),n=5,e=t,r+1):"x"===t&&1===o.length&&"0"===o[0]?(n=11,o.push(t),e=t,r+1):/[^\d]/.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function I(){return"f"===t&&(o.push(t),e=t,r+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(o.push(t),e=t,r+1):/[^\d]/.test(t)?(p(o.join("")),n=ko,r):(o.push(t),e=t,r+1)}function M(){if(/[^\d\w_]/.test(t)){var s=o.join("");return n=To.indexOf(s)>-1?8:Co.indexOf(s)>-1?7:6,p(o.join("")),n=ko,r}return o.push(t),e=t,r+1}}(),s=[];return(s=s.concat(e(t))).concat(e(null))}(t)}const zo=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function Oo(t,e){for(let s=e-1;s>=0;s--){const e=t[s];if("whitespace"!==e.type&&"block-comment"!==e.type){if("keyword"!==e.type)break;if("attribute"===e.data||"in"===e.data)return!0}}return!1}function Ro(t,e,s,r){r=r||s;for(const i of t)if("ident"===i.type&&i.data===s)return r in e?e[r]++:e[r]=0,Ro(t,e,r+"_"+e[r],r);return s}function Do(t,e,s="afterVersion"){function r(t,e){for(let s=e;s<t.length;s++){const e=t[s];if("operator"===e.type&&";"===e.data)return s}return null}const i={data:"\n",type:"whitespace"},n=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let o=function(t){let e=-1,i=0,n=-1;for(let o=0;o<t.length;o++){const a=t[o];if("preprocessor"===a.type&&(/#(if|ifdef|ifndef)\s+.+/.test(a.data)?++i:/#endif\s*.*/.test(a.data)&&--i),"afterVersion"!==s&&"afterPrecision"!==s||"preprocessor"===a.type&&a.data.startsWith("#version")&&(n=Math.max(n,o)),"afterPrecision"===s&&"keyword"===a.type&&"precision"===a.data){const e=r(t,o);if(null===e)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,e)}e<n&&0===i&&(e=o)}return e+1}(t);n(o-1)&&t.splice(o++,0,i);for(const s of e)t.splice(o++,0,s);n(o-1)&&n(o)&&t.splice(o,0,i)}function Lo(t,e,s,r="lowp"){Do(t,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function No(t,e,s,r,i="lowp"){Do(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:r.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:i},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"ident",data:e},{type:"operator",data:";"}],"afterPrecision")}function Bo(t,e){let s,r,i=-1;for(let n=e;n<t.length;n++){const e=t[n];if("operator"===e.type&&("["===e.data&&(s=n),"]"===e.data)){r=n;break}"integer"===e.type&&(i=parseInt(e.data,10))}return s&&r&&t.splice(s,r-s+1),i}function Go(t,e){if(t.startsWith("#version 300"))return t;const s=Eo(t);if("300 es"===function(t,e="100",s="300 es"){const r=/^\s*#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const i of t)if("preprocessor"===i.type){const t=r.exec(i.data);if(t){const r=t[1].replaceAll(/\s{2,}/g," ");if(r===s)return r;if(r===e)return i.data="#version "+s,e;throw new Error("unknown glsl version: "+r)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+s},{type:"whitespace",data:"\n"}),null}(s,"100","300 es"))return t;let r=null,i=null;const n={},o={};for(let t=0;t<s.length;++t){const a=s[t];switch(a.type){case"keyword":e===dt.Co.VERTEX_SHADER&&"attribute"===a.data?a.data="in":"varying"===a.data&&(a.data=e===dt.Co.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(a.data.trim())&&(a.data=a.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===dt.Co.FRAGMENT_SHADER&&"gl_FragColor"===a.data&&(r||(r=Ro(s,n,"fragColor"),Lo(s,r,"vec4")),a.data=r),e===dt.Co.FRAGMENT_SHADER&&"gl_FragData"===a.data){const e=Bo(s,t+1),r=Ro(s,n,"fragData");No(s,r,"vec4",e,"mediump"),a.data=r}else e===dt.Co.FRAGMENT_SHADER&&"gl_FragDepthEXT"===a.data&&(i||(i=Ro(s,n,"gl_FragDepth")),a.data=i);break;case"ident":if(Po.includes(a.data)){if(e===dt.Co.VERTEX_SHADER&&Oo(s,t))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");a.data in o||(o[a.data]=Ro(s,n,a.data)),a.data=o[a.data]}}}for(let t=s.length-1;t>=0;--t){const e=s[t];if("preprocessor"===e.type){const r=e.data.match(/#extension\s+(.*):/);if(r?.[1]&&zo.has(r[1].trim())){const e=s[t+1];s.splice(t,e&&"whitespace"===e.type?2:1)}const i=e.data.match(/#ifdef\s+(.*)/);i?.[1]&&zo.has(i[1].trim())&&(e.data="#if 1");const n=e.data.match(/#ifndef\s+(.*)/);n?.[1]&&zo.has(n[1].trim())&&(e.data="#if 0")}}return function(t,e){return e}(0,function(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}(s))}new Map;class Uo{constructor(t,e,s,r,i=new Map,n=[]){this._context=t,this._locations=r,this._uniformBlockBindings=i,this._transformFeedbackVaryings=n,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,t||console.error("RenderingContext isn't initialized!"),0===e.length&&console.error("Shaders source should not be empty!"),e=Go(e,dt.Co.VERTEX_SHADER),s=Go(s,dt.Co.FRAGMENT_SHADER),this._vShader=Vo(this._context,dt.Co.VERTEX_SHADER,e),this._fShader=Vo(this._context,dt.Co.FRAGMENT_SHADER,s),Wo.enabled&&(this._linesOfCode=e.match(/\n/g).length+s.match(/\n/g).length+2,this._context.instanceCounter.increment(dt.vt.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(dt.vt.Shader,this),(0,ut.Xc)()&&(this.vertexShader=e,this.fragmentShader=s),this.usedMemory=e.length+s.length;const o=this._context.gl,a=o.createProgram();o.attachShader(a,this._vShader),o.attachShader(a,this._fShader),this._locations.forEach(((t,e)=>o.bindAttribLocation(a,t,e))),this._transformFeedbackVaryings?.length&&o.transformFeedbackVaryings(a,this._transformFeedbackVaryings,o.SEPARATE_ATTRIBS),o.linkProgram(a),(0,ut.Xc)()&&!o.getProgramParameter(a,o.LINK_STATUS)&&console.error(`Could not link shader\nvalidated: ${o.getProgramParameter(a,o.VALIDATE_STATUS)}, gl error ${o.getError()}, vertex: ${o.getShaderParameter(this._vShader,o.COMPILE_STATUS)}, fragment: ${o.getShaderParameter(this._fShader,o.COMPILE_STATUS)}, info log: ${o.getProgramInfoLog(a)}, vertex source: ${this.vertexShader}, fragment source: ${this.fragmentShader}`);for(const[t,e]of this._uniformBlockBindings){const s=o.getUniformBlockIndex(a,t);s<4294967295&&o.uniformBlockBinding(a,s,e)}this._glName=a,this._context.instanceCounter.increment(dt.vt.Program,this)}get glName(){return this._glName}get hasGLName(){return null!=this._glName}get hasTransformFeedbackVaryings(){return!!this._transformFeedbackVaryings?.length}get compiled(){if(this._compiled)return!0;const t=this._context.gl.getExtension("KHR_parallel_shader_compile");return null==t||null==this.glName?(this._compiled=!0,!0):(this._compiled=!!this._context.gl.getProgramParameter(this.glName,t.COMPLETION_STATUS_KHR),this._compiled)}dispose(){if(--this._refCount>0)return;const t=this._context.gl,e=this._context.instanceCounter;this._nameToUniformLocation.forEach((t=>t&&e.decrement(dt.vt.Uniform,t))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(dt.vt.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(dt.vt.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(dt.vt.Program,this))}ref(){++this._refCount}_getUniformLocation(t){const e=this._nameToUniformLocation.get(t);if(void 0!==e)return e;if(this.glName){const e=this._context.gl.getUniformLocation(this.glName,t);return this._nameToUniformLocation.set(t,e),e&&this._context.instanceCounter.increment(dt.vt.Uniform,e),e}return null}hasUniform(t){return null!=this._getUniformLocation(t)}setUniform1i(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1i(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1iv(t,e){qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e){qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e){qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e){qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4iv(this._getUniformLocation(t),e)}setUniform1f(t,e){const s=this._nameToUniform1.get(t);void 0!==s&&e===s||(this._context.gl.uniform1f(this._getUniformLocation(t),e),this._nameToUniform1.set(t,e))}setUniform1fv(t,e){qo(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,s){const r=this._nameToUniform2.get(t);void 0===r?(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),this._nameToUniform2.set(t,[e,s])):e===r[0]&&s===r[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),r[0]=e,r[1]=s)}setUniform2fv(t,e){qo(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,s,r){const i=this._nameToUniform3.get(t);void 0===i?(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,r),this._nameToUniform3.set(t,[e,s,r])):e===i[0]&&s===i[1]&&r===i[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,r),i[0]=e,i[1]=s,i[2]=r)}setUniform3fv(t,e){const s=this._getUniformLocation(t);null!=s&&qo(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(s,e)}setUniform4f(t,e,s,r,i){const n=this._nameToUniform4.get(t);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,r,i),this._nameToUniform4.set(t,[e,s,r,i])):void 0!==n&&e===n[0]&&s===n[1]&&r===n[2]&&i===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,r,i),n[0]=e,n[1]=s,n[2]=r,n[3]=i)}setUniform4fv(t,e){const s=this._getUniformLocation(t);null!=s&&qo(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(s,e)}setUniformMatrix3fv(t,e,s=!1){const r=this._getUniformLocation(t);null!=r&&qo(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(r,s,e)}setUniformMatrix4fv(t,e,s=!1){const r=this._getUniformLocation(t);null!=r&&qo(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(r,s,e)}stop(){}}function Vo(t,e,s){const r=t.gl,i=r.createShader(e);return r.shaderSource(i,s),r.compileShader(i),(0,ut.Xc)()&&!r.getShaderParameter(i,r.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===dt.Co.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(r.getShaderInfoLog(i)),console.error(function(t){let e=2;return t.replaceAll("\n",(()=>"\n"+function(t){return t>=1e3?t.toString():(" "+t).slice(-3)}(e++)+":"))}(s))),i}function qo(t,e,s){const r=t.get(e);if(!r)return t.set(e,Array.from(s)),!0;const i=s.length;if(r.length!==i)return t.set(e,Array.from(s)),!0;for(let t=0;t<i;++t){const e=s[t];if(r[t]!==e){for(r[t]=e;t<i;++t)r[t]=s[t];return!0}}return!1}const Wo={enabled:!1};function jo(t,e,s){const i=e.length;if(i!==s){const n=new r.A("Invalid Uniform",`Invalid length, expected ${s} but got ${i}`,{uniformName:t,values:e});E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}class Yo{constructor(t,e,s,r,i,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=t,this.fragmentShader=e,this._locations=s,this._locationInfo=r,this._uniformBindings=i,this._transformFeedbackBindings=n}destroy(){this._program&&this._program.dispose(),this.cleanupTemporaryTextures()}get locations(){return this._locations}get locationInfo(){return this._locationInfo}setUniforms(t){this._uniforms=t}cleanupTemporaryTextures(){for(const t of this._temporaryTextures)t.dispose();this._temporaryTextures=[]}bind(t){const e=this._uniforms;if(!this._program){const e=new Map;for(const[t,s]of this._locations)e.set(t,s);const s=[];for(const t of this._transformFeedbackBindings??[]){const{index:e,propertyKey:r}=t;s[e]=`v_${r}`}this._program=new Uo(t,this.vertexShader,this.fragmentShader,e,new Map,s)}const s=this._program;t.useProgram(s);for(const r of this._uniformBindings){const{shaderModulePath:i,uniformName:n,uniformType:o,uniformArrayLength:a}=r,h=(0,U.wc)(i,e);if(null==h){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${i}`)}switch("array"===o||"array-2d"===o?r.uniformArrayElementType:o){case"sampler2D":{const{unit:e,texture:r}=h;if(s.setUniform1i(n,e),"type"in r)t.bindTexture(r,e);else{const s=St(t,r.descriptor,r.data);t.bindTexture(s,e)}break}case"int":if(!a){s.setUniform1i(n,h);break}jo(r.uniformName,h,a),s.setUniform1iv(n,h);break;case"float":if(!a){s.setUniform1f(n,h);break}jo(r.uniformName,h,a),s.setUniform1fv(n,h);break;case"vec2":if(!a){s.setUniform2f(n,h[0],h[1]);break}jo(r.uniformName,h,a),s.setUniform2fv(n,h.flat());break;case"vec3":if(!a){s.setUniform3f(n,h[0],h[1],h[2]);break}jo(r.uniformName,h,a),s.setUniform3fv(n,h.flat());break;case"vec4":if(!a){s.setUniform4f(n,h[0],h[1],h[2],h[3]);break}jo(r.uniformName,h,a),s.setUniform4fv(n,h.flat());break;case"mat3":s.setUniformMatrix3fv(n,h);break;case"mat4":s.setUniformMatrix4fv(n,h);break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function Xo(t){return new t}function $o(t,e,s){const r=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:r.slice()}),t.constructor[e].push(s)}function Ho(t,e){return(s,r)=>{$o(s,"locations",{typeCtor:e,propertyKey:r,parameterIndex:null,index:t})}}const Zo=t=>(e,s,r)=>{$o(e,"inputs",{inputCtor:t,propertyKey:s,parameterIndex:r})},Qo=t=>(e,s)=>{$o(e,"uniforms",{typeCtor:t,propertyKey:s})},Ko=t=>(e,s)=>{$o(e,"options",{typeCtor:t,propertyKey:s})},Jo=(t,e)=>{$o(t,"defines",{propertyKey:e})},ta=(t,e)=>(s,r)=>{s.constructor.builtins.push({builtin:t,propertyKey:r,typeCtor:e})};class ea{}ea.builtins=[],(0,P._)([ta("gl_VertexID",Tn)],ea.prototype,"glVertexID",void 0);class sa{}class ra{}ra.builtins=[],(0,P._)([ta("gl_FragCoord",mn)],ra.prototype,"glFragCoord",void 0),(0,P._)([ta("gl_PointCoord",fn)],ra.prototype,"glPointCoord",void 0);class ia{}class na{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class oa{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const t=this._shaderModuleClass.inputs.findLast((t=>"vertex"===t.propertyKey&&0===t.parameterIndex));if(!t)throw new Error("Unable to find vertex input parameter");return t}get computeInput(){return this._shaderModuleClass.inputs.findLast((t=>"vertex"===t.propertyKey&&1===t.parameterIndex))}get fragmentInput(){const t=this._shaderModuleClass.inputs.findLast((t=>"fragment"===t.propertyKey));if(!t)throw new Error("Unable to find fragment input parameter");return t}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const t=new Map,e=new Set;for(const s of this.locations)e.has(s.index)?E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${s.propertyKey} to ${s.index}. Index already in use`,{locationsMap:t}):(t.set(s.propertyKey,s.index),e.add(s.index));return t}get locationInfo(){if(!this._locationInfo){const t=this.locationsMap,e=Array.from(t.entries()).map((([t,e])=>`${t}.${e}`)).join("."),s=(0,lt.Wm)(e),r=this.computeAttributes;this._locationInfo={hash:s,locations:t,computeAttributeMap:r}}return this._locationInfo}get renamedLocationsMap(){const t=new Map;for(const e of this.locations)t.set("a_"+e.propertyKey,e.index);return t}get optionPropertyKeys(){if(!this._optionPropertyKeys){const t=new Set;for(const e of this._options)t.add(e.propertyKey);this._optionPropertyKeys=t}return this._optionPropertyKeys}get _shaderModuleClass(){return this.constructor}get _defines(){return this._shaderModuleClass.defines??[]}get _options(){return this._shaderModuleClass.options??[]}get _uniforms(){return this._shaderModuleClass.uniforms??[]}getProgram(t,e,s,r){try{const{vertex:i,fragment:n,uniformBindings:o}=this._generateShaders(t,e,s,r);return new Yo(i,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(t){return new Yo("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(t){const e=this._options.find((e=>e.propertyKey===t));if(e)return{type:"option",className:e.typeCtor};const s=this._uniforms.find((e=>e.propertyKey===t));if(!s)throw new Error(`Unable to find uniform class type for property: ${t}`);return{type:"required",className:s.typeCtor}}getShaderKey(t,e,s,r){const i=Object.keys(t).map((e=>`${e}.${t[e]}`)).join("."),n=Object.keys(s).map((t=>`${t}.${s[t]}`)).join("."),o=Object.keys(r).map((t=>`${t}.${r[t]}`)).join("."),a=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${i}.${n}.${o}.${a}`}_generateShaders(t,e,s,r){const i=[];this._setDefines(s),this._setOptionalUniforms(i,e),this._setRequiredUniforms(i);const n=this._hydrateVertexInput(r),o=this._injectPackPrecisionFactor(n,t),a=this._hydrateComputeInput(),h=a&&this._injectComputePackPrecisionFactor(a,t),c=this.vertex(o,h),l=this._hydrateFragmentInput(c),u=this.fragment(l),d=new Set;for(const t in u)Li(d,u[t]);const _=this._getVertexInputBuiltins(),p=Mo.createVertex({...n,...a},c,_,i,this.transformFeedbackBindings,d);(new vo).write(p);const f=this._getFragmentInputBuiltins(u);f.set("glPointCoord","gl_PointCoord");const g=Mo.createFragment(l,u,f,i,p,this.transformFeedbackBindings);(new vo).write(g);const m=this._createShaderBuilder(p,g),y=m.generate("vertex",!0),b=m.generate("fragment",!0);return this.logShader&&(console.log(y),console.log(b)),{vertex:y,fragment:b,uniformBindings:i}}_setDefines(t){for(const e in t)this[e]=t[e]}_setOptionalUniforms(t,e){for(const s of this._options)e[s.propertyKey]?this[s.propertyKey]=this._hydrateUniformGroup(t,s):this[s.propertyKey]=null}_setRequiredUniforms(t){for(const e of this._uniforms)this[e.propertyKey]=this._hydrateUniformGroup(t,e)}_hydrateUniformGroup(t,e){const s=new(0,e.typeCtor);for(const r of s._uniforms??[]){const i=Xo(r.typeCtor),n=`u_${e.propertyKey}_${r.propertyKey}`,o=i.type,a=[e.propertyKey,r.propertyKey].join(".");if("type"in r.typeCtor&&"array"===r.typeCtor.type){const e=i;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:i})}else if("type"in r.typeCtor&&"array-2d"===r.typeCtor.type){const e=i;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:i})}else t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:i});s[r.propertyKey]=i}return s}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,s=e.locations.reduce(((e,s)=>!1===t[s.propertyKey]?e:{...e,[s.propertyKey]:Xo(s.typeCtor)}),{});for(const{propertyKey:t,typeCtor:r}of e.builtins){const e=Xo(r);s[t]=e}return s}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:Xo(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const s={};for(const r in t){const i=t[r],n=e[r];if(n){if("float"!==i.type&&"vec2"!==i.type&&"vec3"!==i.type&&"vec4"!==i.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${i.type}`);s[r]=i.divide(new pn(n))}else s[r]=i}return s}_injectComputePackPrecisionFactor(t,e){const s={},r=new Map;for(const t in this.computeAttributes)for(const e of this.computeAttributes[t]??[])r.set(e,t);for(const i in t){const n=t[i],o=r.get(i);if(!o)continue;const a=e[o];if(a){if("float"!==n.type&&"vec2"!==n.type&&"vec3"!==n.type&&"vec4"!==n.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${n.type}`);s[i]=n.divide(new pn(a))}else s[i]=n}return s}_hydrateFragmentInput(t){const e={};for(const s in t)e[s]=t[s];for(const{propertyKey:t,typeCtor:s}of ra.builtins){const r=Xo(s);e[t]=r}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:s,propertyKey:r}of t.builtins)e.set(r,s);return e}_getFragmentInputBuiltins(t){const e=t.constructor,s=new Map;for(const t of e.builtins??[])s.set(t.propertyKey,t.builtin);return s}_createShaderBuilder(t,e){const s=new Ai;return this._insertDebugInfo(s),t.insertVertexShader(s),e.insertFragmentShader(s),s}_insertDebugInfo(t){t.vertex.code.add("// DEFINES: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._defines)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`);t.vertex.code.add(""),t.vertex.code.add("// OPTIONS: "),t.vertex.code.add("// --------------------------------------------------------- ");for(const e of this._options)this[e.propertyKey]?t.vertex.code.add(`// ${e.propertyKey}: true`):t.vertex.code.add(`// ${e.propertyKey}: false`)}}function aa(t){const e=Dn(12.9898),s=Dn(78.233),r=Dn(43758.5453);return lo(yo(go(co(t,Ln(e,s)),Dn(3.14))).multiply(r))}function ha(t){return Jn(t,Dn(1e-30))}function ca(t,e){const s=Dn(2**e);return go(function(t){return Vn("floor",t)}(t.divide(s)),Dn(2))}function la(t,e){return ca(t,e+B.U5)}class ua extends na{getVisualVariableData(t){if(!this._vvData){const e=this.getAttributeDataCoords(t);this._vvData=wo(this.visualVariableData,e).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(t){if(!this._uv){const e=function(t){const e=ca(t.z,7),s=Dn(1).subtract(e),r=t.xyz.subtract(((...t)=>new gn(...t))(0,0,Dn(128)));return s.multiply(t).add(e.multiply(r))}(t),s=this.size,r=Rn(e.x),i=Rn(e.y).multiply(Rn(256)),n=Rn(e.z).multiply(Rn(256)).multiply(Rn(256)),o=Dn(r.add(i).add(n)),a=go(o,s),h=o.subtract(a).divide(s);this._uv=new fn(a,h).add(.5).divide(s)}return this._uv}getFilterData(t){const e=this.getAttributeDataCoords(t);return wo(this.filterFlags,e).setDebugName("storage0")}getAnimationData(t){const e=this.getAttributeDataCoords(t);return wo(this.animation,e).setDebugName("storage1")}getVVData(t){return this.getVisualVariableData(t)}getDataDrivenData0(t){const e=this.getAttributeDataCoords(t);return wo(this.dataDriven0,e).setDebugName("storage30")}getDataDrivenData1(t){const e=this.getAttributeDataCoords(t);return wo(this.dataDriven1,e).setDebugName("storage31")}getDataDrivenData2(t){const e=this.getAttributeDataCoords(t);return wo(this.dataDriven2,e).setDebugName("storage32")}getGPGPUData(t){const e=this.getAttributeDataCoords(t);return wo(this.gpgpu,e).setDebugName("storage4")}getLocalTimeOrigin(t){const e=this.getAttributeDataCoords(t);return wo(this.localTimeOrigin,e).x.setDebugName("storage5")}getFilterFlags(t){return(0,n.A)("webgl-ignores-sampler-precision")?function(t){return Vn("ceil",t)}(this.getFilterData(t).x.multiply(Dn(255))):this.getFilterData(t).x.multiply(Dn(255))}getLabelVisibility(t){const e=this.getFilterData(t).y.multiply(255);return new pn(1).subtract(e)}getAnimationValue(t){return this.getAnimationData(t).x}getSizeValue(t){return this.getVisualVariableData(t).x}getColorValue(t){return this.getVisualVariableData(t).y}getOpacityValue(t){return this.getVisualVariableData(t).z}getRotationValue(t){return this.getVisualVariableData(t).w}}(0,P._)([Qo(_n)],ua.prototype,"filterFlags",void 0),(0,P._)([Qo(_n)],ua.prototype,"animation",void 0),(0,P._)([Qo(_n)],ua.prototype,"gpgpu",void 0),(0,P._)([Qo(_n)],ua.prototype,"localTimeOrigin",void 0),(0,P._)([Qo(_n)],ua.prototype,"visualVariableData",void 0),(0,P._)([Qo(_n)],ua.prototype,"dataDriven0",void 0),(0,P._)([Qo(_n)],ua.prototype,"dataDriven1",void 0),(0,P._)([Qo(_n)],ua.prototype,"dataDriven2",void 0),(0,P._)([Qo(pn)],ua.prototype,"size",void 0);class da extends na{}(0,P._)([Qo(pn)],da.prototype,"activeReasons",void 0),(0,P._)([Qo(pn)],da.prototype,"highlightAll",void 0);class _a extends na{}(0,P._)([Qo(fn)],_a.prototype,"position",void 0),(0,P._)([Qo(pn)],_a.prototype,"distance",void 0),(0,P._)([Qo(pn)],_a.prototype,"smallSymbolDistance",void 0),(0,P._)([Qo(pn)],_a.prototype,"smallSymbolSizeThreshold",void 0);class pa extends na{}(0,P._)([Qo(En)],pa.prototype,"displayViewScreenMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"displayViewMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"displayMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"viewMat3",void 0),(0,P._)([Qo(En)],pa.prototype,"tileMat3",void 0),(0,P._)([Qo(pn)],pa.prototype,"displayZoomFactor",void 0),(0,P._)([Qo(pn)],pa.prototype,"requiredZoomFactor",void 0),(0,P._)([Qo(fn)],pa.prototype,"tileOffset",void 0),(0,P._)([Qo(pn)],pa.prototype,"currentScale",void 0),(0,P._)([Qo(pn)],pa.prototype,"currentZoom",void 0),(0,P._)([Qo(pn)],pa.prototype,"metersPerSRUnit",void 0),(0,P._)([Qo(pn)],pa.prototype,"rotation",void 0),(0,P._)([Qo(pn)],pa.prototype,"pixelRatio",void 0);class fa extends ea{}(0,P._)([Ho(0,gn)],fa.prototype,"id",void 0),(0,P._)([Ho(1,pn)],fa.prototype,"bitset",void 0),(0,P._)([Ho(2,fn)],fa.prototype,"pos",void 0);class ga extends sa{}(0,P._)([Ho(14,fn)],ga.prototype,"nextPos1",void 0),(0,P._)([Ho(15,fn)],ga.prototype,"nextPos2",void 0);class ma extends ra{}class ya extends oa{clip(t,e){let s=new pn(0);const r=this.storage.getFilterFlags(t);if(s=s.add(Dn(2).multiply(Dn(1).subtract(la(r,0)))),this.inside?s=s.add(Dn(2).multiply(Dn(1).subtract(la(r,1)))):this.outside?s=s.add(Dn(2).multiply(la(r,1))):this.highlight&&(s=s.add(Dn(2).multiply(Dn(1).subtract(this._checkHighlight(r))))),null!=e){const t=new pn(1).subtract(bo(e.x,this.view.currentZoom)),r=bo(e.y,this.view.currentZoom);s=s.add(new pn(2).multiply(t.add(r)))}return s}getFragmentOutput(t,e,s=new pn(1/255)){const r=new ia;return r.glFragColor=this._maybeWriteHittest(e)??this._maybeHighlight(t,s)??t,r}_maybeHighlight(t,e){return this.highlight?new mn(t.rgb,bo(e,t.a)):null}_checkHighlight(t){let e=this._checkHighlightBit(t,0);for(let s=1;s<B.U5;s++)e=e.add(this._checkHighlightBit(t,s));return bo(new pn(.1),e.add(this.highlight.highlightAll))}_checkHighlightBit(t,e){return function(t,e){return ca(t,e)}(t,e).multiply(ca(this.highlight.activeReasons,e))}maybeRunHittest(t,e,s){if(null==this.hittestRequest)return null;let r=Xn(eo(this.hittest(t,e,s),this.hittestRequest.distance),new pn(2),new pn(0));const i=function(t){return t.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(t.id));r=r.add(this.clip(t.id,t.zoomRange));const n=new mn(new pn(1/255),0,0,0);return{glPointSize:new pn(1),glPosition:new mn(i,r,1),color:n}}_maybeWriteHittest(t){return null!=this.hittestRequest?t.color:null}}function ba(t,e,s){const r=s.subtract(e),i=ao((n=t.subtract(e),o=r,co(n,function(t){return Vn("normalize",t)}(o))).divide(uo(r)),new pn(0),new pn(1));var n,o;return function(t,e){return qn("distance",t,e,pn)}(t,e.add(i.multiply(s.subtract(e))))}function wa(t,e,s,r){return Jn(function(t){const e=function(t){return Vn("abs",t)}(t);return bo(e.x.add(e.y).add(e.z),new pn(1.05))}(function(t,e,s,r){const i=new En(s.x.multiply(r.y).subtract(r.x.multiply(s.y)),r.x.multiply(e.y).subtract(e.x.multiply(r.y)),e.x.multiply(s.y).subtract(s.x.multiply(e.y)),s.y.subtract(r.y),r.y.subtract(e.y),e.y.subtract(s.y),r.x.subtract(s.x),e.x.subtract(r.x),s.x.subtract(e.x)),n=e.x.multiply(s.y.subtract(r.y)),o=s.x.multiply(r.y.subtract(e.y)),a=r.x.multiply(e.y.subtract(s.y)),h=n.add(o).add(a);return new pn(1).divide(h).multiply(i.multiply(new gn(1,t)))}(t,e,s,r)),new pn(1))}function xa(t){return t.distance.add(1)}function va(t,e,s){const{viewMat3:r,tileMat3:i}=t.view,n=r.multiply(i),o=n.multiply(new gn(e.pos,1)),a=n.multiply(new gn(s.nextPos1,1)),h=n.multiply(new gn(s.nextPos2,1));return function(t,e,s,r){const i=function(t,e){return t.x.multiply(e.y).subtract(e.x.multiply(t.y))}(s.subtract(e),r.subtract(e)),n=io(function(t,e){return Un("<",t,e,vn)}(i,new pn(.05)),eo(i,new pn(-.05)));return $n([io(mo(n),wa(t.xy,e,s,r)),new pn(-1)],[!0,()=>{const i=ba(t,e,s),n=ba(t,s,r),o=ba(t,r,e);return po(po(i,n),o)}])}(t.hittestRequest.position,o.xy,a.xy,h.xy)}(0,P._)([Jo],ya.prototype,"inside",void 0),(0,P._)([Jo],ya.prototype,"outside",void 0),(0,P._)([Ko(da)],ya.prototype,"highlight",void 0),(0,P._)([Qo(ua)],ya.prototype,"storage",void 0),(0,P._)([Qo(pa)],ya.prototype,"view",void 0),(0,P._)([Ko(_a)],ya.prototype,"hittestRequest",void 0);class Sa extends na{getColor(t,e,s){return $n([ro(ha(t),s),e],[to(t,this.values.first()),this.colors.first()],[so(t,this.values.last()),this.colors.last()],[!0,()=>{const e=this.values.findIndex((e=>eo(e,t))),s=this.values.get(e),r=e.subtract(1),i=this.values.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.colors.get(r),this.colors.get(e),n)}])}}(0,P._)([Qo(un.ofType(mn,8))],Sa.prototype,"colors",void 0),(0,P._)([Qo(un.ofType(pn,8))],Sa.prototype,"values",void 0);class Ia extends na{getOpacity(t){return $n([ha(t),new pn(1)],[to(t,this.opacityValues.first()),this.opacities.first()],[so(t,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const e=this.opacityValues.findIndex((e=>eo(e,t))),s=this.opacityValues.get(e),r=e.subtract(1),i=this.opacityValues.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.opacities.get(r),this.opacities.get(e),n)}])}}function Ma(t){return null!=t.visualVariableSizeMinMaxValue||null!=t.visualVariableSizeScaleStops||null!=t.visualVariableSizeStops||null!=t.visualVariableSizeUnitValue}function Pa(t,e,s,r=new vn(!1)){if(null==t.visualVariableColor)return s;const i=t.storage.getColorValue(e);return t.visualVariableColor.getColor(i,s,r)}function Ta(t,e){if(null==t.visualVariableOpacity)return new pn(1);const s=t.storage.getOpacityValue(e);return t.visualVariableOpacity.getOpacity(s)}(0,P._)([Qo(un.ofType(pn,8))],Ia.prototype,"opacities",void 0),(0,P._)([Qo(un.ofType(pn,8))],Ia.prototype,"opacityValues",void 0);class Aa extends fa{}(0,P._)([Ho(3,mn)],Aa.prototype,"color",void 0),(0,P._)([Ho(4,fn)],Aa.prototype,"zoomRange",void 0);class Ca extends ya{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Ta(this,t.id),r=Pa(this,t.id,t.color).multiply(s),i=this.view.displayViewScreenMat3.multiply(new gn(t.pos.xy,1)),n=this.clip(t.id,t.zoomRange);return{glPosition:new mn(i.xy,n,1),color:r,...this.maybeRunHittest(t,e,null)}}fragment(t){return this.getFragmentOutput(t.color,t,new pn(0))}hittest(t,e){return va(this,t,e)}}(0,P._)([Ko(Sa)],Ca.prototype,"visualVariableColor",void 0),(0,P._)([Ko(Ia)],Ca.prototype,"visualVariableOpacity",void 0),(0,P._)([(0,P.a)(0,Zo(Aa)),(0,P.a)(1,Zo(ga))],Ca.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(ma))],Ca.prototype,"fragment",null);class ka extends na{getPatternOffsetAtTileOrigin(t,e=new pn(0),s=new pn(1)){const r=new fn(16777216).divide(t);let i=t.multiply(lo(this.maxIntsToLocalOrigin.multiply(r))).add(this.tileOffsetFromLocalOrigin).subtract(new pn(.5).multiply(t));return i=new fn(i.x.multiply(s).subtract(i.y.multiply(e)),i.x.multiply(e).add(i.y.multiply(s))),go(i,t)}}(0,P._)([Qo(fn)],ka.prototype,"tileOffsetFromLocalOrigin",void 0),(0,P._)([Qo(fn)],ka.prototype,"maxIntsToLocalOrigin",void 0);class Fa extends na{}(0,P._)([Qo(fn)],Fa.prototype,"size",void 0),(0,P._)([Qo(_n)],Fa.prototype,"texture",void 0);class Ea extends Aa{}function za(t,e){const s=t.view.requiredZoomFactor,r=new fn(e.width,e.height),i=r.multiply(e.scale).multiply(s),n=e.angle.multiply(Mr),o=yo(n),a=ho(n),h=function(t,e,s,r,i){const n=Jn(ca(i,2),Dn(1)),o=function(t){return co(t,new mn(...[255/256,255/65536,255/16777216,255/4294967296]))}(new mn(t,0));return Xn(n,Nn(r.divide(e.x),s.divide(e.y),0,jn(s.divide(e.x)),r.divide(e.y),0,aa(Ln(o,0)),aa(Ln(0,o)),1),Nn(r.divide(e.x),s.divide(e.y),0,jn(s.divide(e.x)),r.divide(e.y),0,0,0,1))}(e.id,i,o,a,e.bitset),c=t.localTileOffset.getPatternOffsetAtTileOrigin(r,o,a),l=s.multiply(e.scale).multiply(e.offset.subtract(c)).divide(i),u=new gn(e.pos,1),d=h.multiply(u).xy.subtract(l),_=e.tlbr.divide(t.mosaicInfo.size.xyxy);let p=ca(e.bitset,4);return null!=t.visualVariableColor&&(p=Xn(ha(t.storage.getColorValue(e.id)),new pn(0),p)),{tileTextureCoord:d,tlbr:_,sampleAlphaOnly:p}}function Oa(t,e){const s=go(e.tileTextureCoord,new pn(1)),r=fo(e.tlbr.xy,e.tlbr.zw,s);let i=wo(t.mosaicInfo.texture,r);return i=Xn(eo(e.sampleAlphaOnly,new pn(.5)),i.aaaa,i),e.color.multiply(i)}(0,P._)([Ho(5,mn)],Ea.prototype,"tlbr",void 0),(0,P._)([Ho(6,pn)],Ea.prototype,"width",void 0),(0,P._)([Ho(7,pn)],Ea.prototype,"height",void 0),(0,P._)([Ho(8,fn)],Ea.prototype,"offset",void 0),(0,P._)([Ho(9,fn)],Ea.prototype,"scale",void 0),(0,P._)([Ho(10,pn)],Ea.prototype,"angle",void 0);class Ra extends Ca{vertex(t,e){return{...super.vertex(t,e),...za(this,t)}}fragment(t){const e=Oa(this,t);return this.getFragmentOutput(e,t,new pn(0))}}(0,P._)([Qo(Fa)],Ra.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],Ra.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(Ea)),(0,P.a)(1,Zo(ga))],Ra.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(class extends ma{}))],Ra.prototype,"fragment",null);class Da extends na{getSize(t,e){const s=this.minMaxValueAndSize.xy,r=this.minMaxValueAndSize.zw;return Xn(ha(t),e,(()=>{const e=ao(t.subtract(s.x).divide(s.y.subtract(s.x)),new pn(0),new pn(1));return r.x.add(e.multiply(r.y.subtract(r.x)))}))}}(0,P._)([Qo(mn)],Da.prototype,"minMaxValueAndSize",void 0);class La extends na{getSizeForViewScale(t){return $n([to(t,this.values.first()),this.sizes.first()],[so(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>eo(e,t))),s=this.values.get(e),r=e.subtract(1),i=this.values.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.sizes.get(r),this.sizes.get(e),n)}])}}(0,P._)([Qo(un.ofType(pn,8))],La.prototype,"sizes",void 0),(0,P._)([Qo(un.ofType(pn,8))],La.prototype,"values",void 0);class Na extends na{getSize(t,e){const s=$n([ha(t),e],[to(t,this.values.first()),this.sizes.first()],[so(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>eo(e,t))),s=this.values.get(e),r=e.subtract(1),i=this.values.get(r),n=t.subtract(i).divide(s.subtract(i));return fo(this.sizes.get(r),this.sizes.get(e),n)}]);return Xn(ha(s),e,s)}}(0,P._)([Qo(un.ofType(pn,8))],Na.prototype,"sizes",void 0),(0,P._)([Qo(un.ofType(pn,8))],Na.prototype,"values",void 0);class Ba extends na{getSize(t,e){return Xn(ha(t),e,t.multiply(this.unitValueToPixelsRatio))}}(0,P._)([Qo(pn)],Ba.prototype,"unitValueToPixelsRatio",void 0);class Ga extends fa{}(0,P._)([Ho(3,mn)],Ga.prototype,"color",void 0),(0,P._)([Ho(4,fn)],Ga.prototype,"offset",void 0),(0,P._)([Ho(5,fn)],Ga.prototype,"normal",void 0),(0,P._)([Ho(6,pn)],Ga.prototype,"halfWidth",void 0),(0,P._)([Ho(7,pn)],Ga.prototype,"referenceHalfWidth",void 0),(0,P._)([Ho(8,fn)],Ga.prototype,"zoomRange",void 0);class Ua extends ma{}class Va extends na{}function qa(t){return _o(new pn(1.1).multiply(bo(t,new pn(1))),new pn(1))}function Wa(t,e){const{id:s,offset:r,pos:i,normal:n,zoomRange:o}=e,{displayViewScreenMat3:a,displayViewMat3:h}=t.view,c=Pa(t,s,e.color),l=Ta(t,s),u=function(t,e){const{id:s,halfWidth:r,referenceHalfWidth:i}=e;if(Ma(t)){const e=function(t,e,s){if(Ma(t)){const r=t.storage.getSizeValue(e);return t.visualVariableSizeMinMaxValue?.getSize(r,s)??t.visualVariableSizeScaleStops?.getSizeForViewScale(t.view.currentScale)??t.visualVariableSizeStops?.getSize(r,s)??t.visualVariableSizeUnitValue?.getSize(r,s)}return s}(t,s,new pn(2).multiply(i));return new pn(.5).multiply(r.divide(_o(i,new pn(1e-5)))).multiply(e)}return r}(t,e),d=new pn(.5).multiply(t.antialiasingControls.antialiasing),_=_o(u.add(d),new pn(.45)).add(new pn(.1).multiply(d)),p=qa(_).multiply(_).multiply(r),f=h.multiply(new gn(p,new pn(0))),g=a.multiply(new gn(i,new pn(1))).add(f),m=new pn(2).multiply(bo(u,new pn(0))).add(t.clip(s,o)),y=new mn(g.xy,m,1);return{color:c,opacity:l,halfWidth:_,normal:n,scaledOffset:p,scaledHalfWidth:u,glPosition:new mn(y.xy,m,1)}}function ja(t,e){const{opacity:s,color:r}=t,i=function(t,e){const{halfWidth:s,normal:r}=t,i=qa(s),n=uo(r).multiply(s);return ao(i.multiply(s.subtract(n)).divide(e.add(i).subtract(new pn(1))),new pn(0),new pn(1))}(t,e);return s.multiply(r).multiply(i)}(0,P._)([Qo(pn)],Va.prototype,"antialiasing",void 0),(0,P._)([Qo(pn)],Va.prototype,"blur",void 0);class Ya extends ya{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Wa(this,t);return{...s,...this.maybeRunHittest(t,e,s.halfWidth)}}fragment(t){const e=ja(t,this.antialiasingControls.blur);return this.getFragmentOutput(e,t)}hittest(t,e,s){const{viewMat3:r,tileMat3:i}=this.view,n=r.multiply(i),o=n.multiply(new gn(t.pos,1)),a=n.multiply(new gn(e.nextPos1,1)),h=n.multiply(new gn(e.nextPos2,1)),{distance:c,smallSymbolDistance:l,smallSymbolSizeThreshold:u}=this.hittestRequest,d=bo(s,u.multiply(.5)).multiply(c.subtract(l)),_=this.hittestRequest.position;return po(ba(_,o.xy,a.xy),ba(_,o.xy,h.xy)).subtract(s).add(d)}}(0,P._)([Qo(Va)],Ya.prototype,"antialiasingControls",void 0),(0,P._)([Ko(Sa)],Ya.prototype,"visualVariableColor",void 0),(0,P._)([Ko(Ia)],Ya.prototype,"visualVariableOpacity",void 0),(0,P._)([Ko(Da)],Ya.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([Ko(La)],Ya.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([Ko(Na)],Ya.prototype,"visualVariableSizeStops",void 0),(0,P._)([Ko(Ba)],Ya.prototype,"visualVariableSizeUnitValue",void 0),(0,P._)([(0,P.a)(0,Zo(Ga)),(0,P.a)(1,Zo(ga))],Ya.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(Ua))],Ya.prototype,"fragment",null);class Xa extends fa{}(0,P._)([Ho(3,fn)],Xa.prototype,"offset",void 0),(0,P._)([Ho(4,mn)],Xa.prototype,"color",void 0),(0,P._)([Ho(5,fn)],Xa.prototype,"normal",void 0),(0,P._)([Ho(6,pn)],Xa.prototype,"halfWidth",void 0),(0,P._)([Ho(7,pn)],Xa.prototype,"referenceHalfWidth",void 0),(0,P._)([Ho(8,fn)],Xa.prototype,"zoomRange",void 0);class $a extends Ua{}function Ha(t,e,s){const{id:r,bitset:i}=e,n=ca(i,0),o=eo(n,new pn(.5)),a=Wa(t,e),h=Xn(o,a.halfWidth,new pn(0)),c=Ta(t,r),l=Pa(t,r,e.color),u=Xn(o,e.color,l.multiply(c)),d=t.view.displayViewScreenMat3.multiply(new gn(e.pos.xy,1)),_=t.clip(e.id),p=new mn(d.xy,_,1),f=Xn(o,a.glPosition,p),g=s&&t.maybeRunHittest(e,s,o);return{isOutline:n,color:u,opacity:new pn(1),halfWidth:h,normal:a.normal,glPosition:f,...g}}class Za extends ya{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,P._)([Qo(Va)],Za.prototype,"antialiasingControls",void 0),(0,P._)([Ko(Sa)],Za.prototype,"visualVariableColor",void 0),(0,P._)([Ko(Ia)],Za.prototype,"visualVariableOpacity",void 0),(0,P._)([Ko(Da)],Za.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([Ko(La)],Za.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([Ko(Na)],Za.prototype,"visualVariableSizeStops",void 0),(0,P._)([Ko(Ba)],Za.prototype,"visualVariableSizeUnitValue",void 0);class Qa extends Za{vertex(t,e){return Ha(this,t,e)}fragment(t){const{color:e,isOutline:s}=t,r=eo(s,new pn(.5)),i=Xn(r,ja(t,this.antialiasingControls.blur),e),n=Xn(r,new pn(1/255),new pn(0));return this.getFragmentOutput(i,t,n)}hittest(t,e,s){return Xn(s,xa(this.hittestRequest),va(this,t,e))}}(0,P._)([(0,P.a)(0,Zo(Xa)),(0,P.a)(1,Zo(ga))],Qa.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo($a))],Qa.prototype,"fragment",null);class Ka extends Aa{}function Ja(t,e){const s=e.tlbr.xy,r=e.tlbr.zw,i=r.x.subtract(s.x),n=s.y.subtract(r.y),o=new fn(i,n).multiply(e.inverseRasterizationScale),a=o.multiply(t.view.requiredZoomFactor),h=function(t){const e=new pn(1),s=new pn(0);return new En(e.divide(t.x),s.divide(t.y),0,jn(s.divide(t.x)),e.divide(t.y),0,0,0,1)}(a),c=t.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),l=new gn(e.pos,1);return{tileTextureCoord:h.multiply(l).xy.subtract(c),tlbr:e.tlbr.divide(t.mosaicInfo.size.xyxy)}}function th(t,e){const s=go(t.tileTextureCoord,new pn(1)),r=fo(t.tlbr.xy,t.tlbr.zw,s),i=wo(e.texture,r);return t.color.multiply(i)}(0,P._)([Ho(5,mn)],Ka.prototype,"tlbr",void 0),(0,P._)([Ho(6,pn)],Ka.prototype,"inverseRasterizationScale",void 0);class eh extends Ca{vertex(t,e){return{...super.vertex(t,e),...Ja(this,t)}}fragment(t){const e=th(t,this.mosaicInfo);return this.getFragmentOutput(e,t,new pn(0))}}(0,P._)([Qo(Fa)],eh.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],eh.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(Ka)),(0,P.a)(1,Zo(ga))],eh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(class extends ma{}))],eh.prototype,"fragment",null);class sh extends Xa{}(0,P._)([Ho(9,mn)],sh.prototype,"tlbr",void 0),(0,P._)([Ho(10,pn)],sh.prototype,"inverseRasterizationScale",void 0);class rh extends $a{}class ih extends Qa{vertex(t,e){return{...Ha(this,t,e),...Ja(this,t)}}fragment(t){const{isOutline:e}=t,s=eo(e,new pn(.5)),r=Xn(s,ja(t,this.antialiasingControls.blur),th(t,this.mosaicInfo)),i=Xn(s,new pn(1/255),new pn(0));return this.getFragmentOutput(r,t,i)}}(0,P._)([Qo(Fa)],ih.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],ih.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(sh)),(0,P.a)(1,Zo(ga))],ih.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(rh))],ih.prototype,"fragment",null);const nh=1/16;class oh extends fa{}(0,P._)([Ho(3,mn)],oh.prototype,"color",void 0),(0,P._)([Ho(4,mn)],oh.prototype,"tlbr",void 0),(0,P._)([Ho(5,pn)],oh.prototype,"angle",void 0),(0,P._)([Ho(6,pn)],oh.prototype,"aux1",void 0),(0,P._)([Ho(7,pn)],oh.prototype,"aux2",void 0),(0,P._)([Ho(8,fn)],oh.prototype,"aux3",void 0),(0,P._)([Ho(9,fn)],oh.prototype,"aux4",void 0),(0,P._)([Ho(10,fn)],oh.prototype,"zoomRange",void 0);class ah extends Za{vertex(t,e){const{aux1:s,aux2:r,aux3:i,aux4:n}=t,o={...t,width:s,height:r,offset:i,scale:n.multiply(nh)},a=Ha(this,{...t,halfWidth:s,referenceHalfWidth:r,offset:i,normal:n.subtract(128).multiply(nh)}),h=za(this,o),c=eo(a.isOutline,new pn(.5));return{...a,...h,...this.maybeRunHittest(t,e,c)}}fragment(t){const{isOutline:e}=t,s=eo(e,new pn(.5)),r=Xn(s,ja(t,this.antialiasingControls.blur),Oa(this,t)),i=Xn(s,new pn(1/255),new pn(0));return this.getFragmentOutput(r,t,i)}hittest(t,e,s){return Xn(s,xa(this.hittestRequest),va(this,t,e))}}(0,P._)([Qo(Fa)],ah.prototype,"mosaicInfo",void 0),(0,P._)([Qo(ka)],ah.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,Zo(oh)),(0,P.a)(1,Zo(ga))],ah.prototype,"vertex",null),(0,P._)([(0,P.a)(0,Zo(class extends rh{}))],ah.prototype,"fragment",null);const hh=pi,ch=vi,lh={createComputedParams:t=>t,optionalAttributes:hh.optionalAttributes,attributes:{...hh.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>_i(t)},aux1:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).width},aux2:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>di(t).height},aux3:{count:2,type:dt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),(0,l.Lz)(e)]},aux4:{count:2,type:dt.pe.UNSIGNED_BYTE,pack:({scaleX:t,scaleY:e})=>[16*t,16*e]}}},uh={createComputedParams:t=>t,optionalAttributes:hh.optionalAttributes,attributes:{...hh.attributes,color:ch.attributes.color,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>Et([[0,!0]])},aux1:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.width)},aux2:{count:1,type:dt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.referenceWidth)},aux3:{count:2,type:dt.pe.HALF_FLOAT,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[t,e]},aux4:{count:2,type:dt.pe.UNSIGNED_BYTE,packTessellation:({normalX:t,normalY:e})=>[16*t+128,16*e+128]}}};class dh extends Si{constructor(){super(...arguments),this.vertexSpec=uh}}class _h extends Ii{constructor(){super(...arguments),this.vertexSpec=lh}_createOutlineWriter(t,e,s,r){return new dh(t,e,s,r)}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),this._lineMeshWriter.writeLineVertices(t,Yt.fromOptimizedCIM(i,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}class ph{constructor(t,e){this._size=t,this._sizeUnits=e,this._relativeSize=null}get relativeSize(){return this._relativeSize??=this.calculateRelativeSize(),this._relativeSize}calculateRelativeSize(){if(this._sizeUnits===Ct.OW.Relative){const t=Math.min(this._size/100,1);return[t,t]}return this.calculateRelativeSizeFromAbsolute()}}class fh extends ph{constructor(t,e,s,r){super(e,s),this.rotationMatrix00=1,this.rotationMatrix01=0,this.rotationMatrix10=0,this.rotationMatrix11=1,this.bounds={xmin:1/0,ymin:1/0,xmax:-1/0,ymax:-1/0},this.rotationMatrix00=Math.cos(r),this.rotationMatrix01=-Math.sin(r),this.rotationMatrix10=-this.rotationMatrix01,this.rotationMatrix11=this.rotationMatrix00;const{bounds:i,rotationMatrix00:n,rotationMatrix01:o,rotationMatrix10:a,rotationMatrix11:h}=this;t.forEachVertex(((t,e)=>{const s=t*n+e*o,r=t*a+e*h;i.xmin=Math.min(i.xmin,s),i.ymin=Math.min(i.ymin,r),i.xmax=Math.max(i.xmax,s),i.ymax=Math.max(i.ymax,r)})),this.center=[(i.xmin+i.xmax)/2,(i.ymin+i.ymax)/2]}}class gh extends fh{constructor(t,e,s,r){super(t,e,s,r),this.method="linear"}getRelativePosition(t,e){const{rotationMatrix00:s,rotationMatrix01:r,bounds:i}=this,{xmin:n,xmax:o}=i;return[(t*s+e*r-n)/(o-n),0]}calculateRelativeSizeFromAbsolute(){const{_size:t,bounds:e}=this,{xmin:s,xmax:r}=e;return[(0,l.Lz)(t)/(r-s),0]}}class mh extends fh{constructor(t,e,s,r){super(t,e,s,r),this.method="rectangular"}getRelativePosition(t,e){const{bounds:s,center:r,rotationMatrix00:i,rotationMatrix01:n,rotationMatrix10:o,rotationMatrix11:a}=this,h=t*o+e*a,c=t*i+e*n-r[0],l=h-r[1];return[c*(2/(s.xmax-s.xmin)),-l*(2/(s.ymax-s.ymin))]}calculateRelativeSizeFromAbsolute(){const{_size:t,bounds:e}=this,{xmin:s,ymin:r,xmax:i,ymax:n}=e;return[(0,l.Lz)(2*t)/(i-s),(0,l.Lz)(2*t)/(n-r)]}}class yh extends fh{constructor(t,e,s){super(t,e,s,0),this.method="circular";const{xmin:r,xmax:i,ymin:n,ymax:o}=this.bounds,a=i-r,h=o-n;this.radius=Math.sqrt(a*a+h*h)/2}getRelativePosition(t,e){const{center:s,radius:r}=this;return[(t-s[0])/r,-(e-s[1])/r]}calculateRelativeSizeFromAbsolute(){const{_size:t}=this;return[(0,l.Lz)(t)/this.radius,0]}}function bh(t,e){if(null==t)return null;const s=(0,ks.kU)(e.angle),r=e.gradientSize,i=e.gradientSizeUnits;switch(e.gradientMethod.toLowerCase()){case"linear":return new gh(t,r,i,s);case"rectangular":return new mh(t,r,i,s);case"circular":return new yh(t,r,i);default:return E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.fill.GradientSizeHelper").errorOnce(`Gradient fill method "${e.gradientMethod}" currently unsupported.`),null}}const wh={createComputedParams:t=>t,optionalAttributes:hi.optionalAttributes,attributes:{...hi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({gradientSizeUnits:t,gradientType:e})=>{let s=0;return t===Ct.OW.Absolute&&(s|=Ft(0)),"discrete"===e.toLowerCase()&&(s|=Ft(1)),s}},tlbr:{count:4,type:dt.pe.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM+B.MZ,n=e.y+B.hM;return[i,n,i+s-2*B.MZ,n+r]}},relativePosition:{count:2,type:dt.pe.HALF_FLOAT,packTessellation:({gradientStats:t},e,s,r)=>t?.getRelativePosition(s,r)??[0,0]},relativeGradientSize:{count:2,type:dt.pe.HALF_FLOAT,packTessellation:({gradientStats:t})=>t?.relativeSize??[1,1]},gradientMethod:{count:1,type:dt.pe.UNSIGNED_BYTE,pack:({gradientMethod:t})=>{switch(t.toLowerCase()){case"rectangular":return 1;case"circular":return 2;default:return 0}}}}};class xh extends ni{constructor(){super(...arguments),this.vertexSpec=wh}get _preventEffectClipping(){return!0}createTesselationParams(t){return{gradientStats:bh(t.readGeometryForDisplay(),this.evaluatedMeshParams)}}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),t.recordEnd()}}const vh={optionalAttributes:li.optionalAttributes,createComputedParams:t=>t,attributes:{...li.attributes,...xi.attributes}},Sh={optionalAttributes:li.optionalAttributes,createComputedParams:t=>t,attributes:{...li.attributes,...vi.attributes}};class Ih extends Si{constructor(){super(...arguments),this.vertexSpec=Sh}}class Mh extends Ii{constructor(){super(...arguments),this.vertexSpec=vh}_createOutlineWriter(t,e,s,r){return new Ih(t,e,s,r)}_write(t,e,s){const r=s?.asOptimized()??e.readGeometryForDisplay(),i=this._clip(r);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,i),this._lineMeshWriter.writeLineVertices(t,Yt.fromOptimizedCIM(i,"esriGeometryPolyline"),e),t.recordEnd()}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._lineMeshWriter.ensurePacked(t,e,s)}enqueueRequest(t,e,s){super.enqueueRequest(t,e,s),this._lineMeshWriter.enqueueRequest(t,e,s)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}const Ph={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1},offset:{type:dt.pe.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};class Th extends wr{constructor(){super(...arguments),this.vertexSpec=Ph}_write(t,e){t.recordStart(this.instanceId,this.attributeLayout);const s=e.getDisplayId();if("esriGeometryPoint"===e.geometryType){const r=e.readXForDisplay(),i=e.readYForDisplay();this._writeQuad(t,s,r,i)}else if("esriGeometryMultipoint"===e.geometryType){const r=e.readGeometryForDisplay();r?.forEachVertex(((e,r)=>{e>=0&&e<=512&&r>=0&&r<=512&&this._writeQuad(t,s,e,r)}))}t.recordEnd()}_writeQuad(t,e,s,r){const i=t.vertexCount();this._writeVertex(t,e,s,r),t.indexWrite(i+0),t.indexWrite(i+1),t.indexWrite(i+2),t.indexWrite(i+1),t.indexWrite(i+3),t.indexWrite(i+2)}}var Ah=s(48163),Ch=s(90708);const kh=8388607,Fh=t=>t&kh;class Eh{constructor(t,e,s,r,i,n,o,a,h=[]){this.entityTexel=t,this.anchorX=e,this.anchorY=s,this.directionX=r,this.directionY=i,this.maxScale=n,this.minScale=o,this.referenceBounds=a,this.bounds=h}serialize(t){t.push(this.entityTexel),t.writeF32(this.anchorX),t.writeF32(this.anchorY),t.writeF32(this.directionX),t.writeF32(this.directionY),t.writeF32(this.maxScale),t.writeF32(this.minScale),null===this.referenceBounds?(t.writeF32(0),t.writeF32(0),t.writeF32(0)):(t.writeF32(this.referenceBounds.size),t.writeF32(this.referenceBounds.offsetX),t.writeF32(this.referenceBounds.offsetY)),j(t,this.bounds)}static deserialize(t){const e=t.readInt32(),s=t.readF32(),r=t.readF32(),i=t.readF32(),n=t.readF32(),o=t.readF32(),a=t.readF32(),h=t.readF32(),c=t.readF32(),l=t.readF32(),u=Y(t,Hs)??[];return new Eh(e,s,r,i,n,o,a,{size:h,offsetX:c,offsetY:l},u)}}const zh=1024;function Oh(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function Rh(t,e){return Math.sqrt(t*t+e*e)}function Dh(t){const e=Rh(t[0],t[1]);t[0]/=e,t[1]/=e}function Lh(t,e){return Rh(t[0]-e[0],t[1]-e[1])}function Nh(t){return t.length-1}function Bh(t,e,s=1){let[r,i]=function(t,e){return t[e+1]}(t,e);return[r,i]=[Math.round(r),Math.round(i)],Math.sqrt(r*r+i*i)*s}class Gh{constructor(t,e,s,r,i){this._segments=t,this._index=e,this._distance=s,this._xStart=r,this._yStart=i,this._done=!1}static create(t){return new Gh(t,0,0,t[0][0],t[0][1])}clone(){return new Gh(this._segments,this._index,this._distance,this.xStart,this.yStart)}equals(t){return this._index===t._index||t._index===this._index-1&&(0===this._distance||1===t._distance)||t._index===this._index+1&&(1===this._distance||0===t._distance)}leq(t){return this._index<t._index||this._index===t._index&&this._distance<=t._distance}geq(t){return this._index>t._index||this._index===t._index&&this._distance>=t._distance}get _segment(){return this._segments[this._index+1]}get angle(){const t=this.dy,e=(0*t+-1*-this.dx)/(1*this.length);let s=Math.acos(e);return t>0&&(s=2*Math.PI-s),s}get xStart(){return this._xStart}get yStart(){return this._yStart}get x(){return this.xStart+this.distance*this.dx}get y(){return this.yStart+this.distance*this.dy}get dx(){return this._segment[0]}get dy(){return this._segment[1]}get xMidpoint(){return this.xStart+.5*this.dx}get yMidpoint(){return this.yStart+.5*this.dy}get xEnd(){return this.xStart+this.dx}get yEnd(){return this.yStart+this.dy}get length(){const{dx:t,dy:e}=this;return Math.sqrt(t*t+e*e)}get remainingLength(){return this.length*(1-this._distance)}get backwardLength(){return this.length*this._distance}get distance(){return this._distance}get done(){return this._done}hasPrev(){return this._index-1>=0}hasNext(){return this._index+1<Nh(this._segments)}next(){return this.hasNext()?(this._xStart+=this.dx,this._yStart+=this.dy,this._distance=0,this._index+=1,this):null}prev(){return this.hasPrev()?(this._index-=1,this._xStart-=this.dx,this._yStart-=this.dy,this._distance=1,this):(this._done=!0,null)}_seekBackwards(t,e){const s=this.backwardLength;if(t<=s)return this._distance=(s-t)/this.length,this;let r=this.backwardLength;for(;this.prev();){if(r+this.length>t)return this._seekBackwards(t-r);r+=this.length}return this._distance=0,e?this:null}seek(t,e=!1){if(t<0)return this._seekBackwards(Math.abs(t),e);if(t<=this.remainingLength)return this._distance=(this.backwardLength+t)/this.length,this;let s=this.remainingLength;for(;this.next();){if(s+this.length>t)return this.seek(t-s,e);s+=this.length}return this._distance=1,e?this:null}}function Uh(t,e,s,r=!0){const i=function(t){let e=0;for(let s=0;s<Nh(t);s++)e+=Bh(t,s);return e}(t),n=Gh.create(t),o=i/2;if(!r)return n.seek(o),void(Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),0,o+0*e,i));const a=Math.max((i-e)/2,0),h=Math.floor(a/e),c=o-h*e;n.seek(c);for(let t=-h;t<=h;t++)Math.abs(n.x)<zh&&Math.abs(n.y)<zh&&s(n.clone(),t,o+t*e,i),n.seek(e)}function Vh(t,e){const s=e;for(let e=0;e<t.length;e++){let r=t[e];qh(r,s);const i=[];i.push(r[0]);for(let t=1;t<r.length;t++){const[e,s]=r[t-1],[n,o]=r[t],a=n-e,h=o-s;i.push([a,h])}t[e]=i,r=i}return t}function qh(t,e){const s=1e-6;if(e<=0)return;const r=t.length;if(r<3)return;const i=[];let n=0;i.push(0);for(let e=1;e<r;e++)n+=Lh(t[e],t[e-1]),i.push(n);e=Math.min(e,.2*n);const o=[];o.push(t[0][0]),o.push(t[0][1]);const a=t[r-1][0],h=t[r-1][1],c=Oh([0,0],t[0],t[1]);Dh(c),t[0][0]+=e*c[0],t[0][1]+=e*c[1],Oh(c,t[r-1],t[r-2]),Dh(c),t[r-1][0]+=e*c[0],t[r-1][1]+=e*c[1];for(let t=1;t<r;t++)i[t]+=e;i[r-1]+=e;const l=.5*e;for(let n=1;n<r-1;n++){let a=0,h=0,c=0;for(let r=n-1;r>=0&&!(i[r+1]<i[n]-l);r--){const o=l+i[r+1]-i[n],u=i[r+1]-i[r],d=i[n]-i[r]<l?1:o/u;if(Math.abs(d)<s)break;const _=d*d,p=d*o-.5*_*u,f=d*u/e,g=t[r+1],m=t[r][0]-g[0],y=t[r][1]-g[1];a+=f/p*(g[0]*d*o+.5*_*(o*m-u*g[0])-_*d*u*m/3),h+=f/p*(g[1]*d*o+.5*_*(o*y-u*g[1])-_*d*u*y/3),c+=f}for(let o=n+1;o<r&&!(i[o-1]>i[n]+l);o++){const r=l-i[o-1]+i[n],u=i[o]-i[o-1],d=i[o]-i[n]<l?1:r/u;if(Math.abs(d)<s)break;const _=d*d,p=d*r-.5*_*u,f=d*u/e,g=t[o-1],m=t[o][0]-g[0],y=t[o][1]-g[1];a+=f/p*(g[0]*d*r+.5*_*(r*m-u*g[0])-_*d*u*m/3),h+=f/p*(g[1]*d*r+.5*_*(r*y-u*g[1])-_*d*u*y/3),c+=f}o.push(a/c),o.push(h/c)}o.push(a),o.push(h);for(let e=0,s=0;e<r;e++)t[e][0]=o[s++],t[e][1]=o[s++]}class Wh{static getPlacement(t,e,s,r,i,n){const o=function(t){if(!t)return null;switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":return $e.local();case"CIMMarkerPlacementAtExtremities":return Ze.local();case"CIMMarkerPlacementAtRatioPositions":return Ke.local();case"CIMMarkerPlacementInsidePolygon":return rs.local();case"CIMMarkerPlacementOnLine":return os.local();case"CIMMarkerPlacementOnVertices":return hs.local();case"CIMMarkerPlacementPolygonCenter":return Ts.local()}return null}(s);return o?(-1===e&&t.invertY(),o.execute(t,s,r,i,n)):null}}class jh{constructor(t){const{offsetX:e,offsetY:s,postAngle:r,fontSize:i,haloSize:n,outlineSize:o,scaleFactor:a,transforms:h}=t;if(this.offsetX=e,this.offsetY=s,this.postAngle=r,this.fontSize=Math.min(i,96),this.haloSize=n??0,this.outlineSize=o??0,this.transforms=h,h&&h.infos.length>1){const t=(0,Te.zb)(i,r,!1,e,s,h,!1);this.fontSize=Math.min(t.size,96);const n=t.size/i;this.haloSize*=n,this.outlineSize*=n,this.postAngle=t.rotation,this.offsetX=t.offsetX,this.offsetY=t.offsetY}a&&(this.fontSize*=a,this.offsetX*=a,this.offsetY*=a)}}const Yh=[4,4],Xh=[16,4],$h={topLeft:Xh,topRight:Xh,bottomLeft:Xh,bottomRight:Xh},Hh=[4,2],Zh=[4,6],Qh={topLeft:Hh,topRight:Hh,bottomLeft:Zh,bottomRight:Zh},Kh={topLeft:Hh,topRight:Zh,bottomLeft:Hh,bottomRight:Zh},Jh={topLeft:Zh,topRight:Zh,bottomLeft:Yh,bottomRight:Yh},tc={topLeft:Yh,topRight:Yh,bottomLeft:Zh,bottomRight:Zh},ec={topLeft:Zh,topRight:Yh,bottomLeft:Zh,bottomRight:Yh},sc={topLeft:Yh,topRight:Zh,bottomLeft:Yh,bottomRight:Zh},rc={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:dt.pe.UNSIGNED_SHORT,count:2,packPrecisionFactor:B.fq,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||28]},clipAngle:{type:dt.pe.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>nc(t||0)},referenceSymbol:{type:dt.pe.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,e)=>{const s=t.isLineLabel||!t.referenceBounds,r=function(t){switch(t){case qs.Right:case"right":return-1;case qs.Center:case"center":return 0;case qs.Left:case"left":return 1;default:return console.debug(`Found invalid horizontal alignment ${t}`),0}}(s?"center":e.horizontalAlignment),i=function(t){switch(t){case Ws.Top:case"top":return 1;case Ws.Center:case"middle":return 0;case Ws.Bottom:case Ws.Baseline:case"baseline":case"bottom":return-1;default:return console.debug(`Found invalid vertical alignment ${t}`),0}}(s?"middle":e.verticalAlignment),{offsetX:n,offsetY:o,size:a}=s?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[(0,l.Lz)(n),-(0,l.Lz)(o),Math.round((0,l.Lz)(a)),r+1<<2|i+1]}}},attributes:{pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>Et([[0,t],[3,!!e]])},offset:{type:dt.pe.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:r,topRight:i}=t;return[r,i,e,s]}}},textureUV:{type:dt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:r,topRight:i}=t;return[r,i,e,s]}}},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:dt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>Math.round((0,l.Lz)(t))},referenceSize:{type:dt.pe.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:e})=>Math.round((0,l.Lz)(e??t))},outlineColor:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>zt(t)},haloColor:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>zt(t)},outlineAndHaloSize:{type:dt.pe.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:e})=>[Math.round((0,l.Lz)(t)),Math.round((0,l.Lz)(e))]}}};class ic extends wr{constructor(){super(...arguments),this.vertexSpec=rc,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new jh(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,s){const r=this._getShaping();if(!r)return;const i=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,r,s);if(s?.nextPath())return s.nextPoint(),this._writeGlyphs(t,i,s.x,s.y,r,0);if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[n,o]=s.coords;return this._writeGlyphs(t,i,n,o,r,0)}if("esriGeometryMultipoint"===e.geometryType){const s=e.readGeometryForDisplay();return void s?.forEachVertex(((e,s)=>this._writeGlyphs(t,i,e,s,r,0)))}const n=e.readXForDisplay(),o=e.readYForDisplay();return this._writeGlyphs(t,i,n,o,r,0)}_writePlacedTextMarkers(t,e,s,r){const i=r??Yt.fromFeatureSetReaderCIM(e);if(!i)return;const n=Wh.getPlacement(i,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,ur());if(!n)return;const o=e.getDisplayId();let a=n.next();for(;null!=a;){const e=a.tx,r=-a.ty,i=-a.getAngle();this._writeGlyphs(t,o,e,r,s,i),a=n.next()}}_getShaping(t){const e=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const r=(0,l.Lz)(e.fontSize),i=(0,l.Lz)(e.offsetX),n=(0,l.Lz)(e.offsetY),o=(0,ks.qE)((0,l.Lz)(s.lineWidth),B.GR,B.cp),a=B.DY*(0,ks.qE)(s.lineHeightRatio,.25,4);return function(t,e){const s=e.scale,r=new Array,{glyphs:i,isRightToLeft:n}=t,o=function(t,e,s){const r=new Array,i=1/s.scale,n=s.maxLineWidth*i,o=e?t.length-1:0,a=e?-1:t.length,h=e?-1:1;let c=o,l=0,u=0,d=c,_=d,p=0,f=1/0,g=0;for(;c!==a;){const{code:e,metrics:s}=t[c],i=Math.abs(s.top);if(sr(e)||rr(e)||(f=Math.min(f,i),g=Math.max(g,i+s.height)),sr(e))c!==o&&(r.push(new er(t,d,c-h,l,f===1/0?0:f,g)),f=1/0,g=0),l=0,d=c+h,_=c+h,u=0;else if(rr(e))_=c+h,u=0,p=s.advance,l+=s.advance;else if(l>n){if(_!==d){const e=_-2*h;l-=p,r.push(new er(t,d,e,l-u,f,g)),f=1/0,g=0,d=_,l=u}else r.push(new er(t,d,c-h,l,f,g)),f=1/0,g=0,d=c,_=c,l=0;l+=s.advance,u+=s.advance}else l+=s.advance,u+=s.advance;c+=h}const m=new er(t,d,c-h,l,f,g);return m.start>=0&&m.end<t.length&&r.push(m),r}(i,n,e),a=o.length?function(t,e){let s=0;for(let e=0;e<t.length;e++){const{width:r}=t[e];s=Math.max(r,s)}const r="underline"===e.decoration?4:0,i=t[0].yMin;return{x:0,y:i,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+r-i,width:s}}(o,e):{x:0,y:0,height:0,width:0},h=Ys(e.horizontalAlignment),c=Xs(e.verticalAlignment),l=c===Ws.Baseline?1:0,u=l?0:c-1,d=(1-l)*-a.y+u*(a.height/2)+-22*(l?1:0);for(let n=0;n<o.length;n++){const{start:a,end:c,width:l}=o[n];let u=-1*(h+1)*(l/2)-3;const _=(t.isRightToLeft?o.length-1-n:n)*e.lineHeight+d-3;o[n].startX=u,o[n].startY=_;for(let t=a;t<=c;t++){const e=i[t];if(sr(e.code))continue;const n=new Qs(u+e.metrics.left,_-e.metrics.top,e,s);u+=e.metrics.advance,r.push(n)}}return new tr(r,o,e)}(s.glyphs,{scale:r/B.eG,angle:e.postAngle,xOffset:i,yOffset:n,horizontalAlignment:s.horizontalAlignment,verticalAlignment:t||s.verticalAlignment,maxLineWidth:o,lineHeight:a,decoration:s.decoration,borderLineSizePx:(0,l.Lz)(s.boxBorderLineSize),hasBackground:!!s.boxBackgroundColor,useCIMAngleBehavior:s.useCIMAngleBehavior})}_writeGlyphs(t,e,s,r,i,n,o,a){const h=this.evaluatedMeshParams,c=this._textMeshTransformProps,u=(0,l.Lz)(c.fontSize),d=c.haloSize,_=c.outlineSize,p=(0,l.Lz)(c.offsetX),f=(0,l.Lz)(c.offsetY),[g,m]=kt(h.scaleInfo,this.getTileInfo());0!==n&&i.setRotation(n);const y=i.bounds,b=s+y.x+p,w=r+y.y-f,x=2*(h.minPixelBuffer?h.minPixelBuffer/u:1),v=Math.max(y.width,y.height)*x;i.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),t.recordBounds(b,w,v,v),this._writeTextBox(t,e,s,r,i.textBox,o,a),t.recordEnd());for(const n of i.glyphs){t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(b,w,v,v);const{texcoords:i,offsets:c}=n;this._writeQuad(t,e,s,r,{texcoords:i,offsets:c,fontSize:u,haloSize:d,outlineSize:_,color:zt(h.color),isBackground:!1,referenceBounds:o,minZoom:g,maxZoom:m,...a}),t.recordEnd()}0!==n&&i.setRotation(-n)}_writeTextBox(t,e,s,r,i,n,o){const a=this.evaluatedMeshParams,{fontSize:h,haloSize:c,outlineSize:l}=this._textMeshTransformProps,{boxBackgroundColor:u,boxBorderLineColor:d}=a,_={isBackground:!0,fontSize:h,haloSize:c,outlineSize:l,referenceBounds:n,...o};u&&(this._writeQuad(t,e,s,r,{texcoords:$h,offsets:i.main,color:zt(u),..._}),d||(this._writeQuad(t,e,s,r,{texcoords:Jh,offsets:i.top,color:zt(u),..._}),this._writeQuad(t,e,s,r,{texcoords:tc,offsets:i.bot,color:zt(u),..._}),this._writeQuad(t,e,s,r,{texcoords:ec,offsets:i.left,color:zt(u),..._}),this._writeQuad(t,e,s,r,{texcoords:sc,offsets:i.right,color:zt(u),..._}))),d&&(this._writeQuad(t,e,s,r,{texcoords:Qh,offsets:i.top,color:zt(d),..._}),this._writeQuad(t,e,s,r,{texcoords:Qh,offsets:i.bot,color:zt(d),..._}),this._writeQuad(t,e,s,r,{texcoords:Kh,offsets:i.left,color:zt(d),..._}),this._writeQuad(t,e,s,r,{texcoords:Kh,offsets:i.right,color:zt(d),..._}))}_writeQuad(t,e,s,r,i){const n=t.vertexCount();this._writeVertex(t,e,s,r,i),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}}const nc=t=>Math.round(t*(254/360)),oc=(0,A.Bj)((t=>{let e=0;if(0===t)return 1/0;for(;!(t%2);)e++,t/=2;return e}));class ac extends ic{constructor(){super(...arguments),this._zoomLevel=0}_write(t,e,s,r){if(this._zoomLevel=r||0,null!=s)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(e.geometryType){case"esriGeometryPoint":{const s=e.readXForDisplay(),r=e.readYForDisplay();this._writePoint(t,s,r,e);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const s=e.readCentroidForDisplay();if(!s)return;const[r,i]=s.coords;this._writePoint(t,r,i,e);break}case"esriGeometryPolyline":this._writeLines(t,e)}}_createLineLabelMetric(t,e,s,r){const i=Fh(t),n="right"===this.evaluatedMeshParams.horizontalAlignment?-1:1,o="bottom"===this.evaluatedMeshParams.verticalAlignment?-1:1,a=this.evaluatedMeshParams.scaleInfo?.maxScale??0,h=this.evaluatedMeshParams.scaleInfo?.minScale??0;return new Eh(i,e,s,n,o,a,h,r??null)}_writePoint(t,e,s,r){const i=this._getShaping();if(!i)return;const n=r.getDisplayId(),o=Ys(this.evaluatedMeshParams.horizontalAlignment),a=Xs(this.evaluatedMeshParams.verticalAlignment),h=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,l=Fh(r.getDisplayId()),u=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};t.metricStart(new Eh(l,e,s,o,a,h,c,u)),this._writeGlyphs(t,n,e,s,i,0,u),t.metricBoxWrite(i.boundsT),t.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const t of this._references){const e=t.getBoundsInfo();if(e)return e}return null}_writeLines(t,e){const{scaleInfo:s,verticalAlignment:r}=this.evaluatedMeshParams,i=this.evaluatedMeshParams.repeatLabelDistance||128,n=this._getShaping("middle");if(!n)return;const o=(t,e,s,r)=>this._placeSubdivGlyphs(t,e,s,r),a=(n.bounds.width+i)/2;this._current={out:t,id:e.getDisplayId(),shaping:n,zoomRange:kt(s,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(e,o,a):this._writeCenterAlong(e,o,a)}_writeAboveAndBelowAlong(t,e,s){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:i}=this._current,n=i.bounds.halfHeight,o=t.readGeometryForDisplay();if(!o)return;const a=new jt.A;(0,Ch.kz)(a,o,!1,!1,"esriGeometryPolyline",1);const h=hc(new jt.A,a,n),c=hc(new jt.A,a,-n),l=(0,Ch.zv)(c,"esriGeometryPolyline",!1,!1),u=Vh((0,Ch.zv)(h,"esriGeometryPolyline",!1,!1).paths,i.bounds.width),d=Vh(l.paths,i.bounds.width);this._current.offsetDirection="above";for(const t of u)Uh(t,s,e,!!r);this._current.offsetDirection="below";for(const t of d)Uh(t,s,e,!!r)}_writeCenterAlong(t,e,s){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:i}=this._current,n=Vh(t.readLegacyGeometryForDisplay().paths,i.bounds.width);for(const t of n)Uh(t,s,e,!!r)}_placeSubdivGlyphs(t,e,s,r){const{allowOverrun:i,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],h=oc(e),c=this._current.shaping.bounds.width/2,l=Math.sqrt(o||128)/2,u=Math.min(s,r-s),d=this._current.shaping.isMultiline?28:Math.log2(u/(l+c/2)),_=0===e?d:Math.min(h,d),p=Math.max(a,this._zoomLevel+1-_),f=this._zoomLevel-p,g=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===e&&this._placeStraight(t,p):i&&f<0?this._placeStraightAlong(t,a):"parallel"===n?this._placeStraightAlong(t,p):"curved"===n&&this._placeCurved(t,p,g)}_placeStraight(t,e){const{out:s,id:r,shaping:i,referenceBounds:n}=this._current,{x:o,y:a}=t;s.metricStart(this._createLineLabelMetric(r,o,a)),s.metricBoxWrite(i.boundsT);const h=t.angle*(180/Math.PI)%360,c=(t.angle*(180/Math.PI)+180)%360;this._writeGlyphs(s,r,o,a,i,0,n,{clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:e}),this._writeGlyphs(s,r,o,a,i,0,n,{clipAngle:c,mapAligned:!0,isLineLabel:!0,minZoom:e}),s.metricEnd()}_placeCurved(t,e,s){const{out:r,id:i}=this._current;r.metricStart(this._createLineLabelMetric(i,t.x,t.y));const n=t.clone(),o=t.angle*(180/Math.PI)%360,a=(t.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(n,e,1,o),this._placeBack(t,n,e,s,1,o),this._placeForward(t,n,e,s,1,o)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(n,e,0,a),this._placeBack(t,n,e,s,0,a),this._placeForward(t,n,e,s,0,a)),r.metricEnd()}_placeStraightAlong(t,e){const{out:s,id:r,shaping:i,zoomRange:n,referenceBounds:o}=this._current,{boxBorderLineColor:a,boxBackgroundColor:h}=this.evaluatedMeshParams,c=t.clone(),u=t.angle*(180/Math.PI)%360,d=(t.angle*(180/Math.PI)+180)%360,_=i.glyphs.length>0&&!(!a&&!h);if(s.metricStart(this._createLineLabelMetric(r,t.x,t.y)),_){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),c=Ds(Gs(),-t.angle),_={minZoom:a,maxZoom:h,clipAngle:u,mapAligned:!0,isLineLabel:!0},p=(0,l.Lz)(this.evaluatedMeshParams.offsetX),f=(0,l.Lz)(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e=(0,js.fA)(p,-1*f),[n,a]=i.shapeBackground(Rs(Gs(),c,e));s.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding);const h=2*Math.max(n.width,n.height);s.recordBounds(t.x+n.x,t.y+n.y,h,h),this._writeTextBox(s,r,t.x,t.y,a,o,_),s.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e=(0,js.fA)(p,f),[n,a]=i.shapeBackground(Rs(Gs(),c,e));_.clipAngle=d,s.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding);const h=2*Math.max(n.width,n.height);s.recordBounds(t.x+n.x,t.y+n.y,h,h),this._writeTextBox(s,r,t.x,t.y,a,o,_),s.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(c,e,1,u,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(c,e,0,d,!0),s.metricEnd()}_placeBack(t,e,s,r,i,n){const o=t.clone();let a=t.backwardLength+0;for(;o.prev()&&!(a>=r);)this._placeOnSegment(o,e,a,s,-1,i,n),a+=o.length+0}_placeForward(t,e,s,r,i,n){const o=t.clone();let a=t.remainingLength+0;for(;o.next()&&!(a>=r);)this._placeOnSegment(o,e,a,s,1,i,n),a+=o.length+0}_placeFirst(t,e,s,r,i=!1){const{out:n,id:o,shaping:a,zoomRange:h,referenceBounds:c}=this._current,l=a.glyphs;for(const u of l){const l=u.x>a.bounds.x?s:1-s,d=l*t.remainingLength+(1-l)*t.backwardLength,_=Math.abs(u.x+u.width/2-a.bounds.x),p=Math.max(0,this._zoomLevel+Math.log2(_/(d+0))),f=Math.max(e,i?0:p);u.maxZoom=Math.min(h[1],28),u.angle=t.angle+(1-s)*Math.PI,u.minZoom=Math.max(h[0],f),this._writeLineGlyph(n,o,t.x,t.y,a.bounds,u,r,c,!0),(s||this._current.offsetDirection)&&this._isVisible(u.minZoom,u.maxZoom)&&n.metricBoxWrite(u.bounds)}}_placeOnSegment(t,e,s,r,i,n,o){const{out:a,id:h,shaping:c,referenceBounds:l}=this._current,u=c.glyphs,d=t.dx/t.length,_=t.dy/t.length,p={x:t.x+s*-i*d,y:t.y+s*-i*_};for(const e of u){const u=e.x>c.bounds.x?n:1-n;if(!(u&&1===i||!u&&-1===i))continue;const d=Math.abs(e.x+e.width/2-c.bounds.x),_=Math.max(0,this._zoomLevel+Math.log2(d/s)-.1),f=Math.max(r,this._zoomLevel+Math.log2(d/(s+t.length+0)));0!==_&&(e.angle=t.angle+(1-n)*Math.PI,e.minZoom=f,e.maxZoom=_,this._writeLineGlyph(a,h,p.x,p.y,c.bounds,e,o,l,!0),(n||this._current.offsetDirection)&&this._isVisible(e.minZoom,e.maxZoom)&&a.metricBoxWrite(e.bounds))}}_writeLineGlyph(t,e,s,r,i,n,o,a,h){const c=s+i.x,l=r+i.y,u=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(i.width,i.height)*u;t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(c,l,d,d);const{texcoords:_,offsets:p}=n,{fontSize:f,haloSize:g,outlineSize:m}=this._textMeshTransformProps;this._writeQuad(t,e,s,r,{texcoords:_,offsets:p,fontSize:f,haloSize:g,outlineSize:m,color:zt(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],n.minZoom),maxZoom:Math.min(this._current.zoomRange[1],n.maxZoom),clipAngle:o,mapAligned:h,isLineLabel:!0}),t.recordEnd()}_isVisible(t,e){const s=Math.floor(this._zoomLevel*B.fq)/B.fq;return t<=s&&s<=e}}function hc(t,e,s){const{coords:r,lengths:i}=e,n=(0,Ah.vt)(),o=(0,Ah.vt)(),a=(0,Ah.vt)(),h=(0,Ah.vt)(),c=(0,Ah.vt)(),l=(0,Ah.vt)();let u=0;for(let e=0;e<i.length;e++){const d=i[e];for(let e=0;e<d;e++){const i=2*(e+u-1),_=2*(e+u),p=2*(e+u+1);e>0?(0,O.hZ)(n,r[i],r[i+1]):(0,O.hZ)(n,0,0),(0,O.hZ)(o,r[_],r[_+1]),e<d-1?(0,O.hZ)(a,r[p],r[p+1]):(0,O.hZ)(a,0,0),0===e?(0,O.hZ)(h,0,0):((0,O.jb)(h,o,n),(0,O.S8)(h,h),(0,O.hZ)(h,h[1],-h[0])),e===d-1?(0,O.hZ)(c,0,0):((0,O.jb)(c,a,o),(0,O.S8)(c,c),(0,O.hZ)(c,c[1],-c[0])),(0,O.WQ)(l,h,c),(0,O.S8)(l,l);const f=l[0]*c[0]+l[1]*c[1];0!==f&&(0,O.hs)(l,l,f),(0,O.hs)(l,l,s),t.coords.push(o[0]+l[0],o[1]+l[1])}t.lengths.push(d),u+=d}return t}const cc={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({gradientMethod:t,gradientSizeUnits:e,gradientType:s})=>Et([[0,"alongline"===t.toLowerCase()],[1,e===Ct.OW.Absolute],[2,"discrete"===s.toLowerCase()]])},tlbr:{type:dt.pe.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM+B.MZ,n=e.y+B.hM;return[i,n,i+s-2*B.MZ,n+r]}},accumulatedDistance:{type:dt.pe.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},gradientSize:{type:dt.pe.HALF_FLOAT,count:1,pack:({gradientSize:t,gradientSizeUnits:e})=>e===Ct.OW.Relative?t/100:(0,l.Lz)(t)},totalLength:{type:dt.pe.HALF_FLOAT,count:1,packTessellation:({pathLength:t})=>t},segmentDirection:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]}}};class lc extends wi{get _preventEffectClipping(){return!0}constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=cc,this._tessellationOptions.textured=!0}_write(t,e,s){const r=s??Yt.fromFeatureSetReaderCIM(e);if(!r)return;const{sprite:i}=this.evaluatedMeshParams;this._writeGeometry(t,e,r,i?.textureBinding)}}const uc={createComputedParams:t=>t,optionalAttributes:yi.optionalAttributes,attributes:{...yi.attributes,bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:t,shouldScaleDash:e,isSDF:s})=>Et([[4,t],[2,e],[3,s]])},tlbr:{type:dt.pe.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:r}=t,i=e.x+B.hM,n=e.y+B.hM;return[i,n,i+s,n+r]}},accumulatedDistance:{type:dt.pe.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},segmentDirection:{type:dt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]},offsetAlongLine:{type:dt.pe.HALF_FLOAT,count:1,pack:({offsetAlongLine:t})=>(0,l.Lz)(t)},capType:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({capType:t})=>{switch(t){case Ct.uT.Butt:case"butt":return 0;case Ct.uT.Square:case"square":return 1;case Ct.uT.Round:case"round":return 2;default:return 0}}}}};class dc extends wi{constructor(t,e,s,r){super(t,e,s,r),this.vertexSpec=uc,this._tessellationOptions.textured=!0}_write(t,e,s){const r=s??Yt.fromFeatureSetReaderCIM(e);if(!r)return;const{sprite:i}=this.evaluatedMeshParams;this._writeGeometry(t,e,r,i?.textureBinding)}}class _c{static from(t){return"width"in t?this.fromSimpleMeshParams(t):this.fromComplexMeshParams(t)}static fromSimpleMeshParams(t){const e=new _c(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects),{type:s,width:r,height:i,angle:n,alignment:o,outlineSize:a,referenceSize:h,sprite:c,overrideOutlineColor:u}=t;return e.rawWidth=(0,l.Lz)(r),e.rawHeight=(0,l.Lz)(i),e.angle=n,e.alignment=o,e.outlineSize=(0,l.Lz)(a),e.referenceSize=(0,l.Lz)(h),e.overrideOutlineColor=u,e.offsetX=(0,l.Lz)(t.offsetX),e.offsetY=(0,l.Lz)(t.offsetY),"simple"!==s||c.sdf||(e.rawWidth=c.width,e.rawHeight=c.height),e._computeSize(t,!1),e}static fromComplexMeshParams(t){const e=new _c(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects);let{alignment:s,transforms:r,size:i,scaleX:n,anchorX:o,anchorY:a,angle:h,colorLocked:c,frameHeight:u,widthRatio:d,offsetX:_,offsetY:p,outlineSize:f,referenceSize:g,scaleFactor:m,sizeRatio:y,isAbsoluteAnchorPoint:b,rotateClockwise:w,scaleSymbolsProportionally:x,sprite:v}=t;if(r&&r.infos.length>0){const t=(0,Te.zb)(i,h,w,_,p,r);i=t.size,h=t.rotation,_=t.offsetX,p=t.offsetY,w=!1}m&&(i*=m,_*=m,p*=m);const S=n*(v.width/v.height);e.alignment=s,e.rawHeight=(0,l.Lz)(i),e.rawWidth=e.rawHeight*S,e.referenceSize=(0,l.Lz)(g),e.sizeRatio=y,e.sdfDecodeCoeff=(v.sdfDecodeCoeff??1)*y,e.angle=h,e.rotateClockwise=w,e.anchorX=o,e.anchorY=a,e.offsetX=(0,l.Lz)(_),e.offsetY=(0,l.Lz)(p),b&&i&&(v.sdf?e.anchorX=o/(i*d):e.anchorX=o/(i*S),e.anchorY=a/i);const I=x&&u?i/u:1;return e.outlineSize=0===f||isNaN(f)?0:(0,l.Lz)(f)*I,e.scaleSymbolsProportionally=x,e.colorLocked=c,e._computeSize(t,!0),e}constructor(t,e,s,r,i,n,o){this.sprite=t,this.color=e,this.outlineColor=s,this.minPixelBuffer=r,this.placement=i,this.scaleInfo=n,this.effects=o,this.rawWidth=0,this.rawHeight=0,this.angle=0,this.outlineSize=0,this.referenceSize=0,this.sizeRatio=1,this.sdfDecodeCoeff=1,this.alignment=Ct.C1.SCREEN,this.scaleSymbolsProportionally=!1,this.overrideOutlineColor=!1,this.colorLocked=!1,this.anchorX=0,this.anchorY=0,this.computedWidth=0,this.computedHeight=0,this.texXmin=0,this.texYmin=0,this.texXmax=0,this.texYmax=0,this.offsetX=0,this.offsetY=0,this.rotateClockwise=!0}get boundsInfo(){return{size:Math.max(this.computedHeight,this.computedWidth),offsetX:this.offsetX,offsetY:this.offsetY}}_computeSize(t,e){const{sprite:s,hasSizeVV:r}=t,i=!!s.sdf,n=s.sdfPaddingRatio??.5,{rawWidth:o,rawHeight:a,sizeRatio:h,outlineSize:c}=this;let l=o*h,u=a*h,d=0,_=0;if(i){const t=1/(1-n);if(l*=t,u*=t,r)this.computedWidth=l,this.computedHeight=u;else{const t=e&&o>a?l:o,r=a,i=c+2;this.computedWidth=Math.min(t+i,l),this.computedHeight=Math.min(r+i,u);const n=Math.max(s.width,s.height)/Math.max(l,u);d=(this.computedWidth-l)*n,_=(this.computedHeight-u)*n}}else this.computedWidth=l*(s.rect.width/s.width),this.computedHeight=u*(s.rect.height/s.height),d=2*B.hM,_=2*B.hM;const p=s.rect.x+B.hM-d/2,f=s.rect.y+B.hM-_/2,g=p+s.width+d,m=f+s.height+_;this.texXmin=pc(p),this.texYmin=pc(f),this.texXmax=fc(g),this.texYmax=fc(m),this.computedWidth*=(this.texXmax-this.texXmin)/(g-p),this.computedHeight*=(this.texYmax-this.texYmin)/(m-f),this.anchorX*=l/this.computedWidth,this.anchorY*=u/this.computedHeight}}function pc(t,e=1e-7){const s=Math.ceil(t);return s-t<e?s:Math.floor(t)}function fc(t,e=1e-7){const s=Math.floor(t);return t-s<e?s:Math.ceil(t)}const gc=128/Math.PI;const mc={createComputedParams:t=>_c.from(t),optionalAttributes:{zoomRange:{type:dt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}},attributes:{pos:{type:dt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({sprite:t,alignment:e,scaleSymbolsProportionally:s,overrideOutlineColor:r,colorLocked:i})=>{let n=0;return t.sdf&&(n|=Ft(Dt)),e===Ct.C1.MAP&&(n|=Ft(Lt)),s&&(n|=Ft(Nt)),r&&(n|=Ft(Bt)),i&&(n|=Ft(Gt)),n}},offset:{type:dt.pe.HALF_FLOAT,count:2,packAlternating:{count:4,pack:({angle:t,computedWidth:e,computedHeight:s,anchorX:r,anchorY:i,offsetX:n,offsetY:o,rotateClockwise:a})=>{const h=function(t,e,s,r,i=!1){const n=Gs(),o=i?1:-1;return Es(n),(e||s)&&Rs(n,n,[e,-s]),r&&Os(n,n,.017453292519944444*o*-r),n}(0,n,o,-t,a),c=-(.5+r)*e,l=-(.5-i)*s,u=[c,l],d=[c+e,l],_=[c,l+s],p=[c+e,l+s];return(0,O.l0)(u,u,h),(0,O.l0)(d,d,h),(0,O.l0)(_,_,h),(0,O.l0)(p,p,h),[u,d,_,p]}}},textureUV:{type:dt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:t,texXmin:e,texYmax:s,texYmin:r})=>[[e,r],[t,r],[e,s],[t,s]]}},color:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>zt(t)},outlineColor:{type:dt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>zt(t)},sizing:{type:dt.pe.UNSIGNED_BYTE,count:4,pack:({rawWidth:t,rawHeight:e,outlineSize:s,referenceSize:r})=>[Ot(Math.max(t,e),128),Ot(s,128),Ot(r,128),0]},placementAngle:{type:dt.pe.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:t})=>function(t){return function(t){return t%=256,Math.abs(t>=0?t:t+256)}(t*gc)}(t)},sdfDecodeCoeff:{type:dt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sdfDecodeCoeff:t})=>t}}};class yc extends wr{constructor(){super(...arguments),this.vertexSpec=mc}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(t,e,s){const r=this.evaluatedMeshParams.sprite?.textureBinding,i=e.getDisplayId();t.recordStart(this.instanceId,this.attributeLayout,r);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),h=-this.evaluatedMeshParams.anchorX*this.evaluatedMeshParams.computedWidth,c=this.evaluatedMeshParams.anchorY*this.evaluatedMeshParams.computedHeight,l=this.evaluatedMeshParams.offsetX+h,u=-this.evaluatedMeshParams.offsetY+c;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(t,e,s,o,a);else if(s?.nextPath()){s.nextPoint();const e=s.x,r=s.y;t.recordBounds(e+l,r+u,o,a),this._writeQuad(t,i,e,r)}else if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[r,n]=s.coords;t.recordBounds(r+l,n+u,o,a),this._writeQuad(t,i,r,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),r=e.readYForDisplay();t.recordBounds(s+l,r+u,o,a),this._writeQuad(t,i,s,r)}else{const s=e.readGeometryForDisplay();s?.forEachVertex(((e,s)=>{t.recordBounds(e+l,s+u,o,a),Math.abs(e)>zh||Math.abs(s)>zh||this._writeQuad(t,i,e,s)}))}t.recordEnd()}_writePlacedMarkers(t,e,s,r,i){const n=s??Yt.fromFeatureSetReaderCIM(e)?.clone();if(!n)return;const o=Wh.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,ur());if(!o)return;const a=e.getDisplayId();let h=o.next();const c=this.evaluatedMeshParams.offsetX,u=-this.evaluatedMeshParams.offsetY;for(;null!=h;){const e=h.tx,s=-h.ty;if(Math.abs(e)>zh||Math.abs(s)>zh){h=o.next();continue}const n=-h.getAngle();t.recordBounds(e+c,s+u,r,i),this._writeQuad(t,a,e,s,n),h=o.next()}}_writeQuad(t,e,s,r,i){const n=t.vertexCount(),o=null==i?null:{placementAngle:i};this._writeVertex(t,e,s,r,o),t.indexWrite(n+0),t.indexWrite(n+1),t.indexWrite(n+2),t.indexWrite(n+1),t.indexWrite(n+3),t.indexWrite(n+2)}}var bc=s(4576),wc=s(71386);function xc(t,e){let s;if("string"==typeof t)s=(0,lt.Wm)(t+`-seed(${e})`);else{let r=12;s=t^e;do{s=107*(s>>8^s)+r|0}while(0!=--r)}return(1+s/(1<<31))/2}function vc(t){return Math.floor(xc(t,Sc)*Ic)}const Sc=53290320,Ic=10;var Mc;!function(t){t.Local="Local",t.Global="Global"}(Mc||(Mc={}));class Pc{generateSource(t){const e=[];for(let s=1;s<this.length;s++)e.push(`vec4 atom${s} = texture(${t.animationTexture}, (pointer + 0.5) / size);`),e.push("pointer.x += 1.0;");for(let t=0;t<this.ins;t++)e.push("top--;"),e.push(`vec4 in${this.ins-t-1} = stack[top];`);for(let t=0;t<this.outs;t++)e.push(`vec4 out${t};`);const{microcode:s}=this;for(const t of s)e.push(t);for(let t=0;t<this.outs;t++)e.push(`stack[top] = out${t};`),e.push("top++;"),e.push(`if (top >= ${Oc}) { top = ${Oc-1}; }`);return e}}let Tc=128;function Ac(t){return[`float duration = clamp(${t.duration}, 0.05, 3600.0);`,`float startTimeOffset = ${t.startTimeOffset};`,`float repeatDelay = ${t.repeatDelay};`,`float timeOriginSelector = ${t.timeOriginSelector};`,`float repeatType = ${t.repeatType};`,`float easing = ${t.easing};`,`float playAnimation = ${t.playAnimation} * (1.0 - step(0.0, -${t.duration}));`,`float reverseAnimation = ${t.reverseAnimation};`,"float time = globalTime - (timeOriginSelector == 1.0 ? localTimeOrigin : 0.0);","time *= playAnimation;","time *= 1.0 - reverseAnimation * 2.0;","float period = duration + repeatDelay;","time += reverseAnimation == 1.0 ? (period - startTimeOffset - 0.001) : startTimeOffset + 0.001;","float omega = time / period;","float oi = floor(omega);","omega = repeatType == 1.0 || repeatType == 3.0 ? omega - oi : omega;","float of = omega * period;","of = (clamp(of, reverseAnimation * repeatDelay, period - (1.0 - reverseAnimation) * repeatDelay) - reverseAnimation * repeatDelay) / duration;","of = easing == 2.0 ? pow(of, 3.0) : of;","of = easing == 3.0 ? 1.0 - pow(1.0 - of, 3.0) : of;","of = easing == 4.0 ? of < 0.5 ? 4.0 * pow(of, 3.0) : 1.0 - pow(-2.0 * of + 2.0, 3.0) / 2.0 : of;","bool oscillate = repeatType == 3.0 && mod(oi, 2.0) == 1.0;",`${t.out} = oscillate ? 1.0 - of : of;`]}const Cc={Linear:1,EaseIn:2,EaseOut:3,EaseInOut:4},kc={Loop:1,None:2,Oscillate:3},Fc={Local:1,Global:2};function Ec(t){const e=Cc[t.easing],s=kc[t.repeatType],r=Fc[t.timeOriginSelector];return[[t.duration,t.startTimeOffset,t.repeatDelay,r],[s,e,t.playAnimation,t.reverseAnimation]]}const zc={scalar:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=1,this.ins=0,this.outs=1,this.microcode=["out0 = vec4(atom0.y, atom0.y, atom0.y, atom0.y);"]}encode(t){return[[this.opcode,t,0,0]]}},vector3:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=1,this.ins=0,this.outs=1,this.microcode=["out0 = vec4(atom0.yzw, 0.0);"]}encode(t){return[[this.opcode,t[0]||0,t[1]||0,t[2]||0]]}},vector4:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=2,this.ins=0,this.outs=1,this.microcode=["out0 = atom1;"]}encode(t){return[[this.opcode,0,0,0],t]}},animatedTransform:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=10,this.ins=1,this.outs=1,this.microcode=["vec2 fromTranslation = atom1.xy;","vec2 toTranslation = atom1.zw;","float fromRotation = atom2.x;","float toRotation = atom2.y;","float fromScale = atom2.z;","float toScale = atom2.w;","bool relativeTranslation = atom9.x == 1.0;","bool absoluteScale = atom9.y == 1.0;","vec2 translationMultiplier = relativeTranslation ? pixelDimensions : vec2(1.0, 1.0);","float scaleDivisor = absoluteScale ? pixelDimensions.y : 1.0;","float fTranslation;","{",...Ac({duration:"atom3.x",startTimeOffset:"atom3.y",repeatDelay:"atom3.z",timeOriginSelector:"atom3.w",repeatType:"atom4.x",easing:"atom4.y",playAnimation:"atom4.z",reverseAnimation:"atom4.w",out:"fTranslation"}),"}","float fRotation;","{",...Ac({duration:"atom5.x",startTimeOffset:"atom5.y",repeatDelay:"atom5.z",timeOriginSelector:"atom5.w",repeatType:"atom6.x",easing:"atom6.y",playAnimation:"atom6.z",reverseAnimation:"atom6.w",out:"fRotation"}),"}","float fScale;","{",...Ac({duration:"atom7.x",startTimeOffset:"atom7.y",repeatDelay:"atom7.z",timeOriginSelector:"atom7.w",repeatType:"atom8.x",easing:"atom8.y",playAnimation:"atom8.z",reverseAnimation:"atom8.w",out:"fScale"}),"}","vec2 aTranslation = mix(fromTranslation, toTranslation, fTranslation);","float aRotation = mix(fromRotation, toRotation, fRotation);","float aScale = mix(fromScale, toScale, fScale);","vec2 pTranslation = in0.xy;","float pRotation = in0.z;","float pScale = in0.w;","aTranslation *= translationMultiplier;","aScale /= scaleDivisor;","float rotation = pRotation + aRotation;","float scale = pScale * aScale;","float sin1 = sin(pRotation);","float cos1 = cos(pRotation);","float s1 = pScale;","float x1 = pTranslation.x;","float y1 = pTranslation.y;","float x2 = aTranslation.x;","float y2 = aTranslation.y;","\n vec2 translation = vec2(\n cos1 * s1 * x2 - sin1 * s1 * y2 + x1,\n sin1 * s1 * x2 + cos1 * s1 * y2 + y1\n );\n ","out0 = vec4(translation, rotation, scale);"]}encode(t){return[[this.opcode,0,0,0],[t.translation.from[0],t.translation.from[1],t.translation.to[0],t.translation.to[1]],[t.rotation.from,t.rotation.to,t.scale.from,t.scale.to],...Ec(t.translation.timing),...Ec(t.rotation.timing),...Ec(t.scale.timing),[t.relativeTranslation?1:0,t.absoluteScale?1:0,0,0]]}},animatedColor:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=7,this.ins=1,this.outs=1,this.microcode=["float fromOpacity = atom0.y;","float toOpacity = atom0.z;","vec4 fromColor = atom1;","vec4 toColor = atom2;","float fColor;","{",...Ac({duration:"atom3.x",startTimeOffset:"atom3.y",repeatDelay:"atom3.z",timeOriginSelector:"atom3.w",repeatType:"atom4.x",easing:"atom4.y",playAnimation:"atom4.z",reverseAnimation:"atom4.w",out:"fColor"}),"}","float fOpacity;","{",...Ac({duration:"atom5.x",startTimeOffset:"atom5.y",repeatDelay:"atom5.z",timeOriginSelector:"atom5.w",repeatType:"atom6.x",easing:"atom6.y",playAnimation:"atom6.z",reverseAnimation:"atom6.w",out:"fOpacity"}),"}","vec4 aColor = mix(fromColor, toColor, fColor);","aColor.a *= mix(fromOpacity, toOpacity, fOpacity);","vec4 pColor = in0;","out0 = aColor * pColor;"]}encode(t){return[[this.opcode,t.opacity.from,t.opacity.to,0],[t.color.from[0],t.color.from[1],t.color.from[2],t.color.from[3]],[t.color.to[0],t.color.to[1],t.color.to[2],t.color.to[3]],...Ec(t.color.timing),...Ec(t.opacity.timing)]}},ret:new class extends Pc{constructor(){super(...arguments),this.opcode=++Tc,this.length=1,this.ins=0,this.outs=0,this.microcode=["break;"]}encode(){return[[this.opcode,0,0,0]]}}},Oc=4;function Rc(t){return t instanceof Dc?t:"object"==typeof t&&"type"in t?Gc[t.type].hydrate(t):new Lc(t)}class Dc{constructor(t){this.inputs=t}encode(){const t=[];for(const e of this.inputs)t.push(...e.encode());return t.push(...this.instructions),t}}class Lc extends Dc{constructor(t){super([]),this.value=t}simplify(){return this}get instructions(){if(Array.isArray(this.value)){const[t,e,s,r]=this.value;return null!=r?zc.vector4.encode([t,e||0,s||0,r]):zc.vector3.encode([t,e||0,s||0])}return zc.scalar.encode(this.value)}}class Nc extends Dc{constructor(t,e){super([e]),this._config=t,this._parent=e}static hydrate(t){return new Nc(t,Rc(t.parent))}simplify(){if(this._config.relativeTranslation||this._config.absoluteScale)return this;const t=this._parent.simplify();if(!(t instanceof Lc))return this;const[e,s,r,i]=t.value,n=this._config.translation.from[0],o=this._config.translation.from[1],a=this._config.rotation.from,h=this._config.scale.from;if(n===this._config.translation.to[0]&&o===this._config.translation.to[1]&&a===this._config.rotation.to&&h===this._config.scale.to){const t=r+a,c=i*h,l=Math.sin(r),u=Math.cos(r);return new Lc([u*i*n-l*i*o+e,l*i*n+u*i*o+s,t,c])}return new Nc(this._config,t)}get instructions(){return zc.animatedTransform.encode(this._config)}}class Bc extends Dc{constructor(t,e){super([e]),this._config=t,this._parent=e}static hydrate(t){return new Bc(t,Rc(t.parent))}simplify(){const t=this._parent.simplify();if(!(t instanceof Lc))return this;const[e,s,r,i]=t.value,n=this._config.color.from[0],o=this._config.color.from[1],a=this._config.color.from[2];let h=this._config.color.from[3];const c=this._config.opacity.from;return n===this._config.color.to[0]&&o===this._config.color.to[1]&&a===this._config.color.to[2]&&h===this._config.color.to[3]&&c===this._config.opacity.to?(h*=c,new Lc([e*n,s*o,r*a,i*h])):new Bc(this._config,t)}get instructions(){return zc.animatedColor.encode(this._config)}}const Gc={AnimatedTransform:Nc,AnimatedColor:Bc};function Uc(t){return qc(t.map((t=>jc(t))).map((t=>Rc(t).simplify())))}function Vc(t){const e=[];return e.push(t.transform),e.push(t.fromColor),e.push(t.toColor),e.push(t.colorMix),e.push(t.toOpacity),e.push(t.opacityMix),e}function qc(t){const e=[],s=[];let r=0;for(const i of t){const n=[...i.encode(),...zc.ret.encode()];e.push([r+t.length,0,0,0]),s.push(...n),r+=n.length}return[...e,...s]}async function Wc(t,e){const s=t;let r;if("number"==typeof s||"string"==typeof s||"boolean"==typeof s)r=s;else if(Array.isArray(s))r=await Promise.all(s.map((t=>Wc(t,e))));else if("object"==typeof s)if("valueExpressionInfo"in s){const{valueExpressionInfo:t}=s,{expression:i}=t;r={...s,computed:await e.createComputedField({expression:i})}}else{r={};for(const t in s)r[t]=await Wc(s[t],e)}return r}function jc(t,e,s){const r=t;let i;if("number"==typeof r||"string"==typeof r||"boolean"==typeof r)i=r;else if(Array.isArray(r))i=r.map((t=>jc(t,e,s)));else if("object"==typeof r)if("type"in r&&null!=r.type&&"Process"===r.type)switch(r.op){case"ArcadeColor":{const t=jc(r.value,e,s);Xc(Array.isArray(t)&&4===t.length),i=[t[0]/255,t[1]/255,t[2]/255,t[3]]}break;case"Transparency":{const t=jc(r.value,e,s);Xc("number"==typeof t),i=1-t/100}break;case"Divide":{const t=jc(r.left,e,s);Xc("number"==typeof t);const n=jc(r.right,e,s);Xc("number"==typeof n),i=t/n}break;case"Random":{const t=jc(r.seed,e,s),n=jc(r.min,e,s),o=jc(r.max,e,s);i=n+xc(vc(e.getObjectId()||0),t)*(o-n)}}else if("computed"in r)i=function(t){if(!("computed"in t))return t;let r=t.computed.readWithDefault(e,s,[255*t.defaultValue[0],255*t.defaultValue[1],255*t.defaultValue[2],t.defaultValue[3]]);if("string"==typeof r){const t=At.A.fromString(r);t&&(r=[t.r,t.g,t.b,t.a])}return r}(r);else{i={};for(const t in r)i[t]=jc(r[t],e,s)}return i}function*Yc(t){const e=t;if(Array.isArray(e))for(const t of e)yield*Yc(t);else if("object"==typeof e)if("type"in e&&null!=e.type&&"Process"===e.type)switch(e.op){case"ArcadeColor":case"Transparency":yield*Yc(e.value);break;case"Divide":yield*Yc(e.left),yield*Yc(e.right);break;case"Random":yield*Yc(e.seed),yield*Yc(e.min),yield*Yc(e.max)}else if("computed"in e)yield e.computed;else for(const t in e)yield*Yc(e[t])}function Xc(t){if(!t)throw new Error("Assertion failed.")}class $c{destroy(){}}class Hc extends $c{constructor(t){super(),this._value=t}resize(t){}read(t,e){return this._value}readWithDefault(t,e,s){return this._value}hasArcadeDependency(t){return!1}}async function Zc(t,e,s=!1){const{defaultValue:r,valueExpressionInfo:i,value:n}=e;if(i){const{expression:n}=i,o=await t.createComputedField({expression:n},s);return o?{...e,computed:o,defaultValue:r}:null}return{...e,computed:new Hc(n),defaultValue:r}}async function Qc(t,e){const{valueExpressionInfo:s}=e,{expression:r}=s,i=await t.createComputedField({expression:r});return i?{...e,computed:i}:null}function Kc(t){return"object"==typeof t&&null!=t&&(!(!("valueExpressionInfo"in t)||!t.valueExpressionInfo)||"type"in t&&"Process"===t.type&&"op"in t&&"Random"===t.op)}function Jc(t){if(Array.isArray(t))for(const e of t)if(Jc(e))return!0;if("object"==typeof t){if(Kc(t))return!0;for(const e in t)if(Jc(t[e]))return!0}return!1}class tl{static async create(t,e,s){const r={},i=new Map,n=new Map,o=new Map,a=new Map,h=new Map,c=new Map;for(const l in s){const u=s[l];if(null!=u&&"object"==typeof u)if(Array.isArray(u)){if("object"==typeof u[0])throw new Error(`InternalError: Cannot handle ${l}. Nested array params are not supported`);r[l]=u}else if("valueExpressionInfo"in u){if(u.value){r[l]=u.value;continue}const e=await Qc(t,u);if(!e){r[l]=u.defaultValue;continue}i.set(l,e),r[l]=null}else switch(u.type){case"cim-effect-infos":if(u.effectInfos.some((t=>t.overrides.length))){n.set(l,{effects:await Promise.all(u.effectInfos.map((async e=>{const s=e.overrides.map((e=>Zc(t,e)));return{effect:e.effect,compiledOverrides:(await Promise.all(s)).filter(bc.Ru)}})))});break}r[l]=u.effectInfos.map((t=>t.effect));break;case"cim-marker-placement-param":u.overrides.length&&o.set(l,{placementInfo:u,compiledOverrides:(await Promise.all(u.overrides.map((e=>Zc(t,e))))).filter(bc.Ru)}),r[l]=u.placement;break;case"text-rasterization-param":{if(u.overrides.length){const e=u.overrides.map((e=>Zc(t,e,u.useLegacyLabelEvaluationRules)));a.set(l,{compiledOverrides:(await Promise.all(e)).filter(bc.Ru),rasterizationParam:u,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:u.resource};r[l]=await e.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(u.overrides.length){const e=u.overrides.map((e=>Zc(t,e)));a.set(l,{compiledOverrides:(await Promise.all(e)).filter(bc.Ru),rasterizationParam:u,objectIdToResourceId:new Map});continue}if("animated"===u.resource.type){a.set(l,{compiledOverrides:[],rasterizationParam:u,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:u.resource};r[l]=await e.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=u;if(Jc(e)){const s={compiledMarkerInfos:[]};await Promise.all(e.map((async e=>{const r={props:{}};for(const s in e)if(Kc(e[s])){const i=await Qc(t,e[s]);r.compiledExpressionMap||(r.compiledExpressionMap=new Map);const n=r.compiledExpressionMap;i&&n.set(s,i)}else r.props[s]=e[s];s.compiledMarkerInfos.push(r)}))),h.set(l,s)}else r[l]={type:"cim-marker-transform-info",infos:e};break}case"animation-params":{const{params:s}=u,i=Vc(s);if(Jc(i)){const e=await Promise.all(i.map((e=>Wc(e,t))));c.set(l,{params:e,propertyIdToResourceId:new Map,key:l})}else{const t=Uc(i),s=await e.fetchResourceImmediate({type:"animation-info",resource:t});null!=s&&"sprite"===s.type&&(r[l]={dataRow:s.rect.y,dataColumn:s.rect.x})}break}default:r[l]=u}else r[l]=u}return new tl(s,r,i,n,o,a,h,c)}constructor(t,e,s,r,i,n,o,a){this.inputMeshParams=t,this._resolvedMeshParams=e,this._dynamicProperties=s,this._dynamicEffectProperties=r,this._dynamicPlacementProperties=i,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this._dynamicAsyncAnimations=a,this.evaluator=t=>t,this._arcadeDependencies=new Set;for(const t of this._expressions())(0,wc.QY)(this._arcadeDependencies,t)}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size||this._dynamicAsyncAnimations.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(t,e,s){for(const i of this._dynamicAsyncProperties.values()){const n=(0,Vt.o8)(i.rasterizationParam.resource);"animated"===i.rasterizationParam.resource.type&&i.rasterizationParam.resource.randomizeStartTime&&(n.primitiveName="__RESERVED__PRIMITIVE__NAME__",n.startGroup=vc(e.getObjectId()||0));for(const{primitiveName:t,propertyName:o,computed:a,defaultValue:h,valueExpressionInfo:c}of i.compiledOverrides)try{fr(n,"animated"===i.rasterizationParam.resource.type?n.primitiveName:t,o,a,e,s,h)}catch(e){E.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new r.A("invalid-arcade-expression",`Encountered an error when evaluating the arcade expression '${c?.expression}' (primitive: '${t}', property: '${o}')`,e))}const o=t.enqueueRequest({type:"cim-rasterization-info",resource:n});i.objectIdToResourceId.set(e.getObjectId(),o)}for(const r of this._dynamicAsyncAnimations.values()){const i=r.params.map((t=>jc(t,e,s))).map(Rc).map((t=>t.simplify())),n=qc(i),o=t.enqueueRequest({type:"animation-info",resource:n});r.propertyIdToResourceId.set(e.getObjectId()+"."+r.key,o)}}evaluateMeshParams(t,e,s){for(const[t,r]of this._dynamicProperties.entries())this._resolvedMeshParams[t]=r.computed.readWithDefault(e,s,r.defaultValue);for(const[t,r]of this._dynamicPlacementProperties.entries())for(const{computed:i,defaultValue:n,propertyName:o}of r.compiledOverrides){const a=i.readWithDefault(e,s,n);r.placementInfo.placement[o]=a,this._resolvedMeshParams[t]=r.placementInfo.placement}for(const[t,r]of this._dynamicEffectProperties.entries())for(const i of r.effects){for(const{computed:t,defaultValue:r,propertyName:n}of i.compiledOverrides){const o=t.readWithDefault(e,s,r);i.effect[n]=o}this._resolvedMeshParams[t]=r.effects.map((t=>t.effect))}for(const[t,r]of this._dynamicTransformProperties.entries()){const i={type:"cim-marker-transform-info",infos:[]};for(const t of r.compiledMarkerInfos){const r={...t.props};if(t.compiledExpressionMap)for(const[i,n]of t.compiledExpressionMap){const t=n.computed.readWithDefault(e,s,n.defaultValue);r[i]="number"==typeof t||"boolean"==typeof t?t:n.defaultValue}i.infos.push(r)}this._resolvedMeshParams[t]=i}for(const[s,r]of this._dynamicAsyncProperties.entries()){const i=r.objectIdToResourceId.get(e.getObjectId());if(null==i)continue;const n=t.getResource(i);this._resolvedMeshParams[s]=n}for(const[s,r]of this._dynamicAsyncAnimations.entries()){const i=r.propertyIdToResourceId.get(e.getObjectId()+"."+s);if(null==i)continue;const n=t.getResource(i);this._resolvedMeshParams[s]={dataRow:n.rect.y,dataColumn:n.rect.x}}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}hasArcadeDependency(t){return this._arcadeDependencies.has(t)}*_expressions(){for(const t of this._dynamicProperties.values())yield t.computed;for(const t of this._dynamicEffectProperties.values())for(const e of t.effects)for(const t of e.compiledOverrides)yield t.computed;for(const t of this._dynamicPlacementProperties.values())for(const e of t.compiledOverrides)yield e.computed;for(const t of this._dynamicAsyncProperties.values())for(const e of t.compiledOverrides)yield e.computed;for(const t of this._dynamicTransformProperties.values())for(const e of t.compiledMarkerInfos)if(null!=e.compiledExpressionMap)for(const t of e.compiledExpressionMap.values())yield t.computed;for(const t of this._dynamicAsyncAnimations.values())for(const e of t.params)yield*Yc(e)}}const el={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:dt.pe.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:dt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},offset:{type:dt.pe.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:t})=>{const e=(0,l.Lz)(t),s=-e/2,r=-e/2;return[[s,r],[s+e,r],[s,r+e],[s+e,r+e]]}}},texCoords:{type:dt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:dt.pe.UNSIGNED_BYTE,count:2,pack:({size:t})=>[t,t]},referenceSize:{type:dt.pe.UNSIGNED_BYTE,count:1,pack:({size:t})=>(0,l.Lz)(t)},zoomRange:{type:dt.pe.UNSIGNED_BYTE,count:2,pack:({scaleInfo:t},{tileInfo:e})=>kt(t,e)}}};class sl extends wr{constructor(){super(...arguments),this.vertexSpec=el}_write(t,e){const s=e.getDisplayId(),r=this.evaluatedMeshParams.minPixelBuffer,i=Math.max((0,l.Lz)(this.evaluatedMeshParams.size),r);let n,o;if("esriGeometryPoint"===e.geometryType)n=e.readXForDisplay(),o=e.readYForDisplay();else{const t=e.readCentroidForDisplay();if(!t)return;n=t?.coords[0],o=t?.coords[1]}t.recordStart(this.instanceId,this.attributeLayout),t.recordBounds(n,o,i,i);const a=t.vertexCount();this._writeVertex(t,s,n,o),t.indexWrite(a+0),t.indexWrite(a+1),t.indexWrite(a+2),t.indexWrite(a+1),t.indexWrite(a+3),t.indexWrite(a+2),t.recordEnd()}}class rl{async createMeshWriter(t,e,s,r){const i=this._getMeshWriter(r.techniqueType),n=await tl.create(t,e,r.inputParams),o=new i(r.id,n,r.optionalAttributes,s);return await o.loadDependencies(),o}_getMeshWriter(t){switch(t){case Pt.Fill:return ci;case Pt.DotDensity:return ai;case Pt.ComplexFill:return fi;case Pt.PatternFill:return ui;case Pt.GradientFill:return xh;case Pt.OutlineFill:return Ii;case Pt.PatternOutlineFill:return Mh;case Pt.ComplexOutlineFill:return _h;case Pt.Marker:return yc;case Pt.PieChart:return sl;case Pt.Text:return ic;case Pt.Line:return wi;case Pt.TexturedLine:return dc;case Pt.GradientStroke:return lc;case Pt.Heatmap:return Th;case Pt.Label:return ac;case Pt.AnimatedMarker:return Pr;default:throw new Error("Internal Error: Mesh writer not in the registry")}}}class il{constructor(t,e,s,r){this.storage=t,this.proxy=e,this.viewParams=s,this.registry=r}async createMeshWriters(t){const e=t.map((t=>this.registry.createMeshWriter(this.storage,this.proxy,this.viewParams,t)));return Promise.all(e)}}class nl{constructor(t){this._outstandingMessages=[],this._queue=new R.e({concurrency:t.concurrency,process:e=>t.process(e)})}async push(t){if(t.end)return await Promise.all(this._outstandingMessages),await this._queue.push(t),void(this._outstandingMessages=[]);const e=this._queue.push(t);return this._outstandingMessages.push(e),e}}var ol=s(43334),al=s(31464),hl=s(95466);class cl{static async create(t,e){if("count"===e.statisticType){const t=new Hc(1);return new cl(e.name,e.alias,e.type,e.statisticType,t)}const s=await t.createComputedField({expression:e.onStatisticExpression?.expression,field:e.onStatisticField});return new cl(e.name,e.alias,e.type,e.statisticType,s)}constructor(t,e,s,r,i){this.name=t,this.alias=e,this.type=s,this.statisticType=r,this.computed=i}}var ll=s(65529),ul=s(70328),dl=s(37730),_l=s(19730);class pl{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class fl{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}get isAggregate(){return!1}onSubscribe(t){const e=this.createState(t);this._sendStates.set(t.key.id,e),this.updateChunks()}onUnsubscribe(t){this._sendStates.get(t.key.id)?.destroy(),this._sendStates.delete(t.key.id)}invalidate(){const t=Array.from(this._sendStates.values());this._sendStates.clear();for(const e of t)e.destroy(),this.onSubscribe(e.subscription)}invalidateAttributeData(t){}hasArcadeDependency(t){return!1}getFeatureObjectIdsForAggregate(t){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(t){return this.displayMap(t,(t=>t),(t=>t))}getDisplayAndObjectIds(t){return this.displayMap(t,(t=>t),((t,e,s)=>[t,s]))}afterUpdateChunks(){}}class gl extends fl{constructor(t,e,s,r){super(t,e),this.spatialReference=s,this.aggregateFields=r,this._arcadeDependencies=new Set,this.events=new ll.A,this.featureAdapter=dl.T;for(const t of r)(0,wc.QY)(this._arcadeDependencies,t.computed)}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new _l.do({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}get isAggregate(){return!0}removeChunks(t){}hasArcadeDependency(t){return this._arcadeDependencies.has(t)}forEach(t){return this.forEachAggregateWorldSpace(t)}forEachInBounds(t,e){}forEachBounds(t,e){const s=(0,ul.vt)();for(const r of t){const t=(0,Ch.jQ)(s,r.geometry,!1,!1);t&&e(t)}}}class ml{constructor(t,e,s,r,i){this.subscription=t,this.reader=e,this.clear=s,this.end=r,this.debugInfo=i,this.type="append"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"append",clear:this.clear,id:this.id,append:t,end:this.end,debugInfo:this.debugInfo,subscriptionVesrion:this.subscription.version,version:e,attributeEpoch:s}}}class yl{constructor(t,e,s,r,i){this.subscription=t,this.reader=e,this.remove=s,this.end=r,this.debugInfo=i,this.type="update"}get id(){return this.subscription.tile.id}createMessage(t,e,s){return{type:"update",id:this.id,modify:t,debugInfo:this.debugInfo,remove:this.remove,version:e,subscriptionVesrion:this.subscription.version,end:this.end,attributeEpoch:s}}}class bl extends $c{constructor(t){super(),this._field=t}resize(t){throw new Error("Method not implemented.")}read(t,e){return t.readAttribute(this._field)}readWithDefault(t,e){return t.readAttribute(this._field)}hasArcadeDependency(t){return!1}}function wl(t,e,s){if(null==t)return null;const r=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;try{return t.evaluate({...s,$feature:r},t.services)}catch(t){return E.A.getLogger("esri.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",t),null}}function xl(t){return null==t||t===1/0||t===-1/0||"number"==typeof t&&isNaN(t)}function vl(t,e,s,r){if(null==t)return null!=r?r:null;const i=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;const n=t.evaluate({...s,$feature:i},t.services);return xl(n)?null!=r?r:null:n}class Sl extends $c{static async create(t,e){const s=await(0,wc.Ad)(t,e.spatialReference,e.fields),r=(0,lt.Wm)(t);return new Sl(s,r)}constructor(t,e){super(),this._compiled=t,this._cacheKey=e}resize(t){}read(t,e){return this.hasArcadeDependency("scale")||"system"!==e.$view.timeZone?wl(this._compiled,t,e):this._readCached(t,e)}readWithDefault(t,e,s){return this.hasArcadeDependency("scale")||"system"!==e.$view.timeZone?vl(this._compiled,t,e,s):this._readWithDefaultCached(t,e,s)}hasArcadeDependency(t){return this._compiled?.references(t)??!1}_getCacheKey(t){if(!this._compiled?.references("timeProperties"))return this._cacheKey;const{currentStart:e,currentEnd:s}=t.$view.timeProperties;return this._cacheKey+function(t,e){const s=43758.5453*Math.sin(12.9898*t+78.233*e);return s-Math.floor(s)}(e??1,s??1)}_readCached(t,e){if(t.setCache(this._getCacheKey(e)),t.hasCachedValue())return t.getCachedValue();const s=wl(this._compiled,t,e);return t.setCachedValue(s),s}_readWithDefaultCached(t,e,s){if(t.setCache(this._getCacheKey(e)),t.hasCachedValue())return t.getCachedValue();const r=vl(this._compiled,t,e,s);return t.setCachedValue(r),r}}var Il=s(97770),Ml=s(18047),Pl=s(68463),Tl=s(30524),Al=s(32730);class Cl extends $c{static async create(t,e){const s=(0,Al.lc)(t);return new Cl((t=>s.replaceAll(/{[^}]*}/g,(e=>{const s=e.slice(1,-1),r=t.metadata.fieldsIndex.get(s);if(null==r)return e;const i=t.readAttribute(s);return null==i?"":function(t,e){if(null==t)return"";const s=e.domain;if(s)if("codedValue"===s.type||"coded-value"===s.type){const e=t;for(const t of s.codedValues)if(t.code===e)return t.name}else if("range"===s.type){const{max:r,min:i}=(0,Pl.A5)(e),n=+t;if(null!=i&&null!=r&&i<=n&&n<=r)return s.name}let r=t;return(0,Tl.vE)(e)?r=(0,Il.Yq)(r,(0,Il.J2)("short-date")):(0,Tl.WA)(e)&&(r=(0,Ml.ZV)(+r)),r||""}(i,r)}))))}constructor(t){super(),this._evaluator=t}resize(t){}read(t,e){return this._evaluator(t)}readWithDefault(t,e,s){const r=this._evaluator(t);return xl(r)?s:r}hasArcadeDependency(t){return!1}}class kl extends $c{constructor(t,e){super(),this._field=t,this._normalizationInfo=e}resize(t){throw new Error("Method not implemented.")}read(t,e){return this._readNormalized(t)}readWithDefault(t,e){return this._readNormalized(t)}hasArcadeDependency(t){return!1}_readNormalized(t){const e=t.readAttribute(this._field);if(null==e)return null;const{normalizationField:s,normalizationTotal:r,normalizationType:i}=this._normalizationInfo,n=t.readAttribute(s);switch(i??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?e/n:void 0:null;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return r?e/r*100:null}}}class Fl{static fromBuffer(t,e){return new Fl(t,e)}static create(t,e=4294967295){const s=new Uint32Array(Math.ceil(t/32));return new Fl(s,e)}constructor(t,e){this._mask=0,this._buf=t,this._mask=e}_getIndex(t){return Math.floor(t/32)}has(t){const e=this._mask&t;return!!(this._buf[this._getIndex(e)]&1<<e%32)}hasRange(t,e){let s=t,r=e;for(;s%32&&s!==r;){if(this.has(s))return!0;s++}for(;r%32&&s!==r;){if(this.has(s))return!0;r--}if(s===r)return!1;for(let t=s/32;t!==r/32;t++)if(this._buf[t])return!0;return!1}set(t){const e=this._mask&t,s=this._getIndex(e),r=1<<e%32;this._buf[s]|=r}setRange(t,e){let s=t,r=e;for(;s%32&&s!==r;)this.set(s++);for(;r%32&&s!==r;)this.set(r--);if(s!==r)for(let t=s/32;t!==r/32;t++)this._buf[t]=4294967295}unset(t){const e=this._mask&t,s=this._getIndex(e),r=1<<e%32;this._buf[s]&=4294967295^r}resize(t){const e=this._buf,s=new Uint32Array(Math.ceil(t/32));s.set(e),this._buf=s}or(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=t._buf[e];return this}and(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=t._buf[e];return this}xor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=t._buf[e];return this}ior(t){for(let e=0;e<this._buf.length;e++)this._buf[e]|=~t._buf[e];return this}iand(t){for(let e=0;e<this._buf.length;e++)this._buf[e]&=~t._buf[e];return this}ixor(t){for(let e=0;e<this._buf.length;e++)this._buf[e]^=~t._buf[e];return this}any(){for(let t=0;t<this._buf.length;t++)if(this._buf[t])return!0;return!1}copy(t){for(let e=0;e<this._buf.length;e++)this._buf[e]=t._buf[e];return this}clone(){return new Fl(this._buf.slice(),this._mask)}clear(){for(let t=0;t<this._buf.length;t++)this._buf[t]=0;return this}forEachSet(t){for(let e=0;e<this._buf.length;e++){let s=this._buf[e],r=32*e;if(s)for(;s;)1&s&&t(r),s>>>=1,r++}}countSet(){let t=0;return this.forEachSet((e=>{t++})),t}}var El=s(39516);const zl=()=>E.A.getLogger("esri.views.2d.layers.features.support.whereUtils"),Ol={getAttribute:(t,e)=>t.readAttribute(e)};async function Rl(t,e){try{const s=await(0,El.G)(t,e);if(!s.isStandardized){const t=new r.A("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",s);zl().error(t)}return e=>{const r=e.readArcadeFeature();try{return s.testFeature(r,Ol)}catch(e){return zl().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),!0}}}catch(e){return zl().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),t=>!0}}const Dl=()=>E.A.getLogger("esri.views.2d.layers.features.support.ComputedAttributeStorage"),Ll=4294967295;function Nl(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(s)}class Bl{constructor(t){this._numerics=[],this._strings=[],this._allocatedSize=256,this._bitsets=[],this._instanceIds=[],this._bounds=[],this._dirtyBitset=this.getBitset(this.createBitset()),this.compilationOptions=t}createBitset(){const t=this._bitsets.length;return this._bitsets.push(Fl.create(this._allocatedSize,kh)),t+1}async createComputedField(t,e=!1){if(t.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return e?await Cl.create(t.expression,this.compilationOptions):await Sl.create(t.expression,this.compilationOptions)}catch(e){const s=new r.A("featurelayer","Failed to compile arcade expression",{error:e,expression:t.expression});return Dl().error(s),null}if(t.normalizationType||t.normalizationField)return new kl(t.field,t);if(t.field)return new bl(t.field);const s=new r.A("featurelayer","Unable to create computed field. No expression or field found",{info:t});return Dl().error(s),null}async createWhereClause(t){return t?Rl(t,this.compilationOptions.fields):null}getBitset(t){return this._bitsets[t-1]}getComputedNumeric(t,e){return this.getComputedNumericAtIndex(t&kh,0)}setComputedNumeric(t,e,s){return this.setComputedNumericAtIndex(t&kh,s,0)}getComputedString(t,e){return this.getComputedStringAtIndex(t&kh,0)}setComputedString(t,e,s){return this.setComputedStringAtIndex(t&kh,0,s)}getComputedNumericAtIndex(t,e){const s=t&kh;return this._ensureNumeric(e,s),this._numerics[e][s]}setComputedNumericAtIndex(t,e,s){const r=t&kh;this._ensureNumeric(e,r),this._numerics[e][r]=s}getPackedChunkId(t){const e=t&kh;return this._ensureInstanceId(e),this._instanceIds[e]}setPackedChunkId(t,e){const s=t&kh;this._ensureInstanceId(s),this._instanceIds[s]=e}getComputedStringAtIndex(t,e){const s=t&kh;return this._ensureString(e,s),this._strings[e][s]}setComputedStringAtIndex(t,e,s){const r=t&kh;this._ensureString(e,r),this._strings[e][r]=s}getXMin(t){return this._bounds[4*(t&kh)]}getYMin(t){return this._bounds[4*(t&kh)+1]}getXMax(t){return this._bounds[4*(t&kh)+2]}getYMax(t){return this._bounds[4*(t&kh)+3]}setBounds(t,e,s=!1){const r=t&kh;if(!s&&!this._dirtyBitset.has(t))return this._bounds[4*r]!==Ll;this._dirtyBitset.unset(t);const i=e.readGeometryWorldSpace();if(Nl(this._bounds,4*r+4,0),!i||!i.coords.length)return this._bounds[4*r]=Ll,this._bounds[4*r+1]=Ll,this._bounds[4*r+2]=Ll,this._bounds[4*r+3]=Ll,!1;let n=1/0,o=1/0,a=-1/0,h=-1/0;return i.forEachVertex(((t,e)=>{n=Math.min(n,t),o=Math.min(o,e),a=Math.max(a,t),h=Math.max(h,e)})),this._bounds[4*r]=n,this._bounds[4*r+1]=o,this._bounds[4*r+2]=a,this._bounds[4*r+3]=h,!0}getBounds(t,e){const s=this.getXMin(e),r=this.getYMin(e),i=this.getXMax(e),n=this.getYMax(e);return(0,ul.BI)(t,s,r,i,n),s!==Ll}_ensureNumeric(t,e){this._numerics[t]||(this._numerics[t]=[]),Nl(this._numerics[t],e,0)}_ensureInstanceId(t){Nl(this._instanceIds,t,0)}_ensureString(t,e){this._strings[t]||(this._strings[t]=[]),Nl(this._strings[t],e,null)}}var Gl=s(58727),Ul=s(62660),Vl=s(86420),ql=s(61956);class Wl{getObjectId(t){return t.getObjectId()}getAttributes(t){return t.readAttributes()}getAttribute(t,e){return t.readAttribute(e)}getAttributeAsTimestamp(t,e){return t.readAttributeAsTimestamp(e)}cloneWithGeometry(t,e){return t}getGeometry(t){return t.readGeometryWorldSpace()}getCentroid(t,e){return t.readCentroidForDisplay()}}Wl.Shared=new Wl;class jl{constructor(t){this._geometryBounds=(0,N.vt)(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new jl(t);return await e.update(t.filterJSON,t.spatialReference),e}get hash(){return this._hash}check(t){return this._applyFilter(t)}clear(){const t=this._resetAllHiddenIds();return this.update(),{show:t,hide:[]}}invalidate(){this._idToVisibility.forEach(((t,e)=>{this._idToVisibility.set(e,0)}))}setKnownIds(t){for(const e of t)this._idToVisibility.set(e,1)}setTrue(t){const e=[],s=[],r=new Set(t);return this._idToVisibility.forEach(((t,i)=>{const n=!!(1&this._idToVisibility.get(i)),o=r.has(i);!n&&o?e.push(i):n&&!o&&s.push(i),this._idToVisibility.set(i,o?3:0)})),{show:e,hide:s}}createQuery(){const{geometry:t,spatialRel:e,where:s,timeExtent:r,objectIds:i}=this;return ql.A.fromJSON({geometry:t,spatialRel:e,where:s,timeExtent:r,objectIds:i})}async update(t,e){this._hash=JSON.stringify(t);const s=await(0,Gl.T2)(t,null,e);await Promise.all([this._setGeometryFilter(s),this._setIdFilter(s),this._setAttributeFilter(s),this._setTimeFilter(s)])}async _setAttributeFilter(t){if(!t?.where)return this._clause=null,void(this.where=null);this._clause=await Rl(t.where,this._serviceInfo.fieldsIndex),this.where=t.where}_setIdFilter(t){this._idsToShow=t?.objectIds&&new Set(t.objectIds),this._idsToHide=t?.hiddenIds&&new Set(t.hiddenIds),this.objectIds=t?.objectIds}async _setGeometryFilter(t){if(!t?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const e=t.geometry,s=t.spatialRel??"esriSpatialRelIntersects",r=await(0,Ul.xt)(s,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,Ue.Rg)(this._geometryBounds,e),this._spatialQueryOperator=r,this.geometry=e,this.spatialRel=s}_setTimeFilter(t){if(this.timeExtent=this._timeOperator=null,t?.timeExtent)if(this._serviceInfo.timeInfo)this.timeExtent=t.timeExtent,this._timeOperator=(0,Vl.I)(this._serviceInfo.timeInfo,t.timeExtent,Wl.Shared);else{const e=new r.A("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",t.timeExtent);E.A.getLogger("esri.views.2d.layers.features.controllers.FeatureFilter").error(e)}}_applyFilter(t){return this._filterByGeometry(t)&&this._filterById(t)&&this._filterByTime(t)&&this._filterByExpression(t)}_filterByExpression(t){return!this.where||this._clause(t)}_filterById(t){return(!this._idsToHide?.size||!this._idsToHide.has(t.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(t.getObjectId()))}_filterByGeometry(t){if(!this.geometry)return!0;const e=t.readGeometryWorldSpace();return!!e&&this._spatialQueryOperator(e)}_filterByTime(t){return null==this._timeOperator||this._timeOperator(t)}_resetAllHiddenIds(){const t=[];return this._idToVisibility.forEach(((e,s)=>{1&e||(this._idToVisibility.set(s,1),t.push(s))})),t}}class Yl{static minimal(t,e,s=[]){return new Yl({geometryType:t,fieldsIndex:new hl.A(s).toJSON(),objectIdField:e,subtypes:null,subtypeField:null,types:null,globalIdField:null,spatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null})}static createFeature(t){return new Yl(t)}constructor(t){this._options=t,this._fieldsIndex=hl.A.fromJSON(t.fieldsIndex),t.spatialReference&&(this._spatialReference=q.A.fromJSON(t.spatialReference)),this._arcadeSchema={fields:this.fieldsIndex.fields,fieldsIndex:this.fieldsIndex,geometryType:this.geometryType,objectIdField:this.objectIdField,globalIdField:this._options.globalIdField,spatialReference:this._spatialReference,timeInfo:this._options.timeInfo,typeIdField:this._options.typeIdField??void 0,types:this._options.types??void 0,subtypeField:this._options.subtypeField,subtypes:this._options.subtypes??void 0}}get fieldsIndex(){return this._fieldsIndex}get geometryType(){return"esriGeometryMultiPatch"===this._options.geometryType?"esriGeometryPolygon":this._options.geometryType}get serviceGeometryType(){return this._options.geometryType}get subtypeField(){return this._options.subtypeField}get timeInfo(){return this._options.timeInfo}get objectIdField(){return this._options.objectIdField}get globalIdField(){return this._options.globalIdField}get arcadeSchema(){return this._arcadeSchema}get spatialReference(){return this._spatialReference}get timeReferenceUnknownClient(){return this._options.timeReferenceUnknownClient}}var Xl=s(66131),$l=s(44729),Hl=s(15032),Zl=s(27647),Ql=s(56400);class Kl{constructor(t){this._valid=Fl.create(t),this._data=new Array(t)}has(t){return this._valid.has(t)}set(t,e){this._valid.set(t),this._data[t]=e}get(t){return this._data[t]}}const Jl=(0,n.A)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],tu=Jl[0],eu=Jl[1],su=Jl[2],ru=Jl[3],iu=(0,n.A)("featurelayer-simplify-payload-size-factors")??[1,2,4],nu=iu[0],ou=iu[1],au=iu[2],hu=(0,n.A)("featurelayer-simplify-mobile-factor")??2,cu=(0,n.A)("esri-mobile"),lu=4294967295;class uu{constructor(t){this.metadata=t,this.type="FeatureSetReader",this._overrides=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}destroy(){}[Symbol.dispose](){this.destroy()}getAreaSimplificationThreshold(t,e){let s=1;const r=cu?hu:1;e>4e6?s=au*r:e>1e6?s=ou*r:e>5e5?s=nu*r:e>1e5&&(s=r);let i=0;return t>4e3?i=ru*s:t>2e3?i=su*s:t>100?i=eu:t>15&&(i=tu),i}getBounds(t){if(function(t,e){if(!(t.length>e))for(;t.length<=e;)t.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===lu)return!1;if(0===this.getBoundsXMin()){const e=this.readGeometryWorldSpace();if(!e)return this.setBoundsXMin(lu),!1;let s=1/0,r=1/0,i=-1/0,n=-1/0;return e.forEachVertex(((t,e)=>{s=Math.min(s,t),r=Math.min(r,e),i=Math.max(i,t),n=Math.max(n,e)})),this.setBoundsXMin(s),this.setBoundsYMin(r),this.setBoundsXMax(i),this.setBoundsYMax(n),(0,ul.BI)(t,s,r,i,n),!0}const e=this.getBoundsXMin(),s=this.getBoundsYMin(),r=this.getBoundsXMax(),i=this.getBoundsYMax();return(0,ul.BI)(t,e,s,r,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(t){this._boundsBuffer[4*this.getIndex()]=t}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(t){this._boundsBuffer[4*this.getIndex()+1]=t}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(t){this._boundsBuffer[4*this.getIndex()+2]=t}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(t){this._boundsBuffer[4*this.getIndex()+3]=t}readAttributeAsTimestamp(t){const e=this.readAttribute(t);return"string"==typeof e?new Date(e).getTime():"number"==typeof e||null==e?e:null}readAttribute(t,e=!1){const s=this._readAttribute(t,e);if(void 0!==s)return s;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(t,e);if(void 0!==r)return r}}readAttributes(){const t=this._readAttributes();for(const e of this._joined){e.setIndex(this.getIndex());const s=e._readAttributes();for(const e of Object.keys(s))t[e]=s[e]}return t}joinAttributes(t){this._joined.push(t)}registerOverrides(t){this._overrides=t}readOptimizedFeatureWorldSpace(){const t=this.readGeometryWorldSpace(),e=this.readAttributes(),s=this.readCentroidWorldSpace();return new ol.Om(t,e,s,this.getObjectId(),this.getDisplayId())}readLegacyFeatureForDisplay(){const t=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyFeatureWorldSpace(){const t=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyGeometryForDisplay(){const t=this.readGeometryForDisplay();return(0,Ch.zv)(t,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const t=this._readX(),e=this.getInTransform();return null==e?t:t*e.scale[0]+e.translate[0]}readYWorldSpace(){const t=this._readY(),e=this.getInTransform();return null==e?t:e.translate[1]-t*e.scale[1]}readGeometryForDisplay(){const t=this._readGeometryDeltaDecoded(!0);if(!t){const t=this._createGeometryFromServerCentroid();return t?t.deltaDecode():null}return t}readGeometryForDisplayTransformed(t){const e=this.readGeometryForDisplay(),s=new jt.A;return(0,Ch.Nl)(s,e,this.hasZ,this.hasM,this.geometryType,t),s.deltaDecode()}readGeometryWorldSpace(){let t=this._readGeometry();if(t||(t=this._createGeometryFromServerCentroid()),!t)return null;const e=t.clone(),s=this.getInTransform();return null!=s&&(0,Ch.Ch)(e,e,this.hasZ,this.hasM,s),e}readCentroidForDisplay(){const t=this.readGeometryForDisplay();return t?this._computeDisplayCentroid(t):this._readServerCentroid()}readCentroidWorldSpace(){const t=this.readGeometryForDisplay(),e=t?this._computeDisplayCentroid(t):this._readServerCentroid();if(!e)return null;const s=e.clone(),r=this.getInTransform();return null!=r&&(0,Ch.Ch)(s,s,this.hasZ,this.hasM,r),s}setCache(t){let e=this._caches.get(t);null==e&&(e=new Kl(this.getSize()),this._caches.set(t,e)),this._activeCache=e}setCachedValue(t){this._activeCache.set(this.getIndex(),t)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}_readGeometryDeltaDecoded(t){const e=this._readGeometry(t);return"esriGeometryPoint"!==this.geometryType&&e&&this.getInTransform()?e.deltaDecode():e}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(t){this._contextTimeZone=t}readArcadeFeature(){return this}hasField(t){return this.fields.has(t)||this._joined.some((e=>e.hasField(t)))}geometry(){const t=this.readGeometryWorldSpace(),e=(0,Ch.zv)(t,this.geometryType,this.hasZ,this.hasM),s=(0,Wt.rS)(e);if(s){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");s.spatialReference=this.metadata.spatialReference}return s}autocastArcadeDate(t,e){return e&&e instanceof Date?this.isUnknownDateTimeField(t)?Xl.lY.unknownDateJSToArcadeDate(e):Xl.lY.dateJSAndZoneToArcadeDate(e,this.contextTimeZone??Ql.qU):e}isUnknownDateTimeField(t){return this.metadata.fieldsIndex.getTimeZone(t)===Ql.L5}field(t){let e=this.fields.get(t);if(e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return $l.n.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Hl.k.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Xl.lY.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const s of this._joined)if(s.setIndex(this.getIndex()),e=s.fields.get(t),e)switch(e.type){case"date-only":case"esriFieldTypeDateOnly":return $l.n.fromReader(s._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Hl.k.fromReader(s._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Xl.lY.fromReaderAsTimeStampOffset(s._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,s._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(t,e){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((t=>t.name))}castToText(t=!1){if(!t)return JSON.stringify(this.readLegacyFeatureForDisplay());const e=this.readLegacyFeatureForDisplay();if(!e)return JSON.stringify(null);const s={geometry:e.geometry,attributes:{...e.attributes??{}}};for(const t in s.attributes){const e=s.attributes[t];e instanceof Date&&(s.attributes[t]=e.getTime())}return JSON.stringify(s)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(t=null){return{attributes:this._readAttributes(),geometry:!0===t?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(t=null,e=null){return Promise.resolve(this.castAsJson(e))}_getExists(){if(this._overrides){const t=this.getObjectId();return!this._overrides.hasOverride(t)}return!0}_computeDisplayCentroid(t){if(null==this.getInTransform())return(0,Zl.Q)(new jt.A,t,this.hasM,this.hasZ);const e=Yt.fromOptimized(t,this.geometryType);e.yFactor*=-1;const s=_s(e);return s?(s[1]*=-1,new jt.A([],s)):null}copyInto(t){t._joined=this._joined,t._overrides=this._overrides,t._objectIdToIndex=this._objectIdToIndex,t._boundsBuffer=this._boundsBuffer,t._activeCache=this._activeCache,t._caches=this._caches,t._contextTimeZone=this._contextTimeZone}_readLegacyGeometryWorldSpace(){const t=this.readGeometryWorldSpace();return(0,Ch.zv)(t,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const t=this._readServerCentroid();if(!t)return null;const[e,s]=t.coords;return this._createQuantizedExtrudedGeometry(e,s)}_createQuantizedExtrudedGeometry(t,e){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(t,e):this._createQuantizedExtrudedQuad(t,e)}_createQuantizedExtrudedQuad(t,e){return new jt.A([5],[t-1,e,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(t,e){return new jt.A([2],[t-1,e+1,1,-1])}}class du extends uu{static fromFeatures(t,e){const{objectIdField:s,geometryType:r}=e,i=(0,Ch.Di)([],t,r,!1,!1,s);for(let e=0;e<i.length;e++)i[e].displayId=t[e].displayId;return du.fromOptimizedFeatures(i,e)}static fromFeatureSet(t,e){const s=(0,Ch.q3)(t,e.objectIdField);return du.fromOptimizedFeatureSet(s,e)}static fromOptimizedFeatureSet(t,e){const s=du.fromOptimizedFeatures(t.features,e);return s._exceededTransferLimit=t.exceededTransferLimit,s._transform=t.transform,s._fieldsIndex=new hl.A(t.fields),s}static fromOptimizedFeatures(t,e,s){const r=new du(t,e);return r._fieldsIndex=e.fieldsIndex,r._transform=s,r}static empty(t){return new du([],t)}constructor(t,e){super(e),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=e.geometryType,this._features=t}get fields(){return this._fieldsIndex}get geometryType(){return this._geometryType}get hasFeatures(){return!!this._features.length}get hasNext(){return this._featureIndex+1<this._features.length}get exceededTransferLimit(){return this._exceededTransferLimit}get hasZ(){return!1}get hasM(){return!1}get _current(){return this._features[this._featureIndex]}get usedMemory(){return this._current.usedMemory}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let t="";for(const e in this._current.attributes)t+=this._current.attributes[e];return t}getIndex(){return this._featureIndex}setIndex(t){this._featureIndex=t}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(t){this._current.displayId=t}copy(){const t=new du(this._features,this.metadata);return this.copyInto(t),t}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return(0,ol.N3)(this._current)?(0,Ch.Rk)(this._current.geometry,2):0}_readX(){return(0,ol.N3)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,ol.N3)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,ol.N3)(this._current)?this._current.geometry??null:null}_readServerCentroid(){return this._current.centroid}_readAttribute(t,e){if(!this._fieldsIndex){const e=this._current.attributes[t];if(void 0!==e)return e;const s=t.toLowerCase();for(const t in this._current.attributes)if(t.toLowerCase()===s)return this._current.attributes[t];return}const s=this._fieldsIndex.get(t);if(!s)return;const r=this._current.attributes[s.name];return null==r?r:e&&this.fields.isDateField(t)?new Date(r):r}_readAttributes(){return this._current.attributes}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._transform=this._transform,t._fieldsIndex=this._fieldsIndex}}class _u extends pl{constructor(t,e){super(t),this.bins=new Map,this.featureCache=new Map,this.done=!1,this._store=e}reset(){this.destroy(),this.done=!1}destroy(){const t=this.subscription.tile.key.level;for(const e of this.featureCache.keys())this._store.releaseDisplayIdForObjectId(`${e}.${t}`);this.bins.clear(),this.featureCache.clear(),this.handledChunks.clear()}get tile(){return this.subscription.tile}*featuresWorldSpace(){for(const t of this.featureCache.values()){const e=t.clone();e.geometry&&(0,Ch.Ch)(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}class pu extends gl{static async create(t,e,s,r,i){const n=new Bl({spatialReference:e}),o=await Promise.all(t.fields.map((async t=>cl.create(n,t)))),a=t.featureFilter?await jl.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:e,filterJSON:t.featureFilter}):null;return"geohash"===t.index.type&&await(0,al.Nk)(e,q.A.WGS84),new pu(t,a,i,o,e,s,r)}constructor(t,e,s,r,i,n,o){super(n,o,i,r),this._schema=t,this._featureFilter=e,this._arcadeContextInfo=s,this._metadata=Yl.createFeature({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fieldsIndex:new hl.A(t.fields).toJSON(),globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(t){return new _u(t,this._attributeStore)}async*applyOverrideUpdate(t){for(const t of this._sendStates.values()){t.reset();const e=new ml(t.subscription,du.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(t,e,s){const r=new Map(t.map((t=>[e(t),t]))),i=[];for(const t of this._sendStates.values())for(const e of t.featuresWorldSpace()){const{objectId:t,displayId:n}=e,o=r.get(t);if(null!=o){const e=s(n,o,t);i.push(e),r.delete(t)}}return i}getDisplayFeatures(t){const e=new Set(t),s=new Set,r=[];for(const t of this._sendStates.values())for(const i of t.featuresWorldSpace())e.has(i.displayId)&&!s.has(i.objectId)&&(i.geometry&&r.push({...(0,Ch.oN)(i,this._metadata.geometryType,!1,!1),displayId:i.displayId}),s.add(i.objectId));return{features:[],aggregates:r}}getFeatureObjectIdsForAggregate(t){for(const e of this._sendStates.values())for(const s of e.bins.values())if(s.id===t)return Array.from(s.containedObjectIds);return[]}async*updateChunks(){for(const t of this._sendStates.values())yield*this._update(t,this._source)}forEachAggregateWorldSpace(t){const e=new Set;for(const s of this._sendStates.values())for(const r of s.featuresWorldSpace())e.has(r.objectId)||(t(r),e.add(r.objectId))}_createIndexOptions(t){switch(this._schema.index.type){case"geohash":return{type:"geohash",fields:this.aggregateFields,featureFilter:this._featureFilter,geohashLevel:this._schema.index.fixBinLevel,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:t.scale};case"grid":{const e=this._schema.index.fixedBinLevel,s=null!=e?t.tileInfoView.getLODInfoAt(e).scale:t.scale;return{type:"grid",fields:this.aggregateFields,cellSize:this._schema.index.size,featureFilter:this._featureFilter,spatialReference:this.spatialReference,arcadeContextInfo:this._arcadeContextInfo,scale:s}}}}async*_update(t,e){const{handledChunks:s,subscription:r,bins:i,featureCache:n}=t,o=r.tile;if(t.done)return;for(const r of e.chunks()){if(s.has(r.chunkId))continue;s.add(r.chunkId);const e=r.queryInfo;if("tileId"in e){const t=new p.A(e.tileId);if(t.level!==o.level||t.world!==o.key.world)continue}r.getAggregateIndex(this._createIndexOptions(t.tile)).putBounded(i,t.tile.extent,t.tile.resolution)}const a=[],h=r.tile.transform,c=r.tile.key.level;for(const t of i.values()){let e=n.get(t.id);if(e)e.attributes=t.getAttributes();else{const s=t.getGeometry(this.spatialReference,h);e=new ol.Om(s,t.getAttributes(),null,t.id),s||(e.centroid=t.getGeometricCentroid(this.spatialReference,h)),e.displayId=this._attributeStore.createDisplayIdForObjectId(`${e.objectId}.${c}`),n.set(t.id,e)}a.push(e)}this.events.emit("changed"),t.done=!e.updateTracking.updating;const l=du.fromOptimizedFeatures(a,this._metadata,h),u=l.getCursor(),d=t.subscription.tile.createArcadeEvaluationOptions(this._arcadeContextInfo);for(;u.next();)this._attributeStore.setAttributeData(u.getDisplayId(),u,d);const _=new yl(t.subscription,l,[],t.done,{});yield _}}class fu{constructor(t){this._statistics=t}get statistics(){return this._statistics}}const gu=Math.PI/180;class mu{static create(t){return new mu(t.map((t=>function(t){switch(t.statisticType){case"min":return new bu(t);case"max":return new wu(t);case"avg":return new vu(t);case"avg_angle":return new Su(t);case"sum":case"count":return new xu(t);case"mode":return new Iu(t)}}(t))))}constructor(t){this._statistics=t}values(){return this._statistics.values()}insert(t,e){for(const s of this._statistics)s.insert(t,e)}merge(t){for(let e=0;e<this._statistics.length;e++){const s=this._statistics[e],r=t._statistics[e];if(s.field.name!==r.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");s.merge(r)}}clone(){return new mu(this._statistics.map((t=>t.clone())))}}class yu{constructor(t){this.field=t}insert(t,e){if(!this.field.computed)return;const s=this.field.computed.read(t,e);xl(s)||this._insertValue(s)}}class bu extends yu{constructor(){super(...arguments),this.type="min",this.value=Number.MAX_VALUE}_insertValue(t){this.value=Math.min(this.value,t)}merge(t){this.value=Math.min(this.value,t.value)}clone(){const t=new bu(this.field);return t.value=this.value,t}}class wu extends yu{constructor(){super(...arguments),this.type="max",this.value=Number.MIN_VALUE}_insertValue(t){this.value=Math.max(this.value,t)}merge(t){this.value=Math.max(this.value,t.value)}clone(){const t=new wu(this.field);return t.value=this.value,t}}class xu extends yu{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(t){this.value+=t}merge(t){this.value+=t.value}clone(){const t=new xu(this.field);return t.value=this.value,t}}class vu extends yu{constructor(){super(...arguments),this.type="avg",this._total=0,this._count=0}get value(){return this._total/this._count}_insertValue(t){this._total+=t,this._count+=1}merge(t){this._total+=t._total,this._count+=t._count}clone(){const t=new vu(this.field);return t._total=this._total,t._count=this._count,t}}class Su extends yu{constructor(){super(...arguments),this.type="avg_angle",this._x=0,this._y=0,this._count=0}get value(){const t=this._x/this._count,e=this._y/this._count,s=180/Math.PI;return Math.atan2(e,t)*s}_insertValue(t){this._x=this._x+Math.cos(t*gu),this._y=this._y+Math.sin(t*gu),this._count+=1}merge(t){this._x+=t._x,this._y+=t._y,this._count+=t._count}clone(){const t=new Su(this.field);return t._x=this._x,t._y=this._y,t._count=this._count,t}}class Iu extends yu{constructor(){super(...arguments),this._frequencies=new Map}get value(){let t,e=0;for(const[s,r]of this._frequencies.entries())r>e&&(e=r,t=s);return t}_insertValue(t){const e=this._frequencies.get(t);null!=e?this._frequencies.set(t,e+1):this._frequencies.set(t,1)}merge(t){for(const[e,s]of t._frequencies.entries()){const t=this._frequencies.get(e);null!=t?this._frequencies.set(e,t+s):this._frequencies.set(e,s)}}clone(){const t=new Iu(this.field);return t._frequencies=new Map(this._frequencies),t}}class Mu extends fu{static createId(t,e){return`${t}.${e}`}static create(t,e,s,r){return new Mu(t,e,mu.create(s),r)}constructor(t,e,s,r){super(s),this.gridX=t,this.gridY=e,this._worldUnitsPerCell=r,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return Mu.createId(this.gridX,this.gridY)}get containedObjectIds(){return this._objectIds}get count(){return this._count}get firstObjectId(){return this._objectIds.values().next().value}get centroidXWorld(){return this._xWorldTotal/this._count}get centroidYWorld(){return this._yWorldTotal/this._count}clone(){const t=new Mu(this.gridX,this.gridY,this._statistics.clone(),this._worldUnitsPerCell);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._firstFeatureAttributes=this._firstFeatureAttributes,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,r){0===this._count?this._firstFeatureAttributes=t.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=s,this._yWorldTotal+=r,this._statistics.insert(t,e),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._firstFeatureAttributes=t._firstFeatureAttributes,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroidX(t){return null==t?this.centroidXWorld:(0,Ch.IE)(t,this.centroidXWorld)}getCentroidY(t){return null==t?this.centroidYWorld:(0,Ch.B2)(t,this.centroidYWorld)}getGeometry(t,e){const s=this.gridX*this._worldUnitsPerCell,r=this.gridY*this._worldUnitsPerCell,i=new jt.A([4],[s,r,s+this._worldUnitsPerCell,r,s+this._worldUnitsPerCell,r+this._worldUnitsPerCell,s,r+this._worldUnitsPerCell]);if(null!=e){const t=new jt.A;return(0,Ch.Nl)(t,i,!1,!1,"esriGeometryPolygon",e)}return i}getCentroid(t){const e=new jt.A([],[this.centroidXWorld,this.centroidYWorld]);if(null!=t){const s=new jt.A;return(0,Ch.Nl)(s,e,!1,!1,"esriGeometryPoint",t)}return e}getGeometricCentroid(t,e){const s=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,r=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,i=new jt.A([],[s,r]);if(null!=e){const t=new jt.A;return(0,Ch.Nl)(t,i,!1,!1,"esriGeometryPoint",e)}return i}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return null!=this._firstFeatureAttributes?{...t,...this._firstFeatureAttributes}:t}}var Pu=s(83047);function Tu(t,{timeZone:e,timeExtent:s}){return{$view:{scale:t,timeZone:e,timeProperties:{currentStart:s?.start,currentEnd:s?.end}}}}class Au{constructor(t){this._options=t}insert(t,e){const s=t.getCursor(),{arcadeContextInfo:r,scale:i}=this._options,n=Tu(i,r);for(;s.next();)this._insertFeature(s,n,e)}_insertFeature(t,e,s){const{featureFilter:r}=this._options;if(null!==r&&!r.check(t))return;let i=0,n=0;if("esriGeometryPoint"===t.geometryType)i=t.readXWorldSpace(),n=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,r]=e.coords;if(s<0||s>B.CQ||r<0||r>B.CQ)return}const e=t.readCentroidWorldSpace();if(null==e)return;i=e.coords[0],n=e.coords[1]}this._insert(t,i,n,e)}}function Cu(t,e){return(0,Pu.GA)(t)*Pu.dy*96/e}class ku extends Au{constructor(t){super(t),this._cells=new Map,this._pixelsPerMapUnit=Cu(t.spatialReference,t.scale)}put(t){for(const e of this._cells.values()){const s=t.get(e.id);s?s.merge(e):t.set(e.id,e.clone())}}putBounded(t,e,s){const r=[e.xmin,e.ymin,e.xmax,e.ymax],[i,n,o,a]=r,h=Math.floor(i*this._pixelsPerMapUnit/this._options.cellSize),c=Math.floor(n*this._pixelsPerMapUnit/this._options.cellSize),l=Math.ceil(o*this._pixelsPerMapUnit/this._options.cellSize),u=Math.ceil(a*this._pixelsPerMapUnit/this._options.cellSize);for(let e=c;e<=u;e++)for(let s=h;s<=l;s++){const r=`${s}.${e}`,i=this._cells.get(r);if(!i)continue;const n=t.get(i.id);n?i&&!t.has(i.id)&&n.merge(i):t.set(i.id,i.clone())}}_insert(t,e,s,r){const i=e*this._pixelsPerMapUnit,n=s*this._pixelsPerMapUnit,o=Math.floor(i/this._options.cellSize),a=Math.floor(n/this._options.cellSize);this._getCellOrCreate(o,a).insert(t,r,e,s)}_getCellOrCreate(t,e){const s=Mu.createId(t,e);let r=this._cells.get(s);if(!r){const i=1*this._options.cellSize/this._pixelsPerMapUnit;r=Mu.create(t,e,this._options.fields,i),this._cells.set(s,r)}return r}}class Fu{constructor(t,e){this.inner=t,this.displayId=e}}class Eu extends pl{constructor(t){super(t),this.didSend=!1,this.done=!1}}class zu{constructor(t,e,s,r,i){this._level=t,this._scale=e,this._indexOptions=s,this._clusterRadius=r,this._store=i,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const t of this._clusters.values())this._store.releaseDisplayIdForObjectId(t.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const t of this._clusters.values()){const e=t.inner.getCentroid(null),s=new ol.Om(e,t.inner.getAttributes(),null,t.inner.id,t.displayId);yield s}}clusters(){return this._clusters.values()}updateChunks(t,e){let s=!1;for(const e of t){const t=e.queryInfo;"tileId"in t&&new p.A(t.tileId).level!==this._level||this._handledChunks.has(e.normalizedChunkId)||(this._handledChunks.add(e.normalizedChunkId),s=!0,e.getAggregateIndex({...this._indexOptions,scale:this._scale}).put(this._cells))}const r={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},i=Cu(this._indexOptions.spatialReference,this._scale),n=this._indexOptions.cellSize;for(const{subscription:t}of e){const e=t.tile.bounds,s=Math.floor(e[0]*i/n),o=Math.floor(e[1]*i/n),a=Math.ceil(e[2]*i/n),h=Math.ceil(e[3]*i/n);r.xMin=Math.min(r.xMin,s),r.yMin=Math.min(r.yMin,o),r.xMax=Math.max(r.xMax,a),r.yMax=Math.max(r.yMax,h)}return null!=this._lastCellBounds&&r.xMin===this._lastCellBounds.xMin&&r.yMin===this._lastCellBounds.yMin&&r.yMin===this._lastCellBounds.yMin&&r.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=r),s&&this._clusterCells(r),s}async updateStatistics(t){let e=!1;for(const t of this._clusters.values())t.inner.count>1&&(e=this._updateAggregateStatistics(this._statistics,t.inner)||e);if(e){const e=Array.from(this._statistics.entries()).map((([t,e])=>({fieldName:t,minValue:e.minValue,maxValue:e.maxValue})));await t.container.updateStatistics(this._level,e)}}createAggregateFeatures(t,e){const s=t.subscription,r=[],i=s.tile.transform;for(const t of this._clusters.values()){let e=t.inner.getCentroidX(i);const n=t.inner.getCentroidY(i),o=s.tile.lod,a=o.wrap?o.worldSize[0]:null,h=1===t.inner.count?t.inner.firstObjectId:t.inner.id,c=t.displayId;if(null!=a)if(1===a){const s=new jt.A([],[e,n]),i=new ol.Om(s,t.inner.getAttributes(),null,h,c);i.geometry.coords[0]-=B.CQ,r.push(i);const o=new jt.A([],[e,n]),a=new ol.Om(o,t.inner.getAttributes(),null,h,c);a.geometry.coords[0]+=B.CQ,r.push(a)}else e>B.CQ+B.CQ/2?e-=a*B.CQ:e<-B.CQ/2&&(e+=a*B.CQ);if(e<B.CQ+128&&e>=-128&&n<B.CQ+128&&n>=-128){const s=new jt.A([],[e,n]),i=new ol.Om(s,t.inner.getAttributes(),null,h,c);r.push(i)}}return du.fromOptimizedFeatures(r,e,s.tile.transform)}_clusterCells(t){let e=Array.from(this._cells.values());e=e.sort(((t,e)=>e.count-t.count));const s=[];for(const t of this._clusters.values())s.push(t.inner.id);this._clusters.clear();const r=this._clusterRadius*(1/Cu(this._indexOptions.spatialReference,this._scale)),i=1+this._clusterRadius/this._indexOptions.cellSize,n=new Set;for(const s of e){if(n.has(s.id))continue;if(s.gridX<t.xMin||s.gridX>t.xMax||s.gridY<t.yMin||s.gridY>t.yMax)continue;const e=this._store.createDisplayIdForObjectId(s.id),o=new Fu(s.clone(),e);n.add(s.id),this._clusters.set(s.id,o);const a=s.centroidXWorld,h=s.centroidYWorld;for(let t=s.gridY-i;t<=s.gridY+i;t++)for(let e=s.gridX-i;e<=s.gridX+i;e++){if(t===s.gridY&&e===s.gridX)continue;const i=this._cells.get(Mu.createId(e,t));if(!i||n.has(i.id))continue;const c=Math.abs(i.centroidXWorld-a),l=Math.abs(i.centroidYWorld-h);c<r&&l<r&&(o.inner.merge(i),n.add(i.id))}}for(const t of s)this._store.releaseDisplayIdForObjectId(t)}_updateAggregateStatistics(t,e){let s=!1;for(const r of e.statistics.values()){if("esriFieldTypeString"===r.field.type)continue;const e=r.value,i=r.field,n=t.get(i.name);if(n){const{minValue:t,maxValue:r}=n,i=Math.min(n.minValue,e),o=Math.max(n.maxValue,e);t===i&&r===o||(n.minValue=i,n.maxValue=o,s=!0)}else t.set(i.name,{minValue:e,maxValue:e}),s=!0}return s}}class Ou extends gl{static async create(t,e,s,r,i,n){const o=new Bl({spatialReference:s}),a={type:"grid",fields:await Promise.all(e.fields.map((async t=>cl.create(o,t)))),spatialReference:s,featureFilter:e.featureFilter?await jl.create({geometryType:r.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:r.metadata.timeInfo,fieldsIndex:r.metadata.fieldsIndex,spatialReference:s,filterJSON:e.featureFilter}):null,cellSize:e.clusterRadius/4,arcadeContextInfo:n};return new Ou(t,e.clusterRadius,a,e.fields,r,i)}constructor(t,e,s,r,i,n){super(i,n,s.spatialReference,s.fields),this._connection=t,this._clusterRadius=e,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=Yl.createFeature({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fieldsIndex:new hl.A([...r,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}]).toJSON(),globalIdField:null,spatialReference:i.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}invalidate(){super.invalidate();for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear()}onSubscribe(t){super.onSubscribe(t),this._requiredLevel=t.tile.level,this._requiredScale=t.tile.scale}createState(t){return new Eu(t)}async*applyOverrideUpdate(t){for(const t of this._cellsPerScale.values())t.destroy();this._cellsPerScale.clear();for(const t of this._sendStates.values())t.done=!1}displayMap(t,e,s){const r=new Map(t.map((t=>[e(t),t]))),i=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.clusters()){const e=r.get(t.inner.id);if(null==e){if(1===t.inner.count){const{firstObjectId:e}=t.inner,n=e?r.get(e):null;if(null!=n){const o=s(t.displayId,n,e);i.push(o),r.delete(e)}}}else{const n=s(t.displayId,e,t.inner.id);i.push(n),r.delete(t.inner.id)}}return i}getDisplayFeatures(t){const e=new Set(t),s=new Set,r=[],i=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.aggregatesWorldSpace())if(e.has(t.displayId)&&!s.has(t.displayId)){const e=(0,Ch.oN)(t,this._metadata.geometryType,!1,!1);if(s.add(t.displayId),1===e.attributes.cluster_count){r.push({...e,displayId:t.displayId});continue}i.push({...e,displayId:t.displayId})}return{features:r,aggregates:i}}getFeatureObjectIdsForAggregate(t){const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.clusters())if(s.inner.id===t)return Array.from(s.inner.containedObjectIds);return[]}async*updateChunks(){const t=this._source.chunks();if(!t.length)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale),s=Array.from(this._sendStates.values()).filter((t=>t.subscription.tile.level===this._requiredLevel));if(e.updateChunks(t,s)||!this._source.updateTracking.updating)for(const t of s)t.subscription.tile.level===this._requiredLevel&&(t.didSend=!1,t.done=!1);const r=Array.from(this._sendStates.values()).filter((t=>t.done)).map((t=>t.subscription.tile.key)),i=new Set(r);for(const t of this._sendStates.values()){if(this._source.updateTracking.updating){if(r.some((e=>e.containsChild(t.subscription.tile.key))))continue;if(t.subscription.tile.key.getChildKeys().every((t=>i.has(t))))continue}t.didSend||t.subscription.tile.level!==this._requiredLevel||(t.didSend=!0,yield*this._update(t,e,this._source))}await e.updateStatistics(this._connection)}forEachAggregateWorldSpace(t){if(null==this._requiredLevel||null==this._requiredScale)return;const e=this._getClusterState(this._requiredLevel,this._requiredScale);for(const s of e.aggregatesWorldSpace())t(s)}_getClusterState(t,e){if(null==t||null==e)throw new Error("InternalError: Level and scale must be defined");let s=this._cellsPerScale.get(e);return s||(s=new zu(t,e,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(e,s)),s}async*_update(t,e,s){if(t.done)return;const r=e.createAggregateFeatures(t,this._metadata);this.events.emit("changed"),t.done=!s.updateTracking.updating;const i=r.getCursor(),n=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.arcadeContextInfo);for(;i.next();)this._attributeStore.setAttributeData(i.getDisplayId(),i,n);const o=new ml(t.subscription,r,!0,t.done,{});yield o}}var Ru=s(11006);function Du(t,e){if(!(this instanceof Du))return new Du(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&("function"==typeof e?this.toBBox=e:this._initFormat(e)),this.clear()}function Lu(t,e,s){if(!s)return e.indexOf(t);for(var r=0;r<e.length;r++)if(s(t,e[r]))return r;return-1}function Nu(t,e){Bu(t,0,t.children.length,e,t)}function Bu(t,e,s,r,i){i||(i=Hu(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var n,o=e;o<s;o++)n=t.children[o],Gu(i,t.leaf?r(n):n);return i}function Gu(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Uu(t,e){return t.minX-e.minX}function Vu(t,e){return t.minY-e.minY}function qu(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Wu(t){return t.maxX-t.minX+(t.maxY-t.minY)}function ju(t,e){return(Math.max(e.maxX,t.maxX)-Math.min(e.minX,t.minX))*(Math.max(e.maxY,t.maxY)-Math.min(e.minY,t.minY))}function Yu(t,e){var s=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),n=Math.min(t.maxY,e.maxY);return Math.max(0,i-s)*Math.max(0,n-r)}function Xu(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function $u(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Hu(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Zu(t,e,s,r,i){for(var n,o=[e,s];o.length;)(s=o.pop())-(e=o.pop())<=r||(n=e+Math.ceil((s-e)/r/2)*r,(0,Ru.q)(t,n,e,s,i),o.push(e,n,n,s))}Du.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,s=[],r=this.toBBox;if(!$u(t,e))return s;for(var i,n,o,a,h=[];e;){for(i=0,n=e.children.length;i<n;i++)o=e.children[i],$u(t,a=e.leaf?r(o):o)&&(e.leaf?s.push(o):Xu(t,a)?this._all(o,s):h.push(o));e=h.pop()}return s},collides:function(t){var e=this.data,s=this.toBBox;if(!$u(t,e))return!1;for(var r,i,n,o,a=[];e;){for(r=0,i=e.children.length;r<i;r++)if(n=e.children[r],$u(t,o=e.leaf?s(n):n)){if(e.leaf||Xu(t,o))return!0;a.push(n)}e=a.pop()}return!1},load:function(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(var e=0,s=t.length;e<s;e++)this.insert(t[e]);return this}var r=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var i=this.data;this.data=r,r=i}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},insert:function(t){return null!=t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Hu([]),this},remove:function(t,e){if(null==t)return this;for(var s,r,i,n,o=this.data,a=this.toBBox(t),h=[],c=[];o||h.length;){if(o||(o=h.pop(),r=h[h.length-1],s=c.pop(),n=!0),o.leaf&&-1!==(i=Lu(t,o.children,e)))return o.children.splice(i,1),h.push(o),this._condense(h),this;n||o.leaf||!Xu(o,a)?r?(s++,o=r.children[s],n=!1):o=null:(h.push(o),c.push(s),s=0,r=o,o=o.children[0])}return this},toBBox:function(t){return t},compareMinX:Uu,compareMinY:Vu,toJSON:function(){return this.data},fromJSON:function(t){return this.data=t,this},_all:function(t,e){for(var s=[];t;)t.leaf?e.push.apply(e,t.children):s.push.apply(s,t.children),t=s.pop();return e},_build:function(t,e,s,r){var i,n=s-e+1,o=this._maxEntries;if(n<=o)return Nu(i=Hu(t.slice(e,s+1)),this.toBBox),i;r||(r=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,r-1))),(i=Hu([])).leaf=!1,i.height=r;var a,h,c,l,u=Math.ceil(n/o),d=u*Math.ceil(Math.sqrt(o));for(Zu(t,e,s,d,this.compareMinX),a=e;a<=s;a+=d)for(Zu(t,a,c=Math.min(a+d-1,s),u,this.compareMinY),h=a;h<=c;h+=u)l=Math.min(h+u-1,c),i.children.push(this._build(t,h,l,r-1));return Nu(i,this.toBBox),i},_chooseSubtree:function(t,e,s,r){for(var i,n,o,a,h,c,l,u;r.push(e),!e.leaf&&r.length-1!==s;){for(l=u=1/0,i=0,n=e.children.length;i<n;i++)h=qu(o=e.children[i]),(c=ju(t,o)-h)<u?(u=c,l=h<l?h:l,a=o):c===u&&h<l&&(l=h,a=o);e=a||e.children[0]}return e},_insert:function(t,e,s){var r=this.toBBox,i=s?t:r(t),n=[],o=this._chooseSubtree(i,this.data,e,n);for(o.children.push(t),Gu(o,i);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(i,n,e)},_split:function(t,e){var s=t[e],r=s.children.length,i=this._minEntries;this._chooseSplitAxis(s,i,r);var n=this._chooseSplitIndex(s,i,r),o=Hu(s.children.splice(n,s.children.length-n));o.height=s.height,o.leaf=s.leaf,Nu(s,this.toBBox),Nu(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(s,o)},_splitRoot:function(t,e){this.data=Hu([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Nu(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,s){var r,i,n,o,a,h,c,l;for(h=c=1/0,r=e;r<=s-e;r++)o=Yu(i=Bu(t,0,r,this.toBBox),n=Bu(t,r,s,this.toBBox)),a=qu(i)+qu(n),o<h?(h=o,l=r,c=a<c?a:c):o===h&&a<c&&(c=a,l=r);return l},_chooseSplitAxis:function(t,e,s){var r=t.leaf?this.compareMinX:Uu,i=t.leaf?this.compareMinY:Vu;this._allDistMargin(t,e,s,r)<this._allDistMargin(t,e,s,i)&&t.children.sort(r)},_allDistMargin:function(t,e,s,r){t.children.sort(r);var i,n,o=this.toBBox,a=Bu(t,0,e,o),h=Bu(t,s-e,s,o),c=Wu(a)+Wu(h);for(i=e;i<s-e;i++)n=t.children[i],Gu(a,t.leaf?o(n):n),c+=Wu(a);for(i=s-e-1;i>=e;i--)n=t.children[i],Gu(h,t.leaf?o(n):n),c+=Wu(h);return c},_adjustParentBBoxes:function(t,e,s){for(var r=s;r>=0;r--)Gu(e[r],t)},_condense:function(t){for(var e,s=t.length-1;s>=0;s--)0===t[s].children.length?s>0?(e=t[s-1].children).splice(e.indexOf(t[s]),1):this.clear():Nu(t[s],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}};class Qu{static fromReader(t){const e=[],s=t.copy(),r=(0,ul.vt)();for(;s.next();)s.getBounds(r)&&e.push(s.getIndex());const i=Du(9,(t=>(s.setIndex(t),{minX:s.getBoundsXMin(),minY:s.getBoundsYMin(),maxX:s.getBoundsXMax(),maxY:s.getBoundsYMax()})));return i.load(e),new Qu(i)}constructor(t){this._index=t}search(t){const e={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this._index.search(e)}}var Ku=s(79258);function Ju(t,e,s,r){if(r.isWebMercator){const r=(0,ks.KJ)(t/Ku.$O.radius),i=r-360*Math.floor((r+180)/360),n=[0,0];return td(n,0,(0,ks.KJ)(Math.PI/2-2*Math.atan(Math.exp(-e/Ku.$O.radius))),i,s),n}const i=(0,al.Cv)({x:t,y:e},r,q.A.WGS84);if(!i)return null;const n=[0,0];return td(n,0,i.y,i.x,s),n}function td(t,e,s,r,i){i%2&&(i+=1);let n=0,o=0,a=-90,h=90,c=-180,l=180;for(let t=0;t<i/2;t++){for(let e=0;e<5;e++){const s=(c+l)/2,i=r>s?1:0;n|=i<<29-(e+5*t),c=(1-i)*c+i*s,l=(1-i)*s+i*l}for(let e=0;e<5;e++){const r=(a+h)/2,i=s>r?1:0;o|=i<<29-(e+5*t),a=(1-i)*a+i*r,h=(1-i)*r+i*h}}t[2*e]=n,t[2*e+1]=o}new Float64Array(2),new Float64Array(2);class ed extends fu{static create(t,e,s,r){const i=mu.create(t),n=new Array(32);for(let t=0;t<n.length;t++)n[t]=null;return new ed(i,e,s,r,n)}constructor(t,e,s,r,i){super(t),this.xNode=e,this.yNode=s,this.depth=r,this.children=i,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}get id(){return`${this.xNode}.${this.yNode}`}get containedObjectIds(){return this._objectIds}get count(){return this._count}clone(){const t=new ed(this._statistics.clone(),this.xNode,this.yNode,this.depth,this.children);return t._count=this._count,t._xWorldTotal=this._xWorldTotal,t._yWorldTotal=this._yWorldTotal,t._xGeohashTotal=this._xGeohashTotal,t._yGeohashTotal=this._yGeohashTotal,t.next=this.next,t._objectIds=new Set(this._objectIds),t}insert(t,e,s,r,i,n){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=s,this._xGeohashTotal+=r,this._yGeohashTotal+=i,this._statistics.insert(t,n),this._objectIds.add(t.getObjectId())}merge(t){if(0!==t._count){this._count+=t._count,this._xWorldTotal+=t._xWorldTotal,this._yWorldTotal+=t._yWorldTotal,this._xGeohashTotal+=t._xWorldTotal,this._yGeohashTotal+=t._yWorldTotal,this._statistics.merge(t._statistics);for(const e of t._objectIds.values())this._objectIds.add(e)}}getCentroid(t){throw new Error("getCentroid not supported for GeohashNode")}getGeometry(t,e){const s=this._getLngLatBounds(),[r,i,n,o]=s,a=(0,al.Cv)({rings:[[[r,i],[r,o],[n,o],[n,i],[r,i]]]},q.A.WGS84,t),h=(0,Ch.Ye)(new jt.A,a,!1,!1);return null!=e?(0,Ch.Nl)(new jt.A,h,!1,!1,"esriGeometryPolygon",e,!1,!1):h}getGeometricCentroid(t,e){const s=this._getLngLatBounds(),[r,i,n,o]=s,a=(0,al.Cv)({x:(r+n)/2,y:(i+o)/2},q.A.WGS84,t),h=(0,Ch.qN)(new jt.A,a);return null!=e?(0,Ch.Nl)(new jt.A,h,!1,!1,"esriGeometryPoint",e,!1,!1):h}getAttributes(){const t={aggregateId:this.id};for(const e of this._statistics.values())t[e.field.name]=e.value;return t.aggregateCount=this._count,t}find(t,e,s,r,i,n){if(r>=s)return this;const o=1-r%2,a=3*o+2*(1-o),h=2*o+3*(1-o),c=30-i-a,l=30-n-h,u=((t&7*o+3*(1-o)<<c)>>c)+((e&3*o+7*(1-o)<<l)>>l)*(8*o+4*(1-o)),d=this.children[u];return null==d?null:d.find(t,e,s,r+1,i+a,n+h)}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),r=30-(3*e+2*s),i=30-(2*e+3*s);return function(t,e){let s=-90,r=90,i=-180,n=180;for(let o=0;o<e;o++){const e=Math.ceil((o+1)/2),a=Math.floor((o+1)/2),h=1-o%2,c=30-(3*e+2*a),l=30-(2*e+3*a),u=2*h+3*(1-h),d=(7*h+3*(1-h)<<c&t.geohashX)>>c,_=(3*h+7*(1-h)<<l&t.geohashY)>>l;for(let t=3*h+2*(1-h)-1;t>=0;t--){const e=(i+n)/2,s=d&1<<t?1:0;i=(1-s)*i+s*e,n=(1-s)*e+s*n}for(let t=u-1;t>=0;t--){const e=(s+r)/2,i=_&1<<t?1:0;s=(1-i)*s+i*e,r=(1-i)*e+i*r}}return[i,s,n,r]}({geohashX:this.xNode<<r,geohashY:this.yNode<<i},this.depth)}}class sd{constructor(t){this._fields=t,this._size=0,this._depth=0,this._root=ed.create(this._fields,0,0,0)}destroy(){}get size(){return this._size}get depth(){return this._depth}find(t,e,s){return this._root.find(t,e,s,0,0,0)}insert(t,e,s,r,i,n,o){let a=this._root,h=0,c=0,l=0;for(;null!==a;){if(a.insert(t,e,s,r,i,o),h>=n)return;const u=Math.ceil((h+1)/2),d=Math.floor((h+1)/2),_=1-h%2,p=30-(3*u+2*d),f=30-(2*u+3*d),g=(r&7*_+3*(1-_)<<p)>>p,m=(i&3*_+7*(1-_)<<f)>>f,y=g+m*(8*_+4*(1-_));c=c<<3*_+2*(1-_)|g,l=l<<2*_+3*(1-_)|m,null==a.children[y]&&(a.children[y]=ed.create(this._fields,c,l,h+1),this._depth=Math.max(this._depth,h+1),this._size+=1),h+=1,a=a.children[y]}}putBins(t,e){for(const s of this.getNodes(e)){const e=t.get(s.id);e?e.merge(s):t.set(s.id,s.clone())}}getNodes(t){const e=[],{geohashBounds:s,level:r}=t;let i=this._root;for(;null!==i;){const t=i.depth,n=i.xNode,o=i.yNode;if(t>=r){e.push(i),i=i.next;continue}const a=Math.ceil((t+1)/2),h=Math.floor((t+1)/2),c=1-t%2,l=30-(3*a+2*h),u=30-(2*a+3*h),d=~((1<<l)-1),_=~((1<<u)-1),p=(s.xLL&d)>>l,f=(s.yLL&_)>>u,g=(s.xTR&d)>>l,m=(s.yTR&_)>>u,y=n<<3*c+2*(1-c),b=o<<2*c+3*(1-c),w=y+8*c+4*(1-c),x=b+4*c+8*(1-c),v=Math.max(y,p),S=Math.max(b,f),I=Math.min(w,g),M=Math.min(x,m);let P=null,T=null;for(let t=S;t<=M;t++)for(let e=v;e<=I;e++){const s=e-y+(t-b)*(8*c+4*(1-c)),r=i.children[s];r&&(P||(P=r,P.next=i.next),T&&(T.next=r),T=r,r.next=i.next)}i=P||i.next}return e}}class rd extends Au{constructor(t){super(t),this._tree=new sd(this._options.fields)}put(t){throw new Error("Geohash tree does not support put")}putBounded(t,e,s){const{geohashLevel:r,spatialReference:i}=this._options,n=function(t,e,s,r){const i=[t.xmin,t.ymin,t.xmax,t.ymax],n=ir.A.fromExtent((0,N.w1)(i,r)),o=(0,al.Cv)(n,r,q.A.WGS84,{densificationStep:64*e});if(!o)return null;const a=(0,Ch.Ye)(new jt.A,o,!1,!1),h=a.coords.filter(((t,e)=>!(e%2))),c=a.coords.filter(((t,e)=>e%2)),l=Math.min(...h),u=Math.min(...c),d=Math.max(...h),_=Math.max(...c),p=Ju(l,u,s,q.A.WGS84),f=Ju(d,_,s,q.A.WGS84);return p&&f?{bounds:i,geohashBounds:{xLL:p[0],yLL:p[1],xTR:f[0],yTR:f[1]},level:s}:null}(e,s,r,i);null!=n&&this._tree.putBins(t,n)}_insert(t,e,s,r){const{geohashLevel:i,spatialReference:n}=this._options,o=Ju(e,s,i,n);o&&this._tree.insert(t,e,s,o[0],o[1],i,r)}}var id=s(69397);class nd extends uu{static from(t,e){return new nd(t.copy(),e)}constructor(t,e){super(t.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=t,this._indices=e,this._isPoint="esriGeometryPoint"===t.geometryType}setTransformForDisplay(t){const e=this._reader.getInTransform();if(null==e){const[e,s]=t.scale,[r,i]=t.translate;return this._displayTranslationX=-r/e,this._displayScaleX=1/e,this._displayTranslationY=i/s,this._displayScaleY=1/-s,void(this._displayTransform=t)}const[s,r]=e.scale,[i,n]=e.translate,[o,a]=t.scale,[h,c]=t.translate;if(this._displayScaleX=s/o,this._displayTranslationX=(i-h)/o,this._displayScaleY=r/a,this._displayTranslationY=(-n+c)/a,!this._isPoint&&e)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=t}getInTransform(){return this._reader.getInTransform()}get fields(){return this._reader.fields}get hasNext(){return this._currentIndex+1<this._indices.length}getSize(){return this._indices.length}getCursor(){return this.copy()}copy(){const t=new nd(this._reader.copy(),this._indices);return t._currentIndex=this._currentIndex,t._displayTransform=this._displayTransform,t._displayTranslationX=this._displayTranslationX,t._displayTranslationY=this._displayTranslationY,t._displayScaleX=this._displayScaleX,t._displayScaleY=this._displayScaleY,t}get contextTimeZone(){return this._reader.contextTimeZone}set contextTimeZone(t){this._reader.contextTimeZone=t}get usedMemory(){return id.qK+this._reader.usedMemory}_nextIndex(){return++this._currentIndex<this._indices.length&&(this._reader.setIndex(this._indices[this._currentIndex]),!0)}next(){for(;this._nextIndex()&&!this._reader._getExists(););return this._currentIndex<this._indices.length}readXForDisplay(){return this._reader.readXForDisplay()*this._displayScaleX+this._displayTranslationX}readYForDisplay(){return this._reader.readYForDisplay()*this._displayScaleY+this._displayTranslationY}readGeometryForDisplay(){return this._displayTransform?this._reader.readGeometryForDisplayTransformed(this._displayTransform):this._reader.readGeometryForDisplay()}readCentroidForDisplay(){const t=this._reader.readCentroidForDisplay()?.clone();if(t){const[e,s]=t.coords;t.coords[0]=e*this._displayScaleX+this._displayTranslationX,t.coords[1]=s*this._displayScaleY+this._displayTranslationY}return t}get geometryType(){return this._reader.geometryType}get hasFeatures(){return this._reader.hasFeatures}get exceededTransferLimit(){return this._reader.exceededTransferLimit}get hasZ(){return this._reader.hasZ}get hasM(){return this._reader.hasM}readAttribute(t,e=!1){return this._reader.readAttribute(t,e)}readAttributes(){return this._reader.readAttributes()}joinAttributes(t){return this._reader.joinAttributes(t)}getBounds(t){return this._reader.getBounds(t)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(t){return this._reader.setDisplayId(t)}setIndex(t){return this._reader.setIndex(t)}getIndex(){return this._reader.getIndex()}readXWorldSpace(){return this._reader.readXWorldSpace()}readYWorldSpace(){return this._reader.readYWorldSpace()}_readX(){return this._reader.readXForDisplay()}_readY(){return this._reader.readYForDisplay()}_readServerCentroid(){return this._reader._readServerCentroid()}readLegacyFeatureForDisplay(){const t=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(t&&{x:t.coords[0],y:t.coords[1]})??null}}readLegacyGeometryForDisplay(){const t=this.readGeometryForDisplay();return(0,Ch.zv)(t,this.geometryType,!1,!1)}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(t,e){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}_readAttributes(){throw new Error("Error: Should not be called. Underlying _reader should be used instead")}readArcadeFeature(){return this._reader.readArcadeFeature()}geometry(){return this._reader.geometry()}field(t){return this._reader.field(t)}hasField(t){return this._reader.hasField(t)}setField(t,e){return this._reader.setField(t,e)}keys(){return this._reader.keys()}castToText(t=!1){return this._reader.castToText(t)}}class od{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._aggregateIndex=null,this._aggregateIndexHash=null,this._spatialIndex=null}registerOverrides(t){this.reader.registerOverrides(t),this.invalidate()}queryFeaturesInBounds(t){const e=this._getSpatialIndex().search(t);return nd.from(this.reader,e)}getAggregateIndex(t){const e=JSON.stringify(t);if(e!==this._aggregateIndexHash){switch(this._aggregateIndexHash=e,t.type){case"grid":this._aggregateIndex=new ku(t);break;case"geohash":this._aggregateIndex=new rd(t)}this._aggregateIndex.insert(this.reader,this.isTiled)}return this._aggregateIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=Qu.fromReader(this.reader)),this._spatialIndex}}class ad{constructor(){this.modified=[],this.removed=[]}modify(t){this.modified.push(t)}remove(t){this.removed.push(t)}get isEmpty(){return 0===this.modified.length&&0===this.removed.length}}class hd extends od{constructor(t){super(),this._reader=t,this.chunkId="override",this.normalizedChunkId="override"}static fromFeatures(t,e){const s=du.fromOptimizedFeatures(t,e);return new hd(s)}get reader(){return this._reader}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}getTileReader(t){if(!this._reader.getSize())return null;const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class cd{constructor(t,e){this.inner=t,this.isWeak=e,this.lastWeak=null}}class ld{constructor(){this._overrides=new Map,this._update=new ad}hasOverride(t){return this._overrides.has(t)}onChunkInsert(t){if(this._overrides.size){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),s=this._overrides.get(t);s?.lastWeak&&(s.lastWeak=null),s?.isWeak&&(this._overrides.delete(t),this._update.remove(t),this.invalidate())}}t.registerOverrides(this)}apply(t,e){const{updateWeak:s,removeWeak:r,update:i,remove:n,release:o}=t.commands;this.invalidate();for(const t of s)this._overrides.set(t.objectId,new cd(t,!0)),this._update.modify(t);for(const t of i){const e=new cd(t,!1),s=this._overrides.get(t.objectId);s?.isWeak&&(e.lastWeak=s),this._overrides.set(t.objectId,e),this._update.modify(t)}for(const t of r)this._overrides.set(t,new cd(null,!0)),this._update.remove(t);for(const t of n){const e=new cd(null,!1),s=this._overrides.get(t);s?.isWeak&&(e.lastWeak=s),this._overrides.set(t,e),this._update.remove(t)}if(o.length){const t=new Set;for(const e of o){const s=this._overrides.get(e);s?.lastWeak?this._overrides.set(e,s.lastWeak):s&&!s.isWeak&&(this._overrides.delete(e),t.add(e))}e.forEachUnsafe((e=>{const s=e.getObjectId();t.has(s)&&(this._update.modify(e.readOptimizedFeatureWorldSpace()),t.delete(s))}));for(const e of t.values())this._update.remove(e)}}takeOverrideUpdate(){const t=this._update;return t.isEmpty?null:(this._update=new ad,t)}asChunk(t){if(!this._chunk){const e=[];for(const t of this._overrides.values())null!=t.inner&&e.push(t.inner);this._chunk=hd.fromFeatures(e,t)}return this._chunk}invalidate(){this._chunk=null}}class ud extends pl{}class dd extends fl{constructor(t,e,s){super(t,e),this._arcadeContextInfo=s,this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set,this._streamLayerDeferredObjectIdsToRemove=[]}destroy(){super.destroy();for(const t of this._source.chunks())this._cleanupChunkIds(t)}invalidateAttributeData(t){this.handledChunksForAttributeData.clear(),this._arcadeContextInfo=t,this._evalOptions=Tu(this._evalOptions.$view.scale,t)}onSubscribe(t){super.onSubscribe(t),this._evalOptions=t.tile.createArcadeEvaluationOptions(this._arcadeContextInfo)}createState(t){return new ud(t)}get aggregateQueryEngine(){return null}displayMap(t,e,s){const r=new Map(t.map((t=>[e(t),t]))),i=[];for(const t of this._source.chunks()){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),o=r.get(t);if(null!=o){const e=s(n,o,t);i.push(e),r.delete(t)}}}return i}getDisplayFeatures(t){const e=new Set(t),s=new Set,r=[];for(const t of this._source.chunks()){const i=t.reader.getCursor();for(;i.next();){const t=i.getObjectId(),n=i.getDisplayId();e.has(n)&&!s.has(t)&&(r.push({...i.readLegacyFeatureWorldSpace(),displayId:n}),s.add(t))}}return{features:r,aggregates:[]}}async*applyOverrideUpdate(t){const e=[];for(const s of t.modified){const t=this._attributeStore.createDisplayIdForObjectId(s.objectId);s.displayId=t,e.push(t)}const s=du.fromOptimizedFeatures(t.modified,this._source.metadata).getCursor();for(;s.next();)this._attributeStore.setAttributeData(s.getDisplayId(),s,this._evalOptions);const r=[];for(const e of t.removed){const t=this._attributeStore.getDisplayIdForObjectId(e);null!=t&&r.push(t)}(0,n.A)("esri-2d-update-debug")&&console.debug("FeatureUpdateStrategy.applyLocalEdit",{message:t,modifiedDisplayIds:e,removedDisplayIds:r});const i=hd.fromFeatures(t.modified,this._source.metadata);this.handledChunks.add(i.chunkId),this.handledChunksForAttributeData.add(i.chunkId),this.handledChunksForIdCreation.add(i.chunkId);for(const t of this._sendStates.values())t.handledChunks.add(i.chunkId),yield new yl(t.subscription,null,e,!1,i.queryInfo);for(const t of this._sendStates.values()){const e=i.getTileReader(t.subscription.tile);yield new yl(t.subscription,e,r,!1,i.queryInfo)}for(const e of t.removed)this._attributeStore.releaseDisplayIdForObjectId(e)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const t of this._sendStates.values())yield*this._update(t)}}removeChunks(t){for(const e of t)this.handledChunks.delete(e.chunkId),this.handledChunksForAttributeData.delete(e.chunkId),this._cleanupChunkIds(e)}afterUpdateChunks(){for(const t of this._streamLayerDeferredObjectIdsToRemove)this._attributeStore.releaseDisplayIdForObjectId(t);this._streamLayerDeferredObjectIdsToRemove=[]}_cleanupChunkIds(t){if(this.handledChunksForIdCreation.has(t.chunkId)){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId();this._source.isStream?this._streamLayerDeferredObjectIdsToRemove.push(t):this._attributeStore.releaseDisplayIdForObjectId(t)}this.handledChunksForIdCreation.delete(t.chunkId)}}async _updateAttributeData(){for(const t of this._source.chunks()){const{chunkId:e,reader:s}=t;if(!this.handledChunksForIdCreation.has(e)){this.handledChunksForIdCreation.add(e);const t=s.getCursor();for(;t.next();){const e=this._attributeStore.createDisplayIdForObjectId(t.getObjectId());t.setDisplayId(e)}}}for(const t of this._source.chunks())if(!this.handledChunksForAttributeData.has(t.chunkId)){this.handledChunksForAttributeData.add(t.chunkId);const e=t.reader.getCursor();for(;e.next();){const t=e.getDisplayId();this._attributeStore.setAttributeData(t,e,this._evalOptions)}}}*_update(t){const{subscription:e,handledChunks:s}=t;for(const r of this._source.chunks()){const{chunkId:i}=r;if(s.has(i))continue;s.add(i);const n=r.getTileReader(e.tile);n&&(yield new ml(t.subscription,n,!1,r.end,r.queryInfo))}}}class _d{constructor(t){this.data=t,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class pd{constructor(){this._freeIdsGenerationA=[],this._freeIdsGenerationB=[],this._idCounter=1,this._freeIds=this._freeIdsGenerationA,this._objectIdToDisplayId=new Map}createIdForObjectId(t){let e=this._objectIdToDisplayId.get(t);return e?e.increment():(e=new _d((0|this._getFreeId())>>>0),e.increment(),this._objectIdToDisplayId.set(t,e)),e.data}releaseIdForObjectId(t){const e=this._objectIdToDisplayId.get(t);e&&(e.decrement(),e.empty()&&(this._objectIdToDisplayId.delete(t),this._freeIds.push(e.data)))}getDisplayIdForObjectId(t){const e=this._objectIdToDisplayId.get(t);return null!=e?e.data:null}releaseAll(){for(const t of this._objectIdToDisplayId.values())this._freeIds.push(t.data);this._objectIdToDisplayId.clear()}incrementGeneration(){this._freeIds=this._freeIds===this._freeIdsGenerationA?this._freeIdsGenerationB:this._freeIdsGenerationA}_getFreeId(){return this._freeIds.length?this._freeIds.pop():this._idCounter++}}const fd=()=>E.A.getLogger("esri.views.layers.2d.features.support.AttributeStore"),gd=(fd(),()=>null),md=(0,n.A)("esri-shared-array-buffer");(0,n.A)("esri-atomics");class yd{constructor(t,e,s){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:r,layout:i,textureOnly:n}=e;this.textureOnly=n||!1,this.pixelType=r,this.layout=i,this._resetRange(),this.size=t,this.isLocal=s,n||(this.data=this._initData(r,t))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(t,e){const s=this.data;for(let r=0;r<this.size*this.size;r++)s[r*this.texelSize+t]&=~e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(t,e){const s=this.data;for(let r=0;r<this.size*this.size;r++)s[r*this.texelSize+t]|=255&e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(t,e,s){const r=this.data;for(const i of s)r[i*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)}setComponentTexel(t,e,s){this.data[s*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}unsetComponentTexel(t,e,s){this.data[s*this.texelSize+t]&=~e,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)}getData(t,e){const s=Fh(t);return this.data[s*this.texelSize+e]}setData(t,e,s){const r=Fh(t),i=1<<e;this.layout&i?null!=this.data&&(this.data[r*this.texelSize+e]=s,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)):fd().error("mapview-attributes-store","Tried to set a value for a texel's readonly component")}expand(t){if(this.size=t,!this.textureOnly){const e=this._initData(this.pixelType,t),s=this.data;e.set(s),this.data=e}}toMessage(){const t=this.dirtyStart,e=this.dirtyEnd,s=this.texelSize;if(t>e)return null;this._resetRange();const r=!this.isLocal,i=this.pixelType,n=this.layout,o=this.data;return{start:t,end:e,data:r&&o.slice(t*s,(e+1)*s)||null,pixelType:i,layout:n}}_initData(t,e){const s=ArrayBuffer,i=function(t){switch(t){case dt.ld.UNSIGNED_BYTE:return Uint8Array;case dt.ld.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case dt.ld.FLOAT:return Float32Array;default:return void E.A.getLogger("esri.views.2d.engine.webgl.Utils").error(new r.A("webgl-utils",`Unable to handle type ${t}`))}}(t),n=new i(new s(e*e*4*i.BYTES_PER_ELEMENT));for(let t=0;t<n.length;t+=4)n[t+1]=255;return n}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}}class bd{constructor(t){this._client=t,this._filters=[],this._blocks=new Array,this._attributeComputeInfo=null,this._abortController=new AbortController,this._size=B.TB,this._idsToHighlight=new Map,this._arcadeDependencies=new Set,this._initialized=!1,this.version=0,this._idGenerator=new pd,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const t=dt.ld.FLOAT;gd(`Creating AttributeStore ${md?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:dt.ld.UNSIGNED_BYTE,layout:1},{pixelType:dt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:dt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:dt.ld.FLOAT,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(t){return this._idGenerator.createIdForObjectId(t)}releaseDisplayIdForObjectId(t){return this._idGenerator.releaseIdForObjectId(t)}getDisplayIdForObjectId(t){return this._idGenerator.getDisplayIdForObjectId(t)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}hasArcadeDependency(t){return this._arcadeDependencies.has(t)}releaseAllIds(){this._idGenerator.releaseAll()}async update(t,e,s,r,i=0){const o=(0,V.Ui)(this._schema,t);if(this.version=i,o&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${i}] AttributeStore.update`,{changed:o}),this._schema=t,this._attributeComputeInfo=null,this._initialize(),null!=t))if(s&&(this._filters=await Promise.all(t.filters.map((t=>t?jl.create({geometryType:s.geometryType,hasM:!1,hasZ:!1,timeInfo:s.timeInfo,fieldsIndex:s.fieldsIndex,spatialReference:r??s.spatialReference,filterJSON:t}):null)))),"subtype"!==t.type)this._attributeComputeInfo={isSubtype:!1,map:new Map},await Promise.all(t.bindings.map((async t=>{const s=await this._bind(e,t);this._updateReferences(s)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:t.subtypeField,map:new Map};for(const s in t.bindings){const r=t.bindings[s];await Promise.all(r.map((async t=>{const r=await this._bind(e,t,parseInt(s,10));this._updateReferences(r)})))}}}setHighlight(t,e){const s=this._getBlock(0);s.unsetComponentAllTexels(0,(1<<B.U5)-1);for(const{displayId:e,highlightFlags:r}of t){if(null==e)continue;const t=Fh(e);s.setComponent(0,r,[t])}this._idsToHighlight.clear();for(const{objectId:e,highlightFlags:s}of t)this._idsToHighlight.set(e,s);for(const{objectId:t,highlightFlags:s}of e)this._idsToHighlight.set(t,s)}setData(t,e,s,r){const i=Fh(t);this._ensureSizeForTexel(i),this._getBlock(e).setData(t,s,r)}getData(t,e,s){return this._getBlock(e).getData(t,s)}getHighlightFlags(t){return this._idsToHighlight.get(t)||0}unsetAttributeData(t){const e=Fh(t);this._getBlock(0).setData(e,0,0)}setAttributeData(t,e,s){const r=Fh(t);this._ensureSizeForTexel(r),this._getBlock(0).setData(r,0,this.getFilterFlags(e));const i=this._attributeComputeInfo;let n=null;i&&(n=i.isSubtype?i.map.get(e.readAttribute(i.subtypeField)):i.map,n?.size&&n.forEach(((t,i)=>{const n=1*i%4,o=Math.floor(1*i/4),a=this._getBlock(o+B.dV.VV);let h=t.field?.read(e,s);t.valueRepresentation&&(h=function(t,e){if(!t||!e)return t;switch(e){case"radius":case"distance":return 2*t;case"diameter":case"width":return t;case"area":return Math.sqrt(t)}return t}(h,t.valueRepresentation)),(null===h||isNaN(h)||h===1/0||h===-1/0)&&(h=1e-30),a.setData(r,n,h)})))}get epoch(){return this._epoch}sendUpdates(){const t=this._blocks.map((t=>null!=t?t.toMessage():null)),e=this._getInitArgs();(0,n.A)("esri-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.start"),this._client.update({initArgs:e,blockData:t,version:this.version,sendUpdateEpoch:this._epoch}),this._epoch+=1,(0,n.A)("esri-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.end")}_ensureSizeForTexel(t){for(;t>=this._size*this._size;)if(this._expand())return}async _bind(t,e,s){const r=await t.createComputedField(e),{valueRepresentation:i}=e,n=this._attributeComputeInfo;if(n.isSubtype){const t=n.map.get(s)??new Map;t.set(e.binding,{field:r,valueRepresentation:i}),n.map.set(s,t)}else n.map.set(e.binding,{field:r,valueRepresentation:i});return r}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(B.dV.Animation),this._getBlock(B.dV.GPGPU),this._getBlock(B.dV.LocalTimeOrigin),{blockSize:this._size,blockDescriptors:this._blocks.map((t=>null!=t?{textureOnly:t.textureOnly,buffer:t.buffer,pixelType:t.pixelType}:null))})}_getBlock(t){const e=this._blocks[t];if(null!=e)return e;gd(`Initializing AttributeBlock at index ${t}`);const s=new yd(this._size,this._blockDescriptors[t],this._client.isLocal);return this._blocks[t]=s,this._initialized=!1,s}_expand(){if(this._size<this._schema.capabilities.maxTextureSize){const t=this._size<<=1;gd("Expanding block size to",t,this._blocks);for(const e of this._blocks)e?.expand(t);return this._initialized=!1,this._size=t,0}return fd().error(new r.A("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}_updateReferences(t){(0,wc.QY)(this._arcadeDependencies,t)}isVisible(t){return!!(this._getBlock(0).getData(t,0)&1<<B.U5)}getFilterFlags(t){let e=0;for(let s=0;s<this._filters.length;s++){const r=!!(1<<s),i=this._filters[s];e|=(!r||null==i||i.check(t)?1:0)<<s}let s=0;if(this._idsToHighlight.size){const e=t.getObjectId();s=this.getHighlightFlags(e)}return e<<B.U5|s}}class wd{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._registry=new rl,this._invalidateRequested=!1,this._proxy=new Mt({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new bd({isLocal:!1,update:t=>(0,u.oV)(this._connection.container.updateAttributeView(t))})}destroy(){this._proxy.destroy(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}get invalidateRequested(){return this._invalidateRequested}get version(){return this._version}getDisplayFeatures(t){return this._strategy?this._strategy.getDisplayFeatures(t):{features:[],aggregates:[]}}getDisplayIds(t){const e={};return this._strategy?(this._strategy.displayMap(t,(t=>t),((t,s,r)=>{e[r]=t})),e):e}getFeatureObjectIdsForAggregate(t){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(t):[]}onSubscribe(t){this._strategy?.onSubscribe(t)}onUnsubscribe(t){this._strategy?.onUnsubscribe(t)}async update(t,e,s,r,i){const o=t.processor,a=(0,U.i8)(this._schema?.storage,o.storage),h=(0,U.i8)(this._schema?.mesh.properties,o.mesh.properties),c=(0,U.i8)(this._schema?.mesh.factory,o.mesh.factory),l=(0,U.i8)(this._schema?.mesh.strategy,o.mesh.strategy),u=function(t,e){const s=[];return t?.timeExtent?.start===e.timeExtent?.start&&t?.timeExtent?.end===e.timeExtent?.end||s.push("timeProperties"),s}(this._schema?.expressionProperties,o.expressionProperties),d=u.some((t=>this._attributeStore.hasArcadeDependency(t))),_=u.some((t=>this._factory?.hasArcadeDependency(t)??!1)),p=u.some((t=>this._strategy?.hasArcadeDependency(t)))||this._strategy?.isAggregate&&d,f=_||p,g=h||c||l;if(!(a||g||_||d||p||r))return;(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:(0,V.Ui)(this._schema,o),schema:o}),this._schema=o;const m=q.A.fromJSON(this._source.service.outSpatialReference),y=new Bl({fields:this._source.metadata.fieldsIndex,spatialReference:m});if((a||g||d)&&(await this._attributeStore.update(o.storage,y,this._source.metadata,m,e),this._strategy?.invalidateAttributeData(xd(o))),!r&&!g&&!f)return;(l||h||f)&&await this._updateStrategy(o.mesh.strategy,m,i,xd(o)),this._updateSortKey(y,"sortKey"in o.mesh.properties?o.mesh.properties.sortKey:null);const b=new il(y,this._proxy,s,this._registry);(c||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await ct.create(b,o.mesh.factory)),this.requestInvalidateMesh(),this._version=e}requestInvalidateMesh(){this._invalidateRequested=!0}async applyOverrideUpdate(t){if(!this._strategy)return;const e=this._strategy.applyOverrideUpdate(t);for await(const t of e)try{await this._process(t)}catch(t){}}async updateChunks(){this._invalidateRequested&&(this._invalidate(),this._invalidateRequested=!1),await this._doUpdateChunks(),this._strategy?.afterUpdateChunks()}async removeChunks(t){this._strategy?.removeChunks(t),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:t}){if(!this._strategy)return void this._attributeStore.setHighlight(t.map((({objectId:t,highlightFlags:e})=>({objectId:t,highlightFlags:e,displayId:-1}))),t);const e=this._strategy.displayMap(t,(({objectId:t})=>t),((t,{highlightFlags:e},s)=>({objectId:s,displayId:t,highlightFlags:e})));this._attributeStore.setHighlight(e,t)}async _doUpdateChunks(){if(!this._strategy)return;const t=this._strategy.updateChunks(),e=[],s=new Map;for await(const r of t){let t=s.get(r.id);null==t&&(t=new nl({concurrency:16,process:t=>this._process(t)}),s.set(r.id,t));const i=t.push(r).catch((t=>(0,a.jH)(t)));e.push(i)}try{await Promise.all(e)}catch(t){}(0,n.A)("esri-2d-update-debug")&&console.log("SendUpdates"),this._attributeStore.sendUpdates(),(0,n.A)("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(t,e,s,r){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new dd(this._source,this._attributeStore,r);break;case"binning":this._strategy=await pu.create(t,e,this._source,this._attributeStore,r);break;case"cluster":this._strategy=await Ou.create(this._connection,t,e,this._source,this._attributeStore,r)}for(const t of s)this._strategy.onSubscribe(t)}async _updateSortKey(t,e){if(this._sortInfo=(0,C.pR)(this._sortInfo?.computed),null!=e){const s=e.byRenderer?null:await t.createComputedField(e);this._sortInfo={...e,computed:s}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(t){const e=t.subscription;if((0,n.A)("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process`)}await this._fetchResources(t),(0,a.Te)(e.signal);const s=await this._write(t,e.tile.createArcadeEvaluationOptions(xd(this._schema))),r=e.tile.tileInfoView.getLODInfoAt(e.tile.key),{message:i,transferList:o}=s.serialize(r),h={objectIdMap:null,inner:t.createMessage(i,this._version,this._attributeStore.epoch)};if(this._schema?.mesh.properties.returnMeshObjectId){h.objectIdMap={};const e=t.reader?.getCursor();if(e)for(;e.next();)h.objectIdMap[e.getDisplayId()]=e.getObjectId()}if((0,a.Te)(e.signal),await this._connection.container.onMessage(h,{signal:e.signal,transferList:o}),this._attributeStore.sendUpdates(),(0,n.A)("esri-2d-update-debug")){const s=e.tile;console.debug(`Version[${this._version}] Tile[${s.key.id}, end=${t.end}] Processor._process.await`)}}async _fetchResources(t){await this._fetchMatcherResources(t),await this._fetchWriterResources(t)}async _fetchMatcherResources(t){if(t.reader)return this._factory.enqueueMatcherRequests(this._proxy,t.reader)}async _fetchWriterResources(t){if(!t.reader)return;const e=t.reader.getCursor(),s=t.subscription.tile.createArcadeEvaluationOptions(xd(this._schema));for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,r=t.reader?.getCursor(),i=r?.getSize()??0,n=s.tileInfoView.tileInfo.isWrappable,o=s.tileInfoView.tileInfo.spatialReference.isWGS84,a=new J(s.key,this._strategy.enablePixelBuffering,n,o,i);if(!r)return a;const h=s.createArcadeEvaluationOptions(xd(this._schema));for(;r.next();){const t=this._getSortKeyValue(r,e);a.entityStart(r.getDisplayId(),t),this._factory.write(a,this._proxy,r,h,s.level),a.entityEnd()}return a}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:r,byRenderer:i}=this._sortInfo,n=i?this._factory.getSortKey(t,e):s?.read(t,e);return null==n||isNaN(n)?0:n*("asc"===r?-1:1)}}function xd(t){const{timeZone:e}=t?.mesh.properties??{},{timeExtent:s}=t?.expressionProperties??{};return{timeZone:e,timeExtent:s}}var vd=s(78888),Sd=s(80893);class Id{static from(t){let e=0,s=0,r=0;return t.forEach((t=>{const i=t._readGeometry();i&&(s+=i.isPoint?1:i.lengths.reduce(((t,e)=>t+e),0),r+=i.isPoint?1:i.lengths.length,e+=1)})),new Id(e,s,r)}constructor(t,e,s){this.featureCount=t,this.vertexCount=e,this.ringCount=s}toJSON(){return{featureCount:this.featureCount,ringCount:this.featureCount,vertexCount:this.featureCount}}}var Md=s(60694),Pd=s(79677);class Td{static fromSchema(t,e,s){const r="feature"===e.type?e.mutable.dataFilter.queryScaleRanges:[];return new Td(function(t,e,s){const r=t.orderByFields??s.objectIdField+" ASC",i=t.source,n={returnCentroid:!(null!==i&&"object"==typeof i&&"path"in i&&(0,Md.Wo)(i.path))&&"esriGeometryPolygon"===s.serviceGeometryType,returnGeometry:!0,timeReferenceUnknownClient:s.timeReferenceUnknownClient??void 0,outSpatialReference:q.A.fromJSON(t.outSpatialReference),orderByFields:"memory"===t.type?[]:[r],where:e.mutable.dataFilter.definitionExpression??"1=1",outFields:e.mutable.availableFields,multipatchOption:"esriGeometryMultiPatch"===s.serviceGeometryType?"xyFootprint":null};if("feature"===e.type){const{gdbVersion:t,historicMoment:s,timeExtent:r}=e.mutable.dataFilter;return{...n,gdbVersion:t,historicMoment:s?new Date(s):null,timeExtent:r?Pd.A.fromJSON(r):null,outFields:e.mutable.availableFields}}return n}(t,e,s),r,s.subtypeField,e.mutable.dataFilter.customParameters,s.geometryType,t.queryMetadata)}constructor(t,e,s,r,i,n){this._queryParams=t,this._queryScaleRanges=e,this._subtypeField=s,this._customParameters=r,this._geometryType=i,this._queryMetadata=n}get pageSize(){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support paged queries");const t=this._queryMetadata.supportsMaxRecordCountFactor?4:null,e=(this._queryMetadata.maxRecordCount??8e3)*(t??1);return Math.min(8e3,e)}updateHistoricMoment(t){this._queryParams.historicMoment=t}updateFields(t){this._queryParams.outFields=t}createPatchFieldsQuery(t,e){if(!e.getSize())return null;const s=t.clone();if("*"===this._queryParams.outFields[0]){if("*"===(s.outFields??[])[0])return null;s.outFields=this._queryParams.outFields}else{const t=new Set(this._queryParams.outFields),r=[];for(const s of t)e.hasField(s)||r.push(s);if(0===r.length)return null;s.outFields=r}return s.returnGeometry=!1,s.returnCentroid=!1,s.quantizationParameters=null,s.cacheHint=!0,{inner:s,customParameters:this._customParameters}}createQuery(t={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new ql.A({...this._queryParams,...t}),customParameters:this._customParameters}}createTileQuery(t,e){if(null==this._queryMetadata)throw new Error("InternalError: Service does not support tile queries");const s=this.createQuery(e),r=s.inner;if(this._queryScaleRanges.length){const e=this._queryScaleRanges.filter((e=>(!e.minScale||e.minScale>=t.maxScale)&&(!e.maxScale||e.maxScale<=t.minScale))).map((t=>t.subtypeCode));if(e.length){const t=`${this._subtypeField} IN (${e})`;r.where=(0,El.m)(r.where,t)}}if(r.quantizationParameters=e.quantizationParameters??t.getQuantizationParameters(),r.resultType="tile",r.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(r.maxAllowableOffset=t.resolution*(0,n.A)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(r.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(r.maxAllowableOffset*=(0,n.A)("feature-polyline-generalization-factor"))),r.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,r.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(r.maxRecordCountFactor=4),(0,n.A)("esri-tiles-debug")){const e=t.id.replaceAll("/",".");s.customParameters=s.customParameters?{...s.customParameters,tileId:e}:{tileId:e}}return s}createPagedTileQuery(t,e){const s=this.pageSize;return this.createTileQuery(t,{start:s*e,num:s,returnExceededLimitFeatures:!0})}createPagedQuery(t){const e=this.pageSize;return this.createQuery({start:e*t,num:e,returnExceededLimitFeatures:!0,maxRecordCountFactor:4})}}let Ad=class extends T.A{constructor(t){super(),this._connection=t,this._enabledEventTypes=new Set,this._updateInfo={websocket:0,client:0},this._lastTime=performance.now(),this._queuedCommands=[],this.addHandles([(0,c.wB)((()=>this._strategy?.connectionStatus??"disconnected"),(t=>{this._layerView.setProperty({propertyName:"pipelineConnectionStatus",value:t})}),{initial:!0}),(0,c.wB)((()=>this._strategy?.errorString||null),(t=>this._layerView.setProperty({propertyName:"pipelineErrorString",value:t})),{initial:!0})])}destroy(){this._strategy=null,this.removeAllHandles()}get _layerView(){return this._connection.layerView}set strategy(t){null==this._strategy&&this._resetUpdateInfo(performance.now());const e="event-handles";this.removeHandles(e),null!=t&&(this.addHandles([t.events.on("data-received",(t=>this._onFeature(t))),t.events.on("message-received",(t=>this._onWebSocketMessage(t))),t.events.on("features-updated",(t=>this._onUpdate(t))),t.events.on("tick",(()=>this._onTick()))],e),this._queuedCommands.forEach((e=>e(t))),this._queuedCommands=[]),this._strategy=t}updateCustomParameters(t){null!=t&&this._callOrEnqueue((e=>e.updateCustomParameters(t)))}sendMessageToSocket(t){this._callOrEnqueue((e=>e.sendMessageToSocket(t)))}sendMessageToClient(t){this._callOrEnqueue((e=>e.sendMessageToClient(t)))}enableEvent(t,e){e?this._enabledEventTypes.add(t):this._enabledEventTypes.delete(t)}disconnect(){this._strategy?.disconnect()}connect(){this._strategy?.connect()}clear(){this._strategy?.clear()}_onWebSocketMessage(t){this._enabledEventTypes.has("message-received")&&this._layerView.emitEvent({name:"message-received",event:t})}_onFeature(t){this._updateInfo.websocket++,this._enabledEventTypes.has("data-received")&&this._layerView.emitEvent({name:"data-received",event:{attributes:t.attributes,centroid:t.centroid,geometry:t.geometry}})}_onUpdate(t){this._updateInfo.client+=t}_onTick(){const t=performance.now(),e=t-this._lastTime;if(e>2500){const s=Math.round(this._updateInfo.client/(e/1e3)),r=Math.round(this._updateInfo.websocket/(e/1e3));this._resetUpdateInfo(t),this._layerView.emitEvent({name:"update-rate",event:{client:s,websocket:r}})}}_resetUpdateInfo(t){this._lastTime=t,this._updateInfo.client=0,this._updateInfo.websocket=0}_callOrEnqueue(t){null!=this._strategy?t(this._strategy):this._queuedCommands.push(t)}};(0,P._)([(0,F.MZ)()],Ad.prototype,"_strategy",void 0),Ad=(0,P._)([(0,z.$)("esri.views.2d.layers.features.sources.StreamMessenger")],Ad);class Cd{constructor(t){this._store=t,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}unsafeSetQueryHistoricMoment(t){throw new Error("InternalError: LoadStrategy does not support query info")}async queryByObjectId(t){throw new Error("InternalError: LoadStrategy does not support fetching")}async addParquetFile(t){throw new Error("InternalError: LoadStrategy does not support loading blobs")}}var kd=s(10382),Fd=s(62577),Ed=s(75321),zd=s(51624),Od=s(53655);const Rd=268435455;class Dd{constructor(){this.hasFeatures=!1,this.exceededTransferLimit=!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}}const Ld=268435455,Nd=128e3,Bd={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(Nd),decoded:new Int32Array(Nd)}};function Gd(t){return t<=Bd.small.delta.length?Bd.small:(t<=Bd.large.delta.length||(Bd.large.delta=new Int32Array(Math.round(1.25*t)),Bd.large.decoded=new Int32Array(Math.round(1.25*t))),Bd.large)}function Ud(t){for(;t.next();){if(1===t.tag())return t.getMessage();t.skip()}return null}function Vd(t,e,s,r,i,n){return.5*Math.abs(t*r+s*n+i*e-t*n-s*e-i*r)}function qd(t,e,s,r,i){return!!t&&0==e*i-r*s&&e*r+s*i>0}class Wd extends uu{static fromBuffer(t,e,s=!1){const i=e.geometryType,n=function(t){try{const e=2,s=new zd.A(new Uint8Array(t),new DataView(t));for(;s.next();){if(s.tag()===e)return Ud(s.getMessage());s.skip()}}catch(t){const e=new r.A("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:t});E.A.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(e)}return null}(t),o=function(t,e,s=!1){const i=t.asUnsafe(),n=i.pos(),o=new Dd;let a=0,h=0,c=null,l=null,u=null,d=!1;const _=[];for(;i.next();)switch(i.tag()){case 1:c=i.getString();break;case 3:l=i.getString();break;case 12:u=i.processMessage(Od.ae);break;case 9:if(o.exceededTransferLimit=i.getBool(),o.exceededTransferLimit){o.offsets.geometry=s?new Float64Array(8e3):new Int32Array(8e3),o.centroid=s?new Float64Array(16e3):new Int32Array(16e3);for(let t=0;t<o.centroid.length;t++)o.centroid[t]=Rd}break;case 13:{const t=i.processMessage(Od.cn);t.index=a++,_.push(t);break}case 15:{const t=i.getLength(),r=i.pos()+t;if(!o.exceededTransferLimit){const t=o.offsets.geometry,e=o.centroid;t.push(0),e.push(Rd),e.push(Rd)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=s?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=h*a;for(;i.pos()<r&&i.next();)switch(i.tag()){case 1:{d?o.offsets.attributes[n++]=i.pos():o.offsets.attributes.push(i.pos());const t=i.getLength();i.skipLen(t);break}case 2:if(e){const t=i.getLength(),e=i.pos()+t;for(;i.pos()<e&&i.next();)switch(i.tag()){case 3:{i.getUInt32();const t=i.getSInt64(),e=i.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:i.skip()}}else{o.offsets.geometry[h]=i.pos();const t=i.getLength();o.vertexCount+=t,i.skipLen(t)}break;case 4:{const t=i.getLength(),e=i.pos()+t;for(;i.pos()<e&&i.next();)switch(i.tag()){case 3:{i.getUInt32();const t=i.getSInt64(),e=i.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:i.skip()}break}default:i.skip()}h++,o.hasFeatures=!0;break}default:i.skip()}const p=c||l;if(!p)throw new r.A("FeatureSet has no objectId or globalId field name");return o.fields=new hl.A(_),o.featureCount=h,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(p)?.index,o.transform=u,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),i.move(n),o}(n,"esriGeometryPoint"===i,s);return new Wd(n,o,e)}constructor(t,e,s){super(s),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0},this._parseCaches=new Array,this._geometryType=s.geometryType,this._reader=t,this._header=e,this._hasNext=e.hasFeatures,this._isPoints="esriGeometryPoint"===s.geometryType}get _size(){return this._header.featureCount}get fields(){return this._header.fields}get geometryType(){return this._geometryType}get hasZ(){return!1}get hasM(){return!1}get hasFeatures(){return this._header.hasFeatures}get hasNext(){return this._hasNext}get exceededTransferLimit(){return this._header.exceededTransferLimit}getSize(){return this._size}getInTransform(){return this._header.transform}getCursor(){return this.copy()}getIndex(){return this._featureIndex}setIndex(t){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._featureIndex=t}getAttributeHash(){let t="";for(const e of this._header.fields.fields)t+=this._readAttributeAtIndex(e.index)+".";return t}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(t){this._header.displayIds[this._featureIndex]=t}readGeometryArea(){return this._cache.area||this._readGeometry(!0),this._cache.area}copy(){const t=this._reader.clone(),e=new Wd(t,this._header,this.metadata);return this.copyInto(e),e}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}get usedMemory(){return id.qK+(this._cache.geometry?.usedMemory??0)}_readX(){return this._header.centroid[2*this._featureIndex]}_readY(){return this._header.centroid[2*this._featureIndex+1]}_readServerCentroid(){const t=this._header.centroid[2*this._featureIndex],e=this._header.centroid[2*this._featureIndex+1];return t===Ld?null:new jt.A([],[t,e])}_readGeometry(t=!1){if(void 0===this._cache.geometry){let e=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===Ld)return null;const t=this._header.centroid[2*this._featureIndex],s=this._header.centroid[2*this._featureIndex+1];e=new jt.A([],[t,s])}else{const s=this._header.offsets.geometry[this._featureIndex],r=this._reader;if(0===s)return null;r.move(s);try{e=t?this._parseGeometryForDisplay(r):this._parseGeometry(r)}catch(t){return null}}return 0===e?.coords.length&&(e=null),this._cache.geometry=e,e}return this._cache.geometry}_readAttribute(t,e){const s=this._header.fields.get(t);if(null==s)return;const r=this._readAttributeAtIndex(s.index),i=this._header.fields.isDateField(s.name);return e?null==r?r:i?new Date(r):r:r}_readAttributes(){const t={};for(const e of this._header.fields.fields)t[e.name]=this._readAttributeAtIndex(e.index);return t}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._featureOffset=this._featureOffset,t._hasNext=this._hasNext,t._parseCaches=this._parseCaches}_readAttributeAtIndex(t){let e=this._parseCaches[t];if(e||(e=new Kl(this.getSize()),this._parseCaches[t]=e),e.has(this._featureIndex))return e.get(this._featureIndex);const s=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+t],r=this._reader;r.move(s);const i=function(t){const e=t.getLength(),s=t.pos()+e;for(;t.pos()<s&&t.next();)switch(t.tag()){case 1:return t.getString();case 2:return t.getFloat();case 3:return t.getDouble();case 4:return t.getSInt32();case 5:return t.getUInt32();case 6:return t.getInt64();case 7:return t.getUInt64();case 8:return t.getSInt64();case 9:return t.getBool();default:return t.skip(),null}return null}(r);return e.set(this._featureIndex,i),i}_readGeometryDeltaDecoded(t=!1){if(void 0===this._cache.unquantGeometry){const e=this._readGeometry(t);if(!e)return this._cache.unquantGeometry=void 0,null;if(!this.getInTransform())return this._cache.unquantGeometry=e,e;const s=Gd(e.coords.length).decoded,r=e.clone(s),i=r.coords;let n=0;for(const t of r.lengths){for(let e=1;e<t;e++){const t=2*(n+e),s=2*(n+e-1);i[t]+=i[s],i[t+1]+=i[s+1]}n+=t}return this._cache.unquantGeometry=r,r}return this._cache.unquantGeometry}_parseGeometry(t){const e=t.asUnsafe(),s=e.getLength(),r=e.pos()+s,i=[],n=[];for(;e.pos()<r&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;)n.push(e.getUInt32());break}case 3:{const t=e.getUInt32(),s=e.pos()+t;for(i.push(e.getSInt64()),i.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();e.pos()<s;)i.push(e.getSInt64()),i.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();break}default:e.skip()}return new jt.A(n,i)}_parseGeometryForDisplay(t){const e=t.asUnsafe(),s=e.getLength(),r=e.pos()+s,i=[],n=[];let o=0,a=0,h=null,c=0;const l="esriGeometryPolygon"===this.geometryType,u="esriGeometryPolyline"===this.geometryType,d=l||u;for(;e.pos()<r&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;){const t=e.getUInt32();i.push(t),o+=t}h=Gd(2*o).delta;break}case 3:{e.getUInt32();const t=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,C.Lw)(h);for(const s of i)if(a+t*s>h.length)for(let t=0;t<s;t++)e.getSInt32(),e.getSInt32(),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();else if(l){const t=this.getAreaSimplificationThreshold(s,this._header.vertexCount);let r=2,i=1;const o=!1;let l=e.getSInt32(),u=e.getSInt32();h[a++]=l,h[a++]=u,this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();let _=e.getSInt32(),p=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();r<s;){let s=e.getSInt32(),n=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const o=l+_,f=u+p;Vd(l,u,o,f,o+s,f+n)>=t?(c+=-.5*(o-l)*(f+u),i>1&&qd(d,h[a-2],h[a-1],_,p)?(h[a-2]+=_,h[a-1]+=p):(h[a++]=_,h[a++]=p,i++),l=o,u=f):(s+=_,n+=p),_=s,p=n,r++}i<3||o?a-=2*i:(c+=-.5*(l+_-l)*(u+p+u),qd(d,h[a-2],h[a-1],_,p)?(h[a-2]+=_,h[a-1]+=p,n.push(i)):(h[a++]=_,h[a++]=p,n.push(++i)))}else{let t=0,r=e.getSInt32(),i=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),h[a++]=r,h[a++]=i,t+=1;for(let n=1;n<s;n++){const s=e.getSInt32(),o=e.getSInt32(),l=r+s,u=i+o;c+=-.5*(l-r)*(u+i),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),n>2&&qd(d,h[a-2],h[a-1],s,o)?(h[a-2]+=s,h[a-1]+=o):(h[a++]=s,h[a++]=o,t+=1),r=l,i=u}n.push(t)}break}default:e.skip()}return this._cache.area=c,n.length?new jt.A(n,h):null!=h?this._createQuantizedExtrudedGeometry(h[0],h[1]):null}}class jd{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}class Yd extends jd{constructor(t,e){super(t,e),this._portsOpen=async function(t){const e=new kd.A;return await e.open(t,{}),e}(t.source).then((t=>this.client=t))}destroy(){this.client.close(),this.client=null}async executeQuery(t,e){await this._portsOpen;const s=await this.client.invoke("queryFeatures",t.toJSON(),e);return du.fromFeatureSet(s,this._metadata)}}class Xd extends jd{async executeQuery(t,e){const{data:s}=await(0,Sd.kS)(this.service.source,t,e),r=!t.quantizationParameters;return Wd.fromBuffer(s,this._metadata,r)}}class $d extends jd{async executeQuery(t,e){const{source:s,queryMetadata:r}=this.service;if(null!=t.quantizationParameters&&!r.supportsQuantization){const r=t.clone(),i=(0,Fd.VV)(r.quantizationParameters);r.quantizationParameters=null;const{data:n}=await(0,Sd.eW)(s,r,this._metadata.spatialReference,e),o=(0,Ch.q3)(n,this._metadata.objectIdField);return(0,Ch.jH)(i,o),du.fromOptimizedFeatureSet(o,this._metadata)}const{data:i}=await(0,Sd.eW)(s,t,this._metadata.spatialReference,e);return"esriGeometryPoint"===this._metadata.geometryType&&(i.features=i.features?.filter((t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0}))),du.fromFeatureSet(i,this._metadata)}}class Hd extends jd{async executeQuery(t,e){if(t.quantizationParameters&&!this.service.queryMetadata.supportsQuantization){const s=t.clone(),r=(0,Fd.VV)(s.quantizationParameters);s.quantizationParameters=null;const i=await(0,Ed.I)(this.service.source,t,e);return(0,Ch.jH)(r,i),du.fromOptimizedFeatureSet(i,this._metadata)}const s=await(0,Ed.I)(this.service.source,t,e);return du.fromOptimizedFeatureSet(s,this._metadata)}}class Zd extends Cd{constructor(t,e,s,r,i){super(s),this._serviceInfo=t,this._queryInfo=e,this._metadata=r,this._connection=i,this._queue=new R.e({concurrency:16,process:async t=>{const e={signal:t.options?.signal,query:t.query.customParameters};return this._adapter.executeQuery(t.query.inner,e)}}),this._adapter=function(t,e){switch(t.type){case"memory":return new Yd(t,e);case"ogc":return new Hd(t,e);case"feature-service":return t.queryMetadata.supportsFormatPBF&&(0,n.A)("featurelayer-pbf")?new Xd(t,e):new $d(t,e)}}(t,r)}unsafeSetQueryHistoricMoment(t){this._queryInfo.updateHistoricMoment(t)}async updateFields(t){this._queryInfo.updateFields(t);const e=Array.from(this._store.chunks()).map((async t=>{const e=ql.A.fromJSON(t.queryInfo.queryJSON);if(e)try{return await this._tryUpdateFields(t.reader,e),null}catch(t){return t}})),s=(await Promise.all(e)).filter((t=>t));if(s.length)throw new r.A("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async queryByObjectId(t){if(0===t.length)return du.empty(this._metadata);const e=this._queryInfo.createQuery({objectIds:t});return this._fetch(e)}async _fetch(t,e){const s=await this._enqueue(t,e);return await this._tryUpdateFields(s,t.inner),s}async _tryUpdateFields(t,e){const s=this._queryInfo.createPatchFieldsQuery(e,t);if(!s)return;const r=await this._enqueue(s,this._options);t.joinAttributes(r)}async _enqueue(t,e){return this._connection.onEvent({type:"fetchStart"}),this._queue.push({query:t,options:e}).finally((()=>{this._connection.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class Qd extends Zd{constructor(){super(...arguments),this._chunksById=new Map}unload(t){this._removeChunks(t.tile)}_addChunk(t){const e=t.tile.id;this._chunksById.has(e)||this._chunksById.set(e,[]);const s=t.size();(s||t.first||t.end)&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] ATileLoadStrategy.addChunk [count=${s}]`),this._chunksById.get(e).push(t),this._store.insert(t))}_removeChunks(t){const e=this._chunksById.get(t.key.id)??[];for(const s of e)(0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t.key.id}] Chunk[${s.chunkId}] ATileLoadStrategy.removeChunk`),this._store.remove(s);this._chunksById.delete(t.key.id)}}class Kd extends od{constructor(t,e,s,r,i,n){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._sourceTile=r,this._sourceTileDepth=i,this._end=n,this.chunkId=`${this._tile.key.id}.${this._sourceTile?.key.id}${this._end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._sourceTile?.key.normalizedId}${this._end?"e":""}`}get queryInfo(){return{type:"drill-down-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,sourceTileDepth:this._sourceTileDepth,sourceTileId:this._sourceTile?.key.id,size:this.size(),end:this.end}}get first(){return 0===this._sourceTileDepth}get reader(){return this._reader}get end(){return this._end}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class Jd{constructor(t,e){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,this._handles=(0,i.vE)([(0,a.u7)(t.signal,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))])}destroy(){this._controller.abort(),this._handles.remove()}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class t_ extends Qd{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new Jd(t,this._options));const e=this._loadStates.get(t.key.id);let s;try{for await(const s of this._fetchChunkInfos(e,t.tile,0)){const{queryJSON:t,reader:r,sourceTile:i,sourceTileDepth:n,tile:o}=s,h=new Kd(r,t,o,i,n,!1);(0,a.Te)(e.options),this._addChunk(h)}}catch(t){s=t}const r=new Kd(du.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(r),s)throw s}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let r=t.get(e.id);const i=!!r;if(r||(r=await this._fetchChunkInfo(t,e,s),t.set(e.id,r)),r.reader.exceededTransferLimit&&s<(0,n.A)("featurelayer-query-max-depth"))for(const r of e.createChildTiles())yield*this._fetchChunkInfos(t,r,s+1);else i||(yield r)}async _fetchChunkInfo(t,e,s){const r=t.subscription.tile.getQuantizationParameters(),i=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:r});return{reader:await this._fetch(i,t.options),queryJSON:i.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}class e_ extends od{constructor(t,e,s,r,i){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._page=r,this._end=i,this.chunkId=`${this._tile.key.id}.${this._page}${this.end?"e":""}`,this.normalizedChunkId=`${this._tile.key.normalizedId}.${this._page}${this.end?"e":""}`}get queryInfo(){return{type:"paged-tile",chunkId:this.chunkId,tileId:this._tile.key.id,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get page(){return this._page}get tile(){return this._tile}get isTiled(){return!0}getTileReader(t){return this._tile.key.id===t.key.id?this.reader:null}}class s_{constructor(t,e){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,this._handles=(0,i.vE)([(0,a.u7)(t.signal,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))])}destroy(){this._controller.abort(),this._handles.remove()}get pageStart(){let t=-1;for(const e of this._pages.values())t=Math.max(t,e);return t+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(t,e){this._pages.add(t),this._done=this._done||e}}class r_ extends Qd{constructor(){super(...arguments),this._loadStates=new Map}destroy(){super.destroy();for(const t of this._loadStates.values())t.destroy();this._loadStates.clear()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new s_(t,this._options));const e=this._loadStates.get(t.key.id);let s;try{await this._fetchPages(e)}catch(t){s=t}const r=new e_(du.empty(this._metadata),null,t.tile,-1,!0);if((0,a.G4)(e.options)||this._addChunk(r),s)throw s}unload(t){super.unload(t),this._loadStates.get(t.key.id)?.destroy(),this._loadStates.delete(t.key.id)}async _fetchPages(t){let e=0,s=t.pageStart,r=1;for(;e<20&&!t.done;){const i=[];for(let e=0;e<r;e++)i.push(this._fetchChunk(t,s++));const n=await Promise.all(i);for(const e of n)(0!==e.size()||e.first)&&(t.add(e.page,!e.reader.exceededTransferLimit),(0,a.Te)(t.options),this._addChunk(e));e++,r=Math.min(r+1,4)}}async _fetchChunk(t,e){const s=t.subscription.tile,r=this._queryInfo.createPagedTileQuery(s,e),i=await this._fetch(r,t.options);return new e_(i,r.inner.toJSON(),s,e,!1)}}var i_=s(2741);let n_;const o_=new Array(128).fill(void 0);function a_(t){return o_[t]}o_.push(void 0,null,!0,!1);let h_=o_.length;function c_(t){const e=a_(t);return function(t){t<132||(o_[t]=h_,h_=t)}(t),e}function l_(t){h_===o_.length&&o_.push(o_.length+1);const e=h_;return h_=o_[e],o_[e]=t,e}const u_="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&u_.decode();let d_=null;function __(){return null!==d_&&0!==d_.byteLength||(d_=new Uint8Array(n_.memory.buffer)),d_}function p_(t,e){return t>>>=0,u_.decode(__().subarray(t,t+e))}function f_(t,e){return t>>>=0,__().subarray(t/1,t/1+e)}const g_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>{n_.__wbindgen_export_1.get(t.dtor)(t.a,t.b)}));function m_(t,e,s){n_._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h6f3c6e2a403d1e3d(t,e,l_(s))}let y_=0;const b_="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},w_="function"==typeof b_.encodeInto?function(t,e){return b_.encodeInto(t,e)}:function(t,e){const s=b_.encode(t);return e.set(s),{read:t.length,written:s.length}};function x_(t,e,s){if(void 0===s){const s=b_.encode(t),r=e(s.length,1)>>>0;return __().subarray(r,r+s.length).set(s),y_=s.length,r}let r=t.length,i=e(r,1)>>>0;const n=__();let o=0;for(;o<r;o++){const e=t.charCodeAt(o);if(e>127)break;n[i+o]=e}if(o!==r){0!==o&&(t=t.slice(o)),i=s(i,r,r=o+3*t.length,1)>>>0;const e=__().subarray(i+o,i+r);o+=w_(t,e).written,i=s(i,r,o,1)>>>0}return y_=o,i}let v_=null;function S_(){return(null===v_||!0===v_.buffer.detached||void 0===v_.buffer.detached&&v_.buffer!==n_.memory.buffer)&&(v_=new DataView(n_.memory.buffer)),v_}function I_(t,e){try{return t.apply(this,e)}catch(t){n_.__wbindgen_exn_store(l_(t))}}let M_=null;function P_(){return null!==M_&&0!==M_.byteLength||(M_=new Float64Array(n_.memory.buffer)),M_}let T_=null;function A_(){return null!==T_&&0!==T_.byteLength||(T_=new Uint32Array(n_.memory.buffer)),T_}function C_(t,e){t>>>=0;const s=S_(),r=[];for(let i=t;i<t+4*e;i+=4)r.push(c_(s.getUint32(i,!0)));return r}let k_=null;function F_(t,e){const s=e(2*t.length,2)>>>0;return(null!==k_&&0!==k_.byteLength||(k_=new Uint16Array(n_.memory.buffer)),k_).set(t,s/2),y_=t.length,s}function E_(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`);return t.ptr}function z_(t,e){const s=e(8*t.length,8)>>>0;return P_().set(t,s/8),y_=t.length,s}function O_(t,e){const s=e(4*t.length,4)>>>0;return A_().set(t,s/4),y_=t.length,s}function R_(t){return null==t}function D_(t,e){const s=e(1*t.length,1)>>>0;return __().set(t,s/1),y_=t.length,s}function L_(t,e,s){const r=x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),i=y_;return c_(n_.readMetadata(r,i,l_(e),l_(s)))}const N_=Object.freeze({None:0,0:"None",Snappy:1,1:"Snappy"}),B_=Object.freeze({Point:0,0:"Point",Polygon:1,1:"Polygon",Polyline:2,2:"Polyline",Multipoint:3,3:"Multipoint"}),G_=["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeBigInteger","esriFieldTypeSingle","esriFieldTypeDouble","esriFieldTypeLong","esriFieldTypeString","esriFieldTypeDate","esriFieldTypeOID","esriFieldTypeGeometry","esriFieldTypeBlob","esriFieldTypeRaster","esriFieldTypeGUID","esriFieldTypeGlobalID","esriFieldTypeXML","esriFieldTypeDateOnly","esriFieldTypeTimeOnly","esriFieldTypeTimestampOffset"],U_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_columndescriptor_free(t>>>0,1)));class V_{static __wrap(t){t>>>=0;const e=Object.create(V_.prototype);return e.__wbg_ptr=t,U_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,U_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_columndescriptor_free(t,0)}name(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_name(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}physicalType(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_physicalType(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}logicalType(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_logicalType(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}encodings(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_encodings(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=C_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}pageEncodings(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_pageEncodings(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=C_(t,e).slice(),n_.__wbindgen_free(t,4*e,4)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}numValues(){return n_.columndescriptor_numValues(this.__wbg_ptr)}compression(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_compression(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}compressedSize(){return n_.columndescriptor_compressedSize(this.__wbg_ptr)}uncompressedSize(){return n_.columndescriptor_uncompressedSize(this.__wbg_ptr)}nullCount(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_nullCount(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getBigInt64(s+8,!0);return 0===t?void 0:e}finally{n_.__wbindgen_add_to_stack_pointer(16)}}distinctCount(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_distinctCount(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getBigInt64(s+8,!0);return 0===t?void 0:e}finally{n_.__wbindgen_add_to_stack_pointer(16)}}minValue(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_minValue(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=f_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}maxValue(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.columndescriptor_maxValue(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=f_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const q_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_fieldmetadata_free(t>>>0,1)));class W_{static __wrap(t){t>>>=0;const e=Object.create(W_.prototype);return e.__wbg_ptr=t,q_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,q_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_fieldmetadata_free(t,0)}get name(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.fieldmetadata_name(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}get index(){return n_.fieldmetadata_index(this.__wbg_ptr)}get type(){const t=n_.fieldmetadata_esri_type(this.__wbg_ptr);return G_[t]}get physicalType(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.fieldmetadata_physical_type(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}get logicalType(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.fieldmetadata_logical_type(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const j_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_filemetadata_free(t>>>0,1)));class Y_{static __wrap(t){t>>>=0;const e=Object.create(Y_.prototype);return e.__wbg_ptr=t,j_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,j_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_filemetadata_free(t,0)}version(){return n_.filemetadata_version(this.__wbg_ptr)}numRows(){return n_.filemetadata_numRows(this.__wbg_ptr)>>>0}numFields(){return n_.filemetadata_numFields(this.__wbg_ptr)>>>0}numColumns(){return n_.filemetadata_numColumns(this.__wbg_ptr)>>>0}createdBy(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.filemetadata_createdBy(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=p_(t,e).slice(),n_.__wbindgen_free(t,1*e,1)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}keyValueMetadata(t){try{const r=n_.__wbindgen_add_to_stack_pointer(-16),i=x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),n=y_;n_.filemetadata_keyValueMetadata(r,this.__wbg_ptr,i,n);var e=S_().getInt32(r+0,!0),s=S_().getInt32(r+4,!0);let o;return 0!==e&&(o=p_(e,s).slice(),n_.__wbindgen_free(e,1*s,1)),o}finally{n_.__wbindgen_add_to_stack_pointer(16)}}keys(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.filemetadata_keys(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);let r;return 0!==t&&(r=C_(t,e).slice(),n_.__wbindgen_free(t,4*e,4)),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}getFieldIndex(t){const e=x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),s=y_,r=n_.filemetadata_getFieldIndex(this.__wbg_ptr,e,s);return 16777215===r?void 0:r}getFieldByIndex(t){const e=n_.filemetadata_getFieldByIndex(this.__wbg_ptr,t);return 0===e?void 0:W_.__wrap(e)}getFields(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.filemetadata_getFields(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=C_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const X_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_filewriter_free(t>>>0,1)));class $_{static __wrap(t){t>>>=0;const e=Object.create($_.prototype);return e.__wbg_ptr=t,X_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,X_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_filewriter_free(t,0)}static new(t,e){const s=function(t,e){const s=e(4*t.length,4)>>>0,r=S_();for(let e=0;e<t.length;e++)r.setUint32(s+4*e,l_(t[e]),!0);return y_=t.length,s}(t,n_.__wbindgen_malloc),r=y_,i=n_.filewriter_new(s,r,e);return $_.__wrap(i)}writeKeyValue(t,e){const s=x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),r=y_,i=x_(e,n_.__wbindgen_malloc,n_.__wbindgen_realloc),n=y_;n_.filewriter_writeKeyValue(this.__wbg_ptr,s,r,i,n)}writeI32Page(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,hp);var s=e.__destroy_into_raw();n_.filewriter_writeI32Page(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeI64Page(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,lp);var s=e.__destroy_into_raw();n_.filewriter_writeI64Page(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeF32Page(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,sp);var s=e.__destroy_into_raw();n_.filewriter_writeF32Page(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeF64Page(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,ip);var s=e.__destroy_into_raw();n_.filewriter_writeF64Page(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeGeometryPage(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,op);var s=e.__destroy_into_raw();n_.filewriter_writeBytesPage(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeStringPage(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,dp);var s=e.__destroy_into_raw();n_.filewriter_writeBytesPage(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeBytesPage(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16);E_(e,tp);var s=e.__destroy_into_raw();n_.filewriter_writeBytesPage(i,this.__wbg_ptr,t,s);var r=S_().getInt32(i+0,!0);if(S_().getInt32(i+4,!0))throw c_(r)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}finish(){try{const i=this.__destroy_into_raw(),n=n_.__wbindgen_add_to_stack_pointer(-16);n_.filewriter_finish(n,i);var t=S_().getInt32(n+0,!0),e=S_().getInt32(n+4,!0),s=S_().getInt32(n+8,!0);if(S_().getInt32(n+12,!0))throw c_(s);var r=f_(t,e).slice();return n_.__wbindgen_free(t,1*e,1),r}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const H_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_geometryinfodescriptor_free(t>>>0,1)));class Z_{static __wrap(t){t>>>=0;const e=Object.create(Z_.prototype);return e.__wbg_ptr=t,H_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,H_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_geometryinfodescriptor_free(t,0)}get geometryType(){const t=n_.__wbg_get_geometryinfodescriptor_geometryType(this.__wbg_ptr);return 4===t?void 0:t}set geometryType(t){n_.__wbg_set_geometryinfodescriptor_geometryType(this.__wbg_ptr,R_(t)?4:t)}get wkbIndex(){const t=n_.__wbg_get_geometryinfodescriptor_wkbIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set wkbIndex(t){n_.__wbg_set_geometryinfodescriptor_wkbIndex(this.__wbg_ptr,R_(t)?16777215:t)}get lngIndex(){const t=n_.__wbg_get_geometryinfodescriptor_lngIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set lngIndex(t){n_.__wbg_set_geometryinfodescriptor_lngIndex(this.__wbg_ptr,R_(t)?16777215:t)}get latIndex(){const t=n_.__wbg_get_geometryinfodescriptor_latIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set latIndex(t){n_.__wbg_set_geometryinfodescriptor_latIndex(this.__wbg_ptr,R_(t)?16777215:t)}get xIndex(){const t=n_.__wbg_get_geometryinfodescriptor_xIndex(this.__wbg_ptr);return 16777215===t?void 0:t}set xIndex(t){n_.__wbg_set_geometryinfodescriptor_xIndex(this.__wbg_ptr,R_(t)?16777215:t)}get inWkid(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.__wbg_get_geometryinfodescriptor_inWkid(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);return 0===t?void 0:e>>>0}finally{n_.__wbindgen_add_to_stack_pointer(16)}}set inWkid(t){n_.__wbg_set_geometryinfodescriptor_inWkid(this.__wbg_ptr,!R_(t),R_(t)?0:t)}get outWkid(){try{const s=n_.__wbindgen_add_to_stack_pointer(-16);n_.__wbg_get_geometryinfodescriptor_outWkid(s,this.__wbg_ptr);var t=S_().getInt32(s+0,!0),e=S_().getInt32(s+4,!0);return 0===t?void 0:e>>>0}finally{n_.__wbindgen_add_to_stack_pointer(16)}}set outWkid(t){n_.__wbg_set_geometryinfodescriptor_outWkid(this.__wbg_ptr,!R_(t),R_(t)?0:t)}static new(){const t=n_.geometryinfodescriptor_new();return Z_.__wrap(t)}setMultiscaleInfo(t){E_(t,K_);var e=t.__destroy_into_raw();n_.geometryinfodescriptor_setMultiscaleInfo(this.__wbg_ptr,e)}}const Q_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_multiscaleinfo_free(t>>>0,1)));class K_{static __wrap(t){t>>>=0;const e=Object.create(K_.prototype);return e.__wbg_ptr=t,Q_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Q_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_multiscaleinfo_free(t,0)}static new(){const t=n_.multiscaleinfo_new();return K_.__wrap(t)}push(t,e,s,r,i){n_.multiscaleinfo_push(this.__wbg_ptr,t,e,s,r,i)}}const J_="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuilderbytes_free(t>>>0,1)));class tp{static __wrap(t){t>>>=0;const e=Object.create(tp.prototype);return e.__wbg_ptr=t,J_.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,J_.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuilderbytes_free(t,0)}static new(){const t=n_.pagebuilderbytes_new();return tp.__wrap(t)}push(t){var e=R_(t)?0:D_(t,n_.__wbindgen_malloc),s=y_;n_.pagebuilderbytes_push(this.__wbg_ptr,e,s)}}const ep="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuilderf32_free(t>>>0,1)));class sp{static __wrap(t){t>>>=0;const e=Object.create(sp.prototype);return e.__wbg_ptr=t,ep.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,ep.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuilderf32_free(t,0)}static new(){const t=n_.pagebuilderbytes_new();return sp.__wrap(t)}push(t){n_.pagebuilderf32_push(this.__wbg_ptr,!R_(t),R_(t)?0:t)}}const rp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuilderf64_free(t>>>0,1)));class ip{static __wrap(t){t>>>=0;const e=Object.create(ip.prototype);return e.__wbg_ptr=t,rp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,rp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuilderf64_free(t,0)}static new(){const t=n_.multiscaleinfo_new();return ip.__wrap(t)}push(t){n_.pagebuilderf64_push(this.__wbg_ptr,!R_(t),R_(t)?0:t)}}const np="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuildergeometry_free(t>>>0,1)));class op{static __wrap(t){t>>>=0;const e=Object.create(op.prototype);return e.__wbg_ptr=t,np.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,np.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuildergeometry_free(t,0)}static new(){const t=n_.pagebuilderbytes_new();return op.__wrap(t)}writeXY(t,e){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.pagebuildergeometry_writeXY(r,this.__wbg_ptr,t,e);var s=S_().getInt32(r+0,!0);if(S_().getInt32(r+4,!0))throw c_(s)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writePBF(t,e,s,r){try{const n=n_.__wbindgen_add_to_stack_pointer(-16),o=z_(t,n_.__wbindgen_malloc),a=y_,h=O_(e,n_.__wbindgen_malloc),c=y_;n_.pagebuildergeometry_writePBF(n,this.__wbg_ptr,o,a,h,c,s,r);var i=S_().getInt32(n+0,!0);if(S_().getInt32(n+4,!0))throw c_(i)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writePolygon(t,e){try{const r=n_.__wbindgen_add_to_stack_pointer(-16),i=z_(t,n_.__wbindgen_malloc),n=y_,o=O_(e,n_.__wbindgen_malloc),a=y_;n_.pagebuildergeometry_writePolygon(r,this.__wbg_ptr,i,n,o,a);var s=S_().getInt32(r+0,!0);if(S_().getInt32(r+4,!0))throw c_(s)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writePolyline(t,e){try{const r=n_.__wbindgen_add_to_stack_pointer(-16),i=z_(t,n_.__wbindgen_malloc),n=y_,o=O_(e,n_.__wbindgen_malloc),a=y_;n_.pagebuildergeometry_writePolyline(r,this.__wbg_ptr,i,n,o,a);var s=S_().getInt32(r+0,!0);if(S_().getInt32(r+4,!0))throw c_(s)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeMultipoint(t,e){try{const r=n_.__wbindgen_add_to_stack_pointer(-16),i=z_(t,n_.__wbindgen_malloc),n=y_,o=O_(e,n_.__wbindgen_malloc),a=y_;n_.pagebuildergeometry_writeMultipoint(r,this.__wbg_ptr,i,n,o,a);var s=S_().getInt32(r+0,!0);if(S_().getInt32(r+4,!0))throw c_(s)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}writeNone(){n_.pagebuildergeometry_writeNone(this.__wbg_ptr)}}const ap="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuilderi32_free(t>>>0,1)));class hp{static __wrap(t){t>>>=0;const e=Object.create(hp.prototype);return e.__wbg_ptr=t,ap.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,ap.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuilderi32_free(t,0)}static new(){const t=n_.pagebuilderbytes_new();return hp.__wrap(t)}push(t){n_.pagebuilderi32_push(this.__wbg_ptr,!R_(t),R_(t)?0:t)}}const cp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuilderi64_free(t>>>0,1)));class lp{static __wrap(t){t>>>=0;const e=Object.create(lp.prototype);return e.__wbg_ptr=t,cp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,cp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuilderi64_free(t,0)}static new(){const t=n_.multiscaleinfo_new();return lp.__wrap(t)}push(t){n_.pagebuilderi64_push(this.__wbg_ptr,!R_(t),R_(t)?0:t)}}const up="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pagebuilderstring_free(t>>>0,1)));class dp{static __wrap(t){t>>>=0;const e=Object.create(dp.prototype);return e.__wbg_ptr=t,up.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,up.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pagebuilderstring_free(t,0)}static new(){const t=n_.pagebuilderbytes_new();return dp.__wrap(t)}push(t){var e=R_(t)?0:x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),s=y_;n_.pagebuilderstring_push(this.__wbg_ptr,e,s)}}const _p="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_pageencodingdescriptor_free(t>>>0,1)));class pp{static __wrap(t){t>>>=0;const e=Object.create(pp.prototype);return e.__wbg_ptr=t,_p.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,_p.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_pageencodingdescriptor_free(t,0)}pageType(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.pageencodingdescriptor_pageType(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}encoding(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.pageencodingdescriptor_encoding(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}count(){return n_.pageencodingdescriptor_count(this.__wbg_ptr)}}const fp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_parquetchunk_free(t>>>0,1)));class gp{static __wrap(t){t>>>=0;const e=Object.create(gp.prototype);return e.__wbg_ptr=t,fp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,fp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_parquetchunk_free(t,0)}size(){return n_.parquetchunk_size(this.__wbg_ptr)>>>0}hasField(t){return 0!==n_.parquetchunk_hasField(this.__wbg_ptr,t)}readX(t){return n_.parquetchunk_readX(this.__wbg_ptr,t)}readY(t){return n_.parquetchunk_readY(this.__wbg_ptr,t)}readCoords(t){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.parquetchunk_readCoords(r,this.__wbg_ptr,t);var e=S_().getInt32(r+0,!0),s=S_().getInt32(r+4,!0);let i;return 0!==e&&(i=function(t,e){return t>>>=0,P_().subarray(t/8,t/8+e)}(e,s).slice(),n_.__wbindgen_free(e,8*s,8)),i}finally{n_.__wbindgen_add_to_stack_pointer(16)}}readLengths(t){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.parquetchunk_readLengths(r,this.__wbg_ptr,t);var e=S_().getInt32(r+0,!0),s=S_().getInt32(r+4,!0);let i;return 0!==e&&(i=function(t,e){return t>>>=0,A_().subarray(t/4,t/4+e)}(e,s).slice(),n_.__wbindgen_free(e,4*s,4)),i}finally{n_.__wbindgen_add_to_stack_pointer(16)}}readGeometryTransformed(t,e,s,r,i){const n=n_.parquetchunk_readGeometryTransformed(this.__wbg_ptr,t,e,s,r,i);return 0===n?void 0:wp.__wrap(n)}boundsXMin(t){return n_.parquetchunk_boundsXMin(this.__wbg_ptr,t)}boundsYMin(t){return n_.parquetchunk_boundsYMin(this.__wbg_ptr,t)}boundsXMax(t){return n_.parquetchunk_boundsXMax(this.__wbg_ptr,t)}boundsYMax(t){return n_.parquetchunk_boundsYMax(this.__wbg_ptr,t)}readAttribute(t,e){return c_(n_.parquetchunk_readAttribute(this.__wbg_ptr,t,e))}}const mp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_parquetfile_free(t>>>0,1)));let yp=class t{static __wrap(e){e>>>=0;const s=Object.create(t.prototype);return s.__wbg_ptr=e,mp.register(s,s.__wbg_ptr,s),s}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,mp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_parquetfile_free(t,0)}metadata(){const t=n_.parquetfile_metadata(this.__wbg_ptr);return Y_.__wrap(t)}rowGroups(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.parquetfile_rowGroups(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=C_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}readChunksWithCallback(t,e){const s=F_(t,n_.__wbindgen_malloc),r=y_;return c_(n_.parquetfile_readChunksWithCallback(this.__wbg_ptr,s,r,l_(e)))}readFirstChunk(t){const e=F_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.parquetfile_readFirstChunk(this.__wbg_ptr,e,s))}readAllChunks(t){const e=F_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.parquetfile_readAllChunks(this.__wbg_ptr,e,s))}updateChunks(t){const e=F_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.parquetfile_updateChunks(this.__wbg_ptr,e,s))}};const bp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_quantizedgeometry_free(t>>>0,1)));class wp{static __wrap(t){t>>>=0;const e=Object.create(wp.prototype);return e.__wbg_ptr=t,bp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,bp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_quantizedgeometry_free(t,0)}readCoordsUnsafe(){return c_(n_.quantizedgeometry_readCoordsUnsafe(this.__wbg_ptr))}readLengthsUnsafe(){return c_(n_.quantizedgeometry_readLengthsUnsafe(this.__wbg_ptr))}}const xp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_rangeproviderjs_free(t>>>0,1)));class vp{static __wrap(t){t>>>=0;const e=Object.create(vp.prototype);return e.__wbg_ptr=t,xp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,xp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_rangeproviderjs_free(t,0)}static new(t,e){const s=n_.rangeproviderjs_new(l_(t),l_(e));return vp.__wrap(s)}static withFetch(){const t=n_.rangeproviderjs_withFetch();return vp.__wrap(t)}}const Sp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_rowgroup_free(t>>>0,1)));class Ip{static __wrap(t){t>>>=0;const e=Object.create(Ip.prototype);return e.__wbg_ptr=t,Sp.register(e,e.__wbg_ptr,e),e}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Sp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_rowgroup_free(t,0)}columns(){try{const r=n_.__wbindgen_add_to_stack_pointer(-16);n_.rowgroup_columns(r,this.__wbg_ptr);var t=S_().getInt32(r+0,!0),e=S_().getInt32(r+4,!0),s=C_(t,e).slice();return n_.__wbindgen_free(t,4*e,4),s}finally{n_.__wbindgen_add_to_stack_pointer(16)}}}const Mp="undefined"==typeof FinalizationRegistry?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((t=>n_.__wbg_schemafield_free(t>>>0,1)));class Pp{static __wrap(t){t>>>=0;const e=Object.create(Pp.prototype);return e.__wbg_ptr=t,Mp.register(e,e.__wbg_ptr,e),e}static __unwrap(t){return t instanceof Pp?t.__destroy_into_raw():0}__destroy_into_raw(){const t=this.__wbg_ptr;return this.__wbg_ptr=0,Mp.unregister(this),t}free(){const t=this.__destroy_into_raw();n_.__wbg_schemafield_free(t,0)}static tryNew(t,e){try{const i=n_.__wbindgen_add_to_stack_pointer(-16),n=x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),o=y_,a=x_(e,n_.__wbindgen_malloc,n_.__wbindgen_realloc),h=y_;n_.schemafield_tryNew(i,n,o,a,h);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);if(S_().getInt32(i+8,!0))throw c_(r);return Pp.__wrap(s)}finally{n_.__wbindgen_add_to_stack_pointer(16)}}name(){let t,e;try{const i=n_.__wbindgen_add_to_stack_pointer(-16);n_.schemafield_name(i,this.__wbg_ptr);var s=S_().getInt32(i+0,!0),r=S_().getInt32(i+4,!0);return t=s,e=r,p_(s,r)}finally{n_.__wbindgen_add_to_stack_pointer(16),n_.__wbindgen_free(t,e,1)}}}function Tp(){const t={wbg:{}};return t.wbg.__wbg_new_abda76e883ba8a5f=function(){return l_(new Error)},t.wbg.__wbg_stack_658279fe44541cf6=function(t,e){const s=x_(a_(e).stack,n_.__wbindgen_malloc,n_.__wbindgen_realloc),r=y_;S_().setInt32(t+4,r,!0),S_().setInt32(t+0,s,!0)},t.wbg.__wbg_error_f851667af71bcfc6=function(t,e){let s,r;try{s=t,r=e,console.error(p_(t,e))}finally{n_.__wbindgen_free(s,r,1)}},t.wbg.__wbindgen_object_drop_ref=function(t){c_(t)},t.wbg.__wbindgen_is_function=function(t){return"function"==typeof a_(t)},t.wbg.__wbg_self_3093d5d1f7bcb682=function(){return I_((function(){return l_(self.self)}),arguments)},t.wbg.__wbg_window_3bcfc4d31bc012f8=function(){return I_((function(){return l_(window.window)}),arguments)},t.wbg.__wbg_globalThis_86b222e13bdf32ed=function(){return I_((function(){return l_(globalThis.globalThis)}),arguments)},t.wbg.__wbg_global_e5a3fe56f8be9485=function(){return I_((function(){return l_(global.global)}),arguments)},t.wbg.__wbindgen_is_undefined=function(t){return void 0===a_(t)},t.wbg.__wbg_newnoargs_76313bd6ff35d0f2=function(t,e){return l_(new Function(p_(t,e)))},t.wbg.__wbindgen_object_clone_ref=function(t){return l_(a_(t))},t.wbg.__wbindgen_number_new=function(t){return l_(t)},t.wbg.__wbindgen_string_new=function(t,e){return l_(p_(t,e))},t.wbg.__wbg_call_1084a111329e68ce=function(){return I_((function(t,e){return l_(a_(t).call(a_(e)))}),arguments)},t.wbg.__wbg_call_89af060b4e1523f2=function(){return I_((function(t,e,s){return l_(a_(t).call(a_(e),a_(s)))}),arguments)},t.wbg.__wbg_call_7de908392845a9a5=function(){return I_((function(t,e,s,r,i){return l_(a_(t).call(a_(e),a_(s),a_(r),a_(i)))}),arguments)},t.wbg.__wbg_valueOf_563b3487b1b116aa=function(t){return a_(t).valueOf()},t.wbg.__wbg_buffer_b7b08af79b0b0974=function(t){return l_(a_(t).buffer)},t.wbg.__wbg_new_b85e72ed1bfd57f9=function(t,e){try{var s={a:t,b:e};return l_(new Promise(((t,e)=>{const r=s.a;s.a=0;try{return function(t,e,s,r){n_.wasm_bindgen__convert__closures__invoke2_mut__h367b7e3d952c2b06(t,e,l_(s),l_(r))}(r,s.b,t,e)}finally{s.a=r}})))}finally{s.a=s.b=0}},t.wbg.__wbg_resolve_570458cb99d56a43=function(t){return l_(Promise.resolve(a_(t)))},t.wbg.__wbg_then_95e6edc0f89b73b1=function(t,e){return l_(a_(t).then(a_(e)))},t.wbg.__wbg_then_876bb3c633745cc6=function(t,e,s){return l_(a_(t).then(a_(e),a_(s)))},t.wbg.__wbg_newwithbyteoffsetandlength_b5293b0eedbac651=function(t,e,s){return l_(new Int16Array(a_(t),e>>>0,s>>>0))},t.wbg.__wbg_new_ea1883e1e5e86686=function(t){return l_(new Uint8Array(a_(t)))},t.wbg.__wbg_newwithbyteoffsetandlength_874df3e29cb555f9=function(t,e,s){return l_(new Uint32Array(a_(t),e>>>0,s>>>0))},t.wbg.__wbg_length_8339fcf5d8ecd12e=function(t){return a_(t).length},t.wbg.__wbg_set_d1e79e2388520f18=function(t,e,s){a_(t).set(a_(e),s>>>0)},t.wbg.__wbindgen_throw=function(t,e){throw new Error(p_(t,e))},t.wbg.__wbindgen_memory=function(){return l_(n_.memory)},t.wbg.__wbindgen_array_new=function(){return l_([])},t.wbg.__wbindgen_array_push=function(t,e){a_(t).push(c_(e))},t.wbg.__wbindgen_uint8_array_new=function(t,e){var s=f_(t,e).slice();return n_.__wbindgen_free(t,1*e,1),l_(s)},t.wbg.__wbg_queueMicrotask_48421b3cc9052b68=function(t){return l_(a_(t).queueMicrotask)},t.wbg.__wbindgen_cb_drop=function(t){const e=c_(t).original;return 1==e.cnt--&&(e.a=0,!0)},t.wbg.__wbg_queueMicrotask_12a30234db4045d3=function(t){queueMicrotask(a_(t))},t.wbg.__wbg_parquetchunk_new=function(t){return l_(gp.__wrap(t))},t.wbg.__wbg_parquetfile_new=function(t){return l_(yp.__wrap(t))},t.wbg.__wbg_filemetadata_new=function(t){return l_(Y_.__wrap(t))},t.wbg.__wbg_fieldmetadata_new=function(t){return l_(W_.__wrap(t))},t.wbg.__wbg_rowgroup_new=function(t){return l_(Ip.__wrap(t))},t.wbg.__wbg_schemafield_unwrap=function(t){return Pp.__unwrap(c_(t))},t.wbg.__wbg_columndescriptor_new=function(t){return l_(V_.__wrap(t))},t.wbg.__wbg_pageencodingdescriptor_new=function(t){return l_(pp.__wrap(t))},t.wbg.__wbindgen_closure_wrapper1827=function(t,e,s){return l_(function(t,e,s,r){const i={a:t,b:e,cnt:1,dtor:163},n=(...t)=>{i.cnt++;const e=i.a;i.a=0;try{return r(e,i.b,...t)}finally{0==--i.cnt?(n_.__wbindgen_export_1.get(i.dtor)(e,i.b),g_.unregister(i)):i.a=e}};return n.original=i,g_.register(n,i,i),n}(t,e,0,m_))},t}function Ap(t,e){return n_=t.exports,Cp.__wbindgen_wasm_module=e,v_=null,M_=null,k_=null,T_=null,d_=null,n_.__wbindgen_start(),n_}async function Cp(t){if(void 0!==n_)return n_;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module_or_path:t}=t):console.warn("using deprecated parameters for the initialization function; pass a single object instead"));const e=Tp();("string"==typeof t||"function"==typeof Request&&t instanceof Request||"function"==typeof URL&&t instanceof URL)&&(t=fetch(t));const{instance:s,module:r}=await async function(t,e){if("function"==typeof Response&&t instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(t,e)}catch(e){if("application/wasm"==t.headers.get("Content-Type"))throw e;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",e)}const s=await t.arrayBuffer();return await WebAssembly.instantiate(s,e)}{const s=await WebAssembly.instantiate(t,e);return s instanceof WebAssembly.Instance?{instance:s,module:t}:s}}(await t,e);return Ap(s,r)}const kp=Object.freeze(Object.defineProperty({__proto__:null,ColumnDescriptor:V_,CompressMode:N_,FieldMetadata:W_,FileMetadata:Y_,FileWriter:$_,GeometryInfoDescriptor:Z_,GeometryType:B_,MultiScaleInfo:K_,PageBuilderBytes:tp,PageBuilderF32:sp,PageBuilderF64:ip,PageBuilderGeometry:op,PageBuilderI32:hp,PageBuilderI64:lp,PageBuilderString:dp,PageEncodingDescriptor:pp,ParquetChunk:gp,ParquetFile:yp,QuantizedGeometry:wp,RangeProviderJs:vp,RowGroup:Ip,SchemaField:Pp,default:Cp,enable_tracing:function(){n_.enable_tracing()},initSync:function(t){if(void 0!==n_)return n_;void 0!==t&&(Object.getPrototypeOf(t)===Object.prototype?({module:t}=t):console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const e=Tp();return t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t)),Ap(new WebAssembly.Instance(t,e),t)},readFile:function(t,e,s,r,i){const n=x_(t,n_.__wbindgen_malloc,n_.__wbindgen_realloc),o=y_;E_(r,Y_);var a=r.__destroy_into_raw();let h=0;return R_(i)||(E_(i,Z_),h=i.__destroy_into_raw()),c_(n_.readFile(n,o,l_(e),l_(s),a,h))},readFileFromBinary:function(t,e){let s=0;R_(t)||(E_(t,Z_),s=t.__destroy_into_raw());const r=D_(e,n_.__wbindgen_malloc),i=y_;return c_(n_.readFileFromBinary(s,r,i))},readMetadata:L_,readMetadataFromFile:function(t){const e=D_(t,n_.__wbindgen_malloc),s=y_;return c_(n_.readMetadataFromFile(e,s))}},Symbol.toStringTag,{value:"Module"}));let Fp=null;async function Ep(){return Fp||(Fp=async function(){const t=await Promise.resolve().then((()=>kp));return await t.default({module_or_path:(0,i_.s)("esri/libs/parquet/pkg/arcgis_parquet_bg.wasm")}),t}()),Fp}const zp=t=>async function(e,s,r){const i=t(),{data:n}=await(0,vd.A)(e,{responseType:"array-buffer",query:i,headers:{range:`bytes=${s}-${r}`}});return n},Op=t=>async function(e){const s=t(),{data:r}=await(0,vd.A)(e,{responseType:"native",method:"head",query:s}),i=r.headers.get("Content-Length");if(null==i)throw new Error("Unable to parse content length");return parseInt(i,10)};class Rp{static async create(t,e){const s=await Ep(),r=await s.readMetadata(t,zp(e),Op(e));return Rp.fromFileMetadata(r)}static fromFileMetadata(t){const e=[];for(let s=0;s<t.numFields();s++){const r=t.getFieldByIndex(s);e.push({name:r.name,type:r.type,alias:r.name,index:r.index}),r.free()}return new Rp(t,e)}constructor(t,e){this._inner=t,this.fields=e}destroy(){this._inner.free()}[Symbol.dispose](){this.destroy()}get size(){return this._inner.numRows()}getFieldIndex(t){return this._inner.getFieldIndex(t)}tryReadGeoMetadata(){const t=this._inner.keyValueMetadata("geo");return null==t?null:JSON.parse(t)}tryReadEsriMetadata(){const t=this._inner.keyValueMetadata("esri");return null==t?null:JSON.parse(t)}}function Dp(t,e,s){const r=Z_.new();if(r.geometryType=function(t){switch(t){case"esriGeometryPoint":return B_.Point;case"esriGeometryPolygon":return B_.Polygon;case"esriGeometryPolyline":return B_.Polyline;case"esriGeometryMultipoint":return B_.Multipoint;default:throw new Error(`InternalError: Found unexpected GeometryType: ${t}`)}}(t.geometryType),"location"===t.type)r.latIndex=e.getFieldIndex(t.latitudeFieldName),r.lngIndex=e.getFieldIndex(t.longitudeFieldName);else{if(null==t.primaryFieldName)throw new Error("InternalError: A primary field name or set of location fields must be defined");if(r.wkbIndex=e.getFieldIndex(t.primaryFieldName),t.multiscale){const s=K_.new();for(const r of t.multiscale.levels){const[t,i]=r.transform.translate,[n,o]=r.transform.scale,a=e.getFieldIndex(r.column);s.push(a,t,i,n,o)}r.setMultiscaleInfo(s)}}return r.inWkid=t.spatialReference.wkid,s&&(r.outWkid=s.wkid),r}class Lp{static async create(t,e){const s=await Ep(),r=zp(e.getCustomParameters),i=Op(e.getCustomParameters),n=await L_(t,r,i),o=Dp(e.geometryInfo,n,e.outSpatialReference),a=await s.readFile(t,r,i,n,o);return new Lp(a,Rp.fromFileMetadata(a.metadata()))}static async fromFile(t,e,s){const r=await Ep(),i=await r.readMetadataFromFile(t),n=e?Dp(e,i,s):void 0,o=await r.readFileFromBinary(n,t);return new Lp(o,Rp.fromFileMetadata(o.metadata()))}constructor(t,e){this.inner=t,this.metadata=e}destroy(){this.inner.free(),this.metadata.destroy()}[Symbol.dispose](){this.destroy()}}class Np extends od{constructor(t,e,s,r){super(),this._reader=t,this._queryJSON=e,this._page=s,this._end=r,this.chunkId=`${this._page}${this.end?"e":""}`,this.normalizedChunkId=this.chunkId}get reader(){return this._reader}get first(){return 0===this._page}get end(){return this._end}get queryInfo(){return{type:"snapshot",chunkId:this.chunkId,queryJSON:this._queryJSON,page:this._page,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Bp extends uu{constructor(t,e,s,r,i,n=new Uint32Array(r.size())){super(t),this._fields=e,this._geometryInfo=s,this._inner=r,this._chunkId=i,this._displayIds=n,this._index=-1,this.usedMemory=id.qK,this._size=this._inner.size(),"geometry"===this._geometryInfo.type&&(this._primaryGeometryIndex=this._fields.get(this._geometryInfo.primaryFieldName)?.index),null!=t.objectIdField&&(this._objectIdFieldIndex=this._fields.get(t.objectIdField)?.index),this._chunkId>65535&&console.error("Exceeded max allowed parquet reader size")}destroy(){super.destroy(),this._inner.free()}get fields(){return this._fields}get geometryType(){return this._geometryInfo.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return null}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let t="";for(const e of this.fields.fields)t+=this._readAttribute(e.name,!1)+".";return t}getObjectId(){return null!=this._objectIdFieldIndex?this._inner.readAttribute(this._index,this._objectIdFieldIndex):this._index<<16|this._chunkId}getDisplayId(){return this._displayIds[this._index]}setDisplayId(t){this._displayIds[this._index]=t}setIndex(t){this._index=t}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(t){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(t){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(t){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(t){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){throw new Error("Method not implemented.")}copy(){const t=new Bp(this.metadata,this._fields,this._geometryInfo,this._inner,this._chunkId,this._displayIds);return this.copyInto(t),t}copyInto(t){super.copyInto(t),t._index=this._index}readGeometryForDisplayTransformed(t){const[e,s]=t.translate,[r,i]=t.scale,n=this._inner.readGeometryTransformed(this._index,e,s,r,-i);return n?new jt.A(n.readLengthsUnsafe(),n.readCoordsUnsafe()):null}_readGeometry(t){const e=this._inner.readCoords(this._index),s=this._inner.readLengths(this._index);return e&&s?new jt.A(s,e):null}_readX(){return this._readGeometry()?.coords[0]}_readY(){return this._readGeometry()?.coords[1]}_readServerCentroid(){return null}_readAttribute(t,e){const s=this.fields.get(t);if(!s)return;const r=this._inner.readAttribute(this._index,s.index);if(null==r)return r;const i=this.fields.isDateField(s.name);return e?null==r?r:i?new Date(r):r:r}_readAttributes(){const t={};for(const e of this._fields.fields)this._inner.hasField(e.index)&&e.index!==this._primaryGeometryIndex&&(t[e.name]=this._readAttribute(e.name,!1));return null==this._objectIdFieldIndex&&(t.__OBJECTID=this.getObjectId()),t}}class Gp extends Cd{constructor(t,e,s,r){super(r),this._service=t,this._metadata=e,this._schema=s,this._chunkId=0,this._files=[],this._availableFields=new Set(s.mutable.availableFields);const{geometryInfo:i}=this._service;if("location"===i.type)this._availableFields.add(i.latitudeFieldName),this._availableFields.add(i.longitudeFieldName);else if(null!=i.multiscale&&i.multiscale.levels.length>=1){const t=i.multiscale.levels[0];this._availableFields.add(t.column)}else this._availableFields.add(i.primaryFieldName)}destroy(){for(const t of this._files)t.destroy()}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}async updateFields(t){await this._promise;const e=new Set(t),s=(0,k.iv)(e,this._availableFields);this._availableFields=(0,k.KC)(s,this._availableFields),s.size&&await Promise.all(this._files.map((t=>{const e=Array.from(s).map((e=>t.metadata.getFieldIndex(e)));return t.inner.updateChunks(new Uint16Array(e))})))}async load(t){return null==this._promise&&(this._promise=this._download().then((()=>{this._loadHigherResGeometry()}))),this._promise}unload(t){}async addParquetFile(t){this._insert(t)}async _loadHigherResGeometry(){const{geometryInfo:t}=this._service;if("geometry"===t.type){if(!(null!=t.multiscale&&t.multiscale.levels.length>=1))return;await this.updateFields([t.primaryFieldName])}const e=Array.from(this._store.chunks());this._store.clear();for(const t of e)this._store.insert(t);this._store.refresh()}async _insert(t){const e=await Lp.create(t,{geometryInfo:this._service.geometryInfo,outSpatialReference:this._service.outSpatialReference,getCustomParameters:()=>this._schema.mutable.dataFilter.customParameters}),{geometryInfo:s}=this._service;(0,a.Te)(this._options);const{fields:r,timeZoneByFieldName:i}=this._service.metadata.fieldsIndex,n=r.map((t=>({...t,index:e.metadata.getFieldIndex(t.name)}))),o=hl.A.fromJSON({fields:n,timeZoneByFieldName:i}),h=new Uint16Array(Array.from(this._availableFields.values()).map((t=>o.get(t)?.index)));await e.inner.readChunksWithCallback(h,(t=>{const e=this._chunkId++,r=new Bp(this._metadata,o,s,t,e),i=new Np(r,null,e,!1);this._store.insert(i)})),this._files.push(e)}async _download(){try{await Promise.all(this._service.source.urls.map((t=>this._insert(t))));const t=new Np(du.empty(this._metadata),null,-1,!0);this._store.insert(t)}catch(t){throw console.error(t),t}}}class Up extends Zd{constructor(t,e,s,r,i,n){super(t,e,s,i,n),this._random=new h.A(1e3),this._featureCount=r}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return null==this._promise&&(this._promise=this._downloadPages(this._featureCount)),this._promise}unload(t){}async _downloadPages(t){const e=Math.ceil(t/this._queryInfo.pageSize),s=Array.from({length:e},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),i=await Promise.all(s.map((t=>this._downloadPage(t)))),n=new Np(du.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=i.filter((t=>t));if(o.length)throw new r.A("featurelayer-query","Encountered errors when downloading data",{errors:o})}async _downloadPage(t){try{const e=this._queryInfo.createPagedQuery(t),s=await this._fetch(e,this._options),r=new Np(s,e.inner.toJSON(),t,!1);return(0,a.Te)(this._options),this._store.insert(r),null}catch(t){return t}}}class Vp{constructor(t){this.size=0,this._start=0,this.maxSize=t,this._buffer=new Array(t)}get entries(){return this._buffer}enqueue(t){if(this.size===this.maxSize){const e=this._buffer[this._start];return this._buffer[this._start]=t,this._start=(this._start+1)%this.maxSize,e}return this._buffer[(this._start+this.size++)%this.maxSize]=t,null}dequeue(){if(0===this.size)return null;const t=this._buffer[this._start];return this._buffer[this._start]=null,this.size--,this._start=(this._start+1)%this.maxSize,t}peek(){return 0===this.size?null:this._buffer[this._start]}peekLast(){return 0===this.size?null:this._buffer[(this._start+(this.size-1))%this.maxSize]}find(t){if(0===this.size)return null;for(const e of this._buffer)if(null!=e&&t(e))return e;return null}clear(t){let e=this.dequeue();for(;null!=e;)t&&t(e),e=this.dequeue()}}const qp="__esri_timestamp__";class Wp{constructor(t,e,s,r,i=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=r,this.store=t,this.objectIdField=e,this.purgeInterval=i,this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}removeById(t){this._removed.push(t)}removeByTrackId(t){const e=this._trackIdToObservations.get(t);if(e)for(const t of e.entries)this._removed.push(t)}add(t){if(this._useGeneratedIds){const e=this._nextId();t.attributes[this.objectIdField]=e,t.objectId=e}else t.objectId=t.attributes[this.objectIdField];const e=t.objectId;if(this._addOrUpdated.set(e,t),this._maxAge=Math.max(this._maxAge,t.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return null==this._trackIdLessObservations&&(this._trackIdLessObservations=new Vp(1e5)),void this._trackIdLessObservations.enqueue(e);const s=t.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(s)){const t=null!=this._purgeOptions?.maxObservations?this._purgeOptions.maxObservations:1e3,e=(0,ks.qE)(t,0,1e3);this._trackIdToObservations.set(s,new Vp(e))}const r=this._trackIdToObservations.get(s),i=r?.enqueue(e);null!=i&&(this._addOrUpdated.has(i)?this._addOrUpdated.delete(i):this._removed.push(i))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const r=[];if(null!=e)for(const t of e){const e=this.store.removeById(t);null!=e&&r.push(e)}const i=[];if(null!=t){const r=new Set(e??[]);for(const e of t)r.has(e.objectId)||(e.attributes[qp]=s,this.store.add(e),i.push(e))}return!(!i.length&&!r?.length||(this.store.update(i,r),0))}_getToAdd(){if(!this._addOrUpdated.size)return null;const t=new Array(this._addOrUpdated.size);let e=0;return this._addOrUpdated.forEach((s=>t[e++]=s)),this._addOrUpdated.clear(),t}_getToRemove(){const t=this._removed;return this._removed.length?(this._removed=[],t):null}_nextId(){const t=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,t}_purge(t){const e=this._purgeOptions;null!=e&&(this._purgeSomeByDisplayCount(e),this._purgeByAge(e),this._purgeByAgeReceived(t,e),this._purgeTracks())}_purgeSomeByDisplayCount(t){if(!t.displayCount)return;let e=this.store.size;if(e>t.displayCount){if(this._timeInfo.trackIdField)for(const s of this._trackIdToObservations.values())if(e>t.displayCount&&s.size){const t=s.dequeue();this._removed.push(t),e--}if(null!=this._trackIdLessObservations){let s=e-t.displayCount;for(;s-- >0;){const t=this._trackIdLessObservations.dequeue();null!=t&&this._removed.push(t)}}}}_purgeByAge(t){const e=this._timeInfo?.startTimeField;if(!t.age||!e)return;const s=60*t.age*1e3,r=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<r&&this._removed.push(t.objectId)}))}_purgeByAgeReceived(t,e){if(!e.ageReceived)return;const s=t-60*e.ageReceived*1e3;this.store.forEach((t=>{t.attributes[qp]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}var jp=s(30624);let Yp=class extends T.A{constructor(t){super(t)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,P._)([(0,F.MZ)()],Yp.prototype,"connection",void 0),(0,P._)([(0,F.MZ)()],Yp.prototype,"connectionStatus",null),(0,P._)([(0,F.MZ)()],Yp.prototype,"errorString",null),Yp=(0,P._)([(0,z.$)("esri.views.2d.layers.features.sources.StreamConnectionState")],Yp);class Xp{constructor(t,e){this._metadata=t,this._onUpdate=e,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return du.fromFeatures([...this._objectIdToFeature.values()],this._metadata)}add(t){this._objectIdToFeature.set(t.objectId,t)}forEach(t){this._objectIdToFeature.forEach(t)}removeById(t){const e=this._objectIdToFeature.get(t);return e?(this._objectIdToFeature.delete(t),e):null}clear(){this._objectIdToFeature=new Map}update(t,e){this._onUpdate(t?.length??0)}}class $p extends od{constructor(t){super(),this._reader=t,this.chunkId="stream-chunk",this.normalizedChunkId="stream-chunk"}get reader(){return this._reader}get first(){return!0}get end(){return!0}get queryInfo(){return{type:"stream",chunkId:this.chunkId,size:this.size(),end:this.end}}get isTiled(){return!1}getTileReader(t){const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Hp extends Cd{constructor(t,e,s,r,i){super(s),this._service=t,this._dataFilter=e,this._streamOptions=r,this._metadata=i,this._connectionState=new Yp,this._forceRefresh=!1,this.events=new ll.A;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=e;this._stagingStore=new Xp(this._metadata,(t=>this.events.emit("features-updated",t))),this._manager=new Wp(this._stagingStore,n,o,a),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}async refresh(){const t=null!=this._chunk;this._manager.checkForUpdates()||!t||this._forceRefresh?(this._chunk&&this._store.remove(this._chunk),this._forceRefresh=!1,this._chunk=new $p(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick")):this.events.emit("tick")}async updateFields(t){throw new Error("Updating available fields not supported for StreamLayer")}async load(t){}unload(t){}disconnect(){this._connection=(0,C.pR)(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:t,spatialReference:e}=this._metadata,{maxReconnectionAttempts:s,maxReconnectionInterval:r,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,jp.createConnection)(this._service.source,e,this._streamOptions.outSR,t,o,n,s,r,a),this._handlesGroup=(0,i.vE)([this._connection.on("data-received",(t=>this._onFeature(t))),this._connection.on("message-received",(t=>this._onWebSocketMessage(t)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(t){this._connection?.updateCustomParameters(t)}sendMessageToSocket(t){this._connection?.sendMessageToSocket(t)}sendMessageToClient(t){this._connection?.sendMessageToClient(t)}_onWebSocketMessage(t){if("type"in t)switch(t.type){case"delete":if(t.objectIds)for(const e of t.objectIds)this._manager.removeById(e);if(t.trackIds)for(const e of t.trackIds)this._manager.removeByTrackId(e);break;case"clear":this.clear()}this.events.emit("message-received",t)}_onFeature(t){try{this._manager.add(t),this.events.emit("data-received",t)}catch(t){}}}class Zp{constructor(t){this._metadata=t,this._chunks=new Map,this._chunksToRemove=[],this._overrides=new ld,this.events=new ll.A,this.featureAdapter=new Wl}destroy(){this.clear()}clear(){for(const t of this._chunks.values())this._chunksToRemove.push(t);this._chunks.clear()}*chunks(){this._overrides&&(yield this._overrides.asChunk(this._metadata)),yield*this._chunks.values()}insert(t){(0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.insert`),this._overrides.onChunkInsert(t),this._chunks.set(t.chunkId,t),this.events.emit("changed")}remove(t){(0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.remove`),this._chunks.delete(t.chunkId),this._chunksToRemove.push(t)}cleanupRemovedChunks(){const t=this._chunksToRemove;return this._chunksToRemove=[],t}applyOverride(t){this._overrides.apply(t,this),this.events.emit("changed");for(const t of this._chunks.values())t.invalidate()}takeOverrideUpdate(){return this._overrides.takeOverrideUpdate()}refresh(){this.events.emit("refresh")}forEach(t){const e=new Set;for(const s of this.chunks()){const r=s.reader.getCursor();for(;r.next();){const s=r.getObjectId();e.has(s)||(t(r.copy()),e.add(s))}}}forEachUnsafe(t){const e=new Set;for(const s of this.chunks()){const r=s.reader.getCursor();for(;r.next();){const s=r.getObjectId();e.has(s)||(t(r),e.add(s))}}}forEachInBounds(t,e){const s=new Set;for(const r of this.chunks()){const i=r.queryFeaturesInBounds(t);for(;i.next();){const t=i.getObjectId();s.has(t)||(e(i.copy()),s.add(t))}}}forEachBounds(t,e){const s=(0,ul.vt)();for(const r of t)r.getBounds(s)&&e(s)}}var Qp=s(32587),Kp=s(79897);let Jp=class extends T.A{constructor(t){super(t),this.debugName="",this._updatingHandles=new Kp.U,this._idToUpdatingState=new Qp.A}get updating(){const t=this._updatingHandles.updating||Array.from(this._idToUpdatingState.values()).some((t=>t));if((0,n.A)("esri-2d-log-updating")){const e=Array.from(this._idToUpdatingState.entries()).map((([t,e])=>`-> ${t}: ${e}`)).join("\n");console.log(`${this.debugName}: Updating: ${t}\n-> Handles: ${this._updatingHandles.updating}\n${e}`)}return t}addUpdateTracking(t,e){const s=(0,c.wB)((()=>e.updating),(e=>this._idToUpdatingState.set(t,e)),{sync:!0});this.addHandles(s)}addPromise(t){return this._updatingHandles.addPromise(t)}};(0,P._)([(0,F.MZ)({constructOnly:!0})],Jp.prototype,"debugName",void 0),(0,P._)([(0,F.MZ)({readOnly:!0})],Jp.prototype,"updating",null),Jp=(0,P._)([(0,z.$)("esri.views.2d.layers.support.UpdateTracking2D")],Jp);class tf{constructor(t,e,s,r){this.service=t,this._aggregateAdapter=e,this._subscriptions=s,this._connection=r,this._updateTracking=new Jp({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._metadata=Yl.createFeature(t.metadata),this._store=new Zp(this._metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((t=>t.close()))}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return Id.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:t}=this._schema.mutable,e=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new _l.do({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:t.definitionExpression,availableFields:e})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(t){this._connection.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._connection.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._connection.onEvent({type:"error",tile:t.tile.id,error:e}))),this._updateTracking.addPromise(e))}onResume(t){this._updateTracking.addPromise((0,a.QZ)(this._strategy?.load(t)))}onUnsubscribe(t){this._connection.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}applyOverride(t){this._didInvalidateData=!0,this._store.applyOverride(t)}takeOverrideUpdate(){return this._store.takeOverrideUpdate()}async update(t,e){const s=t.source,r=(0,V.Ui)(this._schema?.mutable,s.mutable);if(!r)return!1;if((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:r}),this._schema=s,this._queryEngine?.destroy(),this._queryEngine=null,"feature-service"===this.service.type&&null!=this.service.queryMetadata.lastEditDate&&(this._lastEditDate=this.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),(0,V.w2)(r,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if(("feature"===s.type||"parquet"===s.type)&&(0,V.w2)(r,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(e);else{this._connection.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._connection.onEvent({type:"updateFieldsEnd"})}catch(t){this._connection.onEvent({type:"updateFieldsError",error:t})}}return!1}return!(!(0,V.Mj)(r,"dataFilter")&&!(0,V.Mj)(r,"sourceRefreshVersion")||(await this._updateStrategy(e),0))}async addParquetFile(t){this._strategy.addParquetFile(t)}unsafeSetQueryHistoricMoment(t){"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=t,this._strategy.unsafeSetQueryHistoricMoment(new Date(t)))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new Ad(this._connection))}async normalizeOverrides(t){const e={historicMoment:t.historicMoment,commands:{updateWeak:t.commands.updateWeak.map(ol.Om.fromJSON),removeWeak:t.commands.removeWeak,update:t.commands.update.map(ol.Om.fromJSON),remove:t.commands.remove,release:t.commands.release}},s=t.commands.updateByIdWeak,r=await this._queryOptimizedFeatures(s);return e.commands.updateWeak.push(...r),e}async _queryOptimizedFeatures(t){if(0===t.length)return[];const e=[],s=(await this._strategy.queryByObjectId(t)).getCursor();for(;s.next();)e.push(s.readOptimizedFeatureWorldSpace());return e}getObjectIdsFromGlobalIds(t){const e=new Set(t),s=this.metadata.globalIdField;if(null==s)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const r=[];return this._store.forEachUnsafe((t=>{const i=t.readAttribute(s);if(e.has(i)){const e=t.getObjectId();null!=e&&r.push(e)}})),r}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,e={...t.query,f:"json"},s=(await(0,vd.A)(t.path,{query:e,responseType:"json"})).data.editingInfo.lastEditDate;return s!==this._lastEditDate&&(this._lastEditDate=s,!0)}async _createStrategy(){const t="isSourceHosted"in this.service&&this.service.isSourceHosted,e=Array.isArray(this.service.source),s=this.service.source&&"collection"in this.service.source,r=t||e||s;if("stream"===this._schema.type){const t=new Hp(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}if("parquet"===this._schema.type){const t=this.service;return new Gp(t,this._metadata,this._schema,this._store)}const i=this.service,n=Td.fromSchema(i,this._schema,this._metadata),o=await this._supportSnapshotMode(i,n);return o?new Up(i,n,this._store,o.featureCount,this.metadata,this._connection):r?new r_(i,n,this._store,this.metadata,this._connection):new t_(i,n,this._store,this.metadata,this._connection)}async _updateStrategy(t){const e=await this._createStrategy();this._connection.onEvent({type:"updateStrategyStart",about:e.about});const s=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=e,(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategy`,{strategy:e});const r=Array.from(this._subscriptions.values());if(!r.length)return void this._connection.onEvent({type:"updateStrategyEnd"});const i=Promise.all(r.map((t=>this._strategy.load(t).then((()=>this._connection.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._connection.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(i);try{s&&await i}catch(t){(0,a.jH)(t)}this._connection.onEvent({type:"updateStrategyEnd"}),(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.updateStrategyEnd`,{strategy:e})}async _supportSnapshotMode(t,e){const{queryMetadata:s}=t,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const i=t.source,n=e.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,Sd.gW)(i,n.inner,{query:n.customParameters})).data.count,{min:a,max:h}=r.snapshotCountThresholds;return o<=a||r.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}class ef{constructor(t,e){this.tile=t,this.version=e,this._abortController=new AbortController}get key(){return this.tile.key}get signal(){return this._abortController.signal}abort(){this._abortController.abort()}}var sf=s(98291),rf=s(27348);class nf{constructor(t,e){this.key=new p.A(0,0,0,0),this.bounds=(0,N.vt)(),this.objectIds=new Set,this.key.set(e);const s=t.getLODInfoAt(this.key);this.tileInfoView=t,this.tileInfoView.getTileBounds(this.bounds,this.key,!0),this.resolution=s.resolution,this.level=s.level,this.scale=s.scale,this.minScale=t.zoomToScale(s.level-1),this.maxScale=t.zoomToScale(s.level+1)}get lod(){return this.tileInfoView.getLODInfoAt(this.key)}get id(){return this.key.id}get extent(){return(0,N.w1)(this.bounds,this.tileInfoView.tileInfo.spatialReference)}get transform(){return{originPosition:"upperLeft",scale:[this.resolution,this.resolution],translate:[this.bounds[0],this.bounds[3]]}}createArcadeEvaluationOptions(t){return Tu(this.scale,t)}createChildTiles(){const t=this.key.getChildKeys(),e=sf.A.acquire();for(let s=0;s<t.length;s++)e[s]=new nf(this.tileInfoView,t[s]);return e}getQuantizationParameters(){return rf.A.fromJSON({mode:"view",originPosition:"upperLeft",tolerance:this.resolution,extent:{xmin:this.bounds[0],ymin:this.bounds[1],xmax:this.bounds[2],ymax:this.bounds[3],spatialReference:this.tileInfoView.tileInfo.spatialReference}})}}class of{constructor(t){this.inner=t,this.resolver=(0,a.Tw)()}}class af{constructor(){this._aggregateAdapter={getFeatureObjectIds:t=>this._processor.getFeatureObjectIdsForAggregate(t)},this._subscriptions=new Map,this._updateRequested=!1,this._didSourceRefresh=!1,this._updateSubscriptionRequests=[],this._updateHighlightRequests=[]}destroy(){this._subscriptions.clear(),this._processor?.destroy(),this._source?.destroy(),this._handles?.remove(),this._updateOverridesRequest=null,this._tileInfoView=null}onAttach(t){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const e=this._connection,s=d.A.fromJSON(t.tileInfoJSON);this._tileInfoView=new M(s),this._source=new tf(t.service,this._aggregateAdapter,this._subscriptions,e),this._processor=new wd(e,this._source),this._handles=(0,i.vE)([this._source.store.events.on("changed",(()=>this._requestUpdate())),this._source.store.events.on("refresh",(()=>this._requestRefresh())),(0,c.wB)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),(0,a.QZ)(this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}))}))])}onDetach(){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.onDetach"),this.destroy()}set remoteClient(t){this._connection=new G(t)}get features(){const t=this._source?.queryEngine;if(!t)throw new r.A("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new r.A("no-queryEngine","No aggregate query engine defined");return t}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(t){return this._processor.getDisplayFeatures(t)}getDisplayIds(t){return this._processor.getDisplayIds(t)}getObjectIdsFromGlobalIds(t){return this._source.getObjectIdsFromGlobalIds(t)}async updateSchema(t,e){return(0,n.A)("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new of({schema:t,version:e}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(t){const e=new of(t);return this._updateSubscriptionRequests.push(e),this._requestUpdate(),e.resolver.promise}updateHighlight(t){const e=new of(t);return this._updateHighlightRequests.push(e),this._requestUpdate(),e.resolver.promise}async addParquetFile(t){return this._source.addParquetFile(t)}async onOverride(t){if(null!=this._updateOverridesRequest)throw new r.A("InternalError - Already processing an edit");this._updateOverridesRequest=new of(t);const e=this._updateOverridesRequest.resolver.promise;return this._requestUpdate(),e}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(t,e){return this.features.executeQuery(t,e)}async queryHeatmapStatistics(t){const e=Math.round((0,l.Lz)(t.radius));let s=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const i="string"==typeof t.fieldOffset,n=t.fieldOffset??0,o=Array.from(this._subscriptions.values()),a=this._source.chunks(),h=e**2,c=3/(Math.PI*h),u=2*e,d=Math.ceil(B.CQ/u);for(const e of o){const o=e.tile,l=new Float64Array(d*d);for(const e of a){const s=e.getTileReader(o);if(!s)continue;const r=s.getCursor();for(;r.next();){let e=1;if(null!=t.field){const s=r.readAttribute(t.field);e=i?-1*+s:+s+n}const s=r.readXForDisplay()/u,o=r.readYForDisplay()/u,a=Math.floor(s),_=Math.floor(o);if(a<0||_<0||a>=d||_>=d)continue;const p=((.5+a-s)*u)**2+((.5+_-o)*u)**2;if(p>h)continue;const f=e*(c*(1-p/h)**2);l[_+a*d]+=f}}for(let t=0;t<l.length;t++)s=Math.min(s,l[t]),r=Math.max(r,l[t])}return{max:r,min:s}}async getSampleFeatures(t){const e=this._source.chunks();if(e.reduce(((t,e)=>t+e.size()),0)<=t.minFeatureCount){if(!this._source.updateTracking.updating){const t=[];return this._source.store.forEachUnsafe((e=>t.push(e.readLegacyFeatureWorldSpace()))),t}return null}const s=new Set,r=[],i=e.map((t=>t.reader.getCursor())),n=new h.A,o=3*t.sampleSize;for(let a=0;a<o&&r.length<t.sampleSize;a++){const t=i[n.getIntRange(0,e.length-1)];if(0===t.getSize())continue;const o=n.getIntRange(0,t.getSize()-1);t.setIndex(o);const a=t.getObjectId();s.has(a)||(s.add(a),r.push(t.readLegacyFeatureWorldSpace()))}return r.length>=t.sampleSize?r:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.d)((()=>this._scheduleNextUpdate())))}_requestRefresh(){this._didSourceRefresh=!0,this._requestUpdate()}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=(0,u.oV)(this._doUpdate()).finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(t){const e=t.tileId;if(this._subscriptions.has(e))return;(0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.subscribe`);const s=new nf(this._tileInfoView,e),r=new ef(s,t.version);this._subscriptions.set(e,r),this._source.onSubscribe(r),this._processor.onSubscribe(r)}_unsubscribe(t){const e=this._subscriptions.get(t);e&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.unsubscribe`),e.abort(),this._source.onUnsubscribe(e),this._processor.onUnsubscribe(e),this._subscriptions.delete(e.key.id))}async _doUpdate(){if((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const t=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const e of t)this._doUpdateSubscriptions(e.inner),e.resolver.resolve()}const t=this._updateSchemaRequest;if(this._updateSchemaRequest=null,null!=t){const{schema:e,version:s}=t.inner;await this._doUpdateSchema(e,s)}this._didSourceRefresh&&(this._processor.requestInvalidateMesh(),this._didSourceRefresh=!1);const e=this._processor.invalidateRequested;e&&await this._connection.container.updateRenderState(this._processor.version);const s=this._updateOverridesRequest;if(this._updateOverridesRequest=null,null!=s){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyOverride",s.inner);const t=await this._source.normalizeOverrides(s.inner);null!=t.historicMoment&&this._source.unsafeSetQueryHistoricMoment(t.historicMoment),this._source.applyOverride(t),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.endOverride",s.inner)}if(this._updateHighlightRequests.length){const t=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const e of t)this._processor.updateHighlight(e.inner),e.resolver.resolve()}const r=this._source.cleanupRemovedChunks();this._processor.removeChunks(r);try{const t=this._source.takeOverrideUpdate();null!=t&&this._subscriptions.size&&((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesStart"),await this._processor.applyOverrideUpdate(t),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyOverrideChangesEnd")),this._subscriptions.size&&((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(t){(0,a.jH)(t)}null!=s&&s.resolver.resolve(),null!=t&&t.resolver.resolve(),e&&await this._connection.container.swapRenderState(),this._updateRequested?((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:!0})):((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=false, After flush]"),await this._connection.layerView.setUpdating({source:this._source.updateTracking.updating,pipeline:this._updateRequested}))}async _doUpdateSchema(t,e){(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateStart`,{schema:t});const s={tileInfo:this._tileInfoView?.tileInfo},r=await this._source.update(t,e),i=Array.from(this._subscriptions.values());await this._processor.update(t,e,s,r,i),(0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] Pipeline.updateEnd`)}_doUpdateSubscriptions(t){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",t);for(const e of t.subscribe)this._subscribe(e);for(const e of t.unsubscribe)this._unsubscribe(e)}}},44159:(t,e,s)=>{s.d(e,{A:()=>i});var r=s(93687);class i{static getId(t,e,s,r){return"object"==typeof t?`${t.level}/${t.row}/${t.col}/${t.world}`:`${t}/${e}/${s}/${r}`}constructor(t,e,s,r){this.set(t,e,s,r)}get key(){return this}get id(){return this.toString()}get normalizedId(){return`${this.level}/${this.row}/${this.col}`}set id(t){this.set(t)}get hash(){const t=4095&this.row,e=4095&this.col,s=63&this.level;return(3&this.world)<<30|e<<22|t<<8|s}acquire(t,e,s,r){this.set(t,e,s,r)}contains(t){const e=t.level-this.level;return e>=0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}containsChild(t){const e=t.level-this.level;return e>0&&this.row===t.row>>e&&this.col===t.col>>e&&this.world===t.world}equals(t){return this.level===t.level&&this.row===t.row&&this.col===t.col&&this.world===t.world}clone(){return new i(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(t,e,s,r){if(null==t)this.level=0,this.row=0,this.col=0,this.world=0;else if("object"==typeof t)this.level=t.level||0,this.row=t.row||0,this.col=t.col||0,this.world=t.world||0;else if("string"==typeof t){const[e,s,r,i]=t.split("/");this.level=parseFloat(e),this.row=parseFloat(s),this.col=parseFloat(r),this.world=parseFloat(i)}else this.level=+t,this.row=+e,this.col=+s,this.world=+r||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new i(this.level-1,this.row>>1,this.col>>1,this.world)}getNormalizedNeighbor(t,e,s){const r=this.clone();return r.col+=t,r.row+=e,s.normalizeKey(r),r}getChildKeys(){const t=this.level+1,e=this.row<<1,s=this.col<<1,r=this.world;return[new i(t,e,s,r),new i(t,e,s+1,r),new i(t,e+1,s,r),new i(t,e+1,s+1,r)]}compareRowMajor(t){return this.row<t.row?-1:this.row>t.row?1:this.col<t.col?-1:this.col>t.col?1:0}}i.pool=new r.A(i,null,null,25,50)},46263:(t,e,s)=>{var r;s.d(e,{c:()=>r}),function(t){t[t.Pass=0]="Pass",t[t.Draw=1]="Draw"}(r||(r={}))},620:(t,e,s)=>{s.d(e,{O_:()=>n,vA:()=>i}),s(48163),s(87317),(0,s(91829).vt)();class r{constructor(t){this.message=t}toString(){return`AssertException: ${this.message}`}}function i(t,e="Assertion"){if(!t){const t=new Error(e).stack;throw new r(`${e} at ${t}`)}}function n(t,e,s,r){let i,n=(s[0]-t[0])/e[0],o=(r[0]-t[0])/e[0];n>o&&(i=n,n=o,o=i);let a=(s[1]-t[1])/e[1],h=(r[1]-t[1])/e[1];if(a>h&&(i=a,a=h,h=i),n>h||a>o)return!1;a>n&&(n=a),h<o&&(o=h);let c=(s[2]-t[2])/e[2],l=(r[2]-t[2])/e[2];return c>l&&(i=c,c=l,l=i),!(n>l||c>o||(l<o&&(o=l),o<0))}},89738:(t,e,s)=>{s.d(e,{e:()=>l}),s(44208);var r=s(97768),i=s(74887),n=s(9775),o=s(32587),a=s(11932),h=s(44794);class c{constructor(t,e){this.item=t,this.controller=e,this.promise=null}}class l{constructor(t){this._schedule=null,this._task=null,this._deferreds=new o.A,this._controllers=new o.A,this._processingItems=new o.A,this._pausedSignal=(0,h.v)(!1),this.concurrency=1,t.concurrency&&(this.concurrency=t.concurrency),this._queue=new n.A(t.peeker),this.process=t.process;const e=t.scheduler;t.priority&&e&&(this._task=e.registerTask(t.priority,this))}destroy(){this.clear(),this._schedule=(0,r.xt)(this._schedule),this._task=(0,r.xt)(this._task)}get updating(){return!!this._task?.updating||this.running}get length(){return this._processingItems.size+this._queue.length}abort(t){const e=this._controllers.get(t);e&&e.abort()}clear(){this._queue.clear();const t=[];this._controllers.forEach((e=>t.push(e))),this._controllers.clear(),t.forEach((t=>t.abort())),this._processingItems.clear(),this._cancelNext()}forEach(t){this._deferreds.forEach(((e,s)=>t(s)))}get(t){const e=this._deferreds.get(t);return e?e.promise:void 0}isOngoing(t){return this._processingItems.has(t)}has(t){return this._deferreds.has(t)}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(t,e){const s=this.get(t);if(s)return s;const r=new AbortController;let n=null;e&&(n=(0,i.u7)(e,(()=>r.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(t),this._queue.remove(t),this._scheduleNext()},a=(0,i.NY)(r.signal,(()=>{const e=this._processingItems.get(t);e&&e.controller.abort(),o(),h.reject((0,i.NK)())})),h=(0,i.Tw)();return this._deferreds.set(t,h),this._controllers.set(t,r),h.promise.then(o,o),this._queue.push(t),this._scheduleNext(),h.promise}last(){return this._queue.last()}lastPromise(){const t=this.last();return t?this.get(t):null}peek(){return this._queue.peek()}popLast(){const t=this._queue.popLast();return t&&(this._deferreds.get(t)?.reject((0,i.NK)()),this._removeItem(t)),t}reset(){const t=Array.from(this._processingItems.values());this._processingItems.clear();for(const e of t)this._queue.push(e.item),e.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const t=[];for(;this._queue.length;)t.push(this._queue.pop());return this.clear(),t}get running(){return!this._pausedSignal.value&&this._queue.length>0&&this._processingItems.size<this.concurrency}runTask(t){for(;!t.done&&this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop()),t.madeProgress()}_removeItem(t){this._deferreds.delete(t),this._controllers.delete(t),this._processingItems.delete(t)}_scheduleNext(){this._task||this._pausedSignal.value||this._schedule||(this._schedule=(0,a._)((()=>{this._schedule=null,this._next()})))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).resolve(e))}_processError(t,e){this._canProcessFulfillment(t)&&(this._scheduleNext(),this._deferreds.get(t.item).reject(e))}_canProcessFulfillment(t){return!!this._deferreds.get(t.item)&&this._processingItems.get(t.item)===t}_process(t){if(null==t)return;let e;const s=new AbortController,r=new c(t,s);this._processingItems.set(t,r);try{e=this.process(t,s.signal)}catch(t){this._processError(r,t)}(0,i.$X)(e)?(r.promise=e,e.then((t=>this._processResult(r,t)),(t=>this._processError(r,t)))):this._processResult(r,e)}get test(){}}}}]);