@arcgis/core 4.30.0-next.20240521 → 4.30.0-next.20240522

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/WebMap.js +1 -1
  2. package/assets/components/assets/icon/developerCredentials16.json +1 -0
  3. package/assets/components/assets/icon/developerCredentials24.json +1 -0
  4. package/assets/components/assets/icon/developerCredentials32.json +1 -0
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/01927419855947110cc1.js.LICENSE.txt +1 -1
  7. package/assets/esri/core/workers/chunks/158c05b16372d8ed33ea.js.LICENSE.txt +1 -1
  8. package/assets/esri/core/workers/chunks/190913c221964292333b.js.LICENSE.txt +1 -1
  9. package/assets/esri/core/workers/chunks/4268373bf374b2a6252a.js.LICENSE.txt +1 -1
  10. package/assets/esri/core/workers/chunks/59b193d42e8abf9d4088.js.LICENSE.txt +1 -1
  11. package/assets/esri/core/workers/chunks/{eac4ec8c410eaf9e621c.js → 606f8b907166190a8b65.js} +2 -2
  12. package/assets/esri/core/workers/chunks/{eac4ec8c410eaf9e621c.js.LICENSE.txt → 606f8b907166190a8b65.js.LICENSE.txt} +1 -1
  13. package/assets/esri/core/workers/chunks/{3716015ccf0888c0a21d.js → 724f221680849db03104.js} +1 -1
  14. package/assets/esri/core/workers/chunks/88c7d84a1fde246ca71f.js +1 -0
  15. package/assets/esri/core/workers/chunks/9b04a666726b5d2ff3c5.js.LICENSE.txt +1 -1
  16. package/assets/esri/core/workers/chunks/9c75837b7e75f0f38dc0.js.LICENSE.txt +1 -1
  17. package/assets/esri/core/workers/chunks/{bd0545bb100b3393fd85.js → bbec62f8792520993909.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{4f3a87586e334c52d0bf.js → caffbaa8b0a67d117f34.js} +1 -1
  19. package/assets/esri/core/workers/chunks/dde183c6bb1710ff16df.js.LICENSE.txt +1 -1
  20. package/assets/esri/images/portal/knowledgegraphlayer16.png +0 -0
  21. package/assets/esri/themes/dark/main.css +1 -1
  22. package/assets/esri/themes/light/main.css +1 -1
  23. package/assets/esri/themes/light/view.css +1 -1
  24. package/chunks/LineSeries.js +1 -1
  25. package/chunks/Theme.js +1 -1
  26. package/chunks/Tooltip.js +1 -1
  27. package/chunks/chartUtilsAm5.js +1 -1
  28. package/interfaces.d.ts +12 -4
  29. package/layers/ImageryTileLayer.js +1 -1
  30. package/layers/support/editableLayers.js +1 -1
  31. package/package.json +2 -2
  32. package/portal/PortalItem.js +1 -1
  33. package/rest/knowledgeGraph/wasmInterface/updateToWasmEncodedFactories.js +1 -1
  34. package/support/revision.js +1 -1
  35. package/views/2d/GoToManager.js +1 -1
  36. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  37. package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
  38. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  39. package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils.js +1 -1
  40. package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
  41. package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
  42. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  43. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  44. package/views/3d/interactive/editingTools/undoRecords.js +5 -0
  45. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  46. package/views/layers/ImageryTileLayerView.js +1 -1
  47. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  48. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  49. package/widgets/LayerList/ListItemPanel.js +1 -1
  50. package/widgets/LayerList/support/layerListUtils.js +1 -1
  51. package/widgets/Sketch/SketchViewModel.js +1 -1
  52. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  53. package/assets/esri/core/workers/chunks/0753c636c2801f067235.js +0 -1
  54. package/views/3d/interactive/editingTools/transform/undoRecords.js +0 -5
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[1463],{9775:(t,e,s)=>{s.d(e,{A:()=>n});var i=s(62788),r=s(95488);class n{constructor(t=(t=>t.values().next().value)){this._peeker=t,this._observable=new r.I,this._items=new Set}get length(){return(0,i.gc)(this._observable),this._items.size}clear(){0!==this.length&&(this._items.clear(),this._observable.notify())}last(){if(0===this.length)return;let t;for(t of this._items);return t}peek(){if(0!==this.length)return this._peeker(this._items)}push(t){this.contains(t)||(this._items.add(t),this._observable.notify())}contains(t){return(0,i.gc)(this._observable),this._items.has(t)}pop(){if(0===this.length)return;const t=this.peek();return this._items.delete(t),this._observable.notify(),t}popLast(){if(0===this.length)return;const t=this.last();return this._items.delete(t),this._observable.notify(),t}remove(t){this.contains(t)&&(this._items.delete(t),this._observable.notify())}filter(t){const e=this.length;return this._items.forEach((e=>{t(e)||this._items.delete(e)})),e!==this._items.size&&this._observable.notify(),this}*[Symbol.iterator](){(0,i.gc)(this._observable),yield*this._items}}},32587:(t,e,s)=>{s.d(e,{A:()=>n});var i=s(62788),r=s(95488);class n{constructor(t){this._observable=new r.I,this._map=new Map(t)}get size(){return(0,i.gc)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(t){const e=this._map.delete(t);return e&&this._observable.notify(),e}entries(){return(0,i.gc)(this._observable),this._map.entries()}forEach(t,e){(0,i.gc)(this._observable),this._map.forEach(((s,i)=>t.call(e,s,i,this)),e)}get(t){return(0,i.gc)(this._observable),this._map.get(t)}has(t){return(0,i.gc)(this._observable),this._map.has(t)}keys(){return(0,i.gc)(this._observable),this._map.keys()}set(t,e){return this._map.set(t,e),this._observable.notify(),this}values(){return(0,i.gc)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.gc)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}},48163:(t,e,s)=>{function i(){return[0,0]}function r(t,e){return[t,e]}function n(){return r(1,1)}function o(){return r(1,0)}function a(){return r(0,1)}s.d(e,{Un:()=>h,fA:()=>r,vt:()=>i});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:i,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 i=0;i<s;++i)e[i]=t[i];return e},fromValues:r,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},37585:(t,e,s)=>{s.d(e,{Cc:()=>f,Io:()=>l,S8:()=>_,WQ:()=>n,e$:()=>g,hZ:()=>r,hs:()=>c,jb:()=>x,l0:()=>m});var i=s(34304);function r(t,e,s){return t[0]=e,t[1]=s,t}function n(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],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,t[1]=e[1]*s,t}function l(t,e){const s=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(s*s+i*i)}function u(t,e){const s=e[0]-t[0],i=e[1]-t[1];return s*s+i*i}function d(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 _(t,e){const s=e[0],i=e[1];let r=s*s+i*i;return r>0&&(r=1/Math.sqrt(r),t[0]=e[0]*r,t[1]=e[1]*r),t}function f(t,e,s,i){const r=e[0],n=e[1];return t[0]=r+i*(s[0]-r),t[1]=n+i*(s[1]-n),t}function m(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r+s[4],t[1]=s[1]*i+s[3]*r+s[5],t}function g(t,e,s,i){const r=e[0]-s[0],n=e[1]-s[1],o=Math.sin(i),a=Math.cos(i);return t[0]=r*a-n*o+s[0],t[1]=r*o+n*a+s[1],t}const y=d,x=o,b=a,w=h,v=l,S=u,I=p;Object.freeze(Object.defineProperty({__proto__:null,add:n,angle:function(t,e){const s=t[0],i=t[1],r=e[0],n=e[1];let o=s*s+i*i;o>0&&(o=1/Math.sqrt(o));let a=r*r+n*n;a>0&&(a=1/Math.sqrt(a));const h=(s*r+i*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:function(t,e){return t[0]=e[0],t[1]=e[1],t},cross:function(t,e,s){const i=e[0]*s[1]-e[1]*s[0];return t[0]=t[1]=0,t[2]=i,t},dist:v,distance:l,div:w,divide:h,dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},equals:function(t,e){const s=t[0],r=t[1],n=e[0],o=e[1],a=(0,i.FD)();return Math.abs(s-n)<=a*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(r-o)<=a*Math.max(1,Math.abs(r),Math.abs(o))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]},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:y,length:d,lerp:f,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:b,multiply:a,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},normalize:_,projectAndScale:function(t,e,s,i,r){let n=e[0]-s[0],o=e[1]-s[1];const a=(i[0]*n+i[1]*o)*(r-1);return n=i[0]*a,o=i[1]*a,t[0]=e[0]+n,t[1]=e[1]+o,t},random:function(t,e){e=e||1;const s=2*(0,i.Ov)()*Math.PI;return t[0]=Math.cos(s)*e,t[1]=Math.sin(s)*e,t},rotate:g,round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:c,scaleAndAdd:function(t,e,s,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t},set:r,sqrDist:S,sqrLen:I,squaredDistance:u,squaredLength:p,str:function(t){return"vec2("+t[0]+", "+t[1]+")"},sub:x,subtract:o,transformMat2:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r,t[1]=s[1]*i+s[3]*r,t},transformMat2d:m,transformMat3:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[3]*r+s[6],t[1]=s[1]*i+s[4]*r+s[7],t},transformMat4:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[4]*r+s[12],t[1]=s[1]*i+s[5]*r+s[13],t}},Symbol.toStringTag,{value:"Module"}))},79897:(t,e,s)=>{s.d(e,{U:()=>l});var i=s(90237),r=s(69622),n=s(36563),o=s(36708),a=s(11932),h=s(10107),c=s(40608);let l=class extends r.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:i=!1}={}){const r=++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:i?t=>e({added:[],removed:t.toArray()}):void 0})],r),(0,n.hA)((()=>this.removeHandles(r)))}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={},i){const r=++this._handleId;s.sync||this._installSyncUpdatingWatch(t,r);const o=i(t,e,s);return this.addHandles(o,r),(0,n.hA)((()=>this.removeHandles(r)))}_installSyncUpdatingWatch(t,e){const s=this._createSyncUpdatingCallback(),i=(0,o.wB)(t,s,{sync:!0,equals:()=>!1});return this.addHandles(i,e),i}_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,i._)([(0,h.MZ)({readOnly:!0})],l.prototype,"updating",void 0),l=(0,i._)([(0,c.$)("esri.core.support.UpdatingHandles")],l);const u=-42},10382:(t,e,s)=>{s.d(e,{A:()=>c});var i=s(36563),r=(s(44208),s(74887)),n=s(9775),o=s(72457),a=s(52268),h=s(61322);class c{constructor(){this._inUseClients=new Array,this._clients=new Array,this._clientPromises=new Array,this._ongoingJobsQueue=new n.A}destroy(){this.close()}get closed(){return!this._clients?.length}open(t,e){return new Promise(((s,i)=>{let n=!0;const o=t=>{(0,r.Te)(e.signal),n&&(n=!1,t())};this._clients.length=t.length,this._clientPromises.length=t.length,this._inUseClients.length=t.length;for(let n=0;n<t.length;++n){const a=t[n];(0,r.$X)(a)?this._clientPromises[n]=a.then((t=>(this._clients[n]=new h.default(t,e,this._ongoingJobsQueue),o(s),this._clients[n])),(()=>(o(i),null))):(this._clients[n]=new h.default(a,e,this._ongoingJobsQueue),this._clientPromises[n]=Promise.resolve(this._clients[n]),o(s))}}))}broadcast(t,e,s){const i=new Array(this._clientPromises.length);for(let r=0;r<this._clientPromises.length;++r){const n=this._clientPromises[r];i[r]=n.then((i=>i?.invoke(t,e,s)))}return i}close(){let t;for(;t=this._ongoingJobsQueue.pop();)t.resolver.reject((0,r.NK)(`Worker closing, aborting job calling '${t.methodName}'`));for(const t of this._clientPromises)t.then((t=>t?.close()));this._clients.length=0,this._clientPromises.length=0,this._inUseClients.length=0,(0,o.h)(this)}invoke(t,e,s){return this.apply(t,[e],s)}apply(t,e,s){const i=(0,r.Tw)();this._ongoingJobsQueue.push({methodName:t,data:e,invokeOptions:s,resolver:i});for(let t=0;t<this._clientPromises.length;t++){const e=this._clients[t];e?e.jobAdded():this._clientPromises[t].then((t=>t?.jobAdded()))}return i.promise}createInvokeProxy(t){return(0,a.L)(this,t)}on(t,e){return Promise.all(this._clientPromises).then((()=>(0,i.vE)(this._clients.map((s=>s.on(t,e))))))}openPorts(){return new Promise((t=>{const e=new Array(this._clientPromises.length);let s=e.length;for(let i=0;i<this._clientPromises.length;++i)this._clientPromises[i].then((r=>{r&&(e[i]=r.openPort()),0==--s&&t(e)}))}))}get test(){}}},72457:(t,e,s)=>{s.d(e,{h:()=>n,k:()=>r});const i=new FinalizationRegistry((t=>{t.close()}));function r(t,e){i.register(t,e,e)}function n(t){i.unregister(t)}},30624:(t,e,s)=>{s.r(e),s.d(e,{createConnection:()=>T});var i=s(90237),r=(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 p=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,i._)([(0,l.MZ)({readOnly:!0})],p.prototype,"connectionError",null),p=(0,i._)([(0,c.$)("esri.layers.support.StreamConnection")],p);const _=p;var f,m;(m=f||(f={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let g=class extends _{constructor(t){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._config=t,this._featureZScaler=(0,u.N)(e,i,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(i){const r=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 ${r}s`,i)),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 i=new WebSocket(t);i.onopen=()=>{if(i.onopen=null,this.destroyed)return i.onclose=null,void i.close();i.onclose=t=>this._onClose(t),i.onerror=t=>this._onError(t),this._setWebSocketJSONParseHandler(i),e(i)},i.onclose=t=>{i.onopen=i.onclose=null,s(t)}}))}async _handshake(t=1e4){const e=this._websocket;if(null==e)return;const s=(0,a.Tw)(),i=e.onmessage,{filter:r,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()),r&&a.filter!==r&&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=i;for(const t of this._outstandingMessages)e.send(JSON.stringify(t));this._outstandingMessages=[],s.resolve()},e.send(JSON.stringify({filter:r,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,i._)([(0,l.MZ)()],g.prototype,"connectionStatus",null),(0,i._)([(0,l.MZ)()],g.prototype,"errorString",void 0),g=(0,i._)([(0,c.$)("esri.layers.graphics.sources.connections.WebSocketConnection")],g);var y=s(80893),x=s(61956),b=s(65864),w=s(16930);const v={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends g{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:i}=this._config;this.destroyed||this._setFilter(s,i)}_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,r.A)(t.path,{query:e,responseType:"json"}),i=(await s).data;return this._serviceDefinition=i,i}_fetchWebSocketUrl(t,e){const s=t[0],{urls:i,token:r}=s,n=this._inferWebSocketBaseUrl(i);return(0,h.a6)(`${n}/subscribe`,{outSR:""+e.wkid,token:r})}_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 i=JSON.stringify({filter:this._serializeFilter(t,e)});let r=!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),r=!0,h.resolve())},s.send(i),setTimeout((()=>{r||(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],i=this._relatedFeatures.get(s);if(!i)return o.A.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",t),t;const{attributes:r,geometry:a}=i;for(const e in r)t.attributes[e]=r[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),i=this._queryArchive(e);await s;const r=await i;if(!r)return;for(const t of r.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(3161),s.e(2829),s.e(1147),s.e(1132),s.e(5494),s.e(4796),s.e(5894),s.e(9558),s.e(620),s.e(3600),s.e(1967)]).then(s.bind(s,13600))).default)({url:t}),{capabilities:i}=await e.load(),r=i.query.supportsMaxRecordCountFactor,n=i.query.supportsPagination,o=i.query.supportsCentroid,a=this._config.maxRecordCountFactor,h=e.capabilities.query.maxRecordCount,c=r?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),r&&(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=[],i=0){e.start=null!=e.num?i*e.num:null;const{data:r}=await(0,y.eW)(t,e,this._config.sourceSpatialReference);return r.exceededTransferLimit&&i<(this._config.maxQueryDepth??0)?(r.features.forEach((t=>s.push(t))),this._queryPages(t,e,s,i+1)):(s.forEach((t=>r.features.push(t))),r)}_addRelatedFeatures(t){const e=new Map,s=t.features,i=this._serviceDefinition.relatedFeatures.joinField;for(const t of s){const s=t.attributes[i];e.set(s,t)}this._relatedFeatures=e}};S=(0,i._)([(0,c.$)("esri.layers.graphics.sources.connections.GeoEventConnection")],S);const I=S;let P=class extends _{constructor(t){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._featureZScaler=(0,u.N)(e,i,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 M(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,i,r,n,o,a,h){const c={source:t,sourceSpatialReference:e,spatialReference:s,geometryType:i,filter:M(r,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:h};return t?t.path.startsWith("wss://")||t.path.startsWith("ws://")?new g(c):new I(c):new P(c)}(0,i._)([(0,l.MZ)()],P.prototype,"connectionStatus",void 0),(0,i._)([(0,l.MZ)()],P.prototype,"errorString",void 0),P=(0,i._)([(0,c.$)("esri.layers.support.ClientSideConnection")],P)},91806:(t,e,s)=>{s.d(e,{A:()=>l});var i,r=s(90237),n=s(25482),o=s(10107),a=s(56507),h=(s(87811),s(44208),s(40608));let c=i=class extends n.oY{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 i({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,r._)([(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,r._)([(0,o.MZ)({type:a.jz,json:{write:!0}})],c.prototype,"level",void 0),(0,r._)([(0,o.MZ)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,r._)([(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,r._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,r._)([(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,r._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=i=(0,r._)([(0,h.$)("esri.layers.support.LOD")],c);const l=c},87045:(t,e,s)=>{s.d(e,{A:()=>I});var i,r=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),p=s(86738),_=s(16930),f=s(19419),m=s(21325),g=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=i=class extends o.oY{static create(t={}){const{resolutionFactor:e=1,scales:s,size:r=256,spatialReference:n=_.A.WebMercator,numLODs:o=24}=t;if(!(0,m.fn)(n)){const t=[];if(s)for(let e=0;e<s.length;e++){const i=s[e];t.push(new y.A({level:e,scale:i,resolution:i}))}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 i({dpi:96,lods:t,origin:new p.A(0,0,n),size:[r,r],spatialReference:n})}const h=(0,m.Vp)(n),c=t.origin?new p.A({x:t.origin.x,y:t.origin.y,spatialReference:n}):new p.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],i=e*l;u.push(new y.A({level:t,scale:e,resolution:i}))}else{let t=(0,m.EA)(n)?512/r*591657527.5917094:256/r*591657527.591555;const s=Math.ceil(o/e);u.push(new y.A({level:0,scale:t,resolution:t*l}));for(let i=1;i<s;i++){const s=t/2**e,r=s*l;u.push(new y.A({level:i,scale:s,resolution:r})),t=s}}return new i({dpi:96,lods:u,origin:c,size:[r,r],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,m.Vp)(t);return t.isWrappable&&!!s&&Math.abs(s.origin[0]-e.x)<=s.dx}return!1}readOrigin(t,e){return p.A.fromJSON({spatialReference:e.spatialReference,...t})}set lods(t){let e=0,s=0;const i=[],r=this._levelToLOD={};t&&(e=-1/0,s=1/0,t.forEach((t=>{i.push(t.scale),e=t.scale>e?t.scale:e,s=t.scale<s?t.scale:s,r[t.level]=t}))),this._set("scales",i),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),i=s+1;return e[s]/(e[s]/e[i])**(t-s)}scaleToZoom(t){const e=this.scales,s=e.length-1;let i=0;for(;i<s;i++){const s=e[i],r=e[i+1];if(s<=t)return i;if(r===t)return i+1;if(s>t&&r<t)return i+Math.log(s/t)/Math.log(s/r)}return i}tileAt(t,e,s,i){const r=this.lodAt(t);if(!r)return null;let n,o;if("number"==typeof e)n=e,o=s;else if((0,m.aI)(e.spatialReference,this.spatialReference))n=e.x,o=e.y,i=s;else{const t=(0,g.Cv)(e,this.spatialReference);if(null==t)return null;n=t.x,o=t.y,i=s}const a=r.resolution*this.size[0],h=r.resolution*this.size[1];return i||(i=new x.U(null,0,0,0,(0,f.vt)())),i.level=t,i.row=Math.floor((this.origin.y-o)/h+.001),i.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(i),i}updateTileInfo(t,e=i.ExtrapolateOptions.NONE){let s=this.lodAt(t.level);if(!s&&e===i.ExtrapolateOptions.POWER_OF_TWO){const e=this.lods[this.lods.length-1];e.level<t.level&&(s=e)}if(!s)return;const r=t.level-s.level,n=s.resolution*this.size[0]/2**r,o=s.resolution*this.size[1]/2**r;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:i}=s,r=i*this.size[0],n=i*this.size[1];return t[0]=this.origin.x+e.col*r,t[1]=this.origin.y-(e.row+1)*n,t[2]=t[0]+r,t[3]=t[1]+n,t}lodAt(t){return this._levelToLOD?.[t]??null}clone(){return i.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=[],r=this.lods.length-e;for(let t=0;t<r;t++){const i=t+e,{scale:r,resolution:n}=i>=0?this.lods[i]:{scale:2*this.lods[0].scale,resolution:2*this.lods[0].resolution};s.push(new y.A({level:t,scale:r,resolution:n}))}return new i({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 i=t[s];this._upsampleLevels[i.level]={parentLevel:e?e.level:-1,factor:e?e.resolution/i.resolution:0},e=i}}};var v,S;(0,r._)([(0,h.MZ)({type:Number,json:{write:!0}})],w.prototype,"compressionQuality",void 0),(0,r._)([(0,h.MZ)({type:Number,json:{write:!0}})],w.prototype,"dpi",void 0),(0,r._)([(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,r._)([(0,h.MZ)({readOnly:!0})],w.prototype,"isWrappable",null),(0,r._)([(0,h.MZ)({type:p.A,json:{write:!0}})],w.prototype,"origin",void 0),(0,r._)([(0,l.w)("origin")],w.prototype,"readOrigin",null),(0,r._)([(0,h.MZ)({type:[y.A],value:null,json:{write:!0}})],w.prototype,"lods",null),(0,r._)([(0,h.MZ)({readOnly:!0})],w.prototype,"scales",void 0),(0,r._)([(0,h.MZ)({cast:t=>Array.isArray(t)?t:"number"==typeof t?[t,t]:[256,256]})],w.prototype,"size",void 0),(0,r._)([(0,l.w)("size",["rows","cols"])],w.prototype,"readSize",null),(0,r._)([(0,d.K)("size",{cols:{type:c.jz},rows:{type:c.jz}})],w.prototype,"writeSize",null),(0,r._)([(0,h.MZ)({type:_.A,json:{write:!0}})],w.prototype,"spatialReference",void 0),w=i=(0,r._)([(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:()=>i});class i{constructor(t,e,s,i,r=void 0){this.id=t,this.level=e,this.row=s,this.col=i,this.extent=r}}},60694:(t,e,s)=>{s.d(e,{Fi:()=>l,HZ:()=>g,Jf:()=>m,LS:()=>y,Wo:()=>f,bd:()=>x,cr:()=>p,iz:()=>d,qg:()=>u,yG:()=>_});var i=s(84952),r=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,i.An)(t),s=e?.path.match(a)||e?.path.match(h);if(!s)return null;const[,r,o,c,l]=s,u=o.indexOf("/");return{title:p(-1!==u?o.slice(u+1):o),serverType:n[c.toLowerCase()],sublayer:null!=l&&""!==l?parseInt(l,10):null,url:{path:r}}}function d(t){const e=(0,i.An)(t).path.match(c);return e?{serviceUrl:e[1],sublayerId:Number(e[2])}:null}function p(t){return(t=t.replaceAll(/\s*[/_]+\s*/g," "))[0].toUpperCase()+t.slice(1)}function _(t,e){const s=[];if(t){const e=u(t);null!=e&&e.title&&s.push(e.title)}if(e){const t=p(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,i.$z)(t,!0);return!!e&&(e=e.toLowerCase(),e.endsWith(".arcgis.com")&&(e.startsWith("services")||e.startsWith("tiles")||e.startsWith("features")))}function m(t,e){return t?(0,i.UC)((0,i.zi)(t,e)):t}function g(t){let{url:e}=t;if(!e)return{url:e};e=(0,i.zi)(e,t.logger);const s=(0,i.An)(e),r=u(s.path);let n;if(null!=r)null!=r.sublayer&&null==t.layer.layerId&&(n=r.sublayer),e=r.url.path;else if(t.nonStandardUrlAllowed){const t=d(s.path);null!=t&&(e=t.serviceUrl,n=t.sublayerId)}return{url:(0,i.UC)(e),layerId:n}}function y(t,e,s,n,o){(0,r.w)(e,n,"url",o),n.url&&null!=t.layerId&&(n.url=(0,i.fj)(n.url,s,t.layerId.toString()))}function x(t){if(!t)return!1;const e=t.toLowerCase(),s=e.includes("/services/"),i=e.includes("/mapserver/wmsserver"),r=e.includes("/imageserver/wmsserver"),n=e.includes("/wmsserver");return s&&(i||r||n)}},58501:(t,e,s)=>{s.d(e,{q:()=>r});var i=s(62815);function r(t,e,s){if(!s?.features||!s.hasZ)return;const r=(0,i.N)(s.geometryType,e,t.outSpatialReference);if(null!=r)for(const t of s.features)r(t.geometry)}},83355:(t,e,s)=>{s.r(e),s.d(e,{default:()=>dp});var i=s(49186),r=s(36563),n=s(44208),o=s(26390),a=s(74887),h=s(87811),c=s(36708),l=s(90629),u=s(87045),d=s(21325),p=s(44159);function _(t,e){return[t,e]}function f(t,e,s){return t[0]=e,t[1]=s,t}const m=new p.A("0/0/0/0");class g{static create(t,e,s=null){const i=(0,d.Vp)(t.spatialReference),r=e.origin||_(t.origin.x,t.origin.y),n=_(t.size[0]*e.resolution,t.size[1]*e.resolution),o=_(-1/0,-1/0),a=_(1/0,1/0),h=_(1/0,1/0);null!=s&&(f(o,Math.max(0,Math.floor((s.xmin-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymax)/n[1]))),f(a,Math.max(0,Math.floor((s.xmax-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymin)/n[1]))),f(h,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:c,rows:l}=e;let u,p,m,y;return!s&&c&&l&&(f(o,c[0],l[0]),f(a,c[1],l[1]),f(h,c[1]-c[0]+1,l[1]-l[0]+1)),t.isWrappable?(u=_(Math.ceil(Math.round((i.valid[1]-i.valid[0])/e.resolution)/t.size[0]),h[1]),p=_(Math.floor((i.origin[0]-r[0])/n[0]),o[1]),m=_(u[0]+p[0]-1,a[1]),y=!0):(p=o,m=a,u=h,y=!1),new g(e.level,e.resolution,e.scale,r,o,a,h,n,p,m,u,y)}constructor(t,e,s,i,r,n,o,a,h,c,l,u){this.level=t,this.resolution=e,this.scale=s,this.origin=i,this.first=r,this.last=n,this.size=o,this.norm=a,this.worldStart=h,this.worldEnd=c,this.worldSize=l,this.wrap=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}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){return this.origin[0]+t*this.norm[0]}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 i=s?m.col:this.denormalizeCol(m.col,m.world),r=m.row;return function(t,e,s,i,r){t[0]=e,t[1]=s,t[2]=i,t[3]=r}(t,this.getXForColumn(i),this.getYForRow(r+1),this.getXForColumn(i+1),this.getYForRow(r)),t}getTileCoords(t,e,s=!1){m.set(e);const i=s?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(t)?f(t,this.getXForColumn(i),this.getYForRow(m.row)):(t.x=this.getXForColumn(i),t.y=this.getYForRow(m.row)),t}}var y=s(93687);class x{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:i}of this.spans)for(let r=s;r<=i;r++){const s=t.getWorldForColumn(r);yield new p.A(t.level,e,t.normalizeCol(r),s)}}forEach(t,e){const{spans:s,lodInfo:i}=this,{level:r}=i;if(0!==s.length)for(const{row:n,colFrom:o,colTo:a}of s)for(let s=o;s<=a;s++)t.call(e,r,n,i.normalizeCol(s),i.getWorldForColumn(s))}}x.pool=new y.A(x);class b{constructor(t,e,s){this.row=t,this.colFrom=e,this.colTo=s}}const w=new p.A("0/0/0/0");class v{static create(t,e){t[1]>e[1]&&([t,e]=[e,t]);const[s,i]=t,[r,n]=e,o=r-s,a=n-i,h=0!==a?o/a:0,c=(Math.ceil(i)-i)*h,l=(Math.floor(i)-i)*h;return new v(s,Math.floor(i),Math.ceil(n),h,o<0?c:l,o<0?l:c,o<0?r:s,o<0?s:r)}constructor(t,e,s,i,r,n,o,a){this.x=t,this.ymin=e,this.ymax=s,this.invM=i,this.leftAdjust=r,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 S=[[0,0],[0,0],[0,0],[0,0]];class I{constructor(t,e=null,s=t.lods[0].level,i=t.lods[t.lods.length-1].level){this.tileInfo=t,this.fullExtent=e,this.scales=[],this._infoByScale={},this._infoByLevel={};const r=t.lods.filter((t=>t.level>=s&&t.level<=i));this.minScale=r[0].scale,this.maxScale=r[r.length-1].scale;const n=this._lodInfos=r.map((s=>g.create(t,s,e)));r.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){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileBounds(t,w,s):t}getTileCoords(t,e,s=!1){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileCoords(t,w,s):t}getTileCoverage(t,e=192,s=!0,i="closest"){if(!s&&(t.scale>this.minScale||t.scale<this.maxScale))return null;const r="closest"===i?this.getClosestInfoForScale(t.scale):this.getSmallestInfoForScale(t.scale),n=x.pool.acquire(r),o=this._wrap;let a,h,c,l=1/0,u=-1/0;const d=n.spans;S[0][0]=S[0][1]=S[1][1]=S[3][0]=-e,S[1][0]=S[2][0]=t.size[0]+e,S[2][1]=S[3][1]=t.size[1]+e;for(const e of S)t.toMap(e,e),e[0]=r.getColumnForX(e[0]),e[1]=r.getRowForY(e[1]);const p=[];let _=3;for(let t=0;t<4;t++){if(S[t][1]===S[_][1]){_=t;continue}const e=v.create(S[t],S[_]);l=Math.min(e.ymin,l),u=Math.max(e.ymax,u),void 0===p[e.ymin]&&(p[e.ymin]=[]),p[e.ymin].push(e),_=t}if(null==l||null==u||u-l>100)return null;let f=[];for(a=l;a<u;){null!=p[a]&&(f=f.concat(p[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>=r.first[1]&&a<=r.last[1])if(o)if(r.size[0]<r.worldSize[0]){const t=Math.floor(c/r.worldSize[0]);for(let e=Math.floor(h/r.worldSize[0]);e<=t;e++)d.push(new b(a,Math.max(r.getFirstColumnForWorld(e),h),Math.min(r.getLastColumnForWorld(e),c)))}else d.push(new b(a,h,c));else h>r.last[0]||c<r.first[0]||(h=Math.max(h,r.first[0]),c=Math.min(c,r.last[0]),d.push(new b(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){w.set(t);const e=this._infoByLevel[w.level],s=this._lodInfos.indexOf(e)-1;return s<0?null:(this._getTileIdAtLOD(w,this._lodInfos[s],w),w.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){w.set(e);const s=this._infoByLevel[w.level],i=t.lodInfo;if(i.resolution>s.resolution){this._getTileIdAtLOD(w,i,w);const e=i.denormalizeCol(w.col,w.world);for(const s of t.spans)if(s.row===w.row&&s.colFrom<=e&&s.colTo>=e)return!0}if(i.resolution<s.resolution){const[e,r,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(w.col,w.world),h=i.getColumnForX(s.getXForColumn(a)),c=i.getRowForY(s.getYForRow(w.row)),l=i.getColumnForX(s.getXForColumn(a+1))-1,u=i.getRowForY(s.getYForRow(w.row+1))-1;return!(h>o||l<n||c>r||u<e)}const r=i.denormalizeCol(w.col,w.world);return t.spans.some((t=>t.row===w.row&&t.colFrom<=r&&t.colTo>=r))}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,d.Vp)(this.tileInfo.spatialReference),i=-s*(e.valid[1]-e.valid[0]);t[0]+=i,t[2]+=i}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 i=this._infoByLevel[s.level];return t.set(s),e.resolution<i.resolution?null:(e.resolution===i.resolution||(t.level=e.level,t.col=Math.floor(s.col*i.resolution/e.resolution+.01),t.row=Math.floor(s.row*i.resolution/e.resolution+.01)),t)}}var P=s(90237),M=s(69622),T=s(97768),C=s(10107),A=s(53966),E=s(40608),F=s(37585),k=s(89738);const z=new Set,O=[],R=new Map,L=[0,0];let N=class extends M.A{constructor(t){super(t),this._keyToItem=new Map,this.concurrency=6,this.strategy="scale-first",this.tileInfoView=null}initialize(){const{concurrency:t,process:e,strategy:s}=this;this._queue=new k.e({concurrency:t,process:(t,s)=>{const i=this._keyToItem.get(t);return e(i,{signal:s})},peeker:"scale-first"===s?t=>this._peekByScaleFirst(t):t=>this._peekByCenterFirst(t)})}destroy(){this.clear(),this._queue=(0,T.pR)(this._queue)}get length(){return this._queue?this._queue.length:0}get onGoingCount(){return this._keyToItem.size}abort(t){const e="string"==typeof t?t:t.id;this._queue.abort(e)}clear(){this._queue.clear(),this._keyToItem.clear()}has(t){return"string"==typeof t?this._keyToItem.has(t):this._keyToItem.has(t.id)}isOngoing(t){const e="string"==typeof t?t:t.id;return this.has(e)&&this._queue.isOngoing(e)}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),i=()=>{this._keyToItem.delete(e)};return this._keyToItem.set(e,t),s.then(i,i),s}reset(){this._queue.reset()}resume(){this._queue.resume()}_peekByScaleFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView;let s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;t.forEach((t=>{const e=this._keyToItem.get(t),r=this.tileInfoView.getTileScale(e.key);R.has(r)||(R.set(r,[]),s=Math.max(r,s),i=Math.min(r,i)),R.get(r).push(e.key),z.add(r)}));let r=this.state.scale;R.has(r)||(function(t,e){t.length=0,e.forEach((e=>t.push(e)))}(O,z),O.sort(((t,e)=>t-e)),r=O.reduce(((t,e)=>Math.abs(e-r)<Math.abs(t-r)?e:t),O[0])),r=Math.min(r,s),r=Math.max(r,i);const n=R.get(r),o=e.getClosestInfoForScale(r),a=o.getColumnForX(this.state.center[0]),h=o.getRowForY(this.state.center[1]);return n.sort(((t,e)=>{const s=o.denormalizeCol(t.col,t.world),i=o.denormalizeCol(e.col,e.world);return Math.sqrt((a-s)*(a-s)+(h-t.row)*(h-t.row))-Math.sqrt((a-i)*(a-i)+(h-e.row)*(h-e.row))})),z.clear(),R.clear(),n[0].id}_peekByCenterFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView,s=this.state.center;let i,r=Number.POSITIVE_INFINITY;return t.forEach((t=>{const n=this._keyToItem.get(t);e.getTileCoords(L,n.key);const o=(0,F.Io)(L,s);o<r&&(r=o,i=n.key)})),i.id}};(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"concurrency",void 0),(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"process",void 0),(0,P._)([(0,C.MZ)()],N.prototype,"state",void 0),(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"strategy",void 0),(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"tileInfoView",void 0),N=(0,P._)([(0,E.$)("esri.views.2d.tiling.TileQueue")],N);var D=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("",{ignoreConnectionErrors:!0}),this.container=this._client.createInvokeProxy("container",{ignoreConnectionErrors:!0}),this.eventLog=this._client.createInvokeProxy("eventLog",{ignoreConnectionErrors:!0})}}var U=s(93637),V=s(6797),q=s(16930);class W{constructor(t,e,s,i,r,n,o){this.instanceId=t,this.textureKey=e,this.indexStart=s,this.indexCount=i,this.vertexStart=r,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,i,r,n,o,a){t.push(e),t.push(s),t.push(i),t.push(r),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(),i=t.readInt32(),r=t.readInt32(),n=t.readInt32(),o=t.readInt32(),a=t.readInt32();return new W(e,s,i,r,n,o,a)}}function Y(t,e){if(null!==e){t.push(e.length);for(const s of e)s.serialize(t);return t}t.push(0)}function j(t,e,s){const i=t.readInt32(),r=new Array(i);for(let i=0;i<r.length;i++)r[i]=e.deserialize(t,s);return r}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),Y(t,this.records),t}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=new X(e,s);return i.records=j(t,W)??[],i}}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),i=new this._ctor(s);i.set(this._buffer,0),this._array=s,this._buffer=i,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 i=e;i!==s;i++)this.writeFixed(t._buffer[i])}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 i=6*s*Uint32Array.BYTES_PER_ELEMENT,r=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,i),this._vertices=new $(Uint32Array,r),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(),i=this._metrics.length?this._metrics.buffer():null;return t.push(e,s),{instanceId:this._instanceId,layout:this.layout,indices:e,vertices:s,metrics:i}}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._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,i){}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)}entityRecordCount(){return this._entities.getValue(this._entityRecordCountOffset)}entityEnd(){0===this.entityRecordCount()?this._entities.seek(this._entityIdIndex):this._entities.incr(this._entityCountOffset)}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 i=this._current.indexStart,r=this._current.writer.indexCount-i;return this._recordIndexStart=i,this._recordIndexCount=r,this._recordVertexStart=e,this._recordVertexCount=s,this._entities.incr(this._entityRecordCountOffset),W.write(this._entities,this._current.instanceId,this._current.textureKey,i,r,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 i=this._current.writer.indexWriter,r=this._current.writer.vertexWriter,n=this._recordIndexStart+this._recordIndexCount,o=this._recordVertexCount;for(let t=this._recordIndexStart;t!==n;t++){const e=i.getValue(t);i.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=r.getValue(t);r.push(e)}const l=this._current.writer.layout.position,u=l.packPrecisionFactor??1,d=l.offset/Uint32Array.BYTES_PER_ELEMENT,p=t*u,_=e*u;for(let t=s*a;t<=r.length;t+=a)r.i1616Add(t+d,p,_);this.recordEnd()}copyLastFrom(t,e,s){const i=t._entities.getValue(t._entityIdIndex);if(i!==this._entities.getValue(this._entityIdIndex)){const e=t._entities.getValueF32(t._entitySortKeyIndex);this.entityStart(i,e)}this.recordStart(t._current.instanceId,t._current.writer.layout,t._current.textureKey);const r=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*r;e!==l.length;e++){const t=l.getValue(e);h.push(t)}const u=this._current.writer.layout.position,d=u.packPrecisionFactor??1,p=u.offset/Uint32Array.BYTES_PER_ELEMENT,_=e*d,f=s*d;for(let t=n*r;t<=h.length;t+=r)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,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,this._copyBufferedDataIntoSelf=s&&this._bufferingEnabled&&0===t.level}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,i){this._bufferingEnabled&&this._addOverlap(t,e,s,i)}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,i)=>{const r=s.serialize(),n=1<<i,o=Q(n),a=K(n),h=function(t,e,s,i){const r=t.clone(),n=1<<r.level,o=r.col+e,a=r.row+s;return i&&o<0?(r.col=o+n,r.world-=1):o>=n?(r.col=o-n,r.world+=1):r.col=o,r.row=a,r}(new p.A(this.tileKey),o,a,t);e.message.push({tileId:h.id,...r.message}),e.transferList.push(...r.transferList)})),e}_addOverlap(t,e,s,i){const r=Math.min(B.CQ/2,s),n=Math.min(B.CQ/2,i),o=255^((t<0+r?148:t>=B.CQ-r?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;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],i=-Q(e)*B.CQ,r=-K(e)*B.CQ;s.copyLastFrom(this._meshes.self,i,r)}}}}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}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(),i=[];for(;s.next();)i.push(this._updateMeshWriterGroup(t,s));await Promise.all(i)}match(t,e){const s=t.getAttributeHash();return this._hashToGroup.get(s)}async _updateMeshWriterGroup(t,e){const s=e.readLegacyFeatureForDisplay(),i=e.getAttributeHash();if(this._hashToGroup.has(i))return;this._hashToGroup.set(i,null);const r=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:s});if(!r)return;const n=await this._context.createMeshWriters(r.meshes);this._hashToGroup.set(i,n)}}class it 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),i=new it(s,e.isMaxInclusive);await Promise.all(e.intervals.map((async e=>{const s=await t.createMeshWriters(e.meshes);i.add(e,s)})));const r=await t.createMeshWriters(e.defaultSymbol);i.setDefault(r);const n=await t.createMeshWriters(e.backgroundFill);return i.setBackgroundFill(n),i}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}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:i}=this._intervals[t],r=s>=e.min,n=this._isMaxInclusive?s<=e.max:s<e.max;if(r&&n)return i}return null}}class rt 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)}})),i=await Promise.all(s);return new rt(i)}constructor(t){super(),this._labels=t}match(t,e){if(!this._labels.length)return null;const s=this._getLabels(e.$view.scale),i=[];for(const e of s)e.where&&!e.where(t)||i.push(...e.meshes);return i}_getLabels(t){return this._labels.filter((e=>this._validForTileScale(e,t)))}_validForTileScale(t,e){const s=e-e/4,i=e+e/2;return(!t.minScale||t.minScale>=s)&&(!t.maxScale||t.maxScale<=i)}}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],i=(await Promise.all(s)).filter((t=>!!t)),r=new nt(i,e.fieldDelimiter),n=await t.createMeshWriters(e.defaultSymbol);r.setDefault(n);const o=await t.createMeshWriters(e.backgroundFill);return r.setBackgroundFill(o),await Promise.all(e.map.map((async(e,s)=>{const i=await t.createMeshWriters(e.symbol);"<Null>"===e.value?r.setNullResult(i):r.add(e.value,i,s+1)}))),r}setNullResult(t){this._nullResult=t}getSortKey(t,e){const s=this._getValueFromFields(t,e);if(null==s||""===s||"<Null>"===s)return 0;const i=this._resultsMap.get(s.toString());return i?i.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}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 i=s.toString();return this._resultsMap.get(i)?.meshWriters}_getValueFromFields(t,e){const s=[];for(const i of this._fields){const r=i.read(t,e);null==r||""===r?s.push("<Null>"):s.push(r)}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 it.fromIntervalSchema(t,e);case"dictionary":return st.fromDictionaryRenderer(t,e);case"label":return rt.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,i=[];for(const r in e.renderers){const n=parseInt(r,10),o=ot(t,e.renderers[r]).then((t=>s.set(n,t)));i.push(o)}return await Promise.all(i),new at(s,e.subtypeField)}match(t,e){const s=t.readAttribute(this._subtypeField),i=this._subMatchers.get(s);return i?i.match(t,e):null}}class ht extends et{static async fromClusterSchema(t,e){const[s,i]=await Promise.all([ot(t,e.feature),ot(t,e.cluster)]);return new ht(s,i)}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),i=e.labels?await ot(t,e.labels):null;return new ct(s,i)}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 i=this._symbology.match(e,s);if(i){for(const r of i)r.enqueueRequest(t,e,s);if(this._labels){const i=this._labels.match(e,s);if(!i)return;for(const r of i)r.enqueueRequest(t,e,s)}}}write(t,e,s,i,r){const n=this._symbology.match(s,i);if(n){for(const o of n)o.write(t,e,s,i,r);if(t.entityRecordCount()>=1&&this._labels){const o=this._labels.match(s,i);if(!o)return;for(const a of o)a.setReferences(n),a.write(t,e,s,i,r)}}}getSortKey(t,e){return this._symbology.getSortKey(t,e)}}var lt=s(799),ut=s(15294),dt=s(94656),pt=s(63907),_t=s(4576),ft=s(34275);const mt=()=>A.A.getLogger("esri.views.webgl.BufferObject");class gt{static createIndex(t,e,s){return new gt(t,pt.NZ.ELEMENT_ARRAY_BUFFER,e,s)}static createVertex(t,e,s){return new gt(t,pt.NZ.ARRAY_BUFFER,e,s)}static createUniform(t,e,s){return new gt(t,pt.NZ.UNIFORM_BUFFER,e,s)}static createPixelPack(t,e=pt._U.STREAM_READ,s){const i=new gt(t,pt.NZ.PIXEL_PACK_BUFFER,e);return s&&i.setSize(s),i}static createPixelUnpack(t,e=pt._U.STREAM_DRAW,s){return new gt(t,pt.NZ.PIXEL_UNPACK_BUFFER,e,s)}static createTransformFeedback(t,e=pt._U.STATIC_DRAW,s){const i=new gt(t,pt.NZ.TRANSFORM_FEEDBACK_BUFFER,e);return i.setSize(s),i}constructor(t,e,s,i){this._context=t,this.bufferType=e,this.usage=s,this._glName=null,this._size=-1,this._indexType=void 0,t.instanceCounter.increment(pt.vt.BufferObject,this),this._glName=this._context.gl.createBuffer(),(0,dt.Y2)(this._context.gl),i&&this.setData(i)}get glName(){return this._glName}get size(){return this._size}get indexType(){return this._indexType}get usedMemory(){return this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER?this._indexType===pt.pe.UNSIGNED_INT?4*this._size:2*this._size:this._size}get _isVAOAware(){return this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER||this.bufferType===pt.NZ.ARRAY_BUFFER}dispose(){this._context?.gl?(this._glName&&(this._context.gl.deleteBuffer(this._glName),this._glName=null),this._context.instanceCounter.decrement(pt.vt.BufferObject,this),this._context=null):this._glName&&mt().warn("Leaked WebGL buffer object")}setSize(t,e=null){if(this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER&&null!=e)switch(this._indexType=e,e){case pt.pe.UNSIGNED_SHORT:t*=2;break;case pt.pe.UNSIGNED_INT:t*=4}this._setBufferData(t)}setData(t){if(!t)return;let e=t.byteLength;this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER&&((0,ft.jq)(t)&&(e/=2,this._indexType=pt.pe.UNSIGNED_SHORT),(0,ft.XJ)(t)&&(e/=4,this._indexType=pt.pe.UNSIGNED_INT)),this._setBufferData(e,t)}_setBufferData(t,e=null){this._size=t;const s=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const i=this._context.gl;null!=e?i.bufferData(this.bufferType,e,this.usage):i.bufferData(this.bufferType,t,this.usage),(0,dt.Y2)(i),this._isVAOAware&&this._context.bindVAO(s)}setSubData(t,e,s,i){if(!t)return;const r=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const{gl:n}=this._context;n.bufferSubData(this.bufferType,e*t.BYTES_PER_ELEMENT,t,s,i-s),(0,dt.Y2)(n),this._isVAOAware&&this._context.bindVAO(r)}getSubData(t,e=0,s,i){if(s<0||i<0)return;const r=function(t){return(0,_t.Xj)(t)}(t)?t.BYTES_PER_ELEMENT:1;if(r*((s??0)+(i??0))>t.byteLength)return;e+r*(i??0)>this.usedMemory&&mt().warn("Potential problem getting subdata: requested data exceeds buffer size!");const n=this._context.gl;this.bufferType===pt.NZ.TRANSFORM_FEEDBACK_BUFFER?(this._context.bindBuffer(this,pt.NZ.TRANSFORM_FEEDBACK_BUFFER),n.getBufferSubData(pt.NZ.TRANSFORM_FEEDBACK_BUFFER,e,t,s,i),this._context.unbindBuffer(pt.NZ.TRANSFORM_FEEDBACK_BUFFER)):(this._context.bindBuffer(this,pt.NZ.COPY_READ_BUFFER),n.getBufferSubData(pt.NZ.COPY_READ_BUFFER,e,t,s,i),this._context.unbindBuffer(pt.NZ.COPY_READ_BUFFER))}async getSubDataAsync(t,e=0,s,i){await this._context.clientWaitAsync(),this.getSubData(t,e,s,i)}}var yt=s(36421),xt=s(42293);class bt{constructor(t,e){this._context=t,this._descriptor=e,this.type=yt.p.RenderBuffer,this._context.instanceCounter.increment(pt.vt.Renderbuffer,this);const s=this._context.gl;this.glName=s.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:i,height:r,internalFormat:n,multisampled:o}=e;o?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,n,i,r):s.renderbufferStorage(s.RENDERBUFFER,n,i,r),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,xt.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 i=this._context.gl;this._context.bindRenderbuffer(this),s.multisampled?i.renderbufferStorageMultisample(i.RENDERBUFFER,this.samples,s.internalFormat,s.width,s.height):i.renderbufferStorage(i.RENDERBUFFER,s.internalFormat,s.width,s.height),this._context.bindRenderbuffer(null)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(pt.vt.Renderbuffer,this),this._context=null)}}var wt=s(21231);class vt{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(pt.vt.FramebufferObject,this);const i=St(e)?e:new wt.g(this._context,e);if(this._colorAttachments.set(pt.Nm.COLOR_ATTACHMENT0,i),this._validateTextureDescriptor(i.descriptor),this._validateColorAttachmentPoint(pt.Nm.COLOR_ATTACHMENT0),null!=s)if(function(t){return St(t)||null!=t&&"pixelFormat"in t}(s))this._depthStencilTexture=St(s)?s:new wt.g(this._context,s),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=function(t){return null!=t&&"type"in t&&t.type===yt.p.RenderBuffer}(s)?s:new bt(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(pt.vt.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(pt.Nm.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(pt.Nm.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(pt.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&&St(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=pt.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=pt.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=pt.Nm.COLOR_ATTACHMENT0){const s=this._colorAttachments.get(e);s&&this._framebufferTexture2D(s.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case yt.p.Texture:return this._attachDepthStencilTexture(t);case yt.p.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==pt.Ab.DEPTH_STENCIL&&e.pixelFormat!==pt.Ab.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==pt.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,pt.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,pt.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,i=this._getGLAttachmentPoint(e);s.framebufferRenderbuffer(pt.R.FRAMEBUFFER,i,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,i=this._getGLAttachmentPoint(t.descriptor);s.framebufferRenderbuffer(pt.R.FRAMEBUFFER,i,s.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,s,i,r,n,o){(t<0||e<0||r<0||n<0)&&console.error("Offsets cannot be negative!"),(s<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==pt.Ap.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||t+s>this.width||e+i>this.height||r+s>a.width||n+i>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,wt.g.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(wt.g.TEXTURE_UNIT_FOR_UPDATES),h.bindFramebuffer(this),h.gl.copyTexSubImage2D(pt.Ap.TEXTURE_2D,0,r,n,t,e,s,i),h.bindTexture(c,wt.g.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,s,i,r,n,o){(s<=0||i<=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,i,r,n,o)}async readPixelsAsync(t,e,s,i,r,n,o){const{gl:a}=this._context,h=gt.createPixelPack(this._context,pt._U.STREAM_READ,o.byteLength);this._context.bindBuffer(h),this._context.bindFramebuffer(this),a.readPixels(t,e,s,i,r,n,0),this._context.unbindBuffer(pt.NZ.PIXEL_PACK_BUFFER),await h.getSubDataAsync(o),h.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const s={width:t,height:e};It(s,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(s.width,s.height))),this._depthStencilTexture?.resize(s.width,s.height),this._initialized&&(It(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=pt.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,Pt(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,Pt(this._depthStencilTexture),t);(0,dt.en)()&&e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=s,this._initialized=!0}_framebufferTexture2D(t,e=pt.Nm.COLOR_ATTACHMENT0,s=pt.Ap.TEXTURE_2D,i=pt.R.FRAMEBUFFER,r=0){this._context.gl.framebufferTexture2D(i,e,s,t,r)}_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(pt.R.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=(0,T.WD)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,T.WD)(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==pt.Ap.TEXTURE_2D&&t.target!==pt.Ap.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),It(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){It(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 pt.yQ.DEPTH_COMPONENT16:case pt.yQ.DEPTH_COMPONENT24:case pt.yQ.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case pt.yQ.DEPTH24_STENCIL8:case pt.yQ.DEPTH32F_STENCIL8:case pt.yQ.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case pt.yQ.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(t){if(-1===vt._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;vt._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const e=t-pt.Nm.COLOR_ATTACHMENT0;e+1>vt._MAX_COLOR_ATTACHMENTS&&A.A.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${e+1}. Implementation supports up to ${vt._MAX_COLOR_ATTACHMENTS} color attachments`)}}function St(t){return null!=t&&"type"in t&&t.type===yt.p.Texture}function It(t,e){const s=Math.max(t.width,t.height);if(s>e){A.A.getLogger("esri.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const i=e/s;return t.width=Math.round(t.width*i),t.height=Math.round(t.height*i),!1}return!0}function Pt(t){return t.descriptor.target===pt.Ap.TEXTURE_CUBE_MAP?pt.Ap.TEXTURE_CUBE_MAP_POSITIVE_X:pt.Ap.TEXTURE_2D}vt._MAX_COLOR_ATTACHMENTS=-1;var Mt,Tt=s(11053),Ct={exports:{}};void 0!==(Mt=["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"])&&(Ct.exports=Mt);const At=(0,Tt.g)(Ct.exports);var Et,Ft={exports:{}};void 0!==(Et=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"])&&(Ft.exports=Et);const kt=(0,Tt.g)(Ft.exports);var zt,Ot,Rt={exports:{}};zt=Rt,void 0!==(Ot=["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"])&&(zt.exports=Ot);const Lt=(0,Tt.g)(Rt.exports);s(62298);var Nt=s(67171);function Dt(t,e,s){const i=new Nt.R(e.width,e.height);return i.dataType=e.dataType,e.depth&&(i.depth=e.depth),e.flipped&&(i.flipped=e.flipped),e.hasMipmap&&(i.hasMipmap=e.hasMipmap),i.internalFormat=e.internalFormat,e.isImmutable&&(i.isImmutable=e.isImmutable),e.isOpaque&&(i.isOpaque=e.isOpaque),e.maxAnisotropy&&(i.maxAnisotropy=e.maxAnisotropy),i.pixelFormat=e.pixelFormat,e.preMultiplyAlpha&&(i.preMultiplyAlpha=e.preMultiplyAlpha),e.samplingMode&&(i.samplingMode=e.samplingMode),e.target&&(i.target=e.target),i.uniform=e.uniform,e.unpackAlignment&&(i.unpackAlignment=e.unpackAlignment),e.wrapMode&&(i.wrapMode=e.wrapMode),new wt.g(t,i,s)}new Map;class Bt{}class Gt extends Bt{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=function(t){return"url"in t&&"urlHash"in t?{...t,url:""}:t}(t.resource),s=(0,lt.Wm)(JSON.stringify(e));return this._pendingIds.has(s)||(this._pendingIds.add(s),this._pendingRequests.push({...t,resourceId:s})),s}async fetchEnqueuedResources(){const t=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const e=await this._fetcher.fetch(t,this._abortOptions);for(let s=0;s<e.length;s++){const i=t[s].resourceId;this._resourceIdToResource.set(i,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 Ut;!function(t){t[t.Fill=0]="Fill",t[t.PatternFill=1]="PatternFill",t[t.ComplexFill=2]="ComplexFill",t[t.OutlineFill=3]="OutlineFill",t[t.PatternOutlineFill=4]="PatternOutlineFill",t[t.ComplexOutlineFill=5]="ComplexOutlineFill",t[t.Marker=6]="Marker",t[t.PieChart=7]="PieChart",t[t.Line=8]="Line",t[t.TexturedLine=9]="TexturedLine",t[t.Text=10]="Text",t[t.Label=11]="Label",t[t.Heatmap=12]="Heatmap",t[t.DotDensity=13]="DotDensity",t[t.Test=14]="Test"}(Ut||(Ut={}));var Vt=s(15585),qt=(s(83349),s(6774)),Wt=s(92722);function Yt(t,e,s,i,r,n,o){fe=0;const a=(i-s)*n,h=r&&r.length,c=h?(r[0]-s)*n:a;let l,u,d,p,_,f=jt(e,s,0,0,c,n,!0);if(f&&f.next!==f.prev){if(h&&(f=function(t,e,s,i,r,n){const o=new Array;for(let r=0,a=i.length;r<a;r++){const h=jt(t,e,0,i[r]*n,r<a-1?i[r+1]*n:s*n,n,!1);h===h.next&&(h.steiner=!0),o.push(Jt(h))}o.sort(he);for(const t of o)r=te(t,r);return r}(e,s,i,r,f,n)),a>80*n){l=d=e[0+s*n],u=p=e[1+s*n];for(let t=n;t<c;t+=n){const i=e[t+s*n],r=e[t+1+s*n];l=Math.min(l,i),u=Math.min(u,r),d=Math.max(d,i),p=Math.max(p,r)}_=Math.max(d-l,p-u),_=0!==_?1/_:0}$t(f,t,n,l,u,_,o,0)}}function jt(t,e,s,i,r,n,o){let a;if(o===function(t,e,s,i,r,n){let o=0;for(let s=i,a=r-n;s<r;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,i,r,n)>0)for(let s=i;s<r;s+=n)a=Qt(s+e*n,t[s+e*n],t[s+1+e*n],a);else for(let s=r-n;s>=i;s-=n)a=Qt(s+e*n,t[s+e*n],t[s+1+e*n],a);return a&&ae(a,a.next)&&(Kt(a),a=a.next),a}function Xt(t,e=t){if(!t)return t;let s,i=t;do{if(s=!1,i.steiner||!ae(i,i.next)&&0!==se(i.prev,i,i.next))i=i.next;else{if(Kt(i),i=e=i.prev,i===i.next)break;s=!0}}while(s||i!==e);return e}function $t(t,e,s,i,r,n,o,a){if(!t)return;!a&&n&&(t=ee(t,i,r,n));let h=t;for(;t.prev!==t.next;){const c=t.prev,l=t.next;if(n?Zt(t,i,r,n):Ht(t))e.push(c.index/s+o),e.push(t.index/s+o),e.push(l.index/s+o),Kt(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?$t(t=ce(t,e,s,o),e,s,i,r,n,o,2):2===a&&le(t,e,s,i,r,n,o):$t(Xt(t),e,s,i,r,n,o,1);break}}}function Ht(t){const e=t.prev,s=t,i=t.next;if(se(e,s,i)>=0)return!1;let r=t.next.next;const n=r;let o=0;for(;r!==t.prev&&(0===o||r!==n);){if(o++,re(e.x,e.y,s.x,s.y,i.x,i.y,r.x,r.y)&&se(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Zt(t,e,s,i){const r=t.prev,n=t,o=t.next;if(se(r,n,o)>=0)return!1;const a=r.x<n.x?r.x<o.x?r.x:o.x:n.x<o.x?n.x:o.x,h=r.y<n.y?r.y<o.y?r.y:o.y:n.y<o.y?n.y:o.y,c=r.x>n.x?r.x>o.x?r.x:o.x:n.x>o.x?n.x:o.x,l=r.y>n.y?r.y>o.y?r.y:o.y:n.y>o.y?n.y:o.y,u=oe(a,h,e,s,i),d=oe(c,l,e,s,i);let p=t.prevZ,_=t.nextZ;for(;p&&p.z>=u&&_&&_.z<=d;){if(p!==t.prev&&p!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&se(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,_!==t.prev&&_!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&se(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&se(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;_&&_.z<=d;){if(_!==t.prev&&_!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&se(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Qt(t,e,s,i){const r=pe.create(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Kt(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 Jt(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 te(t,e){const s=function(t,e){let s=e;const i=t.x,r=t.y;let n,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const t=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=i&&t>o){if(o=t,t===i){if(r===s.y)return s;if(r===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(i===o)return n.prev;const a=n,h=n.x,c=n.y;let l,u=1/0;for(s=n.next;s!==a;)i>=s.x&&s.x>=h&&i!==s.x&&re(r<c?i:o,r,h,c,r<c?o:i,r,s.x,s.y)&&(l=Math.abs(r-s.y)/(i-s.x),(l<u||l===u&&s.x>n.x)&&ne(s,t)&&(n=s,u=l)),s=s.next;return n}(t,e);if(!s)return e;const i=de(s,t);return Xt(i,i.next),Xt(s,s.next)}function ee(t,e,s,i){let r;for(;r!==t;r=r.next){if(r=r||t,null===r.z&&(r.z=oe(r.x,r.y,e,s,i)),r.prev.next!==r||r.next.prev!==r)return r.prev.next=r,r.next.prev=r,ee(t,e,s,i);r.prevZ=r.prev,r.nextZ=r.next}return t.prevZ.nextZ=null,t.prevZ=null,function(t){let e,s=1;for(;;){let i,r=t;t=null,e=null;let n=0;for(;r;){n++,i=r;let o=0;for(;o<s&&i;o++)i=i.nextZ;let a=s;for(;o>0||a>0&&i;){let s;0===o?(s=i,i=i.nextZ,a--):0!==a&&i?r.z<=i.z?(s=r,r=r.nextZ,o--):(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,o--),e?e.nextZ=s:t=s,s.prevZ=e,e=s}r=i}if(e.nextZ=null,s*=2,n<2)return t}}(t)}function se(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function ie(t,e,s,i){return!!(ae(t,e)&&ae(s,i)||ae(t,i)&&ae(s,e))||se(t,e,s)>0!=se(t,e,i)>0&&se(s,i,t)>0!=se(s,i,e)>0}function re(t,e,s,i,r,n,o,a){return(r-o)*(e-a)-(t-o)*(n-a)>=0&&(t-o)*(i-a)-(s-o)*(e-a)>=0&&(s-o)*(n-a)-(r-o)*(i-a)>=0}function ne(t,e){return se(t.prev,t,t.next)<0?se(t,e,t.next)>=0&&se(t,t.prev,e)>=0:se(t,e,t.prev)<0||se(t,t.next,e)<0}function oe(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ae(t,e){return t.x===e.x&&t.y===e.y}function he(t,e){return t.x-e.x}function ce(t,e,s,i){let r=t;do{const n=r.prev,o=r.next.next;!ae(n,o)&&ie(n,r,r.next,o)&&ne(n,o)&&ne(o,n)&&(e.push(n.index/s+i),e.push(r.index/s+i),e.push(o.index/s+i),Kt(r),Kt(r.next),r=t=o),r=r.next}while(r!==t);return r}function le(t,e,s,i,r,n,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.index!==t.index&&ue(a,t)){let h=de(a,t);return a=Xt(a,a.next),h=Xt(h,h.next),$t(a,e,s,i,r,n,o,0),void $t(h,e,s,i,r,n,o,0)}t=t.next}a=a.next}while(a!==t)}function ue(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&&ie(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&ne(t,e)&&ne(e,t)&&function(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==t);return i}(t,e)}function de(t,e){const s=pe.create(t.index,t.x,t.y),i=pe.create(e.index,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}class pe{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 i=fe<_e.length?_e[fe++]:new pe;return i.index=t,i.x=e,i.y=s,i.prev=null,i.next=null,i.z=null,i.prevZ=null,i.nextZ=null,i.steiner=!1,i}}const _e=[];let fe=0;for(let t=0;t<8096;t++)_e.push(new pe);const me=new qt.O3(0,0,0,1,0),ge=new qt.O3(0,0,0,1,0);function ye(t,e,s){let i=0;for(let r=1;r<s;r++){const s=t[2*(e+r-1)],n=t[2*(e+r-1)+1];i+=(t[2*(e+r)]-s)*(t[2*(e+r)+1]+n)}return i}function xe(t,e,s,i,r){let n=0;for(let o=s;o<i;o+=3){const s=2*(t[o]-r),i=2*(t[o+1]-r),a=2*(t[o+2]-r);n+=Math.abs((e[s]-e[a])*(e[i+1]-e[s+1])-(e[s]-e[i])*(e[a+1]-e[s+1]))}return n}function be(t,e){if(null==t)return null;if(!function(t,e,s){let i=0;for(let e=0;e<t.lengths.length;e++){const r=t.lengths[e];for(let e=0;e<r;e++){const r=t.coords[2*(e+i)],n=t.coords[2*(e+i)+1];if(r<-128||r>s||n<-128||n>s)return!0}i+=r}return!1}(t,0,B.CQ+128))return t;me.setPixelMargin(e),me.reset(qt.dC.Polygon);let s=0;for(let e=0;e<t.lengths.length;e++){const i=t.lengths[e];let r=t.coords[2*(0+s)],n=t.coords[2*(0+s)+1];me.moveTo(r,n);for(let e=1;e<i;e++)r=t.coords[2*(e+s)],n=t.coords[2*(e+s)+1],me.lineTo(r,n);me.close(),s+=i}const i=me.result(!1);if(!i)return null;const r=[],n=[];for(const t of i){let e=0;for(const s of t)n.push(s.x),n.push(s.y),e++;r.push(e)}return new Wt.A(r,n)}me.setExtent(B.CQ),ge.setExtent(B.CQ);var we=s(4718),ve=s(51118),Se=s(65864);class Ie{static fromOptimized(t,e,s=!1,i=!1,r=1){return(new Pe).initialize(t,e,s,i,r)}static fromJSON(t,e=!1,s=!1){const[i,r]=Te(t);return(new Ce).initialize(i,r,e,s,1)}static fromOptimizedCIM(t,e,s=!1,i=!1,r=1){return(new Ae).initialize(t,e,s,i,r)}static fromJSONCIM(t,e=!1,s=!1,i=1){const[r,n]=Te(t);return(new Ee).initialize(r,n,e,s,i)}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,i=1){return(new Pe).initialize(new Wt.A,t,e,s,i)}static createEmptyJSON(t,e=!1,s=!1){return(new Ce).initialize([],t,e,s,1)}static createEmptyOptimizedCIM(t,e=!1,s=!1,i=1){return(new Ae).initialize(new Wt.A,t,e,s,i)}static createEmptyJSONCIM(t,e=!1,s=!1,i=1){return(new Ee).initialize([],t,e,s,i)}asJSON(){const t=(0,ve.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 i=t,r=e;for(;this.nextPoint();)s+=(t-this.x)*(e+this.y),t=this.x,e=this.y;return s+=(t-i)*(e+r),-.5*s}invertY(){this.yFactor*=-1}}class Pe extends Ie{constructor(){super(...arguments),this._end=-1}initialize(t,e,s,i,r){return this.hasZ=s,this.hasM=i,this.geometryType=e,this._stride=2+Number(s)+Number(i),this._geometry=t,this._pathIndex=-1,this._pathOffset=0,this._pointOffset=-this._stride,this._end=-1,this.yFactor=r,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))}pathLength(){const t=this._end,e=this._stride,s=this._geometry.coords;let i=0;for(let r=this._pathOffset+e;r<t;r+=e){const t=s[r-e],n=s[r-e+1],o=s[r]-t,a=s[r+1]-n;i+=Math.sqrt(o*o+a*a)}return i}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 i=0;i<this._stride;i++)if(t[e+i]!==t[s+i])return!1;return!0}clone(){return(new Pe).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._pathIndex<0||this._pathIndex>t.length-1?0:this._geometry.isPoint?1:t[this._pathIndex]}get totalSize(){return 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 Me(t){const e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e}function Te(t){return(0,Se.Bi)(t)?[t.rings,"esriGeometryPolygon"]:(0,Se.Rg)(t)?[t.paths,"esriGeometryPolyline"]:(0,Se.U9)(t)?[[t.points],"esriGeometryMultipoint"]:(0,Se.ZC)(t)?[[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]],"esriGeometryEnvelope"]:(0,Se.fT)(t)?[[[Me(t)]],"esriGeometryPoint"]:[[],"esriGeometryPolyline"]}class Ce extends Ie{initialize(t,e,s,i,r){return this._paths=t,this.geometryType=e,this.hasZ=s,this.hasM=i,this._pathIndex=this._pointIndex=-1,this.yFactor=r,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 i=1;i<t;i++){const t=e[i-1],r=e[i],n=t[0],o=t[1],a=r[0]-n,h=r[1]-o;s+=Math.sqrt(a*a+h*h)}return s}startPath(){this._paths.push([])}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,ve.x)(t);for(const t of e)this.pushPath(t)}asOptimized(){const t=new Wt.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 Ce).initialize((0,we.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 Ae extends Pe{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r),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 Ae).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 Ee extends Ce{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r)}clone(){return(new Ee).initialize((0,we.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]}}let Fe;class ke{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}function ze(t,e){Fe||(Fe=new qt.O3(0,0,0,1));const s="esriGeometryPolygon"===t.geometryType,i=s?qt.dC.Polygon:qt.dC.LineString,r=s?3:2;let n,o;for(Fe.reset(i),Fe.setPixelMargin(e+1),Fe.setExtent(512);t.nextPath();)if(!(t.pathSize<r)){for(t.nextPoint(),n=t.x,o=-t.y,Fe.moveTo(n,o);t.nextPoint();)n=t.x,o=-t.y,Fe.lineTo(n,o);s&&Fe.close()}const a=Fe.result(!1);if(a){const e=Ie.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 Oe{static local(){return null===Oe.instance&&(Oe.instance=new Oe),Oe.instance}execute(t,e,s,i,r){return new Re(t,e,s)}}Oe.instance=null;class Re{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 i=e,r=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?(p=e,_=s):(p=t.x,_=t.y);const f=p-i,m=_-r,g=Math.sqrt(f*f+m*m);d>1&&g>0&&h>0&&(o*f+a*m)/g/h<=this._maxCosAngle&&t.setControlPointAt(d-1),1===d&&(c=f,l=m,u=g),g>0&&(i=p,r=_,o=f,a=m,h=g)}this._isClosed&&h>0&&u>0&&(o*c+a*l)/u/h<=this._maxCosAngle&&t.setControlPointAt(0)}}}class Le{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 Ne(t,e){t[4]=e}class De{constructor(t,e=!0,s=!0,i=0){this.isClosed=!1,this.geometryCursor=null,this.geometryCursor=!e&&"esriGeometryPolygon"===t.geometryType||!s&&"esriGeometryPolyline"===t.geometryType?null:t,this.geomUnitsPerPoint=i,this.iterateMultiPath=!1,this.iteratePath=!1,this.internalPlacement=new Le}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 Be{constructor(t,e,s,i=0){this.isClosed=!1,this._tileKey=null,this.inputGeometries=t,this.acceptPolygon=e,this.acceptPolyline=s,this.geomUnitsPerPoint=i,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;this._tileKey&&this.isClippingRequired(this.multiPathCursor)&&(this.multiPathCursor.reset(),this.multiPathCursor=ze(this.multiPathCursor,256))}for(;this.iteratePath||this.multiPathCursor.nextPath();){this.multiPathCursor.seekPathStart();const t=this.processPath(this.multiPathCursor);if(t)return t}this.multiPathCursor=null}}isClippingRequired(t){return!1}}const Ge=.03;class Ue{constructor(t=0,e=!1){}isEmpty(t){if(!t.nextPoint())return!0;let e,s,i,r;for(e=t.x,s=t.y;t.nextPoint();e=s,s=r)if(i=t.x,r=t.y,i!==e||r!==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,i){const r=s-t,n=i-e;return Math.sqrt(r*r+n*n)}getSegLength(t){const[[e,s],[i,r]]=t;return this.getLength(e,s,i,r)}getCoord2D(t,e,s,i,r){return[t+(s-t)*r,e+(i-e)*r]}getSegCoord2D(t,e){const[[s,i],[r,n]]=t;return this.getCoord2D(s,i,r,n,e)}getAngle(t,e,s,i,r){const n=s-t,o=i-e;return Math.atan2(o,n)}getAngleCS(t,e,s,i,r){const n=s-t,o=i-e,a=Math.sqrt(n*n+o*o);return a>0?[n/a,o/a]:[1,0]}getSegAngleCS(t,e){const[[s,i],[r,n]]=t;return this.getAngleCS(s,i,r,n,e)}cut(t,e,s,i,r,n){return[r<=0?[t,e]:this.getCoord2D(t,e,s,i,r),n>=1?[s,i]:this.getCoord2D(t,e,s,i,n)]}getSubCurve(t,e,s){const i=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");return this.appendSubCurve(i,t,e,s)?i:null}appendSubCurve(t,e,s,i){t.startPath(),e.seekPathStart();let r=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(r+h>s){const c=(s-r)/h;let l=1,u=!1;r+h>=i&&(l=(i-r)/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(r+h>i){const s=this.cut(o,a,e.x,e.y,0,(i-r)/h);s&&t.pushPoint(s[1]);break}t.pushXY(e.x,e.y)}r+=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,i,r,n,o=0;for(s=t.x,i=t.y;t.nextPoint();s=r,i=n){r=t.x,n=t.y;const a=this.getLength(s,i,r,n);if(0!==a){if(o+a>e){const t=(e-o)/a;return this.getCoord2D(s,i,r,n,t)}o+=a}}return null}offset(t,e,s,i,r){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 r=0;r<a;r++){const n=r===a-1?h?t[0]:null:t[r+1];if(o)if(n){const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t);const r=[l[0]-o[0],l[1]-o[1]];this.normalize(r);const a=r[0]*t[1]-r[1]*t[0],h=r[0]*t[0]+r[1]*t[1];if(0===a&&1===h){l=n;continue}if(a>=0==e<=0){if(h<1){const s=[t[0]-r[0],t[1]-r[1]];this.normalize(s);const n=Math.sqrt((1+h)/2);if(n>1/i){const t=-Math.abs(e)/n;c.push([l[0]-s[0]*t,l[1]-s[1]*t])}}}else switch(s){case ut.xw.Mitered:{const s=Math.sqrt((1+h)/2);if(s>0&&1/s<i){const i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=Math.abs(e)/s;c.push([l[0]-i[0]*n,l[1]-i[1]*n]);break}}case ut.xw.Bevelled:c.push([l[0]+r[1]*e,l[1]-r[0]*e]),c.push([l[0]+t[1]*e,l[1]-t[0]*e]);break;case ut.xw.Rounded:if(h<1){c.push([l[0]+r[1]*e,l[1]-r[0]*e]);const s=Math.floor(2.5*(1-h));if(s>0){const i=1/s;let n=i;for(let o=1;o<s;o++,n+=i){const s=[r[1]*(1-n)+t[1]*n,-r[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 ut.xw.Square:default:if(a<0)c.push([l[0]+(r[1]+r[0])*e,l[1]+(r[1]-r[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),i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=e/s;c.push([l[0]-i[0]*n,l[1]-i[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 Ve=ut.oF.OpenEnded;class qe{static local(){return null===qe.instance&&(qe.instance=new qe),qe.instance}execute(t,e,s,i,r){return new We(t,e,s)}}qe.instance=null;class We extends Be{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new Ue,this._width=(void 0!==e.width?e.width:5)*s,this._arrowType=void 0!==e.geometricEffectArrowType?e.geometricEffectArrowType:void 0!==e.arrowType?e.arrowType:Ve,this._offsetFlattenError=Ge*s}processPath(t){const e=Ie.createEmptyOptimizedCIM(t.geometryType);switch(this._arrowType){case ut.oF.OpenEnded:default:this._constructSimpleArrow(e,t,!0);break;case ut.oF.Block:this._constructSimpleArrow(e,t,!1);break;case ut.oF.Crossed:this._constructCrossedArrow(e,t)}return e}_constructSimpleArrow(t,e,s){const i=e.pathLength();let r=this._width;i<2*r&&(r=i/2);const n=this._curveHelper.getSubCurve(e,0,i-r);if(!n||!n.nextPath())return;n.seekPathStart();const o=r/2;if(this._curveHelper.isEmpty(n))return;const a=(0,ve.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 i=this._width;s<3.732050807568877*i&&(i=s/3.732050807568877),e.seekPathStart();const r=this._curveHelper.getSubCurve(e,0,s-2.732050807568877*i);if(!r)return;r.nextPath();const n=i/2;if(this._curveHelper.isEmpty(r))return;const o=(0,ve.A)(r),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-i);if(!c)return;if(c.nextPath(),this._curveHelper.isEmpty(c))return;const l=(0,ve.A)(c),u=this._constructOffset(l,n);if(!u)return;const d=this._constructOffset(l,-n);if(!d)return;const p=u[u.length-1],_=this._constructArrowBasePoint(u,n/2);if(!_)return;const f=d[d.length-1],m=this._constructArrowBasePoint(d,-n/2);if(!m)return;e.seekInPath(e.pathSize-1);const g=[e.x,e.y];t.pushPath(a),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(f),t.nextPoint(),t.setControlPoint(),t.pushPoint(m),t.nextPoint(),t.setControlPoint(),t.pushPoint(g),t.nextPoint(),t.setControlPoint(),t.pushPoint(_),t.nextPoint(),t.setControlPoint(),t.pushPoint(p),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.nextPoint(),t.setControlPoint(),t.reset()}_constructOffset(t,e){return this._curveHelper.offset(t,e,ut.xw.Rounded,4,this._offsetFlattenError)}_constructArrowBasePoint(t,e){if(!t||t.length<2)return null;const s=t[t.length-2],i=t[t.length-1],r=[i[0]-s[0],i[1]-s[1]];return this._curveHelper.normalize(r),[i[0]+r[1]*e,i[1]-r[0]*e]}}s(59456);class Ye{static local(){return null===Ye.instance&&(Ye.instance=new Ye),Ye.instance}execute(t,e,s,i,r,n){return new je(t,e,s,i,r,n)}}Ye.instance=null;class je{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new Ue,this._size=(void 0!==e.size?e.size:1)*s,this._maxInflateSize=n*s,this._offsetFlattenError=Ge*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=Ie.createEmptyOptimizedCIM(t.geometryType),s=(0,ve.x)(t)[0],i=this._curveHelper.offset(s,this._size,ut.xw.Rounded,4,this._offsetFlattenError);if(i)return e.pushPath(i),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 Ie.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._tileKey?ze(t,this._maxInflateSize):t;if(!s)continue;const i=e.buffer(q.A.WebMercator,s.asJSON(),this._size,1);return i?Ie.fromJSONCIM(i):null}return null}}class Xe{static local(){return null===Xe.instance&&(Xe.instance=new Xe),Xe.instance}execute(t,e,s,i,r){return new $e(t,e,s)}}Xe.instance=null;class $e{constructor(t,e,s){this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=e.rule??ut.uQ.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){const e=this._processGeom((0,ve.x)(t));if(e?.length)return Ie.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,i){return[t[0]*e+s[0]*i,t[1]*e+s[1]*i]}_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 i=t[0]*e-t[1]*s,r=t[0]*s+t[1]*e;t[0]=i,t[1]=r}_makeCtrlPt(t){const e=[t[0],t[1]];return Ne(e,1),e}_addAngledTicks(t,e,s,i){const r=this._sub(s,e);this._normalize(r);const n=this._crossProduct(r,this._sub(i,e));let o;o=n>0?this._rightPerp(r):this._leftPerp(r);const a=Math.abs(n)/2,h=[];h.push([e[0]+(o[0]-r[0])*a,e[1]+(o[1]-r[1])*a]),h.push(e),h.push(s),h.push([s[0]+(o[0]+r[0])*a,s[1]+(o[1]+r[1])*a]),t.push(h)}_addBezier2(t,e,s,i,r){if(0==r--)return void t.push(i);const n=this._mid(e,s),o=this._mid(s,i),a=this._mid(n,o);this._addBezier2(t,e,n,a,r),this._addBezier2(t,a,o,i,r)}_addBezier3(t,e,s,i,r,n){if(0==n--)return void t.push(r);const o=this._mid(e,s),a=this._mid(s,i),h=this._mid(i,r),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,r,n)}_add90DegArc(t,e,s,i,r){const n=r??this._crossProduct(this._sub(s,e),this._sub(i,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 i=e[0],r=e[1],n=e[e.length-1],o=this._sub(i,r),a=this._norm(o);this._normalize(o);const h=Math.abs(this._crossProduct(o,this._sub(n,r)));let c=this._dotProduct(o,this._sub(n,r));c<.05*a?c=.05*a:c>.95*a&&(c=.95*a);const l=.5*h,u=this._leftPerp(o),d=[r[0]+o[0]*c,r[1]+o[1]*c],p=e.length-1,_=[];_.push(s?[-u[0],-u[1]]:u);let f=[-o[0],-o[1]];for(let t=1;t<p-1;t++){const s=this._sub(e[t+1],e[t]);this._normalize(s);const i=this._dotProduct(s,f),r=this._crossProduct(s,f),n=Math.sqrt((1+i)/2),o=this._sub(s,f);this._normalize(o),o[0]/=n,o[1]/=n,_.push(r<0?[-o[0],-o[1]]:o),f=s}_.push(this._rightPerp(f));for(let s=_.length-1;s>0;s--)t.push([e[s][0]+_[s][0]*l,e[s][1]+_[s][1]*l]);t.push([d[0]+_[0][0]*l,d[1]+_[0][1]*l]),t.push([d[0]+_[0][0]*h,d[1]+_[0][1]*h]),t.push(i),t.push([d[0]-_[0][0]*h,d[1]-_[0][1]*h]),t.push([d[0]-_[0][0]*l,d[1]-_[0][1]*l]);for(let s=1;s<_.length;s++)t.push([e[s][0]-_[s][0]*l,e[s][1]-_[s][1]*l])}_cp2(t,e,s){return t.length>=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,i){if(t.length>=3)return t[2];const r=this._mix(t[0],1-s,e,s),n=this._sub(e,t[0]);return this._normalize(n),this._rightPerpendicular(n),[r[0]+n[0]*i*this._defaultSize,r[1]+n[1]*i*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),i=this._sub(e,s);this._normalize(i);const r=this._rightPerp(i);return[e,s,[e[0]+(r[0]-i[0])*this._defaultSize,e[1]+(r[1]-i[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let i;if(t.length>=3)i=t[t.length-1];else{const t=this._sub(e,s);this._normalize(t);const r=this._rightPerp(t);i=[e[0]+(r[0]-t[0])*this._defaultSize,e[1]+(r[1]-t[1])*this._defaultSize]}return[s,i]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){if(!s||0===s.length)continue;const t=s.length;let i=s[0];switch(this._rule){case ut.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 ut.uQ.ReversedFirstSegment:{const t=this._cp2(s,0,-1);e.push([t,i]);break}case ut.uQ.PerpendicularToSecondSegment:{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 ut.uQ.SecondSegmentWithTicks:{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 ut.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 ut.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 ut.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 ut.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 ut.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 ut.uQ.HalfCircleExtended:{const r=this._cp2(s,0,-2),n=this._cp3(s,r,1,-1);let o;if(t>=4)o=s[3];else{const t=this._sub(i,r);o=this._add(n,t)}const a=this._dist(r,n)/2/.75,h=this._sub(r,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(r,h),r,4),u.push(i),e.push(u);break}case ut.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 ut.uQ.CoverageEdgesWithTicks:{const r=this._cp2(s,0,-1);let n,o;if(t>=3)n=s[2];else{const t=this._sub(r,i),e=this._leftPerp(t);n=[i[0]+e[0]-.25*t[0],i[1]+e[1]-.25*t[1]]}if(t>=4)o=s[3];else{const t=this._mid(i,r),e=this._sub(i,r);this._normalize(e),this._leftPerpendicular(e);const s=this._crossProduct(e,this._sub(n,t));this._rightPerpendicular(e),o=[n[0]+e[0]*s*2,n[1]+e[1]*s*2]}const a=this._sub(r,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,r))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push([r[0]+(h[0]+a[0])/3,r[1]+(h[1]+a[1])/3]),c.push(r),c.push(o),e.push(c);break}case ut.uQ.GapExtentWithDoubleTicks:{const r=this._cp2(s,0,2),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}this._addAngledTicks(e,i,r,this._mid(n,o)),this._addAngledTicks(e,n,o,this._mid(i,r));break}case ut.uQ.GapExtentMidline:{const r=this._cp2(s,2,0),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}const a=[];a.push(this._mid(i,n)),a.push(this._mid(r,o)),e.push(a);break}case ut.uQ.Chevron:{const r=this._cp2(s,-1,-1);let n;if(t>=3)n=s[2];else{const t=this._sub(r,i);this._leftPerpendicular(t),n=this._add(i,t)}e.push([r,this._makeCtrlPt(i),n]);break}case ut.uQ.PerpendicularWithArc:{const r=this._cp2(s,0,-2),n=this._cp3(s,r,.5,-1),o=this._sub(r,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),t>=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 p=[r[0]+u[0]*h,r[1]+u[1]*h];u=this._sub(r,p);const _=Math.cos(Math.PI/18);let f=Math.sin(Math.PI/18);h<0&&(f=-f),d=[i,r];for(let t=1;t<=9;t++)this._rotateDirect(u,_,f),d.push(this._add(p,u));e.push(d);break}case ut.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 ut.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]),Ne(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 ut.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 ut.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 ut.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 ut.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 ut.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 ut.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 ut.uQ.CircleWithArc:{let r=this._cp2(s,3,0);const n=this._cp3(s,r,.5,-1);let o,a;if(t>=4)o=s[3],a=this._crossProduct(this._sub(o,r),this._sub(n,r))>0;else{o=r,a=this._crossProduct(this._sub(o,i),this._sub(n,i))>0;const t=24*this._geomUnitsPerPoint,e=this._sub(o,i);this._normalize(e,t);const s=Math.sqrt(2)/2;this._rotateDirect(e,s,a?s:-s),r=this._add(i,e)}const h=this._sub(r,i),c=Math.cos(Math.PI/18),l=Math.sin(Math.PI/18),u=[r];for(let t=1;t<=36;t++)this._rotateDirect(h,c,l),u.push(this._add(i,h));this._add90DegArc(u,r,o,n,a),Ne(u[u.length-8],1),e.push(u);break}case ut.uQ.DoubleJog:{let r,n=this._cp2(s,-3,1),o=this._cp3(s,n,-1,-.5);if(t>=4)r=s[3];else{const t=i;i=n,r=o;const e=this._dist(i,t),s=this._dist(r,t);let a=30*this._geomUnitsPerPoint;.5*e<a&&(a=.5*e),.5*s<a&&(a=.5*s),n=this._mix(i,a/e,t,(e-a)/e),o=this._mix(r,a/s,t,(s-a)/s)}const a=this._mid(i,n),h=this._mid(r,o),c=this._dist(i,n),l=this._dist(o,r);let u=Math.min(c,l)/8;u=Math.min(u,24*this._geomUnitsPerPoint);const d=Math.cos(Math.PI/4);let p=this._sub(i,n);this._normalize(p,u),this._crossProduct(p,this._sub(r,n))>0?this._rotateDirect(p,d,-d):this._rotateDirect(p,d,d);let _=[];_.push(n),_.push(this._add(a,p)),_.push(this._sub(a,p)),_.push(i),e.push(_),p=this._sub(r,o),this._normalize(p,u),this._crossProduct(p,this._sub(i,o))<0?this._rotateDirect(p,d,d):this._rotateDirect(p,d,-d),_=[],_.push(o),_.push(this._add(h,p)),_.push(this._sub(h,p)),_.push(r),e.push(_);break}case ut.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 ut.uQ.LineExcludingLastSegment:{const t=this._arrowPath(s),i=[];let r=t.length-2;for(;r--;)i.push(t[r]);e.push(i);break}case ut.uQ.MultivertexArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!1),e.push(i);break}case ut.uQ.CrossedArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!0),e.push(i);break}case ut.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 ut.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 ut.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 ut.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 ut.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],i=[this._clone(s)];i.push(this._add(s,[n[0]/4,n[1]/4])),e.push(i)}break}case ut.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 ut.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 p=[];p.push([u[0]+l[0]*(h+d)-o[0]*d,u[1]+l[1]*(h+d)-o[1]*d]),p.push([u[0]+l[0]*h,u[1]+l[1]*h]),p.push([u[0]-l[0]*h,u[1]-l[1]*h]),p.push([u[0]-l[0]*(h+d)-o[0]*d,u[1]-l[1]*(h+d)-o[1]*d]),e.push(p),e.push([u,i]);break}case ut.uQ.FullGeometry:default:e.push(s)}}return e}}class He{static local(){return null===He.instance&&(He.instance=new He),He.instance}execute(t,e,s,i,r){return new Ze(t,e,s)}}He.instance=null;class Ze extends Be{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new Ue,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:i}=this,r=t.pathLength(),n=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==e||0!==s||0!==i)if(e+s+i>=r)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*(r-i),.5*(r+i)),this._curveHelper.appendSubCurve(n,t,r-s,s)}else if(0===e&&0===s&&0===i)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else e+s+i<r&&(0===i?this._curveHelper.appendSubCurve(n,t,e,r-s):(this._curveHelper.appendSubCurve(n,t,e,.5*(r-i)),this._curveHelper.appendSubCurve(n,t,.5*(r+i),r-s)));return 0===n.totalSize?null:n}}var Qe,Ke=s(95108);class Je{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 i=Math.abs(t[e]);s&&i<1e-7&&(i=1e-7),this._values.push(i),this._length+=i}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 ts{constructor(){this.pt=null,this.ca=0,this.sa=0}}!function(t){t[t.FAIL=0]="FAIL",t[t.END=1]="END",t[t.CONTINUE=2]="CONTINUE"}(Qe||(Qe={}));class es{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 ss extends Ue{constructor(t=0,e=!1){super(t,e),this._tolerance=Ge,this._currentPosition=new es}updateTolerance(t){this._tolerance=Ge*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=Qe.FAIL){const s=new es;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=Qe.FAIL){const i=new es;if(!this._nextPosition(t,i,null,s))return!1;i.copyTo(this._currentPosition),e.pt=this._getPoint(i);const[r,n]=this._getAngleCS(i);return e.ca=r,e.sa=n,!0}nextCurve(t){if(0===t)return null;const e=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");e.startPath(),e.nextPath();const s=new es;return this._nextPosition(t,s,e,Qe.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,i){if(this._currentPosition.isPathEnd)return!1;let r=this._currentPosition.abscissa;for(this._currentPosition.segmentLength>0&&(r/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(0===s.pathSize)if(0===r){const t=e.segment[0];s.pushXY(t[0],t[1])}else s.pushPoint(this.getSegCoord2D(e.segment,r));const t=e.segment[1];s.pushXY(t[0],t[1])}if(r=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 i!==Qe.FAIL&&(e.segmentLength=this.getSegLength(e.segment),e.isPartEnd=!0,i===Qe.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===r?s.pushPoint(e.segment[0]):s.pushPoint(this.getSegCoord2D(e.segment,r)));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 is=s(93397);class rs{static local(){return null===rs.instance&&(rs.instance=new rs),rs.instance}execute(t,e,s,i,r){return new ns(t,e,s,i)}}rs.instance=null;class ns extends Be{constructor(t,e,s,i){super(t,!0,!0),this._firstCurve=null,this._walker=new ss,this._walker.updateTolerance(s),this._endings=e.lineDashEnding,this._customDashPos=-(e.offsetAlongLine??0)*s,this._offsetAtEnd=(e.customEndingOffset??0)*s,this._tileKey=i;let r=(0,is.K3)(e).dashTemplate;r.length%2&&(r=[...r,...r]);let n=0;for(let t=0;t<r.length;t++){let e=Math.abs(r[t]);e<1e-7&&(e=1e-7),n+=e}this._patternLength=n,this._numOfDashesPerPattern=r.length/2,this._pattern=new Je,this._pattern.init(r,!0),this._pattern.scale(s)}processPath(t){if(0===this._pattern.length()){this.iteratePath=!1;const e=(0,ve.A)(t);return Ie.fromJSONCIM({paths:[e]})}if(!this.iteratePath){let e=!0;switch(this._endings){case ut.yS.HalfPattern:case ut.yS.HalfGap:default:this._pattern.extPtGap=0;break;case ut.yS.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case ut.yS.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case ut.yS.NoConstraint:this.isClosed||(e=!1);break;case ut.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,ve.A)(t);return Ie.fromJSONCIM({paths:[e]})}if(!this._walker.init(t,this._pattern,e)){const e=(0,ve.A)(t);return Ie.fromJSONCIM({paths:[e]})}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case ut.yS.HalfPattern:default:t=.5*this._pattern.firstValue();break;case ut.yS.HalfGap:t=.5*-this._pattern.lastValue();break;case ut.yS.FullGap:t=-this._pattern.lastValue();break;case ut.yS.FullPattern:t=0;break;case ut.yS.NoConstraint:case ut.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 i=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),i=!i;e-=t,i?(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}isClippingRequired(t){const e=(0,ve.x)(t);let s=0;for(const t of e)s+=(0,Ke.Yl)(t);return Math.round(this._numOfDashesPerPattern*(s/this._patternLength))>1e3}}class os{static local(){return null===os.instance&&(os.instance=new os),os.instance}execute(t,e,s,i,r,n){return new as(t,e,s,i,r,n)}}os.instance=null;class as{constructor(t,e,s,i,r,n){switch(this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._maxInflateSize=n*s,this._width=(void 0!==e.width?e.width:2)*s,e.method){case ut.M1.Mitered:case ut.M1.Bevelled:case ut.M1.Rounded:case ut.M1.TrueBuffer:case ut.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:Ie.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._tileKey?ze(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.buffer(q.A.WebMercator,s.asJSON(),-this._width,1);if(i)for(const t of i.rings)if(t){s.startPath();for(const e of t.reverse())s.pushXY(e[0],s.yFactor*e[1])}return s}}return null}}class hs{static local(){return null===hs.instance&&(hs.instance=new hs),hs.instance}execute(t,e,s,i,r){return new cs(t,e,s)}}hs.instance=null;class cs extends Be{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new Ue,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=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._curveHelper.isEmpty(t))return null;t.seekInPath(0);const s=t.x,i=t.y;t.seekInPath(t.pathSize-1);const r=t.x,n=t.y,o=[r-s,n-i];this._curveHelper.normalize(o);const a=s+(r-s)*this._position/100,h=i+(n-i)*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,i],u,d,[r,n]]),e}}class ls{static local(){return null===ls.instance&&(ls.instance=new ls),ls.instance}execute(t,e,s,i,r){return new us(t,e,s)}}ls.instance=null;class us{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 ds{static local(){return null===ds.instance&&(ds.instance=new ds),ds.instance}execute(t,e,s,i,r,n){return new ps(t,e,s,i,r,n)}}ds.instance=null;class ps{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new Ue,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=Ge*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._offset)return t.clone();if("esriGeometryEnvelope"===t.geometryType){if(this._method===ut.xw.Rounded&&this._offset>0){const e=(0,ve.A)(t),s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=Ie.createEmptyOptimizedCIM(t.geometryType);return e.pushPath(s),e}return null}const e=t.asJSON();if((0,Se.ZC)(e)&&Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._offset>0)return Ie.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._tileKey?ze(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.offset(q.A.WebMercator,s.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return i?Ie.fromJSONCIM(i):null}return null}}class _s{static local(){return null===_s.instance&&(_s.instance=new _s),_s.instance}execute(t,e,s,i,r){return new fs(t,e,s)}}_s.instance=null;class fs{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 ms(t.clone());t=this._inputGeometries.next()}return null}}function ms(t){for(;t.nextPath();)for(let e=0;e<t.pathSize/2;e++){t.seekInPath(e);const s=t.x,i=t.y;t.seekInPath(t.pathSize-e-1);const r=t.x,n=t.y;t.x=s,t.y=i,t.seekInPath(e),t.x=r,t.y=n}return t.reset(),t}var gs=s(537);class ys{static local(){return null===ys.instance&&(ys.instance=new ys),ys.instance}execute(t,e,s,i,r){return new xs(t,e,s)}}ys.instance=null;class xs{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,gs.z8)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._rotate(t.clone(),s,i)}t=this._inputGeometries.next()}return null}_rotate(t,e,s){const i=Math.cos(this._rotateAngle),r=Math.sin(this._rotateAngle);for(;t.nextPath();)for(;t.nextPoint();){const n=t.x-e,o=t.y-s;t.x=e+n*i-o*r,t.y=s+n*r+o*i}return t.reset(),t}}class bs{static local(){return null===bs.instance&&(bs.instance=new bs),bs.instance}execute(t,e,s,i,r){return new ws(t,e,s)}}bs.instance=null;class ws{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,gs.z8)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._scaleCursor(t.clone(),s,i)}}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 vs{static local(){return null===vs.instance&&(vs.instance=new vs),vs.instance}execute(t,e,s,i,r){return new Ss(t,e,s)}}vs.instance=null;class Ss{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 Je,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new ss,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=Ie.createEmptyOptimizedCIM(t.geometryType);for(;t.nextPath();){e.startPath();const s=t.pathLength();if(this._walker.init(t,this._pattern))switch(this._style){case ut.WE.Sinus:default:this._constructCurve(e,s,!1);break;case ut.WE.Square:this._constructSquare(e,s);break;case ut.WE.Triangle:this._constructTriangle(e,s);break;case ut.WE.Random:this._constructCurve(e,s,!0)}else for(;t.nextPoint();)e.pushXY(t.x,t.y)}return e}_constructCurve(t,e,s){let i=Math.round(e/this._period);0===i&&(i=1);const r=16*i+1,n=e/i,o=this._period/16,a=1/r,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,p=.75-Math.random()/2,_=new ts;this._walker.curPointAndAngle(_),t.pushPoint(_.pt);let f=0;for(;;){if(!this._walker.nextPointAndAngle(o,_)){t.pushPoint(this._walker.getPathEnd());break}{const e=f;let i;if(f+=a,s){const t=this._height/2*(1+.3*Math.sin(d*h*e+c));i=t*Math.sin(h*e+l),i+=t*Math.sin(p*h*e+u),i/=2}else i=.5*this._height*Math.sin(.5*h*e);t.pushXY(_.pt[0]-i*_.sa,_.pt[1]+i*_.ca)}}}_constructSquare(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const i=new ts;this._walker.curPointAndAngle(i);const r=new ts;if(this._walker.nextPointAndAngle(this._period,r)){const n=new ts;this._walker.nextPointAndAngle(this._period,n)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(r.pt[0]+this._height/2*r.sa,r.pt[1]-this._height/2*r.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 i=new ts;this._walker.curPointAndAngle(i);const r=new ts;if(this._walker.nextPointAndAngle(this._period/2,r)){const n=new ts;this._walker.nextPointAndAngle(this._period,n)&&(this._walker.nextPosition(this._period/2)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.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 Is{static local(){return null===Is.instance&&(Is.instance=new Is),Is.instance}execute(t,e,s,i,r){return new Ps(t,e,s)}}Is.instance=null;class Ps extends De{constructor(t,e,s){super(t),this._geometryWalker=new ss,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 Je,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===ut.e_.WithFullGap&&this.isClosed?this._endings=ut.e_.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let s,i=!0;switch(this._endings){case ut.e_.NoConstraint:s=-this._position,s=this._adjustPosition(s),i=!1;break;case ut.e_.WithHalfGap:default:s=-this._pattern.lastValue()/2;break;case ut.e_.WithFullGap:s=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case ut.e_.WithMarkers:s=0;break;case ut.e_.Custom:s=-this._position,s=this._adjustPosition(s),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,i))return null;this._pattern.reset();let r=0;for(;s>r;)s-=r,r=this._pattern.nextValue();r-=s,e=r,this.iteratePath=!0}const s=new ts;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===ut.e_.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===ut.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 Ms{static local(){return null===Ms.instance&&(Ms.instance=new Ms),Ms.instance}execute(t,e,s,i,r){return new Ts(t,e,s)}}Ms.instance=null;class Ts extends De{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new Ue,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 ut.$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 ut.$2.JustBegin:e=this._atExtremities(t,this._position,!0);break;case ut.$2.JustEnd:e=this._atExtremities(t,this._position,!1);case ut.$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 i=0,[r,n]=[0,0],[o,a]=[t.x,t.y];for(;s?t.nextPoint():t.prevPoint();){r=o,n=a,o=t.x,a=t.y;const s=this._curveHelper.getLength(r,n,o,a);if(i+s>e){const t=(e-i)/s,[h,c]=this._curveHelper.getAngleCS(r,n,o,a,t),l=this._curveHelper.getCoord2D(r,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}i+=s}}return null}}class Cs{static local(){return null===Cs.instance&&(Cs.instance=new Cs),Cs.instance}execute(t,e,s,i,r){return new As(t,e,s)}}Cs.instance=null;class As extends De{constructor(t,e,s){super(t),this._walker=new ss,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 Je,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,i=this._beginGap+s;e=i-this._prevPos,this._prevPos=i,this.iteratePath=!0}const s=new ts;if(!this._walker.nextPointAndAngle(e,s,Qe.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const i=this._isFirst&&this._flipFirst;let r,n;return this._angleToLine?(r=s.ca,n=s.sa):(r=1,n=0),i&&(r=-r,n=-n),this.internalPlacement.setRotateCS(r,n),this._isFirst=!1,this._posCount--,0===this._posCount&&(this.iteratePath=!1),this.internalPlacement}}const Es=512,Fs=24,ks=1e-6;class zs{static local(){return null===zs.instance&&(zs.instance=new zs),zs.instance}execute(t,e,s,i,r){return new Os(t,e,s,i,r)}}zs.instance=null;class Os{constructor(t,e,s,i,r){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??ut.Q1.Fixed,this._gridType===ut.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!=i){const[t,e,s,r]=i.split("/"),n=parseFloat(t),o=parseFloat(e),a=parseFloat(s),h=parseFloat(r);this._graphicOriginX=-(h*2**n+a)*Es,this._graphicOriginY=o*Es,this._testInsidePolygon=!0}this._internalPlacement=new Le,this._calculateMinMax(t),this._geometryCursor=t}}next(){return this._geometryCursor?this._nextInside():null}_buildRandomValues(){if(!Os._randValues){Os._randValues=[];for(let t=0;t<Fs;t++)for(let t=0;t<Fs;t++)Os._randValues.push(this._randomLCG.getFloat()),Os._randValues.push(this._randomLCG.getFloat())}}_calculateMinMax(t){let e,s,i,r,n,o,a,h,c,l,u,d,p,_;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=h=p=u=Number.MAX_VALUE,c=l=_=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?(i=this._cosAngle*e-this._sinAngle*s,r=this._sinAngle*e+this._cosAngle*s):(i=e,r=s),a=Math.min(a,i),c=Math.max(c,i),h=Math.min(h,r),l=Math.max(l,r),u=Math.min(u,n),d=Math.max(d,n),p=Math.min(p,o),_=Math.max(_,o);u=u!==Number.MAX_VALUE?u:-512-this._stepY,d=d!==-Number.MAX_VALUE?d:this._stepY,p=p!==Number.MAX_VALUE?p:-this._stepX,_=_!==-Number.MAX_VALUE?_:Es+this._stepX;const m=d-u,g=_-p;if(this._verticalSubdivision=m>=g,this._polygonMin=this._verticalSubdivision?u:p,this._testInsidePolygon){let t=0-this._graphicOriginX-this._offsetX-this._stepX,e=Es-this._graphicOriginX-this._offsetX+this._stepX,s=-512-this._graphicOriginY-this._offsetY-this._stepY,i=0-this._graphicOriginY-this._offsetY+this._stepY;if(f){const r=[[t,s],[t,i],[e,s],[e,i]];t=s=Number.MAX_VALUE,e=i=-Number.MAX_VALUE;for(const n of r){const r=this._cosAngle*n[0]-this._sinAngle*n[1],o=this._sinAngle*n[0]+this._cosAngle*n[1];t=Math.min(t,r),e=Math.max(e,r),s=Math.min(s,o),i=Math.max(i,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,i):i}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,i,r){t.reset();const n=new Map,o=this._verticalSubdivision,a=o?r-i:s-e;let h=Math.ceil(a/10);if(h<=1)return;const c=Math.floor(a/h);let l,u,d,p,_,f,m,g,y,x,b;for(h++,this._delta=c,o?(y=-512-2*this._stepY,x=2*this._stepY,b=i):(y=-2*this._stepX,x=Es+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=p){if(d=t.x,p=t.y,o){if(u===p||u<y&&p<y||u>x&&p>x)continue;_=Math.min(u,p),f=Math.max(u,p)}else{if(l===d||l<y&&d<y||l>x&&d>x)continue;_=Math.min(l,d),f=Math.max(l,d)}for(;_<f;)m=Math.floor((_-b)/c),Rs(m,l,u,d,p,n),_+=c;g=Math.floor((f-b)/c),g>m&&Rs(g,l,u,d,p,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,i;if(this._currentX++,this._gridType===ut.Q1.Random){const r=(this._currentX%Fs+Fs)%Fs,n=(this._currentY%Fs+Fs)%Fs;s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-Os._randValues[n*Fs+r])*2/3,i=this._graphicOriginY+e+this._stepY*this._randomness*(.5-Os._randValues[n*Fs+r+1])*2/3}else s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,i=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e;if(!this._testInsidePolygon||this._isInsidePolygon(s,i,this._geometryCursor))return this._internalPlacement.setTranslate(s,i),this._internalPlacement}}_isInsidePolygon(t,e,s){if(null==this._accelerationMap)return function(t,e,s){let i,r,n,o,a=0;for(t+=ks,e+=ks,s.reset();s.nextPath();)if(s.nextPoint())for(i=s.x,r=s.y;s.nextPoint();i=n,r=o)n=s.x,o=s.y,r>e!=o>e&&((n-i)*(e-r)-(o-r)*(t-i)>0?a++:a--);return 0!==a}(t,e,s);t+=ks,e+=ks;const i=this._verticalSubdivision,r=i?e:t,n=Math.floor((r-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],i){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 Rs(t,e,s,i,r,n){let o=n.get(t);o||(o=[],n.set(t,o)),o.push([[e,s],[i,r]])}class Ls{static local(){return null===Ls.instance&&(Ls.instance=new Ls),Ls.instance}execute(t,e,s,i,r){return new Ns(t,e,s)}}Ls.instance=null;class Ns extends De{constructor(t,e,s){super(t),this._curveHelper=new Ue,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===ut.ip.SegmentMidpoint){if(this.iteratePath||(this.iteratePath=!0),t.nextPoint()){let[e,s]=[t.x,t.y],[i,r]=[0,0];for(;t.nextPoint();){i=t.x,r=t.y;const n=this._curveHelper.getLength(e,s,i,r);if(n<this._epsilon){e=i,s=r;continue}const o=.5+this._position/n,[a,h]=this._curveHelper.getAngleCS(e,s,i,r,o),c=this._curveHelper.getCoord2D(e,s,i,r,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===ut.ip.LineEnd;return this.onLine(t,e,s)}onLine(t,e,s){let i,r=!1;switch(this._relativeTo){case ut.ip.LineMiddle:default:t.seekPathStart(),i=t.pathLength()/2+e;break;case ut.ip.LineBeginning:i=e;break;case ut.ip.LineEnd:i=e,r=!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>i){const t=(i-n)/s,[c,l]=this._curveHelper.getAngleCS(e,o,a,h,t),u=this._curveHelper.getCoord2D(e,o,a,h,t),d=r?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-d*l,u[1]+d*c),this._angleToLine&&(r?this.internalPlacement.setRotateCS(-c,-l):this.internalPlacement.setRotateCS(c,l)),this.internalPlacement}e=a,o=h,n+=s}}return null}}class Ds{static local(){return null===Ds.instance&&(Ds.instance=new Ds),Ds.instance}execute(t,e,s,i,r){return new Bs(t,e,s)}}Ds.instance=null;class Bs extends De{constructor(t,e,s){super(t),this._curveHelper=new Ue,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],i=e[1];if(0!==this._offset){const t=Math.cos(e[2]),r=Math.sin(e[2]);s-=this._offset*r,i+=this._offset*t}return this.internalPlacement.setTranslate(s,i),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0,t.seekPathStart();const e=t.isClosed();let s=0,i=!1,r=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,p=t.getControlPoint();(this._angleToLine||0!==this._offset)&&(r=this._curveHelper.getAngle(o,a,u,d,0)),c?(c=!1,e?(s=r,i=h):(this._endPoints||this._controlPoints&&h)&&this._tags.push([o,a,r])):h?this._controlPoints&&this._tags.push([o,a,Gs(n,r)]):this._regularVertices&&this._tags.push([o,a,Gs(n,r)]),(this._angleToLine||0!==this._offset)&&(n=this._curveHelper.getAngle(o,a,u,d,1)),l=t.nextPoint(),l||(e?p||i?this._controlPoints&&this._tags.push([u,d,Gs(n,s)]):this._regularVertices&&this._tags.push([u,d,Gs(n,s)]):(this._endPoints||this._controlPoints&&p)&&this._tags.push([u,d,n])),o=u,a=d,h=p}}this._tagIterator=0}}function Gs(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),Vs=s(12176);function qs(t){if(0===t.totalSize)return null;const e=(0,gs.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 i=0,r=0;t.reset();for(let e=0;t.nextPath();e++){const s=t.getCurrentRingArea();s>r&&(r=s,i=e)}if(t.seekPath(i),0===t.pathSize)return null;t.seekPathStart();const n=(0,gs.B$)(t);if(Math.abs(r)<=2*s*s)return[(n[0]+n[2])/2,(n[1]+n[3])/2];t.seekPathStart();const o=(0,Us.w2)(t,(0,D.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=Ys(o,t,!0);0===u.distance&&(l=!0,a[0][0]=o[0],a[0][1]=o[1],u=Ys(o,t,!1)),h[0]=u.distance,c[0]=0;const d=[NaN,NaN];let p=!1,_=.25,f=-1,m=NaN;do{if(m=NaN,a[1]=js(t,ti(n[0],n[2],_),0,e),isNaN(a[1][0])||isNaN(a[1][1])||(u=Ys(a[1],t,!1),m=u.distance),!isNaN(m)&&m>s&&Ws(a[1],t))p=!0,h[1]=m,c[1]=ei(a[1],o);else if(!isNaN(m)&&m>f&&(f=m,d[0]=a[1][0],d[1]=a[1][1]),_-=.01,_<.1){if(!(f>=0))break;p=!0,h[1]=f,a[1][0]=d[0],a[1][1]=d[1],c[1]=ei(a[1],o)}}while(!p);p=!1,_=.5,f=-1;let g=.01,y=1;do{if(m=NaN,a[2]=js(t,ti(n[0],n[2],_),0,e),isNaN(a[2][0])||isNaN(a[2][1])||(u=Ys(a[2],t,!1),m=u.distance),!isNaN(m)&&m>s&&Ws(a[2],t))p=!0,h[2]=m,c[2]=ei(a[2],o);else if(!isNaN(m)&&m>f)f=m,d[0]=a[2][0],d[1]=a[2][1];else if(m>f&&(f=m,d[0]=a[2][0],d[1]=a[2][1]),_=.5+g*y,g+=.01,y*=-1,_<.3||_>.7){if(!(f>=0))break;p=!0,h[2]=f,a[2][0]=d[0],a[2][1]=d[1],c[2]=ei(a[2],o)}}while(!p);p=!1,_=.75,f=-1;do{if(m=NaN,a[3]=js(t,ti(n[0],n[2],_),0,e),isNaN(a[3][0])||isNaN(a[3][1])||(u=Ys(a[3],t,!1),m=u.distance),!isNaN(m)&&m>s&&Ws(a[3],t))p=!0,h[3]=m,c[3]=ei(a[3],o);else if(m>f&&(f=m,d[0]=a[3][0],d[1]=a[3][1]),_+=.01,_>.9){if(!(f>=0))break;p=!0,h[3]=f,a[3][0]=d[0],a[3][1]=d[1],c[3]=ei(a[3],o)}}while(!p);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];si(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 Ws(t,e){let s,i,r,n,o=0;for(e.reset();e.nextPath()&&e.nextPoint();)for(s=e.x,i=e.y;e.nextPoint();s=r,i=n)r=e.x,n=e.y,i>t[1]!=n>t[1]&&((r-s)*(t[1]-i)-(n-i)*(t[0]-s)>0?o++:o--);return 0!==o}function Ys(t,e,s){if(s&&Ws(t,e))return{coord:t,distance:0};let i=1/0,r=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,Ke.gR)(h,t,o,a);const s=ei(t,h);s<i&&(i=s,r=h[0],n=h[1])}return{coord:[r,n],distance:Math.sqrt(i)}}function js(t,e,s,i){const r=[e,0];let n=1/0,o=1/0,a=!1,h=!1;const c=[[e,i[1]-1],[e,i[3]+1]],l=[0,0],u=[0,0],d=[0,0],p=[[0,0],[0,0]],_=(0,D.vt)();for(t.reset();t.nextPath()&&t.nextPoint();)if(!(t.pathSize<2))for(p[0][0]=t.x,p[0][1]=t.y;t.nextPoint();p[0][0]=p[1][0],p[0][1]=p[1][1]){if(p[1][0]=t.x,p[1][1]=t.y,null===Xs(_,p))continue;if(u[0]=c[0][0],u[1]=c[0][1],d[0]=c[1][0],d[1]=c[1][1],0===Ks(_,u,d))continue;if(!(0,Vs.Ql)(c[0],c[1],p[0],p[1],l))continue;const e=l[1];n>o?e<n&&(n=e,a=!0):e<o&&(o=e,h=!0)}return a&&h?r[1]=(n+o)/2:r[0]=r[1]=NaN,r}function Xs(t,e){if(e.length<2)return null;t||(t=(0,D.vt)());const[s,i]=e[0],[r,n]=e[1];return t[0]=Math.min(s,r),t[1]=Math.min(i,n),t[2]=Math.max(s,r),t[3]=Math.max(i,n),t}const $s=1,Hs=4,Zs=3,Qs=12;function Ks(t,e,s){let i=Js(e,t),r=Js(s,t);const n=t[0],o=t[1],a=t[2],h=t[3];if(i&r)return 0;if(!(i|r))return 4;const c=(i?1:0)|(r?2:0);do{const c=s[0]-e[0],l=s[1]-e[1];if(c>l)i&Zs?(i&$s?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Js(e,t)):r&Zs?(r&$s?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Js(s,t)):i?(i&Hs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Js(e,t)):(r&Hs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Js(s,t));else if(i&Qs?(i&Hs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Js(e,t)):r&Qs?(r&Hs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Js(s,t)):i?(i&$s?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Js(e,t)):(r&$s?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Js(s,t)),i&r)return 0}while(i|r);return c}function Js(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 ti(t,e,s){return t+(e-t)*s}function ei(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])}function si(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;const s=isNaN(t),i=isNaN(e);return s<i?-1:s>i?1:0}class ii{static local(){return null===ii.instance&&(ii.instance=new ii),ii.instance}execute(t,e,s,i,r){return new ri(t,e,s)}}ii.instance=null;class ri{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:ut.YI.OnPolygon,this._internalPlacement=new Le}next(){const t=this._geometryCursor;return this._geometryCursor=null,t?this._polygonCenter(t):null}_polygonCenter(t){let e=!1;switch(this._method){case ut.YI.CenterOfMass:{const s=(0,Us.TP)(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case ut.YI.BoundingBoxCenter:{const s=(0,gs.z8)(t);s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case ut.YI.OnPolygon:default:{const s=qs(t);null!==s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function ni(t){if(!t)return null;switch(t.type){case"CIMGeometricEffectAddControlPoints":return Oe.local();case"CIMGeometricEffectArrow":return qe.local();case"CIMGeometricEffectBuffer":return Ye.local();case"CIMGeometricEffectControlMeasureLine":return Xe.local();case"CIMGeometricEffectCut":return He.local();case"CIMGeometricEffectDashes":return rs.local();case"CIMGeometricEffectDonut":return os.local();case"CIMGeometricEffectJog":return hs.local();case"CIMGeometricEffectMove":return ls.local();case"CIMGeometricEffectOffset":return ds.local();case"CIMGeometricEffectReverse":return _s.local();case"CIMGeometricEffectRotate":return ys.local();case"CIMGeometricEffectScale":return bs.local();case"CIMGeometricEffectWave":return vs.local()}return null}new(s(32488).A),s(11831),s(92602),new Map,new Set,s(28076),s(5760);var oi=s(34304);function ai(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function hi(t,e,s){const i=e[0],r=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],p=s[4],_=s[5];return t[0]=i*c+n*l,t[1]=r*c+o*l,t[2]=i*u+n*d,t[3]=r*u+o*d,t[4]=i*p+n*_+a,t[5]=r*p+o*_+h,t}function ci(t,e,s){const i=e[0],r=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]=i*l+n*c,t[1]=r*l+o*c,t[2]=i*-c+n*l,t[3]=r*-c+o*l,t[4]=a,t[5]=h,t}function li(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i,t[1]=r,t[2]=n,t[3]=o,t[4]=i*c+n*l+a,t[5]=r*c+o*l+h,t}function ui(t,e){const s=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=s,t[2]=-s,t[3]=i,t[4]=0,t[5]=0,t}function di(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 pi=hi,_i=di;function fi(){const t=new Float32Array(6);return t[0]=1,t[3]=1,t}function mi(t,e,s,i){const r=e[i],n=e[i+1];t[i]=s[0]*r+s[2]*n+s[4],t[i+1]=s[1]*r+s[3]*n+s[5]}function gi(t,e,s,i=0,r=0,n=2){const o=r||e.length/n;for(let r=i;r<o;r++)mi(t,e,s,r*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],i=t[1],r=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],p=e[5],_=(0,oi.FD)();return Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-c)<=_*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-l)<=_*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=_*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-p)<=_*Math.max(1,Math.abs(a),Math.abs(p))},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:ui,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:ai,invert:function(t,e){const s=e[0],i=e[1],r=e[2],n=e[3],o=e[4],a=e[5];let h=s*n-i*r;return h?(h=1/h,t[0]=n*h,t[1]=-i*h,t[2]=-r*h,t[3]=s*h,t[4]=(r*a-n*o)*h,t[5]=(i*o-s*a)*h,t):null},mul:pi,multiply:hi,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,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t[2]=e[2]+s[2]*i,t[3]=e[3]+s[3]*i,t[4]=e[4]+s[4]*i,t[5]=e[5]+s[5]*i,t},rotate:ci,scale:function(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i*c,t[1]=r*c,t[2]=n*l,t[3]=o*l,t[4]=a,t[5]=h,t},set:function(t,e,s,i,r,n,o){return t[0]=e,t[1]=s,t[2]=i,t[3]=r,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:_i,subtract:di,translate:li},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:fi,createView:function(t,e){return new Float32Array(t,e,6)},fromValues:function(t,e,s,i,r,n){const o=new Float32Array(6);return o[0]=t,o[1]=e,o[2]=s,o[3]=i,o[4]=r,o[5]=n,o},transform:mi,transformMany:gi},Symbol.toStringTag,{value:"Module"}));var yi=s(88340);const xi=()=>A.A.getLogger("esri.views.2d.engine.webgl.alignmentUtils");var bi,wi;function vi(t){if(!t)return bi.Center;switch(t){case"Left":case"left":return bi.Left;case"Right":case"right":return bi.Right;case"Justify":return xi().warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),bi.Center;case"Center":case"center":return bi.Center}}function Si(t){if(!t)return wi.Center;switch(t){case"Top":case"top":return wi.Top;case"Center":case"middle":return wi.Center;case"Baseline":case"baseline":return wi.Baseline;case"Bottom":case"bottom":return wi.Bottom}}!function(t){t[t.Left=-1]="Left",t[t.Center=0]="Center",t[t.Right=1]="Right"}(bi||(bi={})),function(t){t[t.Top=1]="Top",t[t.Center=0]="Center",t[t.Bottom=-1]="Bottom",t[t.Baseline=2]="Baseline"}(wi||(wi={}));var Ii=s(18989);class Pi{constructor(t,e,s,i){this.computedX=0,this.computedY=0,this.center=(0,yi.fA)(t,e),this.centerT=(0,yi.vt)(),this.halfWidth=s/2,this.halfHeight=i/2,this.width=s,this.height=i}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 Pi(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]),i=Math.abs(t.centerT[1]-this.centerT[1]),r=(t.halfWidth+this.halfWidth+e)/s,n=(t.halfHeight+this.halfHeight+e)/i,o=Math.min(r,n);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),i=Math.max(this.xmax,t.xmax)-e,r=Math.max(this.ymax,t.ymax)-s,n=e+i/2,o=s+r/2;this.width=i,this.height=r,this.halfWidth=i/2,this.halfHeight=r/2,this.x=n,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),i=t.readInt32(),r=t.readInt32();return new Pi(e,s,i,r)}}const Mi=Math.PI/180;class Ti{constructor(t,e,s,i){this._rotationT=fi(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const r=s.rect,n=new Float32Array(8);t*=i,e*=i;const o=s.code?r.width*i:s.metrics.width,a=s.code?r.height*i: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(r),this._scale=i,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,ui(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,i=Math.abs(t)*this._scale,r=new Float32Array(8);r[0]=this.x,r[1]=this.y,r[2]=this.x+s,r[3]=this.y,r[4]=this.x,r[5]=this.y+i,r[6]=this.x+s,r[7]=this.y+i,gi(r,r,hi(fi(),this._rotationT,this._transform));let n=1/0,o=1/0,a=0,h=0;for(let t=0;t<4;t++){const e=r[2*t],s=r[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 Pi(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=hi(fi(),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,F.l0)(this._offsets.topLeft,this._offsets.topLeft,t),(0,F.l0)(this._offsets.topRight,this._offsets.topRight,t),(0,F.l0)(this._offsets.bottomLeft,this._offsets.bottomLeft,t),(0,F.l0)(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:e,width:s,height:i}){this._texcoords={topLeft:[t,e],topRight:[t+s,e],bottomLeft:[t,e+i],bottomRight:[t+s,e+i]}}}const Ci=(t,e)=>({code:0,page:0,sdf:!0,rect:new Ii.A(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function Ai(t,e){return t.forEach((t=>(0,F.l0)(t,t,e))),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class Ei{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;hi(e,ui(fi(),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 i=s.scale,r="underline"===s.decoration?26:16,n=t[0].textureBinding;for(const s of e){const e=s.startX*i,o=s.startY*i,a=(s.width+s.glyphWidthEnd)*i;t.push(new Ti(e,o+r*i,Ci(a,n),1))}}shapeBackground(t){const e=(1.5+(this._borderLineSizePx||0))/2,s=this._borderLineSizePx?e:0,{xmin:i,ymin:r,xmax:n,ymax:o,x:a,y:h,width:c,height:l}=this.bounds,u=[i-8,r-8],d=[n+8,r-8],p=[i-8,o+8],_=[n+8,o+8],f=Ai([[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),m=Ai([[p[0]+s,p[1]-s],[_[0]-s,_[1]-s],[p[0]-e,p[1]+e],[_[0]+e,_[1]+e]],t),g=Ai([[u[0]-e,u[1]-e],[u[0]+s,u[1]+s],[p[0]-e,p[1]+e],[p[0]+s,p[1]-s]],t),y=Ai([[d[0]-s,d[1]+s],[d[0]+e,d[1]-e],[_[0]-s,_[1]-s],[_[0]+e,_[1]+e]],t),x={main:Ai([u,d,p,_],t),top:f,bot:m,left:g,right:y};return[new Pi(a,h,c+2*e,l+2*e),x]}get boundsT(){const t=this.bounds,e=(0,F.hZ)((0,yi.vt)(),t.x,t.y);if((0,F.l0)(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Pi(e[0],e[1],s,s)}return new Pi(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,r=0;for(const n of t)e=Math.min(e,n.xTopLeft),s=Math.min(s,n.yTopLeft),i=Math.max(i,n.xBottomRight),r=Math.max(r,n.yBottomRight);const n=i-e,o=r-s;return new Pi(e+n/2,s+o/2,n,o)}_createGlyphTransform(t,e){const s=Mi*e.angle,i=fi(),r=(0,yi.vt)();return li(i,i,(0,F.hZ)(r,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?ci(i,i,s):(li(i,i,(0,F.hZ)(r,t.x,t.y)),ci(i,i,s),li(i,i,(0,F.hZ)(r,-t.x,-t.y))),i}}class Fi{constructor(t,e,s,i,r,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=i,this.yMin=r,this.yMax=n}}const ki=t=>10===t,zi=t=>32===t;var Oi=s(39829);Math.PI,s(59868);var Ri=s(13195);function Li(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,is.$w)(t.offsetX)),Math.abs((0,is.$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 Ni(t){if(!t)return 0;let e=0;for(const s of t)e+=Li(s);return e}Math.PI,Math.PI;const Di=96/72;class Bi{static executeEffects(t,e,s,i){const r=Di,n=Ni(t);let o=new ke(e);for(const e of t){const t=ni(e);t&&(o=t.execute(o,e,r,s,i,n))}return o}static applyEffects(t,e,s){if(!t)return e;const i=Ni(t);let r,n=new ke(Ie.fromJSONCIM(e));for(const e of t){const t=ni(e);t&&(n=t.execute(n,e,1,null,s,i))}const o=[];let a=null;for(;r=n.next();)o.push(...(0,ve.x)(r)),a=r.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let Gi=null;function Ui(){return Gi}const Vi=new Float32Array(1),qi=new Uint32Array(Vi.buffer);function Wi(t){const e=function(t){return Vi[0]=t,qi[0]}(t),s=e>>>31;let i=e>>>23&255,r=8388607&e;return i-=127,i>15?s<<15|31744:i<-25?0:(i<-14&&(r+=8388608,r/=2**(-14-i),i=-15),i+=15,r/=8192,r=function(t,e){const s=Math.floor(t),i=t-s;return s<1023&&(i>.5||.5===i&&s%2==1)?s+1:s}(r),s<<15|i<<10|r)}function Yi(t,e,s,i,r,n,o){if(t.primitiveName===e)for(const e in t)if(e===s){let s=i?.readWithDefault(r,n,t[e]&&o);return"text"===t.type&&(s=s.toString()),void(t[e]=s)}if("type"in t&&null!=t.type)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.symbolLayers)for(const a of t.symbolLayers)Yi(a,e,s,i,r,n,o);break;case"CIMHatchFill":t.lineSymbol&&Yi(t.lineSymbol,e,s,i,r,n,o);break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if("CIMVectorMarker"===t.type&&t.markerGraphics)for(const a of t.markerGraphics)Yi(a,e,s,i,r,n,o),Yi(a.symbol,e,s,i,r,n,o)}}function ji(t){const e=t.width;return null!=t.effects?256:Math.max(1.25*e,8)}function Xi(t){switch(t){case pt.pe.BYTE:case pt.pe.UNSIGNED_BYTE:return 1;case pt.pe.SHORT:case pt.pe.UNSIGNED_SHORT:case pt.pe.HALF_FLOAT:return 2;case pt.pe.FLOAT:case pt.pe.INT:case pt.pe.UNSIGNED_INT:return 4}}class $i{static fromVertexSpec(t,e){const{attributes:s,optionalAttributes:i}=t;let r,n,o;const a=[];for(const t in s){const e=s[t];"position"===e.pack?r={...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 i)if(!0===e[t]){const e=i[t];a.push({...e,name:t})}const h=function(t){const e=[],s=[],i=[];for(const r of t){const t=Xi(r.type)*r.count;switch(t%2||t%4||4){case 4:e.push(r);continue;case 2:s.push(r);continue;case 1:i.push(r);continue;default:throw new Error("Found unexpected dataType byte count")}}return e.push(...s),e.push(...i),e}(a),c=[];let l=8,u=1;for(const t of h)c.push({...t,offset:l}),l+=Xi(t.type)*t.count,t.packAlternating&&(u=Math.max(t.packAlternating.count,u));const d=Uint32Array.BYTES_PER_ELEMENT,p=l%d;return new $i(r,n,o,c,l+(p?d-p:0),u)}constructor(t,e,s,i,r,n){this.position=t,this.id=e,this.bitset=s,this.standardAttributes=i,this.stride=r,this.packVertexCount=n,i.push(s),this._attributes=[t,e,s,...i]}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 Hi{static fromVertexSpec(t,e){const s=$i.fromVertexSpec(t,e);return new Hi(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,i,r,n){for(let t=0;t<this._spec.packVertexCount;t++){const o=t*this._spec.stride;this._packPosition(s,i,o),this._packId(e,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const t=a.packTessellation(n,r);this._pack(t,a,o)}for(const t of this._spec.standardAttributes)if(null!=t.packTessellation){const e=t.packTessellation(n,r);this._pack(e,t,o)}else if(t.packAlternating?.packTessellation){const e=t.packAlternating.packTessellation(n,r);for(let s=0;s<this._spec.packVertexCount;s++){const i=e[s];this._pack(i,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 i=s.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++)this._pack(i,s,t*this._spec.stride)}else if(s.packAlternating?.pack){const i=s.packAlternating.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++){const e=i[t];this._pack(e,s,t*this._spec.stride)}}}_packPosition(t,e,s){const{offset:i}=this._spec.position,r=this._spec.position.packPrecisionFactor??1,n=function(t,e){return 65535&t|e<<16}(t*r,e*r);this._dataView.setUint32(s+i,n,!0)}_packId(t,e){const s=t*(this._spec.id.packPrecisionFactor??1),i=4278190080&this._dataView.getUint32(e+this._spec.id.offset,!0);this._dataView.setUint32(e+this._spec.id.offset,s|i,!0)}_pack(t,e,s){!function(t,e,s,i){const r=s.packPrecisionFactor??1;switch(s.type){case pt.pe.BYTE:if(1===s.count)t.setInt8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;t.setInt8(i+s.offset+o,e[n]*r)}break;case pt.pe.UNSIGNED_BYTE:if(1===s.count)t.setUint8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;t.setUint8(i+s.offset+o,e[n]*r)}break;case pt.pe.SHORT:if(1===s.count)t.setInt16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;t.setInt16(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.UNSIGNED_SHORT:if(1===s.count)t.setUint16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.INT:if(1===s.count)t.setInt32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;t.setInt32(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.UNSIGNED_INT:if(1===s.count)t.setUint32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;t.setUint32(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.FLOAT:if(1===s.count)t.setFloat32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;t.setFloat32(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.HALF_FLOAT:if(1===s.count)t.setUint16(i+s.offset,Wi(e*r),!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(i+s.offset+o,Wi(e[n]*r),!0)}}}(this._dataView,t,e,s)}}class Zi{constructor(t,e,s,i){this._instanceId=t,this._evaluator=e,this._enabledOptionalAttributes=s,this._viewParams=i,this._evaluator.evaluator=t=>this.vertexSpec.createComputedParams(t)}get _vertexPack(){if(!this._cachedVertexPack){const t=Hi.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}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(){Gi=await Promise.all([s.e(9930),s.e(9940)]).then(s.bind(s,47559))}()}enqueueRequest(t,e,s){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(t,e,s)}write(t,e,s,i,r){this.ensurePacked(e,s,i);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(t,s,void 0,r);const o=s.readGeometryForDisplay()?.clone();if(!o)return;const a=Ie.fromOptimizedCIM(o,s.geometryType),h=Ui();a.invertY();const c=t.id||"",l=Bi.executeEffects(n,a,c,h);let u;for(;u=l.next();)u.invertY(),this._write(t,s,u,r)}ensurePacked(t,e,s){if(!this._evaluator.hasDynamicProperties)return;const i=this._evaluator.evaluateMeshParams(t,e,s);this._vertexPack.pack(i,this._viewParams)}_writeVertex(t,e,s,i,r){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(t,e,s,i,n,r)}}const Qi=(0,n.A)("featurelayer-fast-triangulation-enabled");class Ki extends Zi{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,Vt.F)()])}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),t.recordEnd())}_clip(t){return t?be(t,this.hasEffects?256:8):null}_writeGeometry(t,e,s){const i=s.maxLength>100,r=[],n=this.createTesselationParams(e);if(!i&&Qi&&function(t,e){const{coords:s,lengths:i,hasIndeterminateRingOrder:r}=e,n=t;if(r)return!1;let o=0;for(let t=0;t<i.length;){let e=t,r=i[t],a=ye(s,o,r);const h=[];for(;++e<i.length;){const t=i[e],n=ye(s,o+r,t);if(!(n>0))break;a+=n,h.push(o+r),r+=t}const c=n.length;Yt(n,s,o,o+r,h,2,0);const l=xe(n,s,c,n.length,0),u=Math.abs(a);if(Math.abs((l-u)/Math.max(1e-7,u))>1e-5)return n.length=0,!1;t=e,o+=r}return!0}(r,s))return void(r.length&&this._writeVertices(t,e,s.coords,n,r));const o=function(t){const{coords:e,lengths:s}=t,{buffer:i}=(0,Vt.l)(e,s);return i}(s);this._writeVertices(t,e,o,n)}_writeVertices(t,e,s,i,r){const n=e.getDisplayId(),o=t.vertexCount(),a=this.hasEffects;let h=0;if(r)for(const e of r){const r=s[2*e],o=s[2*e+1];a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}else for(let e=0;e<s.length;e+=2){const r=Math.round(s[e]),o=Math.round(s[e+1]);a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}t.indexEnsureSize(h);for(let e=0;e<h;e++)t.indexWrite(e+o)}}const Ji={createComputedParams:t=>t,optionalAttributes:{},attributes:{id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:pt.pe.FLOAT,count:1,packTessellation:({inverseArea:t})=>t}}};class tr extends Ki{constructor(){super(...arguments),this.vertexSpec=Ji}createTesselationParams(t){return{inverseArea:1/t.readGeometryArea()}}}var er=s(68197);function sr(t,e){return[!!t?.minScale&&e.scaleToZoom(t.minScale)||0,!!t?.maxScale&&e.scaleToZoom(t.maxScale)||100]}function ir(t){return 1<<t}function rr(t){let e=0;for(const[s,i]of t)i&&(e|=1<<s);return e}function nr(t){let e;if(!t)return[0,0,0,0];if("string"==typeof t){const s=er.A.fromString(t);if(!s)return A.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new i.A("mapview:mesh-processing","Unable to parse string into color",{color:t})),[0,0,0,0];e=s.toArray()}else e=t;const[s,r,n,o]=e;return[s*(o/255),r*(o/255),n*(o/255),o]}function or(t,e){return Math.round(Math.min(Math.sqrt(t*e),255))}function ar(t,e){return Math.round(t*e)/e}const hr={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:pt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}},attributes:{id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)}}};class cr extends Ki{constructor(){super(...arguments),this.vertexSpec=hr}createTesselationParams(t){return null}}const lr={createComputedParams:t=>t,optionalAttributes:hr.optionalAttributes,attributes:{...hr.attributes,tlbr:{count:4,type:pt.pe.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.hM,n=e.y+B.hM;return[r,n,r+s,n+i]}},inverseRasterizationScale:{count:1,type:pt.pe.BYTE,packPrecisionFactor:16,pack:({sprite:t})=>1/t.rasterizationScale}}};class ur extends cr{constructor(){super(...arguments),this.vertexSpec=lr}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),t.recordEnd()}}var dr,pr;(pr=dr||(dr={}))[pr.Geographic=0]="Geographic",pr[pr.Arithmatic=1]="Arithmatic";const _r=1.1,fr=1,mr=1e-5,gr=.05,yr=1e-30,xr=2;function br(t){const{sprite:e,aspectRatio:s,scaleProportionally:i}=t,r=(0,l.Lz)(t.height),n=r>0?r:e.height;let o=r*s;return o<=0?o=e.width:i&&(o*=e.width/e.height),{width:o,height:n}}function wr(t){const{applyRandomOffset:e,sampleAlphaOnly:s}=t;return rr([[xr,e],[4,s]])}const vr={createComputedParams:t=>t,optionalAttributes:lr.optionalAttributes,attributes:{...lr.attributes,bitset:{count:1,type:pt.pe.UNSIGNED_BYTE,pack:wr},width:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).width},height:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).height},offset:{count:2,type:pt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),-(0,l.Lz)(e)]},scale:{count:2,type:pt.pe.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:t,scaleY:e})=>[t,e]},angle:{count:1,type:pt.pe.UNSIGNED_BYTE,pack:({angle:t})=>(0,Ri.wV)(t)}}};class Sr extends ur{constructor(){super(...arguments),this.vertexSpec=vr}}var Ir=s(83773);class Pr{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0}}const Mr={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:pt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}},attributes:{id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)},offset:{type:pt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[ar(t,16),ar(e,16)]},normal:{type:pt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:t,normalY:e})=>[ar(t,16),ar(e,16)]},halfWidth:{type:pt.pe.HALF_FLOAT,count:1,pack:({width:t})=>(0,l.Lz)(.5*t)},referenceHalfWidth:{type:pt.pe.HALF_FLOAT,count:1,pack:({referenceWidth:t})=>(0,l.Lz)(.5*t)}}};class Tr{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0}}class Cr extends Zi{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Mr,this._currentWrite=new Tr,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new Pr,this._initializeTessellator()}writeLineVertices(t,e,s){const i=this._getLines(e);null!=i&&this._writeVertices(t,s,i)}_initializeTessellator(){this._lineTessellator=new Ir.i(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(t,e,s){const i=s??Ie.fromFeatureSetReaderCIM(e);i&&this._writeGeometry(t,e,i)}_writeGeometry(t,e,s,i){t.recordStart(this.instanceId,this.attributeLayout,i),this.writeLineVertices(t,s,e),t.recordEnd()}_getLines(t){return function(t,e){ge.setPixelMargin(e);const s=ge,i=-e,r=B.CQ+e;let n=[],o=!1;if(!t.nextPath())return null;let a=!0;for(;a;){t.seekPathStart();const e=[];if(!t.pathSize)return null;s.reset(qt.dC.LineString),t.nextPoint();let h=t.x,c=t.y;if(o)s.moveTo(h,c);else{if(h<i||h>r||c<i||c>r){o=!0;continue}e.push({x:h,y:c})}let l=!1;for(;t.nextPoint();)if(h=t.x,c=t.y,o)s.lineTo(h,c);else{if(h<i||h>r||c<i||c>r){l=!0;break}e.push({x:h,y:c})}if(l)o=!0;else{if(o){const t=s.resultWithStarts();if(t)for(const e of t)n.push(e)}else n.push({line:e,start:0});a=t.nextPath(),o=!1}}return n=n.filter((t=>t.line.length>1)),0===n.length?null:n}(t,ji(this.evaluatedMeshParams))}_writeVertices(t,e,s){const{_currentWrite:i,_tessellationOptions:r,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:h,miterLimit:c,hasSizeVV:u}=n,d=(0,l.Lz)(.5*o);r.halfWidth=d,r.capType=function(t){switch(t){case"butt":case ut.uT.Butt:return ut.xR.BUTT;case"round":case ut.uT.Round:return ut.xR.ROUND;case"square":case ut.uT.Square:return ut.xR.SQUARE}}(a),r.joinType=function(t){switch(t){case"bevel":case ut.wd.Bevel:return ut.JO.BEVEL;case"miter":case ut.wd.Miter:return ut.JO.MITER;case"round":case ut.wd.Round:return ut.JO.ROUND}}(h),r.miterLimit=c;const p=!u;i.out=t,i.id=e.getDisplayId(),i.vertexCount=0,i.indexCount=0,i.vertexFrom=t.vertexCount(),i.vertexBounds=p&&d<B.Gh?0:1;for(const{line:t,start:e}of s)r.initialDistance=e%65535,this._lineTessellator.tessellate(t,r,p)}_writeTesselatedVertex(t,e,s,i,r,n,o,a,h,c,l){const{out:u,id:d,vertexBounds:p}=this._currentWrite;return this.hasEffects&&u.recordBounds(t,e,p,p),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=c,this._tessParams.directionX=r,this._tessParams.directionY=n,this._tessParams.distance=l,this._writeVertex(u,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,s){const{out:i}=this._currentWrite;i.indexEnsureSize(3),i.indexWrite(t),i.indexWrite(e),i.indexWrite(s),this._currentWrite.indexCount+=3}}const Ar={createComputedParams:t=>t,optionalAttributes:Mr.optionalAttributes,attributes:{...Mr.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)}}},Er={createComputedParams:t=>t,optionalAttributes:Mr.optionalAttributes,attributes:{...Mr.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>rr([[0,!0]])},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>nr(t)}}};class Fr extends Cr{constructor(){super(...arguments),this.vertexSpec=Er}}class kr extends cr{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Ar,this._lineMeshWriter=this._createOutlineWriter(t,e,s,i)}_createOutlineWriter(t,e,s,i){return new Fr(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,Ie.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd())}_clip(t){return t?be(t,ji(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 zr=s(46263),Or=s(620);class Rr{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 Lr extends Rr{constructor(){super(...arguments),this.vertex=new Br,this.fragment=new Br,this.attributes=new Gr,this.varyings=new Ur,this.extensions=new Vr,this.constants=new qr}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(t,e=!0){const s=this.extensions.generateSource(t),i=this.attributes.generateSource(t),r=this.varyings.generateSource(t),n="vertex"===t?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),h="vertex"===t?Wr:function(t=!0){return`#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${t?"out vec4 fragColor;":""}\n`}(e),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${i.join("\n")}\n${r.join("\n")}\n${a.join("\n")}`}generateBindPass(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Pass];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Pass];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r)=>{for(let n=0;n<i;++n)s[n](t,e,r)}}generateBindDraw(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Draw];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Draw];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r,n)=>{for(let o=0;o<i;++o)s[o](t,e,r,n)}}}class Nr{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 i.A(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else A.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 Dr{constructor(){this._entries=new Array}add(t){this._entries.push(t)}generateSource(){return this._entries}}class Br extends Rr{constructor(){super(...arguments),this.uniforms=new Nr,this.code=new Dr,this.constants=new qr}get builder(){return this}}class Gr{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 Ur{constructor(){this._entries=new Map}add(t,e){this._entries.has(t)&&(0,Or.vA)(this._entries.get(t)===e),this._entries.set(t,e)}generateSource(t){const e=new Array;return this._entries.forEach(((s,i)=>e.push("vertex"===t?`out ${s} ${i};`:`in ${s} ${i};`))),e}}class Vr{constructor(){this._entries=new Set}add(t){this._entries.add(t)}generateSource(t){const e="vertex"===t?Vr.ALLOWLIST_VERTEX:Vr.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((t=>e.includes(t))).map((t=>`#extension ${t} : enable`))}}Vr.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],Vr.ALLOWLIST_VERTEX=[];class qr{constructor(){this._entries=new Set}add(t,e,s){let i="ERROR_CONSTRUCTOR_STRING";switch(e){case"float":i=qr._numberToFloatStr(s);break;case"int":i=qr._numberToIntStr(s);break;case"bool":i=s.toString();break;case"vec2":i=`vec2(${qr._numberToFloatStr(s[0])}, ${qr._numberToFloatStr(s[1])})`;break;case"vec3":i=`vec3(${qr._numberToFloatStr(s[0])}, ${qr._numberToFloatStr(s[1])}, ${qr._numberToFloatStr(s[2])})`;break;case"vec4":i=`vec4(${qr._numberToFloatStr(s[0])}, ${qr._numberToFloatStr(s[1])}, ${qr._numberToFloatStr(s[2])}, ${qr._numberToFloatStr(s[3])})`;break;case"ivec2":i=`ivec2(${qr._numberToIntStr(s[0])}, ${qr._numberToIntStr(s[1])})`;break;case"ivec3":i=`ivec3(${qr._numberToIntStr(s[0])}, ${qr._numberToIntStr(s[1])}, ${qr._numberToIntStr(s[2])})`;break;case"ivec4":i=`ivec4(${qr._numberToIntStr(s[0])}, ${qr._numberToIntStr(s[1])}, ${qr._numberToIntStr(s[2])}, ${qr._numberToIntStr(s[3])})`;break;case"mat2":case"mat3":case"mat4":i=`${e}(${Array.prototype.map.call(s,(t=>qr._numberToFloatStr(t))).join(", ")})`}return this._entries.add(`const ${e} ${t} = ${i};`),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 Wr="precision highp float;\nprecision highp sampler2D;";function Yr(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 jr{constructor(){this.uid=jr.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 jr&&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 Xr(t){return"object"==typeof t?t.clone():t}jr.NodeCount=0;class $r extends jr{constructor(){super(...arguments),this.shaderType="primitive-node"}}class Hr extends jr{constructor(t){super(),this.child=t,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const t=new Hr(Xr(this.child));return this.cloneInto(t),t}}class Zr extends jr{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 Zr(this.property,Xr(this.target),this.returnType);return this.cloneInto(t),t}}class Qr extends jr{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=Xr(this.ifTrue),e=this.ifFalse?Xr(this.ifFalse):null,s=new Qr(this.condition,t,e);return this.cloneInto(s),s}}class Kr extends jr{constructor(t,e,s,i){super(),this.captureList=t,this.returnType=e,this.generator=i,this.shaderType="block-node",s&&(this.subgraph=new Hr(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]=Xr(this.captureList[e]);const e=new Kr(t,this.returnType,this.subgraph?Xr(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(e),e}}class Jr extends jr{constructor(t,e,s,i,r,n=!1){super(),this.token=t,this._children=e,this.isInfix=s,this.isPropertyAccess=i,this.returnType=r,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const t=new Jr(this.token,this._children.map(Xr),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(t),t}}var tn,en,sn,rn,nn,on,an,hn,cn,ln,un,dn,pn,_n;function fn(t){return new Proxy(t,{get(e,s){if("constructor"===s)return new Proxy(e.constructor,{construct:(t,e,s)=>fn(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=>Gn[t]));throw new Error("Unable to find type family")}(t.type);return jn(t,s,e[s.length-1])}}})}function mn(t){return new Proxy(t,{construct:(t,e,s)=>fn(new t(...e))})}class gn extends Error{}let yn=tn=class extends $r{constructor(t,e){super(),this.elementType=t,this.size=e,this.children=[],this.type="array"}clone(){const t=new tn(this.elementType,this.size);return super.cloneInto(t),t}get(t){if("number"==typeof t){const e=new zn(t);return e.isImplicit=!0,jn(this,e,this.elementType.constructor)}return jn(this,t,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,i=t.size){const r=new zn(s).setMutable().setDebugName("FindIndexIterator"),n=e(t.get(r)).setDebugName("FindIndexPredicate"),o=Kn({iter:r},zn,n,(({out:t,iter:e,subgraph:s})=>`\n${t} = -1;\n\nfor (; ${e} < ${i}; ${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,i=t.size){const r=Kn({array:t},zn,null,(({out:t,array:r})=>`\n${t} = -1;\nfor (int i = ${s}; i < ${i}; i++) {\n bool condition;\n ${e({array:r,i:"i",out:"condition"})}\n if (condition) {\n ${t} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return r}(this,t,e,s)}static ofType(t,e){const s={construct:(s,i)=>new tn(new t,e)};return new Proxy(tn,s)}};yn.type="array",yn=tn=(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 jn(t,`[${e}]`,t.elementType.constructor)}}})}(new t(...e))})}],yn);class xn extends $r{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const t=new xn;return t.children=this.children.map(Xr),super.cloneInto(t),t}}xn.type="sampler2D";class bn extends $r{constructor(t){super(),this.type="float",this.children=[t]}clone(){const t=new bn(Xr(this.children[0]));return super.cloneInto(t),t}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}}bn.type="float";let wn=en=class extends $r{constructor(t,e){super(),this.type="vec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new en(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}get 0(){return jn(this,"[0]",bn)}get 1(){return jn(this,"[1]",bn)}get 2(){throw new gn}get 3(){throw new gn}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}};wn.type="vec2",wn=en=(0,P._)([mn],wn);let vn=sn=class extends $r{constructor(t,e,s){super(),this.type="vec3",this.children=[t,e,s].filter((t=>null!=t))}get 0(){return jn(this,"[0]",bn)}get 1(){return jn(this,"[1]",bn)}get 2(){return jn(this,"[2]",bn)}get 3(){throw new gn}clone(){const t=new sn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}};vn.type="vec3",vn=sn=(0,P._)([mn],vn);let Sn=rn=class extends $r{constructor(t,e,s,i){super(),this.type="vec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new rn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}get 0(){return jn(this,"[0]",bn)}get 1(){return jn(this,"[1]",bn)}get 2(){return jn(this,"[2]",bn)}get 3(){return jn(this,"[3]",bn)}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}};Sn.type="vec4",Sn=rn=(0,P._)([mn],Sn);let In=nn=class extends $r{constructor(t){super(),this.type="uint",this.children=[t]}clone(){const t=new nn(Xr(this.children[0]));return super.cloneInto(t),t}};In.type="uint",In=nn=(0,P._)([mn],In);let Pn=on=class extends $r{constructor(t,e){super(),this.type="uvec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new on(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}};Pn.type="uvec2",Pn=on=(0,P._)([mn],Pn);let Mn=an=class extends $r{constructor(t,e,s){super(),this.type="uvec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new an(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}};Mn.type="uvec3",Mn=an=(0,P._)([mn],Mn);let Tn=hn=class extends $r{constructor(t,e,s,i){super(),this.type="uvec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new hn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}};Tn.type="uvec4",Tn=hn=(0,P._)([mn],Tn);class Cn extends $r{constructor(t){super(),this.type="bool",this.children=[t]}and(t){return lo(this,t)}or(t){return co(this,t)}clone(){const t=new Cn(Xr(this.children[0]));return super.cloneInto(t),t}}Cn.type="bool";let An=cn=class extends $r{constructor(t,e){super(),this.type="bvec2",this.children=[t,e].filter((t=>null!=t))}all(){return uo(this)}any(){return po(this)}clone(){const t=new cn(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}};An.type="bvec2",An=cn=(0,P._)([mn],An);let En=ln=class extends $r{constructor(t,e,s){super(),this.type="bvec3",this.children=[t,e,s].filter((t=>null!=t))}all(){return uo(this)}any(){return po(this)}clone(){const t=new ln(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}};function Fn(t,e){return"number"==typeof t?new e(t):t}En.type="bvec3",En=ln=(0,P._)([mn],En);let kn=un=class extends $r{constructor(t,e,s,i){super(),this.type="bvec4",this.children=[t,e,s,i].filter((t=>null!=t))}all(){return uo(this)}any(){return po(this)}clone(){const t=new un(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}};kn.type="bvec4",kn=un=(0,P._)([mn],kn);class zn extends $r{constructor(t){super(),this.type="int",this.children=[t]}multiply(t){return eo(this,Fn(t,zn))}add(t){return io(this,Fn(t,zn))}subtract(t){return ro(this,Fn(t,zn))}divide(t){return so(this,Fn(t,zn))}clone(){const t=new zn(Xr(this.children[0]));return super.cloneInto(t),t}}zn.type="int";let On=dn=class extends $r{constructor(t,e){super(),this.type="ivec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new dn(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}};On.type="ivec2",On=dn=(0,P._)([mn],On);let Rn=pn=class extends $r{constructor(t,e,s){super(),this.type="ivec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new pn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}};Rn.type="ivec3",Rn=pn=(0,P._)([mn],Rn);let Ln=_n=class extends $r{constructor(t,e,s,i){super(),this.type="ivec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new _n(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}};Ln.type="ivec4",Ln=_n=(0,P._)([mn],Ln);class Nn extends $r{constructor(t,e,s,i){super(),this.type="mat2",this.children=[t,e,s,i]}clone(){const t=new Nn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}}Nn.type="mat2";class Dn extends $r{static identity(){return new Dn(1,0,0,0,1,0,0,0,1)}static fromRotation(t){const e=Io(t),s=fo(t);return new Dn(s,e,0,Qn(e),s,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h){super(),this.type="mat3",this.children=[t,e,s,i,r,n,o,a,h]}add(t){return io(this,t)}multiply(t){return eo(this,t)}clone(){const t=new Dn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]),Xr(this.children[4]),Xr(this.children[5]),Xr(this.children[6]),Xr(this.children[7]),Xr(this.children[8]));return super.cloneInto(t),t}}Dn.type="mat3";class Bn extends $r{static identity(){return new Bn(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f){super(),this.type="mat4",this.children=[t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f]}static fromColumns(t,e,s,i){return new Bn(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}multiply(t){return eo(this,t)}clone(){const t=new Bn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]),Xr(this.children[4]),Xr(this.children[5]),Xr(this.children[6]),Xr(this.children[7]),Xr(this.children[8]),Xr(this.children[9]),Xr(this.children[10]),Xr(this.children[11]),Xr(this.children[12]),Xr(this.children[13]),Xr(this.children[14]),Xr(this.children[15]));return super.cloneInto(t),t}}Bn.type="mat4";const Gn={float:bn,vec2:wn,vec3:vn,vec4:Sn,int:zn,ivec2:On,ivec3:Rn,ivec4:Ln,uint:In,uvec2:Pn,uvec3:Mn,uvec4:Tn,bool:Cn,bvec2:An,bvec3:En,bvec4:kn},Un=(...t)=>new zn(...t),Vn=(...t)=>new bn(...t),qn=(...t)=>new wn(...t),Wn=(...t)=>new Sn(...t),Yn=(...t)=>new Dn(...t);function jn(t,e,s){const i=new s(new Zr(e,t,s));return i.isImplicit=!0,i}function Xn(t,e,s,i=null){if(i){const r=new i,n=new i(new Jr(t,[e,s],!0,!1,r));return n.isImplicit=!0,n}if("float"===e.type||"int"===e.type){const i=new s.constructor(new Jr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}if(("mat2"===e.type||"mat3"===e.type||"mat4"===e.type)&&"float"!==s.type){const i=new s.constructor(new Jr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}const r=new e.constructor(new Jr(t,[e,s],!0,!1,e.constructor));return r.isImplicit=!0,r}function $n(t,e,s=e.constructor){const i=new s(new Jr(t,[e],!1,!1,s));return i.isImplicit=!0,i}function Hn(t,e,s,i=e.constructor){const r=new i(new Jr(t,[e,s],!1,!1,i));return r.isImplicit=!0,r}function Zn(t,e,s,i,r=e.constructor){const n=new r(new Jr(t,[e,s,i],!1,!1,r));return n.isImplicit=!0,n}function Qn(t){return eo(t,Vn(-1))}function Kn(t,e,s,i){return new e(new Kr(t,e,s,i))}function Jn(t,e,s){const i="function"==typeof e?e():e,r="function"==typeof s?s():s,n=new i.constructor(new Qr(t,i,r));return n.isImplicit=!0,n}function to(...t){const e=t.map((([t,e])=>"function"==typeof e?[t,e()]:[t,e])),s=e[0][1].constructor,i=e.findIndex((t=>!0===t[0]));if(-1===i)throw new Error("A cond must have a fallthrough case with `true`/; ");const r=e.slice(0,i),n=e[i][1],o=new s(r.reduceRight(((t,e)=>Jn(e[0],e[1],t)),n));return o.isImplicit=!0,o}function eo(t,e){return Xn("*",t,e)}function so(t,e){return Xn("/",t,e)}function io(t,e){return Xn("+",t,e)}function ro(t,e){return Xn("-",t,e)}function no(t,e){return Xn("==",t,e,Cn)}function oo(t,e){return Xn("<=",t,e,Cn)}function ao(t,e){return Xn(">",t,e,Cn)}function ho(t,e){return Xn(">=",t,e,Cn)}function co(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Xn("||",t,e,Cn)}(t,e)),t[0])}function lo(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Xn("&&",t,e,Cn)}(t,e)),t[0])}function uo(t){return $n("all",t,Cn)}function po(t){return $n("any",t,Cn)}function _o(t,e,s){return Zn("clamp",t,e,s,t.constructor)}function fo(t){return $n("cos",t)}function mo(t,e){return Hn("dot",t,e,bn)}function go(t){return $n("fract",t)}function yo(t){return $n("length",t,bn)}function xo(t,e){return Hn("max",t,e)}function bo(t,e){return Hn("min",t,e)}function wo(t,e,s){return Zn("mix",t,e,s)}function vo(t,e){return Hn("mod",t,e)}function So(t){return"bool"===t.type?$n("!",t):$n("not",t)}function Io(t){return $n("sin",t)}function Po(t,e){return Hn("step",t,e,e.constructor)}function Mo(t,e){return Hn("texture2D",t,e,Sn)}function To(t,e,s){const i=e.split("\n");for(const e of i)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 Co{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 i=t.getEmit(e);if(i)return i;switch(e.shaderType){case"scope-node":i=this._writeScopeNode(t,e);break;case"primitive-node":i=this._writePrimitiveNode(t,e,s);break;case"function-node":i=this._writeFunctionNode(t,e);break;case"property-access-node":i=this._writePropertyAccessNode(t,e);break;case"text-node":i=e.text;break;case"block-node":i=this._writeBlockNode(t,e);break;case"condition-node":i=this._writeConditionNode(t,e)}return t.setEmit(e,i),i}_writeScopeNode(t,e){const s=new e.child.constructor;s.setDebugName(e.debugInfo.name);const i=this._write(t,s,!0);return To(t,`{ /*ScopeStart: ${e.uid} ${e.debugInfo.name}*/`),t.indent+=2,To(t,`${i} = ${this._write(t,e.child)};`),t.indent-=2,To(t,`} /*ScopeEnd: ${e.uid} ${e.debugInfo.name}*/`),i}_writeConditionNode(t,e){const s=new e.ifTrue.constructor,i=this._write(t,s,!0);To(t,`if (${this._write(t,e.condition)}) {`),t.indent+=2;const r=t.createSubgraphContext(),n=this._write(r,e.ifTrue);if(t.body+=r.body,n&&To(t,`${i} = ${n};`),t.indent-=2,To(t,"}"),e.ifFalse){To(t,"else {"),t.indent+=2;const s=t.createSubgraphContext(),r=this._write(s,e.ifFalse);t.body+=s.body,r&&To(t,`${i} = ${r};`),t.indent-=2,To(t,"}")}return i}_writeBlockNode(t,e){const{captureList:s,generator:i,returnType:r}=e,n={};for(const e in s){if(!s[e])continue;const i=this._write(t,s[e]);n[e]=i}const o=new r,a=this._write(t,o,!0);if(n.out=a,e.subgraph){const s=t.createSubgraphContext(),i=this._write(s,e.subgraph.child),r=s.body;n.subgraph={varName:i,body:r}}const h=i(n);return To(t,"{\n"),t.indent+=2,To(t,h),t.indent-=2,To(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}`}_writeFunctionNode(t,e){const s=e.returnType.type;if(e.isInfix){const[i,r]=e.children.map((e=>this._write(t,e))),n=this._createVarName(t,e);return To(t,`${s.padEnd(5)} ${n} = ${i} ${e.token} ${r};`,e.uid),n}const i=e.children.map((e=>this._write(t,e))).join(", "),r=this._createVarName(t,e);return To(t,`${s.padEnd(5)} ${r} = ${e.token}(${i});`,e.uid),r}_writePrimitiveNode(t,e,s=!1){const i=t.getInput(e);if(i)return i.isUsed=!0,i.variableName;const r=1===e.children.length&&e.children[0]?.type===e.type;if(e.isImplicit||r)return this._write(t,e.children[0]);const n=this._createVarName(t,e);if(s)return To(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?(To(t,`${e.type.padEnd(5)} ${n} = [${a}];`,e.uid),n):o?`${e.type}(${a})`:(To(t,`${e.type.padEnd(5)} ${n} = ${e.type}(${a});`,e.uid),n)}}class Ao{constructor(t,e,s){this.variableName=t,this.variableInputType=e,this.node=s,this.type="shader-input",this.isUsed=!1}clone(){return new Ao(this.variableName,this.variableInputType,Xr(this.node))}}class Eo{constructor(t,e,s){this.outVariableName=t,this.outVariableType=e,this.node=s,this.type="shader-output"}clone(){const t=new Eo(this.outVariableName,this.outVariableType,Xr(this.node));return t.variableName=this.variableName,t}}class Fo{static createVertex(t,e,s,i,r,n){const o=[];for(const e in t){const i=t[e],r=s.get(e);r?o.push(new Ao(r,"builtin",i)):o.push(new Ao("a_"+e,"attribute",i))}for(const t of i){const e=t.uniformHydrated;o.push(new Ao(t.uniformName,"uniform",e))}const a=[];for(const t in e){const s=e[t];"glPosition"===t?a.push(new Eo("gl_Position","builtin",s)):"glPointSize"===t?a.push(new Eo("gl_PointSize","builtin",s)):a.push(new Eo("v_"+t,"varying",s))}return new Fo(o,a,r,n)}static createFragment(t,e,s,i,r,n){const o=[],a=Array.from(r.rootOutputNodes());for(const e in t){const i=t[e],r=s.get(e);if(r){o.push(new Ao(r,"builtin",i));continue}const n=a.find((t=>t.node===i));n&&o.push(new Ao(n.outVariableName,n.outVariableType,i))}for(const t of i){const e=t.uniformHydrated;o.push(new Ao(t.uniformName,"uniform",e))}const h=[];for(const t in e){const i=e[t],r=s.get(t);if("discard"===t)h.push(new Eo(null,"discard",i));else{if(!r)throw new Error(`Member ${t} in shader fragment output shoule be tagged as builtin`);h.push(new Eo(r,"builtin",i))}}return new Fo(o,h,n)}constructor(t,e,s,i){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=i}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 Fo([],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("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}];`):t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.type.padEnd(9)} ${s.variableName};`))}}const ko=["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"],zo=!1;var Oo=999,Ro=9999,Lo=0,No=1,Do=2,Bo=3,Go=4,Uo=5,Vo=6,qo=7,Wo=8,Yo=9,jo=10,Xo=11,$o=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Ho(t){return function(t){var e=function(){var t,e,s,i=0,r=0,n=Oo,o=[],a=[],h=1,c=0,l=0,u=!1,d=!1,p="";return function(t){return a=[],null!==t?f(t.replace?t.replace(/\r\n/g,"\n"):t):(o.length&&_(o.join("")),n=jo,_("(eof)"),a)};function _(t){t.length&&a.push({type:$o[n],data:t,position:l,line:h,column:c})}function f(e){var o;for(i=0,s=(p+=e).length;t=p[i],i<s;){switch(o=i,n){case Lo:i=x();break;case No:case Do:i=y();break;case Bo:i=b();break;case Go:i=S();break;case Xo:i=v();break;case Uo:i=I();break;case Ro:i=P();break;case Yo:i=g();break;case Oo:i=m()}o!==i&&("\n"===p[o]?(c=0,++h):++c)}return r+=i,p=p.slice(i),a}function m(){return o=o.length?[]:o,"/"===e&&"*"===t?(l=r+i-1,n=Lo,e=t,i+1):"/"===e&&"/"===t?(l=r+i-1,n=No,e=t,i+1):"#"===t?(n=Do,l=r+i,i):/\s/.test(t)?(n=Yo,l=r+i,i):(u=/\d/.test(t),d=/[^\w_]/.test(t),l=r+i,n=u?Go:d?Bo:Ro,i)}function g(){return/[^\s]/g.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function y(){return"\r"!==t&&"\n"!==t||"\\"===e?(o.push(t),e=t,i+1):(_(o.join("")),n=Oo,i)}function x(){return"/"===t&&"*"===e?(o.push(t),_(o.join("")),n=Oo,i+1):(o.push(t),e=t,i+1)}function b(){if("."===e&&/\d/.test(t))return n=Uo,i;if("/"===e&&"*"===t)return n=Lo,i;if("/"===e&&"/"===t)return n=No,i;if("."===t&&o.length){for(;w(o););return n=Uo,i}if(";"===t||")"===t||"("===t){if(o.length)for(;w(o););return _(t),n=Oo,i+1}var s=2===o.length&&"="!==t;if(/[\w_\d\s]/.test(t)||s){for(;w(o););return n=Oo,i}return o.push(t),e=t,i+1}function w(t){for(var e,s,i=0;;){if(e=kt.indexOf(t.slice(0,t.length+i).join("")),s=kt[e],-1===e){if(i--+t.length>0)continue;s=t.slice(0,1).join("")}return _(s),l+=s.length,(o=o.slice(s.length)).length}}function v(){return/[^a-fA-F0-9]/.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function S(){return"."===t||/[eE]/.test(t)?(o.push(t),n=Uo,e=t,i+1):"x"===t&&1===o.length&&"0"===o[0]?(n=Xo,o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function I(){return"f"===t&&(o.push(t),e=t,i+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function P(){if(/[^\d\w_]/.test(t)){var s=o.join("");return n=At.indexOf(s)>-1?Wo:Lt.indexOf(s)>-1?qo:Vo,_(o.join("")),n=Oo,i}return o.push(t),e=t,i+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 Qo(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 Ko(t,e,s,i){i=i||s;for(const r of t)if("ident"===r.type&&r.data===s)return i in e?e[i]++:e[i]=0,Ko(t,e,i+"_"+e[i],i);return s}function Jo(t,e,s="afterVersion"){function i(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 r={data:"\n",type:"whitespace"},n=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let o=function(t){let e=-1,r=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)?++r:/#endif\s*.*/.test(a.data)&&--r),"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=i(t,o);if(null===e)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,e)}e<n&&0===r&&(e=o)}return e+1}(t);n(o-1)&&t.splice(o++,0,r);for(const s of e)t.splice(o++,0,s);n(o-1)&&n(o)&&t.splice(o,0,r)}function ta(t,e,s,i="lowp"){Jo(t,[{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 ea(t,e,s,i,r="lowp"){Jo(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:i.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{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 sa(t,e){let s,i,r=-1;for(let n=e;n<t.length;n++){const e=t[n];if("operator"===e.type&&("["===e.data&&(s=n),"]"===e.data)){i=n;break}"integer"===e.type&&(r=parseInt(e.data,10))}return s&&i&&t.splice(s,i-s+1),r}function ia(t,e){if(t.startsWith("#version 300"))return t;const s=function(t){return zo?ra.get(t):null}(t);if(null!=s)return s;const i=Ho(t);if("300 es"===function(t,e="100",s="300 es"){const i=/^\s*#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const r of t)if("preprocessor"===r.type){const t=i.exec(r.data);if(t){const i=t[1].replaceAll(/\s{2,}/g," ");if(i===s)return i;if(i===e)return r.data="#version "+s,e;throw new Error("unknown glsl version: "+i)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+s},{type:"whitespace",data:"\n"}),null}(i,"100","300 es"))return t;let r=null,n=null;const o={},a={};for(let t=0;t<i.length;++t){const s=i[t];switch(s.type){case"keyword":e===pt.Co.VERTEX_SHADER&&"attribute"===s.data?s.data="in":"varying"===s.data&&(s.data=e===pt.Co.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(s.data.trim())&&(s.data=s.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===pt.Co.FRAGMENT_SHADER&&"gl_FragColor"===s.data&&(r||(r=Ko(i,o,"fragColor"),ta(i,r,"vec4")),s.data=r),e===pt.Co.FRAGMENT_SHADER&&"gl_FragData"===s.data){const e=sa(i,t+1),r=Ko(i,o,"fragData");ea(i,r,"vec4",e,"mediump"),s.data=r}else e===pt.Co.FRAGMENT_SHADER&&"gl_FragDepthEXT"===s.data&&(n||(n=Ko(i,o,"gl_FragDepth")),s.data=n);break;case"ident":if(ko.includes(s.data)){if(e===pt.Co.VERTEX_SHADER&&Qo(i,t))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");s.data in a||(a[s.data]=Ko(i,o,s.data)),s.data=a[s.data]}}}for(let t=i.length-1;t>=0;--t){const e=i[t];if("preprocessor"===e.type){const s=e.data.match(/#extension\s+(.*):/);if(s?.[1]&&Zo.has(s[1].trim())){const e=i[t+1];i.splice(t,e&&"whitespace"===e.type?2:1)}const r=e.data.match(/#ifdef\s+(.*)/);r?.[1]&&Zo.has(r[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 zo&&ra.set(t,e),e}(t,function(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}(i))}const ra=new Map;class na{constructor(t,e,s,i,r=new Map,n=[]){this._context=t,this._locations=i,this._uniformBlockBindings=r,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=ia(e,pt.Co.VERTEX_SHADER),s=ia(s,pt.Co.FRAGMENT_SHADER),this._vShader=oa(this._context,pt.Co.VERTEX_SHADER,e),this._fShader=oa(this._context,pt.Co.FRAGMENT_SHADER,s),ha.enabled&&(this._linesOfCode=e.match(/\n/g).length+s.match(/\n/g).length+2,this._context.instanceCounter.increment(pt.vt.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(pt.vt.Shader,this),(0,dt.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,dt.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(pt.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(pt.vt.Uniform,t))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(pt.vt.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(pt.vt.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(pt.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(pt.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){aa(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e){aa(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e){aa(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e){aa(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){aa(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,s){const i=this._nameToUniform2.get(t);void 0===i?(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),this._nameToUniform2.set(t,[e,s])):e===i[0]&&s===i[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),i[0]=e,i[1]=s)}setUniform2fv(t,e){aa(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,s,i){const r=this._nameToUniform3.get(t);void 0===r?(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),this._nameToUniform3.set(t,[e,s,i])):e===r[0]&&s===r[1]&&i===r[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),r[0]=e,r[1]=s,r[2]=i)}setUniform3fv(t,e){const s=this._getUniformLocation(t);null!=s&&aa(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(s,e)}setUniform4f(t,e,s,i,r){const n=this._nameToUniform4.get(t);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),this._nameToUniform4.set(t,[e,s,i,r])):void 0!==n&&e===n[0]&&s===n[1]&&i===n[2]&&r===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),n[0]=e,n[1]=s,n[2]=i,n[3]=r)}setUniform4fv(t,e){const s=this._getUniformLocation(t);null!=s&&aa(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(s,e)}setUniformMatrix3fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&aa(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(i,s,e)}setUniformMatrix4fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&aa(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(i,s,e)}stop(){}}function oa(t,e,s){const i=t.gl,r=i.createShader(e);return i.shaderSource(r,s),i.compileShader(r),(0,dt.Xc)()&&!i.getShaderParameter(r,i.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===pt.Co.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(i.getShaderInfoLog(r)),console.error(function(t){let e=2;return t.replaceAll("\n",(()=>"\n"+function(t){return t>=1e3?t.toString():(" "+t).slice(-3)}(e++)+":"))}(s))),r}function aa(t,e,s){const i=t.get(e);if(!i)return t.set(e,Array.from(s)),!0;const r=s.length;if(i.length!==r)return t.set(e,Array.from(s)),!0;for(let t=0;t<r;++t){const e=s[t];if(i[t]!==e){for(i[t]=e;t<r;++t)i[t]=s[t];return!0}}return!1}const ha={enabled:!1};function ca(t,e,s){const r=e.length;if(r!==s){const n=new i.A("Invalid Uniform",`Invalid length, expected ${s} but got ${r}`,{uniformName:t,values:e});A.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}class la{constructor(t,e,s,i,r,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=t,this.fragmentShader=e,this._locations=s,this._locationInfo=i,this._uniformBindings=r,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:i}=t;s[e]=`v_${i}`}this._program=new na(t,this.vertexShader,this.fragmentShader,e,new Map,s)}const s=this._program;t.useProgram(s);for(const i of this._uniformBindings){const{shaderModulePath:r,uniformName:n,uniformType:o,uniformArrayLength:a}=i,h=(0,U.wc)(r,e);if(null==h){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${r}`)}switch("array"===o?i.uniformArrayElementType:o){case"sampler2D":{const{unit:e,texture:i}=h;if(s.setUniform1i(n,e),"type"in i)t.bindTexture(i,e);else{const s=Dt(t,i.descriptor,i.data);t.bindTexture(s,e)}break}case"int":if(!a){s.setUniform1i(n,h);break}ca(i.uniformName,h,a),s.setUniform1iv(n,h);break;case"float":if(!a){s.setUniform1f(n,h);break}ca(i.uniformName,h,a),s.setUniform1fv(n,h);break;case"vec2":if(!a){s.setUniform2f(n,h[0],h[1]);break}ca(i.uniformName,h,a),s.setUniform2fv(n,h.flat());break;case"vec3":if(!a){s.setUniform3f(n,h[0],h[1],h[2]);break}ca(i.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}ca(i.uniformName,h,a),s.setUniform4fv(n,h.flat());break;case"mat3":s.setUniformMatrix3fv(n,h.flat());break;case"mat4":s.setUniformMatrix4fv(n,h.flat());break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function ua(t){return new t}function da(t,e,s){const i=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:i.slice()}),t.constructor[e].push(s)}function pa(t,e){return(s,i)=>{da(s,"locations",{typeCtor:e,propertyKey:i,parameterIndex:null,index:t})}}const _a=t=>(e,s,i)=>{da(e,"inputs",{inputCtor:t,propertyKey:s,parameterIndex:i})},fa=t=>(e,s)=>{da(e,"uniforms",{typeCtor:t,propertyKey:s})},ma=t=>(e,s)=>{da(e,"options",{typeCtor:t,propertyKey:s})},ga=(t,e)=>{da(t,"defines",{propertyKey:e})},ya=(t,e)=>(s,i)=>{s.constructor.builtins.push({builtin:t,propertyKey:i,typeCtor:e})};class xa{}xa.builtins=[],(0,P._)([ya("gl_VertexID",zn)],xa.prototype,"glVertexID",void 0);class ba{}class wa{}wa.builtins=[],(0,P._)([ya("gl_FragCoord",Sn)],wa.prototype,"glFragCoord",void 0),(0,P._)([ya("gl_PointCoord",wn)],wa.prototype,"glPointCoord",void 0);class va{}(0,P._)([(t,e)=>{da(t,"builtins",{builtin:"gl_FragColor",propertyKey:e})}],va.prototype,"glFragColor",void 0);class Sa{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class Ia{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)?A.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),i=this.computeAttributes;this._locationInfo={hash:s,locations:t,computeAttributeMap:i}}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,i){try{const{vertex:r,fragment:n,uniformBindings:o}=this._generateShaders(t,e,s,i);return new la(r,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(t){return new la("","",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,i){const r=Object.keys(t).map((e=>`${e}.${t[e]}`)).join("."),n=Object.keys(s).map((t=>`${t}.${s[t]}`)).join("."),o=Object.keys(i).map((t=>`${t}.${i[t]}`)).join("."),a=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${r}.${n}.${o}.${a}`}_generateShaders(t,e,s,i){const r=[];this._setDefines(s),this._setOptionalUniforms(r,e),this._setRequiredUniforms(r);const n=this._hydrateVertexInput(i),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)Yr(d,u[t]);const p=this._getVertexInputBuiltins(),_=Fo.createVertex({...n,...a},c,p,r,this.transformFeedbackBindings,d);(new Co).write(_);const f=this._getFragmentInputBuiltins(u);f.set("glPointCoord","gl_PointCoord");const m=Fo.createFragment(l,u,f,r,_,this.transformFeedbackBindings);(new Co).write(m);const g=this._createShaderBuilder(_,m),y=g.generate("vertex",!1),x=g.generate("fragment",!1);return this.logShader&&(console.log(y),console.log(x)),{vertex:y,fragment:x,uniformBindings:r}}_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 i of s._uniforms??[]){const r=ua(i.typeCtor),n=`u_${e.propertyKey}_${i.propertyKey}`,o=r.type,a=[e.propertyKey,i.propertyKey].join(".");if("type"in i.typeCtor&&"array"===i.typeCtor.type){const e=r;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:r})}else t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:r});s[i.propertyKey]=r}return s}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,s=e.locations.reduce(((e,s)=>!1===t[s.propertyKey]?e:{...e,[s.propertyKey]:ua(s.typeCtor)}),{});for(const{propertyKey:t,typeCtor:i}of e.builtins){const e=ua(i);s[t]=e}return s}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:ua(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const s={};for(const i in t){const r=t[i],n=e[i];if(n){if("float"!==r.type&&"vec2"!==r.type&&"vec3"!==r.type&&"vec4"!==r.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${r.type}`);s[i]=r.divide(new bn(n))}else s[i]=r}return s}_injectComputePackPrecisionFactor(t,e){const s={},i=new Map;for(const t in this.computeAttributes)for(const e of this.computeAttributes[t]??[])i.set(e,t);for(const r in t){const n=t[r],o=i.get(r);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[r]=n.divide(new bn(a))}else s[r]=n}return s}_hydrateFragmentInput(t){const e={};for(const s in t)e[s]=t[s];for(const{propertyKey:t,typeCtor:s}of wa.builtins){const i=ua(s);e[t]=i}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:s,propertyKey:i}of t.builtins)e.set(i,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 Lr;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`)}}let Pa=class extends M.A{constructor(){super(...arguments),this.color=new er.A([0,255,255]),this.haloOpacity=1,this.fillOpacity=.25,this.multiHighlightEnabled=!1}equals(t){return this.color.equals(t.color)&&(this.haloColor||this.color).equals(t.haloColor||t.color)&&this.haloOpacity===t.haloOpacity&&this.fillOpacity===t.fillOpacity&&this.multiHighlightEnabled===t.multiHighlightEnabled}};(0,P._)([(0,C.MZ)({type:er.A})],Pa.prototype,"color",void 0),(0,P._)([(0,C.MZ)({type:er.A})],Pa.prototype,"haloColor",void 0),(0,P._)([(0,C.MZ)()],Pa.prototype,"haloOpacity",void 0),(0,P._)([(0,C.MZ)()],Pa.prototype,"fillOpacity",void 0),(0,P._)([(0,C.MZ)()],Pa.prototype,"multiHighlightEnabled",void 0),Pa=(0,P._)([(0,E.$)("esri.views.2d.support.HighlightOptions")],Pa);const Ma=Pa,Ta={selection:t=>new Ma({color:new er.A([t.color.r/2,t.color.g/2,t.color.b/2,t.color.a])}),highlight:t=>t,popup:t=>new Ma({color:new er.A([t.color.g,t.color.b,t.color.r,t.color.a])})},Ca=Object.keys(Ta);function Aa(t){const e=Vn(12.9898),s=Vn(78.233),i=Vn(43758.5453);return go(Io(vo(mo(t,qn(e,s)),Vn(3.14))).multiply(i))}function Ea(t){return no(t,Vn(yr))}function Fa(t,e){const s=Vn(2**e);return vo(function(t){return $n("floor",t)}(t.divide(s)),Vn(2))}function ka(t,e){return Fa(t,e+Ca.length)}class za extends Sa{getVisualVariableData(t){if(!this._vvData){const e=this.getAttributeDataCoords(t);this._vvData=Mo(this.visualVariableData,e).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(t){if(!this._uv){const e=function(t){const e=Fa(t.z,7),s=Vn(1).subtract(e),i=t.xyz.subtract(((...t)=>new vn(...t))(0,0,Vn(128)));return s.multiply(t).add(e.multiply(i))}(t),s=this.size,i=Un(e.x),r=Un(e.y).multiply(Un(256)),n=Un(e.z).multiply(Un(256)).multiply(Un(256)),o=Vn(i.add(r).add(n)),a=vo(o,s),h=o.subtract(a).divide(s);this._uv=new wn(a,h).add(.5).divide(s)}return this._uv}getFilterData(t){const e=this.getAttributeDataCoords(t);return Mo(this.filterFlags,e).setDebugName("storage0")}getAnimationData(t){const e=this.getAttributeDataCoords(t);return Mo(this.animation,e).setDebugName("storage1")}getVVData(t){return this.getVisualVariableData(t)}getDataDrivenData0(t){const e=this.getAttributeDataCoords(t);return Mo(this.dataDriven0,e).setDebugName("storage30")}getDataDrivenData1(t){const e=this.getAttributeDataCoords(t);return Mo(this.dataDriven1,e).setDebugName("storage31")}getDataDrivenData2(t){const e=this.getAttributeDataCoords(t);return Mo(this.dataDriven2,e).setDebugName("storage32")}getGPGPUData(t){const e=this.getAttributeDataCoords(t);return Mo(this.gpgpu,e).setDebugName("storage4")}getFilterFlags(t){return(0,n.A)("webgl-ignores-sampler-precision")?function(t){return $n("ceil",t)}(this.getFilterData(t).x.multiply(Vn(255))):this.getFilterData(t).x.multiply(Vn(255))}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._)([fa(xn)],za.prototype,"filterFlags",void 0),(0,P._)([fa(xn)],za.prototype,"animation",void 0),(0,P._)([fa(xn)],za.prototype,"gpgpu",void 0),(0,P._)([fa(xn)],za.prototype,"visualVariableData",void 0),(0,P._)([fa(xn)],za.prototype,"dataDriven0",void 0),(0,P._)([fa(xn)],za.prototype,"dataDriven1",void 0),(0,P._)([fa(xn)],za.prototype,"dataDriven2",void 0),(0,P._)([fa(bn)],za.prototype,"size",void 0);class Oa extends Sa{}(0,P._)([fa(bn)],Oa.prototype,"activeReasons",void 0),(0,P._)([fa(bn)],Oa.prototype,"highlightAll",void 0);class Ra extends Sa{}(0,P._)([fa(wn)],Ra.prototype,"position",void 0),(0,P._)([fa(bn)],Ra.prototype,"distance",void 0),(0,P._)([fa(bn)],Ra.prototype,"smallSymbolDistance",void 0),(0,P._)([fa(bn)],Ra.prototype,"smallSymbolSizeThreshold",void 0);class La extends Sa{}(0,P._)([fa(Dn)],La.prototype,"displayViewScreenMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"displayViewMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"displayMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"viewMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"tileMat3",void 0),(0,P._)([fa(bn)],La.prototype,"displayZoomFactor",void 0),(0,P._)([fa(bn)],La.prototype,"requiredZoomFactor",void 0),(0,P._)([fa(wn)],La.prototype,"tileOffset",void 0),(0,P._)([fa(bn)],La.prototype,"currentScale",void 0),(0,P._)([fa(bn)],La.prototype,"currentZoom",void 0),(0,P._)([fa(bn)],La.prototype,"metersPerSRUnit",void 0),(0,P._)([fa(bn)],La.prototype,"rotation",void 0),(0,P._)([fa(bn)],La.prototype,"pixelRatio",void 0);class Na extends xa{}(0,P._)([pa(0,vn)],Na.prototype,"id",void 0),(0,P._)([pa(1,bn)],Na.prototype,"bitset",void 0),(0,P._)([pa(2,wn)],Na.prototype,"pos",void 0);class Da extends ba{}(0,P._)([pa(14,wn)],Da.prototype,"nextPos1",void 0),(0,P._)([pa(15,wn)],Da.prototype,"nextPos2",void 0);class Ba extends wa{}class Ga extends Ia{clip(t,e){let s=new bn(0);const i=this.storage.getFilterFlags(t);if(s=s.add(Vn(2).multiply(Vn(1).subtract(ka(i,0)))),this.inside?s=s.add(Vn(2).multiply(Vn(1).subtract(ka(i,1)))):this.outside?s=s.add(Vn(2).multiply(ka(i,1))):this.highlight&&(s=s.add(Vn(2).multiply(Vn(1).subtract(this._checkHighlight(i))))),null!=e){const t=new bn(1).subtract(Po(e.x,this.view.currentZoom)),i=Po(e.y,this.view.currentZoom);s=s.add(new bn(2).multiply(t.add(i)))}return s}getFragmentOutput(t,e,s=new bn(1/255)){const i=new va;return i.glFragColor=this._maybeWriteHittest(e)??this._maybeHighlight(t,s)??t,i}_maybeHighlight(t,e){return this.highlight?new Sn(t.rgb,Po(e,t.a)):null}_checkHighlight(t){let e=this._checkHighlightBit(t,0);for(let s=1;s<Ca.length;s++)e=e.add(this._checkHighlightBit(t,s));return Po(new bn(.1),e.add(this.highlight.highlightAll))}_checkHighlightBit(t,e){return function(t,e){return Fa(t,e)}(t,e).multiply(Fa(this.highlight.activeReasons,e))}maybeRunHittest(t,e,s){if(null==this.hittestRequest)return null;let i=Jn(ao(this.hittest(t,e,s),this.hittestRequest.distance),new bn(2),new bn(0));const r=function(t){return t.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(t.id));i=i.add(this.clip(t.id,t.zoomRange));const n=new Sn(new bn(1/255),0,0,0);return{glPointSize:new bn(1),glPosition:new Sn(r,i,1),color:n}}_maybeWriteHittest(t){return null!=this.hittestRequest?t.color:null}}function Ua(t,e,s){const i=s.subtract(e),r=_o(function(t,e){return mo(t,function(t){return $n("normalize",t)}(e))}(t.subtract(e),i).divide(yo(i)),new bn(0),new bn(1));return function(t,e){return Hn("distance",t,e,bn)}(t,e.add(r.multiply(s.subtract(e))))}function Va(t,e,s,i){return no(function(t){const e=function(t){return $n("abs",t)}(t);return Po(e.x.add(e.y).add(e.z),new bn(1.05))}(function(t,e,s,i){const r=new Dn(s.x.multiply(i.y).subtract(i.x.multiply(s.y)),i.x.multiply(e.y).subtract(e.x.multiply(i.y)),e.x.multiply(s.y).subtract(s.x.multiply(e.y)),s.y.subtract(i.y),i.y.subtract(e.y),e.y.subtract(s.y),i.x.subtract(s.x),e.x.subtract(i.x),s.x.subtract(e.x)),n=e.x.multiply(s.y.subtract(i.y)),o=s.x.multiply(i.y.subtract(e.y)),a=i.x.multiply(e.y.subtract(s.y)),h=n.add(o).add(a);return new bn(1).divide(h).multiply(r.multiply(new vn(1,t)))}(t,e,s,i)),new bn(1))}function qa(t){return t.distance.add(1)}function Wa(t,e,s){const{viewMat3:i,tileMat3:r}=t.view,n=i.multiply(r),o=n.multiply(new vn(e.pos,1)),a=n.multiply(new vn(s.nextPos1,1)),h=n.multiply(new vn(s.nextPos2,1));return function(t,e,s,i){const r=function(t,e){return t.x.multiply(e.y).subtract(e.x.multiply(t.y))}(s.subtract(e),i.subtract(e)),n=lo(function(t,e){return Xn("<",t,e,Cn)}(r,new bn(gr)),ao(r,new bn(-gr)));return to([lo(So(n),Va(t.xy,e,s,i)),new bn(-1)],[!0,()=>{const r=Ua(t,e,s),n=Ua(t,s,i),o=Ua(t,i,e);return bo(bo(r,n),o)}])}(t.hittestRequest.position,o.xy,a.xy,h.xy)}(0,P._)([ga],Ga.prototype,"inside",void 0),(0,P._)([ga],Ga.prototype,"outside",void 0),(0,P._)([ma(Oa)],Ga.prototype,"highlight",void 0),(0,P._)([fa(za)],Ga.prototype,"storage",void 0),(0,P._)([fa(La)],Ga.prototype,"view",void 0),(0,P._)([ma(Ra)],Ga.prototype,"hittestRequest",void 0);class Ya extends Sa{getColor(t,e,s){return to([co(Ea(t),s),e],[oo(t,this.values.first()),this.colors.first()],[ho(t,this.values.last()),this.colors.last()],[!0,()=>{const e=this.values.findIndex((e=>ao(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.colors.get(i),this.colors.get(e),n)}])}}(0,P._)([fa(yn.ofType(Sn,8))],Ya.prototype,"colors",void 0),(0,P._)([fa(yn.ofType(bn,8))],Ya.prototype,"values",void 0);class ja extends Sa{getOpacity(t){return to([Ea(t),new bn(1)],[oo(t,this.opacityValues.first()),this.opacities.first()],[ho(t,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const e=this.opacityValues.findIndex((e=>ao(e,t))),s=this.opacityValues.get(e),i=e.subtract(1),r=this.opacityValues.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.opacities.get(i),this.opacities.get(e),n)}])}}function Xa(t){return null!=t.visualVariableSizeMinMaxValue||null!=t.visualVariableSizeScaleStops||null!=t.visualVariableSizeStops||null!=t.visualVariableSizeUnitValue}function $a(t,e,s,i=new Cn(!1)){if(null==t.visualVariableColor)return s;const r=t.storage.getColorValue(e);return t.visualVariableColor.getColor(r,s,i)}function Ha(t,e){if(null==t.visualVariableOpacity)return new bn(1);const s=t.storage.getOpacityValue(e);return t.visualVariableOpacity.getOpacity(s)}(0,P._)([fa(yn.ofType(bn,8))],ja.prototype,"opacities",void 0),(0,P._)([fa(yn.ofType(bn,8))],ja.prototype,"opacityValues",void 0);class Za extends Na{}(0,P._)([pa(3,Sn)],Za.prototype,"color",void 0),(0,P._)([pa(4,wn)],Za.prototype,"zoomRange",void 0);class Qa extends Ga{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Ha(this,t.id),i=$a(this,t.id,t.color).multiply(s),r=this.view.displayViewScreenMat3.multiply(new vn(t.pos.xy,1)),n=this.clip(t.id,t.zoomRange);return{glPosition:new Sn(r.xy,n,1),color:i,...this.maybeRunHittest(t,e,null)}}fragment(t){return this.getFragmentOutput(t.color,t,new bn(0))}hittest(t,e){return Wa(this,t,e)}}(0,P._)([ma(Ya)],Qa.prototype,"visualVariableColor",void 0),(0,P._)([ma(ja)],Qa.prototype,"visualVariableOpacity",void 0),(0,P._)([(0,P.a)(0,_a(Za)),(0,P.a)(1,_a(Da))],Qa.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(Ba))],Qa.prototype,"fragment",null);class Ka extends Sa{getPatternOffsetAtTileOrigin(t,e=new bn(0),s=new bn(1)){const i=new wn(16777216).divide(t);let r=t.multiply(go(this.maxIntsToLocalOrigin.multiply(i))).add(this.tileOffsetFromLocalOrigin).subtract(new bn(.5).multiply(t));return r=new wn(r.x.multiply(s).subtract(r.y.multiply(e)),r.x.multiply(e).add(r.y.multiply(s))),vo(r,t)}}(0,P._)([fa(wn)],Ka.prototype,"tileOffsetFromLocalOrigin",void 0),(0,P._)([fa(wn)],Ka.prototype,"maxIntsToLocalOrigin",void 0);class Ja extends Sa{}(0,P._)([fa(wn)],Ja.prototype,"size",void 0),(0,P._)([fa(xn)],Ja.prototype,"texture",void 0);class th extends Za{}function eh(t,e){const s=t.view.requiredZoomFactor,i=new wn(e.width,e.height),r=i.multiply(e.scale).multiply(s),n=e.angle.multiply(.024543692606171875),o=Io(n),a=fo(n),h=function(t,e,s,i,r){const n=no(Fa(r,xr),Vn(1)),o=function(t){return mo(t,Wn(255/256,255/65536,255/16777216,255/4294967296))}(new Sn(t,0));return Jn(n,Yn(i.divide(e.x),s.divide(e.y),0,Qn(s.divide(e.x)),i.divide(e.y),0,Aa(qn(o,0)),Aa(qn(0,o)),1),Yn(i.divide(e.x),s.divide(e.y),0,Qn(s.divide(e.x)),i.divide(e.y),0,0,0,1))}(e.id,r,o,a,e.bitset),c=t.localTileOffset.getPatternOffsetAtTileOrigin(i,o,a),l=s.multiply(e.scale).multiply(e.offset.subtract(c)).divide(r),u=new vn(e.pos,1),d=h.multiply(u).xy.subtract(l),p=e.tlbr.divide(t.mosaicInfo.size.xyxy);let _=Fa(e.bitset,4);return null!=t.visualVariableColor&&(_=Jn(Ea(t.storage.getColorValue(e.id)),new bn(0),_)),{tileTextureCoord:d,tlbr:p,sampleAlphaOnly:_}}function sh(t,e){const s=vo(e.tileTextureCoord,new bn(1)),i=wo(e.tlbr.xy,e.tlbr.zw,s);let r=Mo(t.mosaicInfo.texture,i);return r=Jn(ao(e.sampleAlphaOnly,new bn(.5)),r.aaaa,r),e.color.multiply(r)}(0,P._)([pa(5,Sn)],th.prototype,"tlbr",void 0),(0,P._)([pa(6,bn)],th.prototype,"width",void 0),(0,P._)([pa(7,bn)],th.prototype,"height",void 0),(0,P._)([pa(8,wn)],th.prototype,"offset",void 0),(0,P._)([pa(9,wn)],th.prototype,"scale",void 0),(0,P._)([pa(10,bn)],th.prototype,"angle",void 0);class ih extends Qa{vertex(t,e){return{...super.vertex(t,e),...eh(this,t)}}fragment(t){const e=sh(this,t);return this.getFragmentOutput(e,t,new bn(0))}}(0,P._)([fa(Ja)],ih.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],ih.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(th)),(0,P.a)(1,_a(Da))],ih.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(class extends Ba{}))],ih.prototype,"fragment",null);class rh extends Sa{getSize(t,e){const s=this.minMaxValueAndSize.xy,i=this.minMaxValueAndSize.zw;return Jn(Ea(t),e,(()=>{const e=_o(t.subtract(s.x).divide(s.y.subtract(s.x)),new bn(0),new bn(1));return i.x.add(e.multiply(i.y.subtract(i.x)))}))}}(0,P._)([fa(Sn)],rh.prototype,"minMaxValueAndSize",void 0);class nh extends Sa{getSizeForViewScale(t){return to([oo(t,this.values.first()),this.sizes.first()],[ho(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>ao(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.sizes.get(i),this.sizes.get(e),n)}])}}(0,P._)([fa(yn.ofType(bn,8))],nh.prototype,"sizes",void 0),(0,P._)([fa(yn.ofType(bn,8))],nh.prototype,"values",void 0);class oh extends Sa{getSize(t,e){const s=to([Ea(t),e],[oo(t,this.values.first()),this.sizes.first()],[ho(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>ao(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.sizes.get(i),this.sizes.get(e),n)}]);return Jn(Ea(s),e,s)}}(0,P._)([fa(yn.ofType(bn,8))],oh.prototype,"sizes",void 0),(0,P._)([fa(yn.ofType(bn,8))],oh.prototype,"values",void 0);class ah extends Sa{getSize(t,e){return Jn(Ea(t),e,t.multiply(this.unitValueToPixelsRatio))}}(0,P._)([fa(bn)],ah.prototype,"unitValueToPixelsRatio",void 0);class hh extends Na{}(0,P._)([pa(3,Sn)],hh.prototype,"color",void 0),(0,P._)([pa(4,wn)],hh.prototype,"offset",void 0),(0,P._)([pa(5,wn)],hh.prototype,"normal",void 0),(0,P._)([pa(6,bn)],hh.prototype,"halfWidth",void 0),(0,P._)([pa(7,bn)],hh.prototype,"referenceHalfWidth",void 0),(0,P._)([pa(8,wn)],hh.prototype,"zoomRange",void 0);class ch extends Ba{}class lh extends Sa{}function uh(t){return xo(new bn(_r).multiply(Po(t,new bn(fr))),new bn(1))}function dh(t,e){const{id:s,offset:i,pos:r,normal:n,zoomRange:o}=e,{displayViewScreenMat3:a,displayViewMat3:h}=t.view,c=$a(t,s,e.color),l=Ha(t,s),u=function(t,e){const{id:s,halfWidth:i,referenceHalfWidth:r}=e;if(Xa(t)){const e=function(t,e,s){if(Xa(t)){const i=t.storage.getSizeValue(e);return t.visualVariableSizeMinMaxValue?.getSize(i,s)??t.visualVariableSizeScaleStops?.getSizeForViewScale(t.view.currentScale)??t.visualVariableSizeStops?.getSize(i,s)??t.visualVariableSizeUnitValue?.getSize(i,s)}return s}(t,s,new bn(2).multiply(r));return new bn(.5).multiply(i.divide(xo(r,new bn(mr)))).multiply(e)}return i}(t,e),d=new bn(.5).multiply(t.antialiasingControls.antialiasing),p=xo(u.add(d),new bn(.45)).add(new bn(.1).multiply(d)),_=uh(p).multiply(p).multiply(i),f=h.multiply(new vn(_,new bn(0))),m=a.multiply(new vn(r,new bn(1))).add(f),g=new bn(2).multiply(Po(u,new bn(0))).add(t.clip(s,o)),y=new Sn(m.xy,g,1);return{color:c,opacity:l,halfWidth:p,normal:n,scaledOffset:_,scaledHalfWidth:u,glPosition:new Sn(y.xy,g,1)}}function ph(t,e){const{opacity:s,color:i}=t,r=function(t,e){const{halfWidth:s,normal:i}=t,r=uh(s),n=yo(i).multiply(s);return _o(r.multiply(s.subtract(n)).divide(e.add(r).subtract(new bn(1))),new bn(0),new bn(1))}(t,e);return s.multiply(i).multiply(r)}(0,P._)([fa(bn)],lh.prototype,"antialiasing",void 0),(0,P._)([fa(bn)],lh.prototype,"blur",void 0);class _h extends Ga{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=dh(this,t);return{...s,...this.maybeRunHittest(t,e,s.halfWidth)}}fragment(t){const e=ph(t,this.antialiasingControls.blur);return this.getFragmentOutput(e,t)}hittest(t,e,s){const{viewMat3:i,tileMat3:r}=this.view,n=i.multiply(r),o=n.multiply(new vn(t.pos,1)),a=n.multiply(new vn(e.nextPos1,1)),h=n.multiply(new vn(e.nextPos2,1)),{distance:c,smallSymbolDistance:l,smallSymbolSizeThreshold:u}=this.hittestRequest,d=Po(s,u.multiply(.5)).multiply(c.subtract(l)),p=this.hittestRequest.position;return bo(Ua(p,o.xy,a.xy),Ua(p,o.xy,h.xy)).subtract(s).add(d)}}(0,P._)([fa(lh)],_h.prototype,"antialiasingControls",void 0),(0,P._)([ma(Ya)],_h.prototype,"visualVariableColor",void 0),(0,P._)([ma(ja)],_h.prototype,"visualVariableOpacity",void 0),(0,P._)([ma(rh)],_h.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([ma(nh)],_h.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([ma(oh)],_h.prototype,"visualVariableSizeStops",void 0),(0,P._)([ma(ah)],_h.prototype,"visualVariableSizeUnitValue",void 0),(0,P._)([(0,P.a)(0,_a(hh)),(0,P.a)(1,_a(Da))],_h.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(ch))],_h.prototype,"fragment",null);class fh extends Na{}(0,P._)([pa(3,wn)],fh.prototype,"offset",void 0),(0,P._)([pa(4,Sn)],fh.prototype,"color",void 0),(0,P._)([pa(5,wn)],fh.prototype,"normal",void 0),(0,P._)([pa(6,bn)],fh.prototype,"halfWidth",void 0),(0,P._)([pa(7,bn)],fh.prototype,"referenceHalfWidth",void 0),(0,P._)([pa(8,wn)],fh.prototype,"zoomRange",void 0);class mh extends ch{}function gh(t,e,s){const{id:i,bitset:r}=e,n=Fa(r,0),o=ao(n,new bn(.5)),a=dh(t,e),h=Jn(o,a.halfWidth,new bn(0)),c=Ha(t,i),l=$a(t,i,e.color),u=Jn(o,e.color,l.multiply(c)),d=t.view.displayViewScreenMat3.multiply(new vn(e.pos.xy,1)),p=t.clip(e.id),_=new Sn(d.xy,p,1),f=Jn(o,a.glPosition,_),m=s&&t.maybeRunHittest(e,s,o);return{isOutline:n,color:u,opacity:new bn(1),halfWidth:h,normal:a.normal,glPosition:f,...m}}class yh extends Ga{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,P._)([fa(lh)],yh.prototype,"antialiasingControls",void 0),(0,P._)([ma(Ya)],yh.prototype,"visualVariableColor",void 0),(0,P._)([ma(ja)],yh.prototype,"visualVariableOpacity",void 0),(0,P._)([ma(rh)],yh.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([ma(nh)],yh.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([ma(oh)],yh.prototype,"visualVariableSizeStops",void 0),(0,P._)([ma(ah)],yh.prototype,"visualVariableSizeUnitValue",void 0);class xh extends yh{vertex(t,e){return gh(this,t,e)}fragment(t){const{color:e,isOutline:s}=t,i=ao(s,new bn(.5)),r=Jn(i,ph(t,this.antialiasingControls.blur),e),n=Jn(i,new bn(1/255),new bn(0));return this.getFragmentOutput(r,t,n)}hittest(t,e,s){return Jn(s,qa(this.hittestRequest),Wa(this,t,e))}}(0,P._)([(0,P.a)(0,_a(fh)),(0,P.a)(1,_a(Da))],xh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(mh))],xh.prototype,"fragment",null);class bh extends Za{}function wh(t,e){const s=e.tlbr.xy,i=e.tlbr.zw,r=i.x.subtract(s.x),n=s.y.subtract(i.y),o=new wn(r,n).multiply(e.inverseRasterizationScale),a=o.multiply(t.view.requiredZoomFactor),h=function(t){const e=new bn(1),s=new bn(0);return new Dn(e.divide(t.x),s.divide(t.y),0,Qn(s.divide(t.x)),e.divide(t.y),0,0,0,1)}(a),c=t.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),l=new vn(e.pos,1);return{tileTextureCoord:h.multiply(l).xy.subtract(c),tlbr:e.tlbr.divide(t.mosaicInfo.size.xyxy)}}function vh(t,e){const s=vo(t.tileTextureCoord,new bn(1)),i=wo(t.tlbr.xy,t.tlbr.zw,s),r=Mo(e.texture,i);return t.color.multiply(r)}(0,P._)([pa(5,Sn)],bh.prototype,"tlbr",void 0),(0,P._)([pa(6,bn)],bh.prototype,"inverseRasterizationScale",void 0);class Sh extends Qa{vertex(t,e){return{...super.vertex(t,e),...wh(this,t)}}fragment(t){const e=vh(t,this.mosaicInfo);return this.getFragmentOutput(e,t,new bn(0))}}(0,P._)([fa(Ja)],Sh.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],Sh.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(bh)),(0,P.a)(1,_a(Da))],Sh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(class extends Ba{}))],Sh.prototype,"fragment",null);class Ih extends fh{}(0,P._)([pa(9,Sn)],Ih.prototype,"tlbr",void 0),(0,P._)([pa(10,bn)],Ih.prototype,"inverseRasterizationScale",void 0);class Ph extends mh{}class Mh extends xh{vertex(t,e){return{...gh(this,t,e),...wh(this,t)}}fragment(t){const{isOutline:e}=t,s=ao(e,new bn(.5)),i=Jn(s,ph(t,this.antialiasingControls.blur),vh(t,this.mosaicInfo)),r=Jn(s,new bn(1/255),new bn(0));return this.getFragmentOutput(i,t,r)}}(0,P._)([fa(Ja)],Mh.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],Mh.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(Ih)),(0,P.a)(1,_a(Da))],Mh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(Ph))],Mh.prototype,"fragment",null);const Th=1/16;class Ch extends Na{}(0,P._)([pa(3,Sn)],Ch.prototype,"color",void 0),(0,P._)([pa(4,Sn)],Ch.prototype,"tlbr",void 0),(0,P._)([pa(5,bn)],Ch.prototype,"angle",void 0),(0,P._)([pa(6,bn)],Ch.prototype,"aux1",void 0),(0,P._)([pa(7,bn)],Ch.prototype,"aux2",void 0),(0,P._)([pa(8,wn)],Ch.prototype,"aux3",void 0),(0,P._)([pa(9,wn)],Ch.prototype,"aux4",void 0),(0,P._)([pa(10,wn)],Ch.prototype,"zoomRange",void 0);class Ah extends yh{vertex(t,e){const{aux1:s,aux2:i,aux3:r,aux4:n}=t,o={...t,width:s,height:i,offset:r,scale:n.multiply(Th)},a=gh(this,{...t,halfWidth:s,referenceHalfWidth:i,offset:r,normal:n.subtract(128).multiply(Th)}),h=eh(this,o),c=ao(a.isOutline,new bn(.5));return{...a,...h,...this.maybeRunHittest(t,e,c)}}fragment(t){const{isOutline:e}=t,s=ao(e,new bn(.5)),i=Jn(s,ph(t,this.antialiasingControls.blur),sh(this,t)),r=Jn(s,new bn(1/255),new bn(0));return this.getFragmentOutput(i,t,r)}hittest(t,e,s){return Jn(s,qa(this.hittestRequest),Wa(this,t,e))}}(0,P._)([fa(Ja)],Ah.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],Ah.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(Ch)),(0,P.a)(1,_a(Da))],Ah.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(class extends Ph{}))],Ah.prototype,"fragment",null);const Eh=vr,Fh=Er,kh={createComputedParams:t=>t,optionalAttributes:Eh.optionalAttributes,attributes:{...Eh.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>wr(t)},aux1:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).width},aux2:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).height},aux3:{count:2,type:pt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),(0,l.Lz)(e)]},aux4:{count:2,type:pt.pe.UNSIGNED_BYTE,pack:({scaleX:t,scaleY:e})=>[16*t,16*e]}}},zh={createComputedParams:t=>t,optionalAttributes:Eh.optionalAttributes,attributes:{...Eh.attributes,color:Fh.attributes.color,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>rr([[0,!0]])},aux1:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.width)},aux2:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.referenceWidth)},aux3:{count:2,type:pt.pe.HALF_FLOAT,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[t,e]},aux4:{count:2,type:pt.pe.UNSIGNED_BYTE,packTessellation:({normalX:t,normalY:e})=>[16*t+128,16*e+128]}}};class Oh extends Fr{constructor(){super(...arguments),this.vertexSpec=zh}}class Rh extends kr{constructor(){super(...arguments),this.vertexSpec=kh}_createOutlineWriter(t,e,s,i){return new Oh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,Ie.fromOptimizedCIM(r,"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 Lh={optionalAttributes:lr.optionalAttributes,createComputedParams:t=>t,attributes:{...lr.attributes,...Ar.attributes}},Nh={optionalAttributes:lr.optionalAttributes,createComputedParams:t=>t,attributes:{...lr.attributes,...Er.attributes}};class Dh extends Fr{constructor(){super(...arguments),this.vertexSpec=Nh}}class Bh extends kr{constructor(){super(...arguments),this.vertexSpec=Lh}_createOutlineWriter(t,e,s,i){return new Dh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,Ie.fromOptimizedCIM(r,"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 Gh={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},offset:{type:pt.pe.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};class Uh extends Zi{constructor(){super(...arguments),this.vertexSpec=Gh}_write(t,e){t.recordStart(this.instanceId,this.attributeLayout);const s=e.getDisplayId();if("esriGeometryPoint"===e.geometryType){const i=e.readXForDisplay(),r=e.readYForDisplay();this._writeQuad(t,s,i,r)}else if("esriGeometryMultipoint"===e.geometryType){const i=e.readGeometryForDisplay();i?.forEachVertex(((e,i)=>{e>=0&&e<=512&&i>=0&&i<=512&&this._writeQuad(t,s,e,i)}))}t.recordEnd()}_writeQuad(t,e,s,i){const r=t.vertexCount();this._writeVertex(t,e,s,i),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}var Vh=s(91869),qh=s(48163),Wh=s(90708);const Yh=8388607,jh=t=>t&Yh;class Xh{constructor(t,e,s,i,r,n,o,a,h=[]){this.entityTexel=t,this.anchorX=e,this.anchorY=s,this.directionX=i,this.directionY=r,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)),Y(t,this.bounds)}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=t.readF32(),r=t.readF32(),n=t.readF32(),o=t.readF32(),a=t.readF32(),h=t.readF32(),c=t.readF32(),l=t.readF32(),u=j(t,Pi)??[];return new Xh(e,s,i,r,n,o,a,{size:h,offsetX:c,offsetY:l},u)}}const $h=1024;function Hh(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function Zh(t,e){return Math.sqrt(t*t+e*e)}function Qh(t){const e=Zh(t[0],t[1]);t[0]/=e,t[1]/=e}function Kh(t,e){return Zh(t[0]-e[0],t[1]-e[1])}function Jh(t){return t.length-1}function tc(t,e,s=1){let[i,r]=function(t,e){return t[e+1]}(t,e);return[i,r]=[Math.round(i),Math.round(r)],Math.sqrt(i*i+r*r)*s}class ec{constructor(t,e,s,i,r){this._segments=t,this._index=e,this._distance=s,this._xStart=i,this._yStart=r,this._done=!1}static create(t){return new ec(t,0,0,t[0][0],t[0][1])}clone(){return new ec(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<Jh(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 i=this.backwardLength;for(;this.prev();){if(i+this.length>t)return this._seekBackwards(t-i);i+=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 sc(t,e,s,i=!0){const r=function(t){let e=0;for(let s=0;s<Jh(t);s++)e+=tc(t,s);return e}(t),n=ec.create(t),o=r/2;if(!i)return n.seek(o),void(Math.abs(n.x)<$h&&Math.abs(n.y)<$h&&s(n.clone(),0,o+0*e,r));const a=Math.max((r-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)<$h&&Math.abs(n.y)<$h&&s(n.clone(),t,o+t*e,r),n.seek(e)}function ic(t,e){const s=e;for(let e=0;e<t.length;e++){let i=t[e];rc(i,s);const r=[];r.push(i[0]);for(let t=1;t<i.length;t++){const[e,s]=i[t-1],[n,o]=i[t],a=n-e,h=o-s;r.push([a,h])}t[e]=r,i=r}return t}function rc(t,e){const s=1e-6;if(e<=0)return;const i=t.length;if(i<3)return;const r=[];let n=0;r.push(0);for(let e=1;e<i;e++)n+=Kh(t[e],t[e-1]),r.push(n);e=Math.min(e,.2*n);const o=[];o.push(t[0][0]),o.push(t[0][1]);const a=t[i-1][0],h=t[i-1][1],c=Hh([0,0],t[0],t[1]);Qh(c),t[0][0]+=e*c[0],t[0][1]+=e*c[1],Hh(c,t[i-1],t[i-2]),Qh(c),t[i-1][0]+=e*c[0],t[i-1][1]+=e*c[1];for(let t=1;t<i;t++)r[t]+=e;r[i-1]+=e;const l=.5*e;for(let n=1;n<i-1;n++){let a=0,h=0,c=0;for(let i=n-1;i>=0&&!(r[i+1]<r[n]-l);i--){const o=l+r[i+1]-r[n],u=r[i+1]-r[i],d=r[n]-r[i]<l?1:o/u;if(Math.abs(d)<s)break;const p=d*d,_=d*o-.5*p*u,f=d*u/e,m=t[i+1],g=t[i][0]-m[0],y=t[i][1]-m[1];a+=f/_*(m[0]*d*o+.5*p*(o*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*o+.5*p*(o*y-u*m[1])-p*d*u*y/3),c+=f}for(let o=n+1;o<i&&!(r[o-1]>r[n]+l);o++){const i=l-r[o-1]+r[n],u=r[o]-r[o-1],d=r[o]-r[n]<l?1:i/u;if(Math.abs(d)<s)break;const p=d*d,_=d*i-.5*p*u,f=d*u/e,m=t[o-1],g=t[o][0]-m[0],y=t[o][1]-m[1];a+=f/_*(m[0]*d*i+.5*p*(i*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*i+.5*p*(i*y-u*m[1])-p*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<i;e++)t[e][0]=o[s++],t[e][1]=o[s++]}var nc=s(34727);class oc{static getPlacement(t,e,s,i,r,n){const o=function(t){if(!t)return null;switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":return Is.local();case"CIMMarkerPlacementAtExtremities":return Ms.local();case"CIMMarkerPlacementAtRatioPositions":return Cs.local();case"CIMMarkerPlacementInsidePolygon":return zs.local();case"CIMMarkerPlacementOnLine":return Ls.local();case"CIMMarkerPlacementOnVertices":return Ds.local();case"CIMMarkerPlacementPolygonCenter":return ii.local()}return null}(s);return o?(-1===e&&t.invertY(),o.execute(t,s,i,r,n)):null}}class ac{constructor(t){const{offsetX:e,offsetY:s,postAngle:i,fontSize:r,scaleFactor:n,transforms:o}=t;if(this.offsetX=e,this.offsetY=s,this.postAngle=i,this.fontSize=Math.min(r,96),this.transforms=o,o&&o.infos.length>1){const t=(0,is.zb)(r,i,!1,e,s,o);this.fontSize=Math.min(t.size,96),this.postAngle=t.rotation,this.offsetX=t.offsetX,this.offsetY=t.offsetY}n&&(this.fontSize*=n,this.offsetX*=n,this.offsetY*=n)}}const hc=[4,4],cc=[16,4],lc={topLeft:cc,topRight:cc,bottomLeft:cc,bottomRight:cc},uc=[4,2],dc=[4,6],pc={topLeft:uc,topRight:uc,bottomLeft:dc,bottomRight:dc},_c={topLeft:uc,topRight:dc,bottomLeft:uc,bottomRight:dc},fc={topLeft:dc,topRight:dc,bottomLeft:hc,bottomRight:hc},mc={topLeft:hc,topRight:hc,bottomLeft:dc,bottomRight:dc},gc={topLeft:dc,topRight:hc,bottomLeft:dc,bottomRight:hc},yc={topLeft:hc,topRight:dc,bottomLeft:hc,bottomRight:dc},xc={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:pt.pe.UNSIGNED_SHORT,count:2,packPrecisionFactor:B.fq,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||28]},clipAngle:{type:pt.pe.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>wc(t||0)},referenceSymbol:{type:pt.pe.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,e)=>{if(!t.referenceBounds)return[0,0,0,0];const s=function(t){switch(t){case bi.Right:case"right":return-1;case bi.Center:case"center":return 0;case bi.Left:case"left":return 1;default:return console.debug(`Found invalid horizontal alignment ${t}`),0}}(e.horizontalAlignment),i=function(t){switch(t){case wi.Top:case"top":return 1;case wi.Center:case"middle":return 0;case wi.Bottom:case wi.Baseline:case"baseline":case"bottom":return-1;default:return console.debug(`Found invalid vertical alignment ${t}`),0}}(e.verticalAlignment),{offsetX:r,offsetY:n,size:o}=t.referenceBounds;return[(0,l.Lz)(r),-(0,l.Lz)(n),(0,l.Lz)(o),s+1<<2|i+1]}}},attributes:{pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>rr([[0,t],[3,!!e]])},offset:{type:pt.pe.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},textureUV:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:pt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>(0,l.Lz)(t)},referenceSize:{type:pt.pe.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:e})=>(0,l.Lz)(e??t)},haloColor:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>nr(t)},haloFontSize:{type:pt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:t})=>(0,l.Lz)(t)}}};class bc extends Zi{constructor(){super(...arguments),this.vertexSpec=xc,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new ac(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,s){const i=this._getShaping();if(!i)return;const r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,s);if(s?.nextPath())return s.nextPoint(),this._writeGlyphs(t,r,s.x,s.y,i,0);if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[n,o]=s.coords;return this._writeGlyphs(t,r,n,o,i,0)}if("esriGeometryMultipoint"===e.geometryType){const s=e.readGeometryForDisplay();return void s?.forEachVertex(((e,s)=>this._writeGlyphs(t,r,e,s,i,0)))}const n=e.readXForDisplay(),o=e.readYForDisplay();return this._writeGlyphs(t,r,n,o,i,0)}_writePlacedTextMarkers(t,e,s,i){const r=i??Ie.fromFeatureSetReaderCIM(e);if(!r)return;const n=oc.getPlacement(r,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,Ui());if(!n)return;const o=e.getDisplayId();let a=n.next();for(;null!=a;){const e=a.tx,i=-a.ty,r=-a.getAngle();this._writeGlyphs(t,o,e,i,s,r),a=n.next()}}_getShaping(t){const e=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const i=Math.round((0,l.Lz)(e.fontSize)),r=(0,l.Lz)(e.offsetX),n=(0,l.Lz)(e.offsetY),o=(0,nc.qE)((0,l.Lz)(s.lineWidth),B.GR,B.cp),a=B.DY*(0,nc.qE)(s.lineHeightRatio,.25,4);return function(t,e){const s=e.scale,i=new Array,{glyphs:r,isRightToLeft:n}=t,o=function(t,e,s){const i=new Array,r=1/s.scale,n=s.maxLineWidth*r,o=e?t.length-1:0,a=e?-1:t.length,h=e?-1:1;let c=o,l=0,u=0,d=c,p=d,_=0,f=1/0,m=0;for(;c!==a;){const{code:e,metrics:s}=t[c],r=Math.abs(s.top);if(ki(e)||zi(e)||(f=Math.min(f,r),m=Math.max(m,r+s.height)),ki(e))c!==o&&(i.push(new Fi(t,d,c-h,l,f,m)),f=1/0,m=0),l=0,d=c+h,p=c+h,u=0;else if(zi(e))p=c+h,u=0,_=s.advance,l+=s.advance;else if(l>n){if(p!==d){const e=p-2*h;l-=_,i.push(new Fi(t,d,e,l-u,f,m)),f=1/0,m=0,d=p,l=u}else i.push(new Fi(t,d,c-h,l,f,m)),f=1/0,m=0,d=c,p=c,l=0;l+=s.advance,u+=s.advance}else l+=s.advance,u+=s.advance;c+=h}const g=new Fi(t,d,c-h,l,f,m);return g.start>=0&&g.end<t.length&&i.push(g),i}(r,n,e),a=o.length?function(t,e){let s=0;for(let e=0;e<t.length;e++){const{width:i}=t[e];s=Math.max(i,s)}const i="underline"===e.decoration?4:0,r=t[0].yMin;return{x:0,y:r,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-r,width:s}}(o,e):{x:0,y:0,height:0,width:0},h=vi(e.horizontalAlignment),c=Si(e.verticalAlignment),l=c===wi.Baseline?1:0,u=l?0:c-1,d=(1-l)*-a.y+u*(a.height/2)+-22*(l?1:0);for(let t=0;t<o.length;t++){const{start:n,end:a,width:c}=o[t];let l=-1*(h+1)*(c/2)-3;const u=t*e.lineHeight+d-3;o[t].startX=l,o[t].startY=u;for(let t=n;t<=a;t++){const e=r[t];if(ki(e.code))continue;const n=new Ti(l+e.metrics.left,u-e.metrics.top,e,s);l+=e.metrics.advance,i.push(n)}}return new Ei(i,o,e)}(s.glyphs,{scale:i/B.eG,angle:e.postAngle,xOffset:r,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,i,r,n,o,a){const h=this.evaluatedMeshParams,c=this._textMeshTransformProps,u=c.fontSize,d=(0,l.Lz)(c.offsetX),p=(0,l.Lz)(c.offsetY),[_,f]=sr(h.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const m=r.bounds,g=s+m.x+d,y=i+m.y-p,x=2*(h.minPixelBuffer?h.minPixelBuffer/u:1),b=Math.max(m.width,m.height)*x;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),t.recordBounds(g,y,b,b),this._writeTextBox(t,e,s,i,r.textBox,o,a),t.recordEnd());for(const n of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(g,y,b,b);const{texcoords:r,offsets:c}=n;this._writeQuad(t,e,s,i,{texcoords:r,offsets:c,fontSize:u,color:nr(h.color),isBackground:!1,referenceBounds:o,minZoom:_,maxZoom:f,...a}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,s,i,r,n,o){const a=this.evaluatedMeshParams,{fontSize:h}=this._textMeshTransformProps,{boxBackgroundColor:c,boxBorderLineColor:l}=a,u={isBackground:!0,fontSize:h,referenceBounds:n,...o};c&&(this._writeQuad(t,e,s,i,{texcoords:lc,offsets:r.main,color:nr(c),...u}),l||(this._writeQuad(t,e,s,i,{texcoords:fc,offsets:r.top,color:nr(c),...u}),this._writeQuad(t,e,s,i,{texcoords:mc,offsets:r.bot,color:nr(c),...u}),this._writeQuad(t,e,s,i,{texcoords:gc,offsets:r.left,color:nr(c),...u}),this._writeQuad(t,e,s,i,{texcoords:yc,offsets:r.right,color:nr(c),...u}))),l&&(this._writeQuad(t,e,s,i,{texcoords:pc,offsets:r.top,color:nr(l),...u}),this._writeQuad(t,e,s,i,{texcoords:pc,offsets:r.bot,color:nr(l),...u}),this._writeQuad(t,e,s,i,{texcoords:_c,offsets:r.left,color:nr(l),...u}),this._writeQuad(t,e,s,i,{texcoords:_c,offsets:r.right,color:nr(l),...u}))}_writeQuad(t,e,s,i,r){const n=t.vertexCount();this._writeVertex(t,e,s,i,r),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 wc=t=>Math.round(t*(254/360)),vc=(0,Vh.Bj)((t=>{let e=0;if(0===t)return 1/0;for(;!(t%2);)e++,t/=2;return e}));class Sc extends bc{constructor(){super(...arguments),this._zoomLevel=0}_write(t,e,s,i){if(this._zoomLevel=i||0,null!=s)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(e.geometryType){case"esriGeometryPoint":{const s=e.readXForDisplay(),i=e.readYForDisplay();return this._writePoint(t,s,i,e)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const s=e.readCentroidForDisplay();if(!s)return;const[i,r]=s.coords;return this._writePoint(t,i,r,e)}case"esriGeometryPolyline":this._writeLines(t,e)}}_writePoint(t,e,s,i){const r=this._getShaping();if(!r)return;let n=this._getPointReferenceBounds();n||(n={offsetX:0,offsetY:0,size:0});const o=r.boundsT,a=vi(this.evaluatedMeshParams.horizontalAlignment),h=Si(this.evaluatedMeshParams.verticalAlignment),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0,u=jh(i.getDisplayId());t.metricStart(new Xh(u,e,s,a,h,c,l,n)),t.metricBoxWrite(o),this._writeGlyphs(t,i.getDisplayId(),e,s,r,0,n),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:i}=this.evaluatedMeshParams,r=this.evaluatedMeshParams.repeatLabelDistance||128,n=this._getShaping("middle");if(!n)return;const o=(t,e,s,i)=>this._placeSubdivGlyphs(t,e,s,i),a=(n.bounds.width+r)/2;this._current={out:t,id:e.getDisplayId(),shaping:n,zoomRange:sr(s,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null},this._verticalPlacement="bottom"===i?"above":"top"===i?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(e,o,a):this._writeCenterAlong(e,o,a)}_writeAboveAndBelowAlong(t,e,s){const{repeatLabel:i,fontSize:r}=this.evaluatedMeshParams,{shaping:n}=this._current,o=(0,l.Lz)(r),a=t.readGeometryForDisplay();if(!a)return;const h=new Wt.A;(0,Wh.kz)(h,a,!1,!1,"esriGeometryPolyline",1);const c=Ic(new Wt.A,h,o),u=Ic(new Wt.A,h,-o),d=(0,Wh.zv)(u,"esriGeometryPolyline",!1,!1),p=ic((0,Wh.zv)(c,"esriGeometryPolyline",!1,!1).paths,n.bounds.width),_=ic(d.paths,n.bounds.width);this._current.offsetDirection="above";for(const t of p)sc(t,s,e,!!i);this._current.offsetDirection="below";for(const t of _)sc(t,s,e,!!i)}_writeCenterAlong(t,e,s){const{repeatLabel:i}=this.evaluatedMeshParams,{shaping:r}=this._current,n=ic(t.readLegacyGeometryForDisplay().paths,r.bounds.width);for(const t of n)sc(t,s,e,!!i)}_placeSubdivGlyphs(t,e,s,i){const{allowOverrun:r,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],h=vc(e),c=this._current.shaping.bounds.width/2,l=Math.sqrt(o||128)/2,u=Math.min(s,i-s),d=this._current.shaping.isMultiline?28:Math.log2(u/(l+c/2)),p=0===e?d:Math.min(h,d),_=Math.max(a,this._zoomLevel+1-p),f=this._zoomLevel-_,m=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===e&&this._placeStraight(t,_):r&&f<0?this._placeStraightAlong(t,a):"parallel"===n?this._placeStraightAlong(t,_):"curved"===n&&this._placeCurved(t,_,m)}_placeStraight(t,e){const{out:s,id:i,shaping:r,referenceBounds:n}=this._current,{x:o,y:a}=t,h=jh(i),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Xh(h,t.x,t.y,0,0,c,l,null)),s.metricBoxWrite(r.boundsT);const u=t.angle*(180/Math.PI)%360,d=(t.angle*(180/Math.PI)+180)%360;this._writeGlyphs(s,i,o,a,r,0,n,{clipAngle:u,mapAligned:!0,isLineLabel:!0,minZoom:e}),this._writeGlyphs(s,i,o,a,r,0,n,{clipAngle:d,mapAligned:!0,isLineLabel:!0,minZoom:e}),s.metricEnd()}_placeCurved(t,e,s){const{out:i,id:r}=this._current,n=t.clone(),o=t.angle*(180/Math.PI)%360,a=(t.angle*(180/Math.PI)+180)%360,h=jh(r),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new Xh(h,t.x,t.y,0,0,c,l,null)),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)),i.metricEnd()}_placeStraightAlong(t,e){const{out:s,id:i,shaping:r,zoomRange:n,referenceBounds:o}=this._current,{boxBorderLineColor:a,boxBackgroundColor:h}=this.evaluatedMeshParams,c=t.clone(),l=t.angle*(180/Math.PI)%360,u=(t.angle*(180/Math.PI)+180)%360;if(r.glyphs.length>0&&(a||h)){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),c=ui(fi(),-t.angle),[d,p]=r.shapeBackground(c),_={minZoom:a,maxZoom:h,clipAngle:l,mapAligned:!0,isLineLabel:!0};this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd()),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(_.clipAngle=u,s.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),this._writeTextBox(s,i,t.x,t.y,p,o,_),s.recordEnd())}const d=jh(i),p=this.evaluatedMeshParams.scaleInfo?.maxScale??0,_=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Xh(d,t.x,t.y,0,0,p,_,null)),this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(c,e,1,l,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(c,e,0,u,!0),s.metricEnd()}_placeBack(t,e,s,i,r,n){const o=t.clone();let a=t.backwardLength+0;for(;o.prev()&&!(a>=i);)this._placeOnSegment(o,e,a,s,-1,r,n),a+=o.length+0}_placeForward(t,e,s,i,r,n){const o=t.clone();let a=t.remainingLength+0;for(;o.next()&&!(a>=i);)this._placeOnSegment(o,e,a,s,1,r,n),a+=o.length+0}_placeFirst(t,e,s,i,r=!1){const n=t,{out:o,id:a,shaping:h,zoomRange:c,referenceBounds:l}=this._current,u=h.glyphs;for(const d of u){const u=d.x>h.bounds.x?s:1-s,p=u*t.remainingLength+(1-u)*t.backwardLength,_=Math.abs(d.x+d.width/2-h.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(_/(p+0))),m=Math.max(e,r?0:f);d.maxZoom=Math.min(c[1],28),d.angle=t.angle+(1-s)*Math.PI,d.minZoom=Math.max(c[0],m),this._writeLineGlyph(o,a,n.x,n.y,h.bounds,d,i,l,!0),s&&this._isVisible(d.minZoom,d.maxZoom)&&o.metricBoxWrite(d.bounds)}}_placeOnSegment(t,e,s,i,r,n,o){const{out:a,id:h,shaping:c,referenceBounds:l}=this._current,u=c.glyphs,d=t.dx/t.length,p=t.dy/t.length,_={x:t.x+s*-r*d,y:t.y+s*-r*p};for(const d of u){const u=d.x>c.bounds.x?n:1-n;if(!(u&&1===r||!u&&-1===r))continue;const p=Math.abs(d.x+d.width/2-c.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(p/s)-.1),m=Math.max(i,this._zoomLevel+Math.log2(p/(s+t.length+0)));if(0!==f&&(d.angle=t.angle+(1-n)*Math.PI,d.minZoom=m,d.maxZoom=f,this._writeLineGlyph(a,h,_.x,_.y,c.bounds,d,o,l,!0),n&&this._isVisible(d.minZoom,d.maxZoom))){const s=d.bounds,i=t.x-e.x,r=t.y-e.y,n=new Pi(s.center[0]+i,s.center[1]+r,s.width,s.height);a.metricBoxWrite(n)}}}_writeLineGlyph(t,e,s,i,r,n,o,a,h){const c=s+r.x,l=i+r.y,u=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(r.width,r.height)*u;t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(c,l,d,d);const{texcoords:p,offsets:_}=n,f=this._textMeshTransformProps.fontSize;this._writeQuad(t,e,s,i,{texcoords:p,offsets:_,fontSize:f,color:nr(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=this._zoomLevel;return t<=s&&s<=e}}function Ic(t,e,s){const{coords:i,lengths:r}=e,n=(0,qh.vt)(),o=(0,qh.vt)(),a=(0,qh.vt)(),h=(0,qh.vt)(),c=(0,qh.vt)(),l=(0,qh.vt)();let u=0;for(let e=0;e<r.length;e++){const d=r[e];for(let e=0;e<d;e++){const r=2*(e+u-1),p=2*(e+u),_=2*(e+u+1);e>0?(0,F.hZ)(n,i[r],i[r+1]):(0,F.hZ)(n,0,0),(0,F.hZ)(o,i[p],i[p+1]),e<d-1?(0,F.hZ)(a,i[_],i[_+1]):(0,F.hZ)(a,0,0),0===e?(0,F.hZ)(h,0,0):((0,F.jb)(h,o,n),(0,F.S8)(h,h),(0,F.hZ)(h,h[1],-h[0])),e===d-1?(0,F.hZ)(c,0,0):((0,F.jb)(c,a,o),(0,F.S8)(c,c),(0,F.hZ)(c,c[1],-c[0])),(0,F.WQ)(l,h,c),(0,F.S8)(l,l);const f=l[0]*c[0]+l[1]*c[1];0!==f&&(0,F.hs)(l,l,f),(0,F.hs)(l,l,s),t.coords.push(o[0]+l[0],o[1]+l[1])}t.lengths.push(d),u+=d}return t}const Pc={createComputedParams:t=>t,optionalAttributes:Mr.optionalAttributes,attributes:{...Mr.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:t,shouldScaleDash:e,isSDF:s})=>rr([[4,t],[2,e],[3,s]])},tlbr:{type:pt.pe.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.hM,n=e.y+B.hM;return[r,n,r+s,n+i]}},accumulatedDistance:{type:pt.pe.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},segmentDirection:{type:pt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]}}};class Mc extends Cr{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Pc,this._tessellationOptions.textured=!0}_write(t,e,s){const i=s??Ie.fromFeatureSetReaderCIM(e);if(!i)return;const{sprite:r}=this.evaluatedMeshParams;this._writeGeometry(t,e,i,r?.textureBinding)}}class Tc{static from(t){return"width"in t?this.fromSimpleMeshParams(t):this.fromComplexMeshParams(t)}static fromSimpleMeshParams(t){const e=new Tc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects),{type:s,width:i,height:r,angle:n,alignment:o,outlineSize:a,referenceSize:h,sprite:c,overrideOutlineColor:u}=t;return e.rawWidth=(0,l.Lz)(i),e.rawHeight=(0,l.Lz)(r),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.sizeRatio=c.sdf?2:1,e._computeSize(t,!1),e}static fromComplexMeshParams(t){const e=new Tc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects);let{alignment:s,transforms:i,size:r,scaleX:n,anchorX:o,anchorY:a,angle:h,colorLocked:c,frameHeight:u,widthRatio:d,offsetX:p,offsetY:_,outlineSize:f,referenceSize:m,scaleFactor:g,sizeRatio:y,isAbsoluteAnchorPoint:x,rotateClockwise:b,scaleSymbolsProportionally:w,sprite:v}=t;if(i&&i.infos.length>0){const t=(0,is.zb)(r,h,b,p,_,i);r=t.size,h=t.rotation,p=t.offsetX,_=t.offsetY,b=!1}g&&(r*=g,p*=g,_*=g);const S=n*(v.width/v.height);e.alignment=s,e.rawHeight=(0,l.Lz)(r),e.rawWidth=e.rawHeight*S,e.referenceSize=(0,l.Lz)(m),e.sizeRatio=y,e.angle=h,e.rotateClockwise=b,e.anchorX=o,e.anchorY=a,e.offsetX=(0,l.Lz)(p),e.offsetY=(0,l.Lz)(_),x&&r&&(v.sdf?e.anchorX=o/(r*d):e.anchorX=o/(r*S),e.anchorY=a/r);const I=w&&u?r/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,i,r,n,o){this.sprite=t,this.color=e,this.outlineColor=s,this.minPixelBuffer=i,this.placement=r,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.alignment=ut.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:i}=t,r=!!s.sdf,{rawWidth:n,rawHeight:o,sizeRatio:a,outlineSize:h}=this,c=n*a,l=o*a;if(r&&!i){const t=e&&n>o?c:n,s=o,i=h+2;this.computedWidth=Math.min(t+i,c),this.computedHeight=Math.min(s+i,l)}else this.computedWidth=c,this.computedHeight=l;const u=r?Math.max(s.width,s.height)/Math.max(c,l):1,d=.5*(c-this.computedWidth)*u,p=.5*(l-this.computedHeight)*u,_=s.rect.x+B.hM+d,f=s.rect.y+B.hM+p,m=_+s.width-2*d,g=f+s.height-2*p;this.texXmin=Math.floor(_),this.texYmin=Math.floor(f),this.texXmax=Math.ceil(m),this.texYmax=Math.ceil(g),this.computedWidth*=(this.texXmax-this.texXmin)/(m-_),this.computedHeight*=(this.texYmax-this.texYmin)/(g-f),this.anchorX*=c/this.computedWidth,this.anchorY*=l/this.computedHeight}}const Cc=0,Ac=1,Ec=2,Fc=3,kc=4,zc=128/Math.PI;const Oc={createComputedParams:t=>Tc.from(t),optionalAttributes:{zoomRange:{type:pt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}},attributes:{pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:({sprite:t,alignment:e,scaleSymbolsProportionally:s,overrideOutlineColor:i,colorLocked:r})=>{let n=0;return t.sdf&&(n|=ir(Cc)),e===ut.C1.MAP&&(n|=ir(Ac)),s&&(n|=ir(Ec)),i&&(n|=ir(Fc)),r&&(n|=ir(kc)),n}},offset:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({angle:t,computedWidth:e,computedHeight:s,anchorX:i,anchorY:r,offsetX:n,offsetY:o,rotateClockwise:a})=>{const h=function(t,e,s,i,r=!1){const n=fi(),o=r?1:-1;return ai(n),(e||s)&&li(n,n,[e,-s]),i&&ci(n,n,.017453292519944444*o*-i),n}(0,n,o,-t,a),c=-(.5+i)*e,l=-(.5-r)*s,u=[c,l],d=[c+e,l],p=[c,l+s],_=[c+e,l+s];return(0,F.l0)(u,u,h),(0,F.l0)(d,d,h),(0,F.l0)(p,p,h),(0,F.l0)(_,_,h),[u,d,p,_]}}},textureUV:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:t,texXmin:e,texYmax:s,texYmin:i})=>[[e,i],[t,i],[e,s],[t,s]]}},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)},outlineColor:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>nr(t)},sizing:{type:pt.pe.UNSIGNED_BYTE,count:4,pack:({rawWidth:t,rawHeight:e,outlineSize:s,referenceSize:i})=>[or(Math.max(t,e),128),or(s,128),or(i,128),0]},placementAngle:{type:pt.pe.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:t})=>function(t){return function(t,e){return t%=256,Math.abs(t>=0?t:t+256)}(t*zc)}(t)},sizeRatio:{type:pt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sizeRatio:t})=>t}}};class Rc extends Zi{constructor(){super(...arguments),this.vertexSpec=Oc}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(t,e,s){const i=this.evaluatedMeshParams.sprite?.textureBinding,r=e.getDisplayId();t.recordStart(this.instanceId,this.attributeLayout,i);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),h=this.evaluatedMeshParams.offsetX,c=-this.evaluatedMeshParams.offsetY;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(t,e,s,o,a);else if(s?.nextPath()){s.nextPoint();const e=s.x,i=s.y;t.recordBounds(e+h,i+c,o,a),this._writeQuad(t,r,e,i)}else if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[i,n]=s.coords;t.recordBounds(i+h,n+c,o,a),this._writeQuad(t,r,i,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),i=e.readYForDisplay();t.recordBounds(s+h,i+c,o,a),this._writeQuad(t,r,s,i)}else{const s=e.readGeometryForDisplay();s?.forEachVertex(((e,s)=>{t.recordBounds(e+h,s+c,o,a),Math.abs(e)>$h||Math.abs(s)>$h||this._writeQuad(t,r,e,s)}))}t.recordEnd()}_writePlacedMarkers(t,e,s,i,r){const n=s??Ie.fromFeatureSetReaderCIM(e)?.clone();if(!n)return;const o=oc.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,Ui());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)>$h||Math.abs(s)>$h){h=o.next();continue}const n=-h.getAngle();t.recordBounds(e+c,s+u,i,r),this._writeQuad(t,a,e,s,n),h=o.next()}}_writeQuad(t,e,s,i,r){const n=t.vertexCount(),o=null==r?null:{placementAngle:r};this._writeVertex(t,e,s,i,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)}}function Lc(t){return Math.floor(function(t,e){let s;if("string"==typeof t)s=(0,lt.Wm)(t+`-seed(${e})`);else{let i=12;s=t^e;do{s=107*(s>>8^s)+i|0}while(0!=--i)}return(1+s/(1<<31))/2}(t,Nc)*Dc)}const Nc=53290320,Dc=10;class Bc{destroy(){}}class Gc extends Bc{constructor(t){super(),this._value=t}resize(t){}read(t,e){return this._value}readWithDefault(t,e,s){return this._value}referencesScale(){return!1}referencesGeometry(){return!1}}async function Uc(t,e,s=!1){const{defaultValue:i,valueExpressionInfo:r,value:n}=e;if(r){const{expression:n}=r,o=await t.createComputedField({expression:n},s);return o?{...e,computed:o,defaultValue:i}:null}return{...e,computed:new Gc(n),defaultValue:i}}async function Vc(t,e){const{defaultValue:s,valueExpressionInfo:i}=e,{expression:r}=i,n=await t.createComputedField({expression:r});return n?{...e,computed:n,defaultValue:s}:null}const qc=t=>"boolean"!=typeof t&&"number"!=typeof t&&"valueExpressionInfo"in t,Wc=t=>t.some((t=>{for(const e in t){const s=t[e];if(qc(s))return!0}return!1}));class Yc{static async create(t,e,s){const i={},r=new Map,n=new Map,o=new Map,a=new Map,h=new Map;for(const c in s){const l=s[c];if(null!=l&&"object"==typeof l)if(Array.isArray(l)){if("object"==typeof l[0])throw new Error(`InternalError: Cannot handle ${c}. Nested array params are not supported`);i[c]=l}else if("valueExpressionInfo"in l){if(l.value){i[c]=l.value;continue}const e=await Vc(t,l);if(!e){i[c]=l.defaultValue;continue}r.set(c,e),i[c]=null}else switch(l.type){case"cim-effect-infos":if(l.effectInfos.some((t=>t.overrides.length))){n.set(c,{effects:await Promise.all(l.effectInfos.map((async e=>{const s=e.overrides.map((e=>Uc(t,e)));return{effect:e.effect,compiledOverrides:(await Promise.all(s)).filter(_t.Ru)}})))});break}i[c]=l.effectInfos.map((t=>t.effect));break;case"cim-marker-placement-param":l.overrides.length&&o.set(c,{placementInfo:l,compiledOverrides:(await Promise.all(l.overrides.map((e=>Uc(t,e))))).filter(_t.Ru)}),i[c]=l.placement;break;case"text-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>Uc(t,e,l.useLegacyLabelEvaluationRules)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(_t.Ru),rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>Uc(t,e)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(_t.Ru),rasterizationParam:l,objectIdToResourceId:new Map});continue}if("animated"===l.resource.type){a.set(c,{compiledOverrides:[],rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=l;if(Wc(e)){const s={compiledMarkerInfos:[]};await Promise.all(e.map((async e=>{const i={props:{}};for(const s in e)if(qc(e[s])){const r=await Vc(t,e[s]);i.compiledExpressionMap||(i.compiledExpressionMap=new Map);const n=i.compiledExpressionMap;r&&n.set(s,r)}else i.props[s]=e[s];s.compiledMarkerInfos.push(i)}))),h.set(c,s)}else i[c]={type:"cim-marker-transform-info",infos:e};break}default:i[c]=l}else i[c]=l}return new Yc(s,i,r,n,o,a,h)}constructor(t,e,s,i,r,n,o){this.inputMeshParams=t,this._resolvedMeshParams=e,this._dynamicProperties=s,this._dynamicEffectProperties=i,this._dynamicPlacementProperties=r,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this.evaluator=t=>t}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(t,e,s){for(const r of this._dynamicAsyncProperties.values()){const n=(0,we.o8)(r.rasterizationParam.resource);"animated"===r.rasterizationParam.resource.type&&r.rasterizationParam.resource.randomizeStartTime&&(n.primitiveName="__RESERVED__PRIMITIVE__NAME__",n.startGroup=Lc(e.getObjectId()||0));for(const{primitiveName:t,propertyName:o,computed:a,defaultValue:h,valueExpressionInfo:c}of r.compiledOverrides)try{Yi(n,"animated"===r.rasterizationParam.resource.type?n.primitiveName:t,o,a,e,s,h)}catch(e){A.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new i.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});r.objectIdToResourceId.set(e.getObjectId(),o)}}evaluateMeshParams(t,e,s){for(const[t,i]of this._dynamicProperties.entries())this._resolvedMeshParams[t]=i.computed.readWithDefault(e,s,i.defaultValue);for(const[t,i]of this._dynamicPlacementProperties.entries())for(const{computed:r,defaultValue:n,propertyName:o}of i.compiledOverrides){const a=r.readWithDefault(e,s,n);i.placementInfo.placement[o]=a,this._resolvedMeshParams[t]=i.placementInfo.placement}for(const[t,i]of this._dynamicEffectProperties.entries())for(const r of i.effects){for(const{computed:t,defaultValue:i,propertyName:n}of r.compiledOverrides){const o=t.readWithDefault(e,s,i);r.effect[n]=o}this._resolvedMeshParams[t]=i.effects.map((t=>t.effect))}for(const[t,i]of this._dynamicTransformProperties.entries()){const r={type:"cim-marker-transform-info",infos:[]};for(const t of i.compiledMarkerInfos){const i={...t.props};if(t.compiledExpressionMap)for(const[r,n]of t.compiledExpressionMap){const t=n.computed.readWithDefault(e,s,n.defaultValue);i[r]="number"==typeof t||"boolean"==typeof t?t:n.defaultValue}r.infos.push(i)}this._resolvedMeshParams[t]=r}for(const[s,i]of this._dynamicAsyncProperties.entries()){const r=i.objectIdToResourceId.get(e.getObjectId());if(null==r)continue;const n=t.getResource(r);this._resolvedMeshParams[s]=n}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}}const jc={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:pt.pe.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},offset:{type:pt.pe.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:t})=>{const e=(0,l.Lz)(t),s=-e/2,i=-e/2;return[[s,i],[s+e,i],[s,i+e],[s+e,i+e]]}}},texCoords:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:pt.pe.UNSIGNED_BYTE,count:2,pack:({size:t})=>[t,t]},referenceSize:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:({size:t})=>(0,l.Lz)(t)},zoomRange:{type:pt.pe.UNSIGNED_BYTE,count:2,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}}};class Xc extends Zi{constructor(){super(...arguments),this.vertexSpec=jc}_write(t,e){const s=e.getDisplayId(),i=this.evaluatedMeshParams.minPixelBuffer,r=Math.max((0,l.Lz)(this.evaluatedMeshParams.size),i);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,r,r);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 $c{async createMeshWriter(t,e,s,i){const r=this._getMeshWriter(i.techniqueType),n=await Yc.create(t,e,i.inputParams),o=new r(i.id,n,i.optionalAttributes,s);return await o.loadDependencies(),o}_getMeshWriter(t){switch(t){case Ut.Fill:return cr;case Ut.DotDensity:return tr;case Ut.ComplexFill:return Sr;case Ut.PatternFill:return ur;case Ut.OutlineFill:return kr;case Ut.PatternOutlineFill:return Bh;case Ut.ComplexOutlineFill:return Rh;case Ut.Marker:return Rc;case Ut.PieChart:return Xc;case Ut.Text:return bc;case Ut.Line:return Cr;case Ut.TexturedLine:return Mc;case Ut.Heatmap:return Uh;case Ut.Label:return Sc;case Ut.Test:throw new Error("Internal Error: Found invalid mesh writer")}}}class Hc{constructor(t,e,s,i){this.storage=t,this.proxy=e,this.viewParams=s,this.registry=i}async createMeshWriters(t){const e=t.map((t=>this.registry.createMeshWriter(this.storage,this.proxy,this.viewParams,t)));return Promise.all(e)}}class Zc{constructor(t){this._outstandingMessages=[],this._queue=new k.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 Qc=s(43334),Kc=s(31464);class Jc{static async create(t,e){if("count"===e.statisticType){const t=new Gc(1);return new Jc(e.name,e.alias,e.type,e.statisticType,t)}const s=await t.createComputedField({expression:e.onStatisticExpression?.expression,field:e.onStatisticField});return new Jc(e.name,e.alias,e.type,e.statisticType,s)}constructor(t,e,s,i,r){this.name=t,this.alias=e,this.type=s,this.statisticType=i,this.computed=r}}var tl=s(65529),el=s(70328),sl=s(37730),il=s(17970);class rl{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class nl{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}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(){}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 ol extends nl{constructor(t,e,s,i){super(t,e),this.spatialReference=s,this.aggregateFields=i,this.events=new tl.A,this.featureAdapter=sl.T}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new il.d({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}removeChunks(t){}forEach(t){return this.forEachAggregateWorldSpace(t)}forEachInBounds(t,e){}forEachBounds(t,e){const s=(0,el.vt)();for(const i of t){const t=(0,Wh.jQ)(s,i.geometry,!1,!1);t&&e(t)}}}class al{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.clear=s,this.end=i,this.debugInfo=r,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 hl{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.remove=s,this.end=i,this.debugInfo=r,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 cl extends Bc{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)}referencesScale(){return!1}referencesGeometry(){return!1}}var ll=s(71386);function ul(t,e,s){if(null==t)return null;const i=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;try{return t.evaluate({...s,$feature:i},t.services)}catch(t){return A.A.getLogger("esri.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",t),null}}function dl(t){return null==t||t===1/0||t===-1/0||"number"==typeof t&&isNaN(t)}function pl(t,e,s,i){if(null==t)return null!=i?i:null;const r=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;const n=t.evaluate({...s,$feature:r},t.services);return dl(n)?null!=i?i:null:n}class _l extends Bc{static async create(t,e){const s=await(0,ll.Ad)(t,e.spatialReference,e.fields),i=(0,lt.Wm)(t);return new _l(s,i)}constructor(t,e){super(),this._compiled=t,this._cacheKey=e}resize(t){}read(t,e){return this.referencesScale()||"system"!==e.$view.timeZone?ul(this._compiled,t,e):this._readCached(t,e)}readWithDefault(t,e,s){return this.referencesScale()||"system"!==e.$view.timeZone?pl(this._compiled,t,e,s):this._readWithDefaultCached(t,e,s)}referencesScale(){return this._compiled?.referencesScale()??!1}referencesGeometry(){return this._compiled?.referencesGeometry()??!1}_readCached(t,e){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const s=ul(this._compiled,t,e);return t.setCachedValue(s),s}_readWithDefaultCached(t,e,s){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const i=pl(this._compiled,t,e,s);return t.setCachedValue(i),i}}var fl=s(97770),ml=s(18047),gl=s(56721),yl=s(30524),xl=s(32730);class bl extends Bc{static async create(t,e){const s=(0,xl.lc)(t);return new bl((t=>s.replaceAll(/{[^}]*}/g,(e=>{const s=e.slice(1,-1),i=t.metadata.fieldsIndex.get(s);if(null==i)return e;const r=t.readAttribute(s);return null==r?"":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:i,min:r}=(0,gl.A5)(e),n=+t;if(null!=r&&null!=i&&r<=n&&n<=i)return s.name}let i=t;return(0,yl.vE)(e)?i=(0,fl.Yq)(i,(0,fl.J2)("short-date")):(0,yl.WA)(e)&&(i=(0,ml.ZV)(+i)),i||""}(r,i)}))))}constructor(t){super(),this._evaluator=t}resize(t){}read(t,e){return this._evaluator(t)}readWithDefault(t,e,s){const i=this._evaluator(t);return dl(i)?s:i}referencesScale(){return!1}referencesGeometry(){return!1}}class wl extends Bc{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)}referencesScale(){return!1}referencesGeometry(){return!1}_readNormalized(t){const e=t.readAttribute(this._field);if(null==e)return null;const{normalizationField:s,normalizationTotal:i,normalizationType:r}=this._normalizationInfo,n=t.readAttribute(s);switch(r??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?e/n:void 0:null;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return i?e/i*100:null}}}class vl{static fromBuffer(t,e){return new vl(t,e)}static create(t,e=4294967295){const s=new Uint32Array(Math.ceil(t/32));return new vl(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,i=e;for(;s%32&&s!==i;){if(this.has(s))return!0;s++}for(;i%32&&s!==i;){if(this.has(s))return!0;i--}if(s===i)return!1;for(let t=s/32;t!==i/32;t++)if(this._buf[t])return!0;return!1}set(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]|=i}setRange(t,e){let s=t,i=e;for(;s%32&&s!==i;)this.set(s++);for(;i%32&&s!==i;)this.set(i--);if(s!==i)for(let t=s/32;t!==i/32;t++)this._buf[t]=4294967295}unset(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]&=4294967295^i}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 vl(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],i=32*e;if(s)for(;s;)1&s&&t(i),s>>>=1,i++}}countSet(){let t=0;return this.forEachSet((e=>{t++})),t}}var Sl=s(39516);const Il=()=>A.A.getLogger("esri.views.2d.layers.features.support.whereUtils"),Pl={getAttribute:(t,e)=>t.readAttribute(e)};async function Ml(t,e){try{const s=await(0,Sl.G)(t,e);if(!s.isStandardized){const t=new i.A("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",s);Il().error(t)}return e=>{const i=e.readArcadeFeature();try{return s.testFeature(i,Pl)}catch(e){return Il().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),!0}}}catch(e){return Il().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),t=>!0}}const Tl=()=>A.A.getLogger("esri.views.2d.layers.features.support.ComputedAttributeStorage"),Cl=4294967295;function Al(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(s)}class El{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(vl.create(this._allocatedSize,Yh)),t+1}async createComputedField(t,e=!1){if(t.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return e?bl.create(t.expression,this.compilationOptions):await _l.create(t.expression,this.compilationOptions)}catch(e){const s=new i.A("featurelayer","Failed to compile arcade expression",{error:e,expression:t.expression});return Tl().error(s),null}if(t.normalizationType||t.normalizationField)return new wl(t.field,t);if(t.field)return new cl(t.field);const s=new i.A("featurelayer","Unable to create computed field. No expression or field found",{info:t});return Tl().error(s),null}async createWhereClause(t){return t?Ml(t,this.compilationOptions.fields):null}getBitset(t){return this._bitsets[t-1]}getComputedNumeric(t,e){return this.getComputedNumericAtIndex(t&Yh,0)}setComputedNumeric(t,e,s){return this.setComputedNumericAtIndex(t&Yh,s,0)}getComputedString(t,e){return this.getComputedStringAtIndex(t&Yh,0)}setComputedString(t,e,s){return this.setComputedStringAtIndex(t&Yh,0,s)}getComputedNumericAtIndex(t,e){const s=t&Yh;return this._ensureNumeric(e,s),this._numerics[e][s]}setComputedNumericAtIndex(t,e,s){const i=t&Yh;this._ensureNumeric(e,i),this._numerics[e][i]=s}getPackedChunkId(t){const e=t&Yh;return this._ensureInstanceId(e),this._instanceIds[e]}setPackedChunkId(t,e){const s=t&Yh;this._ensureInstanceId(s),this._instanceIds[s]=e}getComputedStringAtIndex(t,e){const s=t&Yh;return this._ensureString(e,s),this._strings[e][s]}setComputedStringAtIndex(t,e,s){const i=t&Yh;this._ensureString(e,i),this._strings[e][i]=s}getXMin(t){return this._bounds[4*(t&Yh)]}getYMin(t){return this._bounds[4*(t&Yh)+1]}getXMax(t){return this._bounds[4*(t&Yh)+2]}getYMax(t){return this._bounds[4*(t&Yh)+3]}setBounds(t,e,s=!1){const i=t&Yh;if(!s&&!this._dirtyBitset.has(t))return this._bounds[4*i]!==Cl;this._dirtyBitset.unset(t);const r=e.readGeometryWorldSpace();if(Al(this._bounds,4*i+4,0),!r||!r.coords.length)return this._bounds[4*i]=Cl,this._bounds[4*i+1]=Cl,this._bounds[4*i+2]=Cl,this._bounds[4*i+3]=Cl,!1;let n=1/0,o=1/0,a=-1/0,h=-1/0;return r.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*i]=n,this._bounds[4*i+1]=o,this._bounds[4*i+2]=a,this._bounds[4*i+3]=h,!0}getBounds(t,e){const s=this.getXMin(e),i=this.getYMin(e),r=this.getXMax(e),n=this.getYMax(e);return(0,el.BI)(t,s,i,r,n),s!==Cl}_ensureNumeric(t,e){this._numerics[t]||(this._numerics[t]=[]),Al(this._numerics[t],e,0)}_ensureInstanceId(t){Al(this._instanceIds,t,0)}_ensureString(t,e){this._strings[t]||(this._strings[t]=[]),Al(this._strings[t],e,null)}}var Fl=s(58727),kl=s(62660),zl=s(86420),Ol=s(61956);class Rl{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()}}Rl.Shared=new Rl;class Ll{constructor(t){this._geometryBounds=(0,D.vt)(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new Ll(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=[],i=new Set(t);return this._idToVisibility.forEach(((t,r)=>{const n=!!(1&this._idToVisibility.get(r)),o=i.has(r);!n&&o?e.push(r):n&&!o&&s.push(r),this._idToVisibility.set(r,o?3:0)})),{show:e,hide:s}}createQuery(){const{geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r}=this;return Ol.A.fromJSON({geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r})}async update(t,e){this._hash=JSON.stringify(t);const s=await(0,Fl.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 Ml(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",i=await(0,kl.xt)(s,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,gs.Rg)(this._geometryBounds,e),this._spatialQueryOperator=i,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,zl.I)(this._serviceInfo.timeInfo,t.timeExtent,Rl.Shared);else{const e=new i.A("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",t.timeExtent);A.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}}var Nl=s(95466);class Dl{static minimal(t,e,s=[]){return new Dl({geometryType:t,fields:s,objectIdField:e,subtypes:null,subtypeField:null,types:null,globalIdField:null,spatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null})}constructor(t){this._options=t,this._fieldsIndex="fieldsIndex"in t?Nl.A.fromJSON(t.fieldsIndex):new Nl.A(t.fields),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 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 Bl=s(66131),Gl=s(44729),Ul=s(15032),Vl=s(27647),ql=s(56400);class Wl{constructor(t){this._valid=vl.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 Yl=(0,n.A)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],jl=Yl[0],Xl=Yl[1],$l=Yl[2],Hl=Yl[3],Zl=(0,n.A)("featurelayer-simplify-payload-size-factors")??[1,2,4],Ql=Zl[0],Kl=Zl[1],Jl=Zl[2],tu=(0,n.A)("featurelayer-simplify-mobile-factor")??2,eu=(0,n.A)("esri-mobile"),su=4294967295;class iu{constructor(t){this.metadata=t,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(t,e){let s=1;const i=eu?tu:1;e>4e6?s=Jl*i:e>1e6?s=Kl*i:e>5e5?s=Ql*i:e>1e5&&(s=i);let r=0;return t>4e3?r=Hl*s:t>2e3?r=$l*s:t>100?r=Xl:t>15&&(r=jl),r}parseTimestampOffset(t){return t}getBounds(t){if(function(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===su)return!1;if(0===this.getBoundsXMin()){const e=this.readGeometryWorldSpace();if(!e)return this.setBoundsXMin(su),!1;let s=1/0,i=1/0,r=-1/0,n=-1/0;return e.forEachVertex(((t,e)=>{s=Math.min(s,t),i=Math.min(i,e),r=Math.max(r,t),n=Math.max(n,e)})),this.setBoundsXMin(s),this.setBoundsYMin(i),this.setBoundsXMax(r),this.setBoundsYMax(n),(0,el.BI)(t,s,i,r,n),!0}const e=this.getBoundsXMin(),s=this.getBoundsYMin(),i=this.getBoundsXMax(),r=this.getBoundsYMax();return(0,el.BI)(t,e,s,i,r),!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 i=s._readAttribute(t,e);if(void 0!==i)return i}}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)}removeIds(t){if(null==this._objectIdToIndex){const t=new Map,e=this.getCursor();for(;e.next();){const s=e.getObjectId();(0,T.Lw)(s),t.set(s,e.getIndex())}this._objectIdToIndex=t}const e=this._objectIdToIndex;for(const s of t.values())e.has(s)&&this._removeAtIndex(e.get(s))}readOptimizedFeatureWorldSpace(){const t=this.readGeometryWorldSpace(),e=this.readAttributes(),s=this.readCentroidWorldSpace(),i=new Qc.Om(t,e,s);return i.objectId=this.getObjectId(),i.displayId=this.getDisplayId(),i}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,Wh.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}readGeometryWorldSpace(){let t=this._readGeometry();if(t||(t=this._createGeometryFromServerCentroid()),!t)return null;const e=t.clone(),s=this.getInTransform();return null!=s&&(0,Wh.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(),i=this.getInTransform();return null!=i&&(0,Wh.Ch)(s,s,this.hasZ,this.hasM,i),s}setCache(t){let e=this._caches.get(t);null==e&&(e=new Wl(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,Wh.zv)(t,this.geometryType,this.hasZ,this.hasM),s=(0,Se.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)?Bl.lY.unknownDateJSToArcadeDate(e):Bl.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 Gl.n.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Ul.k.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Bl.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 Gl.n.fromReader(s._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Ul.k.fromReader(s._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Bl.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(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(t){if(null==this.getInTransform())return(0,Vl.Q)(new Wt.A,t,this.hasM,this.hasZ);const e=Ie.fromOptimized(t,this.geometryType);e.yFactor*=-1;const s=qs(e);return s?(s[1]*=-1,new Wt.A([],s)):null}copyInto(t){t._joined=this._joined,t._deleted=this._deleted,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,Wh.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 Wt.A([5],[t-1,e,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(t,e){return new Wt.A([2],[t-1,e+1,1,-1])}_removeAtIndex(t){null==this._deleted&&(this._deleted=vl.create(this.getSize())),this._deleted.set(t)}}class ru extends iu{static fromFeatures(t,e){const{objectIdField:s,geometryType:i}=e,r=(0,Wh.Di)([],t,i,!1,!1,s);for(let e=0;e<r.length;e++)r[e].displayId=t[e].displayId;return ru.fromOptimizedFeatures(r,e)}static fromFeatureSet(t,e){const s=(0,Wh.q3)(t,e.objectIdField);return ru.fromOptimizedFeatureSet(s,e)}static fromOptimizedFeatureSet(t,e){const s=ru.fromOptimizedFeatures(t.features,e);return s._exceededTransferLimit=t.exceededTransferLimit,s._transform=t.transform,s._fieldsIndex=new Nl.A(t.fields),s}static fromOptimizedFeatures(t,e,s){const i=new ru(t,e);return i._fieldsIndex=e.fieldsIndex,i._transform=s,i}static empty(t){return new ru([],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]}removeIds(t){const e=new Set(t);this._features=this._features.filter((t=>!(null!=t.objectId&&e.has(t.objectId))))}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 ru(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,Qc.N3)(this._current)?(0,Wh.Rk)(this._current.geometry,2):0}_readX(){return(0,Qc.N3)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,Qc.N3)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,Qc.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;let i=this._current.attributes[s.name];return null==i?i:("esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i)),e&&this.fields.isDateField(t)?new Date(i):i)}_readAttributes(){return this._current.attributes}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._transform=this._transform,t._fieldsIndex=this._fieldsIndex}}class nu extends rl{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,Wh.Ch)(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}class ou extends ol{static async create(t,e,s,i,r){const n=new El({spatialReference:e}),o=await Promise.all(t.fields.map((async t=>Jc.create(n,t)))),a=t.featureFilter?await Ll.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,Kc.Nk)(e,q.A.WGS84),new ou(t,a,r,o,e,s,i)}constructor(t,e,s,i,r,n,o){super(n,o,r,i),this._schema=t,this._featureFilter=e,this._timeZone=s,this._metadata=new Dl({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:t.fields,globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(t){return new nu(t,this._attributeStore)}async*applyLocalEdit(t){for(const t of this._sendStates.values()){t.reset();const e=new al(t.subscription,ru.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._sendStates.values())for(const e of t.featuresWorldSpace()){const{objectId:t,displayId:n}=e,o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._sendStates.values())for(const r of t.featuresWorldSpace())e.has(r.displayId)&&!s.has(r.objectId)&&(r.geometry&&i.push({...(0,Wh.oN)(r,this._metadata.geometryType,!1,!1),displayId:r.displayId}),s.add(r.objectId));return{features:[],aggregates:i}}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(){if(this._source.chunks().length)for(const t of this._sendStates.values())yield*this._update(t,this._source)}forEachAggregateWorldSpace(t){for(const e of this._sendStates.values())for(const s of e.featuresWorldSpace())t(s)}_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,timeZone:this._timeZone,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,timeZone:this._timeZone,scale:s}}}}async*_update(t,e){const{handledChunks:s,subscription:i,bins:r,featureCache:n}=t,o=i.tile;if(t.done)return;for(const i of e.chunks()){if(s.has(i.chunkId))continue;s.add(i.chunkId);const e=i.queryInfo;if("tileId"in e){const t=new p.A(e.tileId);if(t.level!==o.level||t.world!==o.key.world)continue}i.getAggregateIndex(this._createIndexOptions(t.tile)).putBounded(r,t.tile.extent,t.tile.resolution)}const a=[],h=i.tile.transform,c=i.tile.key.level;for(const t of r.values()){let e=n.get(t.id);if(!e){const s=t.getGeometry(this.spatialReference,h);e=new Qc.Om(s,t.getAttributes(),null),s||(e.centroid=t.getGeometricCentroid(this.spatialReference,h)),e.objectId=t.id,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=ru.fromOptimizedFeatures(a,this._metadata,h),u=l.getCursor(),d=t.subscription.tile.createArcadeEvaluationOptions(this._timeZone);for(;u.next();)this._attributeStore.setAttributeData(u.getDisplayId(),u,d);const _=new hl(t.subscription,l,[],t.done,{});yield _}}class au{constructor(t){this._statistics=t}get statistics(){return this._statistics}}const hu=Math.PI/180;class cu{static create(t){return new cu(t.map((t=>function(t){switch(t.statisticType){case"min":return new uu(t);case"max":return new du(t);case"avg":return new _u(t);case"avg_angle":return new fu(t);case"sum":case"count":return new pu(t);case"mode":return new mu(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],i=t._statistics[e];if(s.field.name!==i.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");s.merge(i)}}clone(){return new cu(this._statistics.map((t=>t.clone())))}}class lu{constructor(t){this.field=t}insert(t,e){if(!this.field.computed)return;const s=this.field.computed.read(t,e);dl(s)||this._insertValue(s)}}class uu extends lu{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 uu(this.field);return t.value=this.value,t}}class du extends lu{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 du(this.field);return t.value=this.value,t}}class pu extends lu{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(t){this.value+=t}merge(t){this.value+=t.value}clone(){const t=new pu(this.field);return t.value=this.value,t}}class _u extends lu{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 _u(this.field);return t._total=this._total,t._count=this._count,t}}class fu extends lu{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*hu),this._y=this._y+Math.sin(t*hu),this._count+=1}merge(t){this._x+=t._x,this._y+=t._y,this._count+=t._count}clone(){const t=new fu(this.field);return t._x=this._x,t._y=this._y,t._count=this._count,t}}class mu extends lu{constructor(){super(...arguments),this._frequencies=new Map}get value(){let t,e=0;for(const[s,i]of this._frequencies.entries())i>e&&(e=i,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 mu(this.field);return t._frequencies=new Map(this._frequencies),t}}class gu extends au{static createId(t,e){return`${t}.${e}`}static create(t,e,s,i){return new gu(t,e,cu.create(s),i)}constructor(t,e,s,i){super(s),this.gridX=t,this.gridY=e,this._worldUnitsPerCell=i,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return gu.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 gu(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,i){0===this._count?this._firstFeatureAttributes=t.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=s,this._yWorldTotal+=i,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,Wh.IE)(t,this.centroidXWorld)}getCentroidY(t){return null==t?this.centroidYWorld:(0,Wh.B2)(t,this.centroidYWorld)}getGeometry(t,e){const s=this.gridX*this._worldUnitsPerCell,i=this.gridY*this._worldUnitsPerCell,r=new Wt.A([4],[s,i,s+this._worldUnitsPerCell,i,s+this._worldUnitsPerCell,i+this._worldUnitsPerCell,s,i+this._worldUnitsPerCell]);if(null!=e){const t=new Wt.A;return(0,Wh.Nl)(t,r,!1,!1,"esriGeometryPolygon",e)}return r}getCentroid(t){const e=new Wt.A([],[this.centroidXWorld,this.centroidYWorld]);if(null!=t){const s=new Wt.A;return(0,Wh.Nl)(s,e,!1,!1,"esriGeometryPoint",t)}return e}getGeometricCentroid(t,e){const s=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,i=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,r=new Wt.A([],[s,i]);if(null!=e){const t=new Wt.A;return(0,Wh.Nl)(t,r,!1,!1,"esriGeometryPoint",e)}return r}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 yu=s(83047);class xu{constructor(t){this._options=t}insert(t,e){const s=t.getCursor(),i={$view:{scale:this._options.scale,timeZone:this._options.timeZone}};for(;s.next();)this._insertFeature(s,i,e)}_insertFeature(t,e,s){const{featureFilter:i}=this._options;if(null!==i&&!i.check(t))return;let r=0,n=0;if("esriGeometryPoint"===t.geometryType)r=t.readXWorldSpace(),n=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,i]=e.coords;if(s<0||s>B.CQ||i<0||i>B.CQ)return}const e=t.readCentroidWorldSpace();if(null==e)return;r=e.coords[0],n=e.coords[1]}this._insert(t,r,n,e)}}function bu(t,e){return(0,yu.GA)(t)*yu.dy*96/e}class wu extends xu{constructor(t){super(t),this._cells=new Map,this._pixelsPerMapUnit=bu(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 i=[e.xmin,e.ymin,e.xmax,e.ymax],[r,n,o,a]=i,h=Math.floor(r*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 i=`${s}.${e}`,r=this._cells.get(i);if(!r)continue;const n=t.get(r.id);n?r&&!t.has(r.id)&&n.merge(r):t.set(r.id,r.clone())}}_insert(t,e,s,i){const r=e*this._pixelsPerMapUnit,n=s*this._pixelsPerMapUnit,o=Math.floor(r/this._options.cellSize),a=Math.floor(n/this._options.cellSize);this._getCellOrCreate(o,a).insert(t,i,e,s)}_getCellOrCreate(t,e){const s=gu.createId(t,e);let i=this._cells.get(s);if(!i){const r=1*this._options.cellSize/this._pixelsPerMapUnit;i=gu.create(t,e,this._options.fields,r),this._cells.set(s,i)}return i}}class vu{constructor(t,e){this.inner=t,this.displayId=e}}class Su extends rl{constructor(t){super(t),this.didSend=!1,this.done=!1}}class Iu{constructor(t,e,s,i,r){this._level=t,this._scale=e,this._indexOptions=s,this._clusterRadius=i,this._store=r,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 Qc.Om(e,t.inner.getAttributes(),null);s.objectId=t.inner.id,s.displayId=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 i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=bu(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]*r/n),o=Math.floor(e[1]*r/n),a=Math.ceil(e[2]*r/n),h=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,s),i.yMin=Math.min(i.yMin,o),i.xMax=Math.max(i.xMax,a),i.yMax=Math.max(i.yMax,h)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),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,i=[],r=s.tile.transform;for(const t of this._clusters.values()){let e=t.inner.getCentroidX(r);const n=t.inner.getCentroidY(r),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 Wt.A([],[e,n]),r=new Qc.Om(s,t.inner.getAttributes(),null);r.geometry.coords[0]-=B.CQ,r.objectId=h,r.displayId=c,i.push(r);const o=new Wt.A([],[e,n]),a=new Qc.Om(o,t.inner.getAttributes(),null);a.geometry.coords[0]+=B.CQ,a.objectId=h,a.displayId=c,i.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 Wt.A([],[e,n]),r=new Qc.Om(s,t.inner.getAttributes(),null);r.objectId=h,r.displayId=c,i.push(r)}}return ru.fromOptimizedFeatures(i,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 i=this._clusterRadius*(1/bu(this._indexOptions.spatialReference,this._scale)),r=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 vu(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-r;t<=s.gridY+r;t++)for(let e=s.gridX-r;e<=s.gridX+r;e++){if(t===s.gridY&&e===s.gridX)continue;const r=this._cells.get(gu.createId(e,t));if(!r||n.has(r.id))continue;const c=Math.abs(r.centroidXWorld-a),l=Math.abs(r.centroidYWorld-h);c<i&&l<i&&(o.inner.merge(r),n.add(r.id))}}for(const t of s)this._store.releaseDisplayIdForObjectId(t)}_updateAggregateStatistics(t,e){let s=!1;for(const i of e.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const e=i.value,r=i.field,n=t.get(r.name);if(n){const{minValue:t,maxValue:i}=n,r=Math.min(n.minValue,e),o=Math.max(n.maxValue,e);t===r&&i===o||(n.minValue=r,n.maxValue=o,s=!0)}else t.set(r.name,{minValue:e,maxValue:e}),s=!0}return s}}class Pu extends ol{static async create(t,e,s,i,r,n){const o=new El({spatialReference:s}),a={type:"grid",fields:await Promise.all(e.fields.map((async t=>Jc.create(o,t)))),spatialReference:s,featureFilter:e.featureFilter?await Ll.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:e.featureFilter}):null,cellSize:e.clusterRadius/4,timeZone:n};return new Pu(t,e.clusterRadius,a,e.fields,i,r)}constructor(t,e,s,i,r,n){super(r,n,s.spatialReference,s.fields),this._connection=t,this._clusterRadius=e,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=new Dl({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fields:[...i,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],globalIdField:null,spatialReference:r.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 Su(t)}async*applyLocalEdit(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 i=new Map(t.map((t=>[e(t),t]))),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.clusters()){const e=i.get(t.inner.id);if(null==e){if(1===t.inner.count){const e=i.get(t.inner.firstObjectId);if(null!=e){const n=s(t.displayId,e,t.inner.firstObjectId);r.push(n),i.delete(t.inner.firstObjectId)}}}else{const n=s(t.displayId,e,t.inner.id);r.push(n),i.delete(t.inner.id)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[],r=[],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,Wh.oN)(t,this._metadata.geometryType,!1,!1);if(s.add(t.displayId),1===e.attributes.cluster_count){i.push({...e,displayId:t.displayId});continue}r.push({...e,displayId:t.displayId})}return{features:i,aggregates:r}}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 i=Array.from(this._sendStates.values()).filter((t=>t.done)).map((t=>t.subscription.tile.key)),r=new Set(i);for(const t of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some((e=>e.containsChild(t.subscription.tile.key))))continue;if(t.subscription.tile.key.getChildKeys().every((t=>r.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 Iu(t,e,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(e,s)),s}async*_update(t,e,s){if(t.done)return;const i=e.createAggregateFeatures(t,this._metadata);this.events.emit("changed"),t.done=!s.updateTracking.updating;const r=i.getCursor(),n=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n);const o=new al(t.subscription,i,!0,t.done,{});yield o}}var Mu=s(11006);function Tu(t,e){if(!(this instanceof Tu))return new Tu(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 Cu(t,e,s){if(!s)return e.indexOf(t);for(var i=0;i<e.length;i++)if(s(t,e[i]))return i;return-1}function Au(t,e){Eu(t,0,t.children.length,e,t)}function Eu(t,e,s,i,r){r||(r=Gu(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var n,o=e;o<s;o++)n=t.children[o],Fu(r,t.leaf?i(n):n);return r}function Fu(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 ku(t,e){return t.minX-e.minX}function zu(t,e){return t.minY-e.minY}function Ou(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Ru(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Lu(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 Nu(t,e){var s=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),n=Math.min(t.maxY,e.maxY);return Math.max(0,r-s)*Math.max(0,n-i)}function Du(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Bu(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Gu(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Uu(t,e,s,i,r){for(var n,o=[e,s];o.length;)(s=o.pop())-(e=o.pop())<=i||(n=e+Math.ceil((s-e)/i/2)*i,(0,Mu.q)(t,n,e,s,r),o.push(e,n,n,s))}Tu.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,s=[],i=this.toBBox;if(!Bu(t,e))return s;for(var r,n,o,a,h=[];e;){for(r=0,n=e.children.length;r<n;r++)o=e.children[r],Bu(t,a=e.leaf?i(o):o)&&(e.leaf?s.push(o):Du(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(!Bu(t,e))return!1;for(var i,r,n,o,a=[];e;){for(i=0,r=e.children.length;i<r;i++)if(n=e.children[i],Bu(t,o=e.leaf?s(n):n)){if(e.leaf||Du(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 i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},insert:function(t){return null!=t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Gu([]),this},remove:function(t,e){if(null==t)return this;for(var s,i,r,n,o=this.data,a=this.toBBox(t),h=[],c=[];o||h.length;){if(o||(o=h.pop(),i=h[h.length-1],s=c.pop(),n=!0),o.leaf&&-1!==(r=Cu(t,o.children,e)))return o.children.splice(r,1),h.push(o),this._condense(h),this;n||o.leaf||!Du(o,a)?i?(s++,o=i.children[s],n=!1):o=null:(h.push(o),c.push(s),s=0,i=o,o=o.children[0])}return this},toBBox:function(t){return t},compareMinX:ku,compareMinY:zu,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,i){var r,n=s-e+1,o=this._maxEntries;if(n<=o)return Au(r=Gu(t.slice(e,s+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,i-1))),(r=Gu([])).leaf=!1,r.height=i;var a,h,c,l,u=Math.ceil(n/o),d=u*Math.ceil(Math.sqrt(o));for(Uu(t,e,s,d,this.compareMinX),a=e;a<=s;a+=d)for(Uu(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),r.children.push(this._build(t,h,l,i-1));return Au(r,this.toBBox),r},_chooseSubtree:function(t,e,s,i){for(var r,n,o,a,h,c,l,u;i.push(e),!e.leaf&&i.length-1!==s;){for(l=u=1/0,r=0,n=e.children.length;r<n;r++)h=Ou(o=e.children[r]),(c=Lu(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 i=this.toBBox,r=s?t:i(t),n=[],o=this._chooseSubtree(r,this.data,e,n);for(o.children.push(t),Fu(o,r);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(r,n,e)},_split:function(t,e){var s=t[e],i=s.children.length,r=this._minEntries;this._chooseSplitAxis(s,r,i);var n=this._chooseSplitIndex(s,r,i),o=Gu(s.children.splice(n,s.children.length-n));o.height=s.height,o.leaf=s.leaf,Au(s,this.toBBox),Au(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(s,o)},_splitRoot:function(t,e){this.data=Gu([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Au(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,s){var i,r,n,o,a,h,c,l;for(h=c=1/0,i=e;i<=s-e;i++)o=Nu(r=Eu(t,0,i,this.toBBox),n=Eu(t,i,s,this.toBBox)),a=Ou(r)+Ou(n),o<h?(h=o,l=i,c=a<c?a:c):o===h&&a<c&&(c=a,l=i);return l},_chooseSplitAxis:function(t,e,s){var i=t.leaf?this.compareMinX:ku,r=t.leaf?this.compareMinY:zu;this._allDistMargin(t,e,s,i)<this._allDistMargin(t,e,s,r)&&t.children.sort(i)},_allDistMargin:function(t,e,s,i){t.children.sort(i);var r,n,o=this.toBBox,a=Eu(t,0,e,o),h=Eu(t,s-e,s,o),c=Ru(a)+Ru(h);for(r=e;r<s-e;r++)n=t.children[r],Fu(a,t.leaf?o(n):n),c+=Ru(a);for(r=s-e-1;r>=e;r--)n=t.children[r],Fu(h,t.leaf?o(n):n),c+=Ru(h);return c},_adjustParentBBoxes:function(t,e,s){for(var i=s;i>=0;i--)Fu(e[i],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():Au(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 Vu{static fromReader(t){const e=[],s=t.copy(),i=(0,el.vt)();for(;s.next();)s.getBounds(i)&&e.push(s.getIndex());const r=Tu(9,(t=>(s.setIndex(t),{minX:s.getBoundsXMin(),minY:s.getBoundsYMin(),maxX:s.getBoundsXMax(),maxY:s.getBoundsYMax()})));return r.load(e),new Vu(r)}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 qu=s(5443),Wu=s(79258);function Yu(t,e,s,i){if(i.isWebMercator){const i=(0,nc.KJ)(t/Wu.$O.radius),r=i-360*Math.floor((i+180)/360),n=[0,0];return ju(n,0,(0,nc.KJ)(Math.PI/2-2*Math.atan(Math.exp(-e/Wu.$O.radius))),r,s),n}const r=(0,Kc.Cv)({x:t,y:e},i,q.A.WGS84);if(!r)return null;const n=[0,0];return ju(n,0,r.y,r.x,s),n}function ju(t,e,s,i,r){r%2&&(r+=1);let n=0,o=0,a=-90,h=90,c=-180,l=180;for(let t=0;t<r/2;t++){for(let e=0;e<5;e++){const s=(c+l)/2,r=i>s?1:0;n|=r<<29-(e+5*t),c=(1-r)*c+r*s,l=(1-r)*s+r*l}for(let e=0;e<5;e++){const i=(a+h)/2,r=s>i?1:0;o|=r<<29-(e+5*t),a=(1-r)*a+r*i,h=(1-r)*i+r*h}}t[2*e]=n,t[2*e+1]=o}new Float64Array(2),new Float64Array(2);class Xu extends au{static create(t,e,s,i){const r=cu.create(t),n=new Array(32);for(let t=0;t<n.length;t++)n[t]=null;return new Xu(r,e,s,i,n)}constructor(t,e,s,i,r){super(t),this.xNode=e,this.yNode=s,this.depth=i,this.children=r,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 Xu(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,i,r,n){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=s,this._xGeohashTotal+=i,this._yGeohashTotal+=r,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(),[i,r,n,o]=s,a=(0,Kc.Cv)({rings:[[[i,r],[i,o],[n,o],[n,r],[i,r]]]},q.A.WGS84,t),h=(0,Wh.Ye)(new Wt.A,a,!1,!1);return null!=e?(0,Wh.Nl)(new Wt.A,h,!1,!1,"esriGeometryPolygon",e,!1,!1):h}getGeometricCentroid(t,e){const s=this._getLngLatBounds(),[i,r,n,o]=s,a=(0,Kc.Cv)({x:(i+n)/2,y:(r+o)/2},q.A.WGS84,t),h=(0,Wh.qN)(new Wt.A,a);return null!=e?(0,Wh.Nl)(new Wt.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,i,r,n){if(i>=s)return this;const o=1-i%2,a=3*o+2*(1-o),h=2*o+3*(1-o),c=30-r-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,i+1,r+a,n+h)}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),i=30-(3*e+2*s),r=30-(2*e+3*s);return function(t,e){let s=-90,i=90,r=-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,p=(3*h+7*(1-h)<<l&t.geohashY)>>l;for(let t=3*h+2*(1-h)-1;t>=0;t--){const e=(r+n)/2,s=d&1<<t?1:0;r=(1-s)*r+s*e,n=(1-s)*e+s*n}for(let t=u-1;t>=0;t--){const e=(s+i)/2,r=p&1<<t?1:0;s=(1-r)*s+r*e,i=(1-r)*e+r*i}}return[r,s,n,i]}({geohashX:this.xNode<<i,geohashY:this.yNode<<r},this.depth)}}class $u{constructor(t){this._fields=t,this._size=0,this._depth=0,this._root=Xu.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,i,r,n,o){let a=this._root,h=0,c=0,l=0;for(;null!==a;){if(a.insert(t,e,s,i,r,o),h>=n)return;const u=Math.ceil((h+1)/2),d=Math.floor((h+1)/2),p=1-h%2,_=30-(3*u+2*d),f=30-(2*u+3*d),m=(i&7*p+3*(1-p)<<_)>>_,g=(r&3*p+7*(1-p)<<f)>>f,y=m+g*(8*p+4*(1-p));c=c<<3*p+2*(1-p)|m,l=l<<2*p+3*(1-p)|g,null==a.children[y]&&(a.children[y]=Xu.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:i}=t;let r=this._root;for(;null!==r;){const t=r.depth,n=r.xNode,o=r.yNode;if(t>=i){e.push(r),r=r.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),p=~((1<<u)-1),_=(s.xLL&d)>>l,f=(s.yLL&p)>>u,m=(s.xTR&d)>>l,g=(s.yTR&p)>>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,_),S=Math.max(x,f),I=Math.min(b,m),P=Math.min(w,g);let M=null,T=null;for(let t=S;t<=P;t++)for(let e=v;e<=I;e++){const s=e-y+(t-x)*(8*c+4*(1-c)),i=r.children[s];i&&(M||(M=i,M.next=r.next),T&&(T.next=i),T=i,i.next=r.next)}r=M||r.next}return e}}class Hu extends xu{constructor(t){super(t),this._tree=new $u(this._options.fields)}put(t){throw new Error("Geohash tree does not support put")}putBounded(t,e,s){const{geohashLevel:i,spatialReference:r}=this._options,n=function(t,e,s,i){const r=[t.xmin,t.ymin,t.xmax,t.ymax],n=Oi.A.fromExtent(qu.A.fromBounds(r,i)),o=(0,Kc.Cv)(n,i,q.A.WGS84,{densificationStep:64*e});if(!o)return null;const a=(0,Wh.Ye)(new Wt.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),p=Math.max(...c),_=Yu(l,u,s,q.A.WGS84),f=Yu(d,p,s,q.A.WGS84);return _&&f?{bounds:r,geohashBounds:{xLL:_[0],yLL:_[1],xTR:f[0],yTR:f[1]},level:s}:null}(e,s,i,r);null!=n&&this._tree.putBins(t,n)}_insert(t,e,s,i){const{geohashLevel:r,spatialReference:n}=this._options,o=Yu(e,s,r,n);o&&this._tree.insert(t,e,s,o[0],o[1],r,i)}}class Zu extends iu{static from(t,e){return new Zu(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,[i,r]=t.translate;return this._displayTranslationX=-i/e,this._displayScaleX=1/e,this._displayTranslationY=r/s,this._displayScaleY=1/-s,void(this._displayTransform=t)}const[s,i]=e.scale,[r,n]=e.translate,[o,a]=t.scale,[h,c]=t.translate;if(this._displayScaleX=s/o,this._displayTranslationX=(r-h)/o,this._displayScaleY=i/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 Zu(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}_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(){const t=this._reader.readGeometryForDisplay();if(!this._displayTransform)return t;const e=new Wt.A;return(0,Wh.Nl)(e,t,this.hasZ,this.hasM,this.geometryType,this._displayTransform),e.deltaDecode()}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,Wh.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 Qu{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._aggregateIndex=null,this._aggregateIndexHash=null,this._spatialIndex=null}queryFeaturesInBounds(t){const e=this._getSpatialIndex().search(t);return Zu.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 wu(t);break;case"geohash":this._aggregateIndex=new Hu(t)}this._aggregateIndex.insert(this.reader,this.isTiled)}return this._aggregateIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=Vu.fromReader(this.reader)),this._spatialIndex}}class Ku extends Qu{constructor(t,e){super(),this.metadata=t,this.removed=new Set,this.overriddenIds=new Set,this._features=[],this.chunkId=e,this.normalizedChunkId=e}get reader(){return ru.fromOptimizedFeatures(this._features,this.metadata)}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(t){super.invalidate();const{reader:e,removed:s}=t,i=[],r=new Set,n=e.getCursor(),o=new Set(s);for(this.overriddenIds.clear();n.next();){const t=n.readOptimizedFeatureWorldSpace(),e=t.objectId;i.push(t),r.add(e),this.overriddenIds.add(e),this.removed.delete(e)}for(const t of this._features){const e=t.objectId;o.has(e)||r.has(e)||(i.push(t),this.overriddenIds.add(e))}this._features=i;for(const t of r.values())this.removed.delete(t);for(const t of s)this.removed.add(t),this.overriddenIds.add(t)}removeOverrides(t){const e=t.reader.getCursor(),s=new Set;for(;e.next();){const t=e.getObjectId();this.overriddenIds.has(t)&&(s.add(t),this.overriddenIds.delete(t))}this._features=this._features.filter((t=>!s.has(t.objectId)))}getTileReader(t){if(!this._features.length)return null;const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Ju extends rl{}class td extends nl{constructor(t,e,s){super(t,e),this._timeZone=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(){this.handledChunksForAttributeData.clear()}onSubscribe(t){super.onSubscribe(t),this._evalOptions=t.tile.createArcadeEvaluationOptions(this._timeZone)}createState(t){return new Ju(t)}get aggregateQueryEngine(){return null}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._source.chunks()){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._source.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId(),n=r.getDisplayId();e.has(n)&&!s.has(t)&&(i.push({...r.readLegacyFeatureWorldSpace(),displayId:n}),s.add(t))}}return{features:i,aggregates:[]}}async*applyLocalEdit(t){const e=[],s=t.reader.getCursor();for(;s.next();){const t=s.getObjectId();e.push(t);const i=this._attributeStore.createDisplayIdForObjectId(t);s.setDisplayId(i),this._attributeStore.setAttributeData(i,s,this._evalOptions)}const i=this.getDisplayIds(e),r=this.getDisplayIds(t.removed),n=new Ku(this._source.metadata,"localEdit");n.applyOverrides(t),this.handledChunks.add(n.chunkId),this.handledChunksForAttributeData.add(n.chunkId),this.handledChunksForIdCreation.add(n.chunkId);for(const t of this._sendStates.values())t.handledChunks.add(n.chunkId),yield new hl(t.subscription,null,i,!1,n.queryInfo);for(const t of this._sendStates.values()){const e=n.getTileReader(t.subscription.tile);yield new hl(t.subscription,e,r,!1,n.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 i of this._source.chunks()){const{chunkId:r}=i;if(s.has(r))continue;s.add(r);const n=i.getTileReader(e.tile);n&&(yield new al(t.subscription,n,!1,i.end,i.queryInfo))}}}class ed{constructor(t){this.data=t,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class sd{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 ed((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)))}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 id=()=>A.A.getLogger("esri.views.layers.2d.features.support.AttributeStore"),rd=(id(),()=>null),nd=(0,n.A)("esri-shared-array-buffer");(0,n.A)("esri-atomics");class od{constructor(t,e,s){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:i,layout:r,textureOnly:n}=e;this.textureOnly=n||!1,this.pixelType=i,this.layout=r,this._resetRange(),this.size=t,this.isLocal=s,n||(this.data=this._initData(i,t))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]&=~e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]|=255&e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(t,e,s){const i=this.data;for(const r of s)i[r*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)}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=jh(t);return this.data[s*this.texelSize+e]}setData(t,e,s){const i=jh(t),r=1<<e;this.layout&r?null!=this.data&&(this.data[i*this.texelSize+e]=s,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)):id().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 i=!this.isLocal,r=this.pixelType,n=this.layout,o=this.data;return{start:t,end:e,data:i&&o.slice(t*s,(e+1)*s)||null,pixelType:r,layout:n}}_initData(t,e){const s=ArrayBuffer,r=function(t){switch(t){case pt.ld.UNSIGNED_BYTE:return Uint8Array;case pt.ld.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case pt.ld.FLOAT:return Float32Array;default:return void A.A.getLogger("esri.views.2d.engine.webgl.Utils").error(new i.A("webgl-utils",`Unable to handle type ${t}`))}}(t),n=new r(new s(e*e*4*r.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 ad{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._referencesScale=!1,this._referencesGeometry=!1,this._initialized=!1,this.version=0,this._idGenerator=new sd,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const t=pt.ld.FLOAT;rd(`Creating AttributeStore ${nd?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:pt.ld.UNSIGNED_BYTE,layout:1},{pixelType:pt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:pt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get referencesScale(){return this._referencesScale}get referencesGeometry(){return this._referencesGeometry}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(t){return this._idGenerator.createIdForObjectId(t)}releaseDisplayIdForObjectId(t){return this._idGenerator.releaseIdForObjectId(t)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}releaseAllIds(){this._idGenerator.releaseAll()}async update(t,e,s,i,r=0){const o=(0,V.Ui)(this._schema,t);if(this.version=r,o&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${r}] 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?Ll.create({geometryType:s.geometryType,hasM:!1,hasZ:!1,timeInfo:s.timeInfo,fieldsIndex:s.fieldsIndex,spatialReference:i??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._referencesGeometry=this._referencesGeometry||(s?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(s?.referencesScale()??!1)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:t.subtypeField,map:new Map},this._referencesScale=!1,this._referencesGeometry=!1;for(const s in t.bindings){const i=t.bindings[s];await Promise.all(i.map((async t=>{const i=await this._bind(e,t,parseInt(s,10));this._referencesGeometry=this._referencesGeometry||(i?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(i?.referencesScale()??!1)})))}}}setHighlight(t,e){const s=this._getBlock(0);s.unsetComponentAllTexels(0,(1<<Ca.length)-1);for(const{displayId:e,highlightFlags:i}of t){if(null==e)continue;const t=jh(e);s.setComponent(0,i,[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,i){const r=jh(t);this._ensureSizeForTexel(r),this._getBlock(e).setData(t,s,i)}getData(t,e,s){return this._getBlock(e).getData(t,s)}getHighlightFlags(t){return this._idsToHighlight.get(t)||0}unsetAttributeData(t){const e=jh(t);this._getBlock(0).setData(e,0,0)}setAttributeData(t,e,s){const i=jh(t);this._ensureSizeForTexel(i),this._getBlock(0).setData(i,0,this.getFilterFlags(e));const r=this._attributeComputeInfo;let n=null;r&&(n=r.isSubtype?r.map.get(e.readAttribute(r.subtypeField)):r.map,n?.size&&n.forEach(((t,r)=>{const n=1*r%4,o=Math.floor(1*r/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=yr),a.setData(i,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 i=await t.createComputedField(e),{valueRepresentation:r}=e,n=this._attributeComputeInfo;if(n.isSubtype){const t=n.map.get(s)??new Map;t.set(e.binding,{field:i,valueRepresentation:r}),n.map.set(s,t)}else n.map.set(e.binding,{field:i,valueRepresentation:r});return i}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(B.dV.Animation),this._getBlock(B.dV.GPGPU),{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;rd(`Initializing AttributeBlock at index ${t}`);const s=new od(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;rd("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 id().error(new i.A("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}isVisible(t){return!!(this._getBlock(0).getData(t,0)&1<<Ca.length)}getFilterFlags(t){let e=0;for(let s=0;s<this._filters.length;s++){const i=!!(1<<s),r=this._filters[s];e|=(!i||null==r||r.check(t)?1:0)<<s}let s=0;if(this._idsToHighlight.size){const e=t.getObjectId();s=this.getHighlightFlags(e)}return e<<Ca.length|s}}class hd{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._registry=new $c,this._proxy=new Gt({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new ad({isLocal:!1,update:t=>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:[]}}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,i,r){const o=t.processor,a=(0,U.bD)(this._schema?.storage,o.storage),h=(0,U.bD)(this._schema?.mesh.properties,o.mesh.properties),c=(0,U.bD)(this._schema?.mesh.factory,o.mesh.factory),l=(0,U.bD)(this._schema?.mesh.strategy,o.mesh.strategy),u=h||c||l;if(!a&&!u&&!i)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 d=q.A.fromJSON(this._source.service.outSpatialReference),p=new El({fields:this._source.metadata.fieldsIndex,spatialReference:d});if(await this._attributeStore.update(o.storage,p,this._source.metadata,d,e),this._strategy?.invalidateAttributeData(),!i&&!u)return;(l||h)&&await this._updateStrategy(o.mesh.strategy,d,r,o.mesh.properties.timeZone),this._updateSortKey(p,"sortKey"in o.mesh.properties?o.mesh.properties.sortKey:null);const _=new Hc(p,this._proxy,s,this._registry);return(c||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await ct.create(_,o.mesh.factory)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)}async applyLocalEdit(t){if(!this._strategy)return;const e=this._strategy.applyLocalEdit(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 i of t){let t=s.get(i.id);null==t&&(t=new Zc({concurrency:16,process:t=>this._process(t)}),s.set(i.id,t));const r=t.push(i).catch((t=>(0,a.jH)(t)));e.push(r)}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,i){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new td(this._source,this._attributeStore,i);break;case"binning":this._strategy=await ou.create(t,e,this._source,this._attributeStore,i);break;case"cluster":this._strategy=await Pu.create(this._connection,t,e,this._source,this._attributeStore,i)}for(const t of s)this._strategy.onSubscribe(t)}async _updateSortKey(t,e){if(this._sortInfo=(0,T.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(this._schema?.mesh.properties.timeZone)),i=e.tile.tileInfoView.tileInfo.isWrappable,{message:r,transferList:o}=s.serialize(i),h={objectIdMap:null,inner:t.createMessage(r,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(this._schema.mesh.properties.timeZone);for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,i=t.reader?.getCursor(),r=i?.getSize()??0,n=s.tileInfoView.tileInfo.isWrappable,o=new J(s.key,this._strategy.enablePixelBuffering,n,r);if(!i)return o;const a=s.createArcadeEvaluationOptions(this._schema.mesh.properties.timeZone);for(;i.next();){const t=this._getSortKeyValue(i,e);o.entityStart(i.getDisplayId(),t),this._factory.write(o,this._proxy,i,a,s.level),o.entityEnd()}return o}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:i,byRenderer:r}=this._sortInfo,n=r?this._factory.getSortKey(t,e):s?.read(t,e);return null==n||isNaN(n)?0:n*("asc"===i?-1:1)}}var cd=s(78888),ld=s(80893);class ud{static from(t){let e=0,s=0,i=0;return t.forEach((t=>{const r=t._readGeometry();r&&(s+=r.isPoint?1:r.lengths.reduce(((t,e)=>t+e),0),i+=r.isPoint?1:r.lengths.length,e+=1)})),new ud(e,s,i)}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 dd=s(60945),pd=s(60694);class _d{static fromSchema(t,e,s){const i="feature"===e.type?e.mutable.dataFilter.queryScaleRanges:[];return new _d(function(t,e,s){const i=t.orderByFields??s.objectIdField+" ASC",r=t.source,n={returnCentroid:!(null!==r&&"object"==typeof r&&"path"in r&&(0,pd.Wo)(r.path))&&"esriGeometryPolygon"===s.geometryType,returnGeometry:!0,timeReferenceUnknownClient:s.timeReferenceUnknownClient??void 0,outSpatialReference:q.A.fromJSON(t.outSpatialReference),orderByFields:[i],where:e.mutable.dataFilter.definitionExpression??"1=1",outFields:e.mutable.availableFields};if("feature"===e.type){const{gdbVersion:t,historicMoment:s,timeExtent:i}=e.mutable.dataFilter;return{...n,gdbVersion:t,historicMoment:s?new Date(s):null,timeExtent:i?dd.A.fromJSON(i):null,outFields:e.mutable.availableFields}}return n}(t,e,s),i,s.subtypeField,e.mutable.dataFilter.customParameters,s.geometryType,t.queryMetadata)}constructor(t,e,s,i,r,n){this._queryParams=t,this._queryScaleRanges=e,this._subtypeField=s,this._customParameters=i,this._geometryType=r,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){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),i=[];for(const s of t)e.hasField(s)||i.push(s);if(0===i.length)return null;s.outFields=i}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 Ol.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),i=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})`;i.where=(0,Sl.m)(i.where,t)}}return i.quantizationParameters=e.quantizationParameters??t.getQuantizationParameters(),i.resultType="tile",i.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset=t.resolution*(0,n.A)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(i.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset*=(0,n.A)("feature-polyline-generalization-factor"))),i.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,i.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(i.maxRecordCountFactor=4),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 fd=class extends M.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)),i=Math.round(this._updateInfo.websocket/(e/1e3));this._resetUpdateInfo(t),this._layerView.emitEvent({name:"update-rate",event:{client:s,websocket:i}})}}_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,C.MZ)()],fd.prototype,"_strategy",void 0),fd=(0,P._)([(0,E.$)("esri.views.2d.layers.features.sources.StreamMessenger")],fd);class md{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 queryOverride(t){throw new Error("InternalError: LoadStrategy does not support fetching")}async queryByObjectId(t){throw new Error("InternalError: LoadStrategy does not support fetching")}}var gd=s(10382),yd=s(62577),xd=s(75321),bd=s(51624),wd=s(53655);const vd=268435455;class Sd{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 Id=268435455,Pd=128e3,Md={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(Pd),decoded:new Int32Array(Pd)}};function Td(t){return t<=Md.small.delta.length?Md.small:(t<=Md.large.delta.length||(Md.large.delta=new Int32Array(Math.round(1.25*t)),Md.large.decoded=new Int32Array(Math.round(1.25*t))),Md.large)}function Cd(t){for(;t.next();){if(1===t.tag())return t.getMessage();t.skip()}return null}function Ad(t,e,s,i,r,n){return.5*Math.abs(t*i+s*n+r*e-t*n-s*e-r*i)}function Ed(t,e,s,i){return 0==t*i-s*e&&t*s+e*i>0}class Fd extends iu{static fromBuffer(t,e,s=!1){const r=e.geometryType,n=function(t){try{const e=2,s=new bd.A(new Uint8Array(t),new DataView(t));for(;s.next();){if(s.tag()===e)return Cd(s.getMessage());s.skip()}}catch(t){const e=new i.A("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:t});A.A.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(e)}return null}(t),o=function(t,e,s=!1){const r=t.asUnsafe(),n=r.pos(),o=new Sd;let a=0,h=0,c=null,l=null,u=null,d=!1;const p=[];for(;r.next();)switch(r.tag()){case 1:c=r.getString();break;case 3:l=r.getString();break;case 12:u=r.processMessage(wd.ae);break;case 9:if(o.exceededTransferLimit=r.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]=vd}break;case 13:{const t=r.processMessage(wd.cn);t.index=a++,p.push(t);break}case 15:{const t=r.getLength(),i=r.pos()+t;if(!o.exceededTransferLimit){const t=o.offsets.geometry,e=o.centroid;t.push(0),e.push(vd),e.push(vd)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=s?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=h*a;for(;r.pos()<i&&r.next();)switch(r.tag()){case 1:{d?o.offsets.attributes[n++]=r.pos():o.offsets.attributes.push(r.pos());const t=r.getLength();r.skipLen(t);break}case 2:if(e){const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}}else{o.offsets.geometry[h]=r.pos();const t=r.getLength();o.vertexCount+=t,r.skipLen(t)}break;case 4:{const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}break}default:r.skip()}h++,o.hasFeatures=!0;break}default:r.skip()}const _=c||l;if(!_)throw new i.A("FeatureSet has no objectId or globalId field name");return o.fields=new Nl.A(p),o.featureCount=h,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(_)?.index,o.transform=u,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),r.move(n),o}(n,"esriGeometryPoint"===r,s);return new Fd(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,centroid:void 0,legacyFeature:void 0,optFeature: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._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=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 Fd(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._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_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===Id?null:new Wt.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]===Id)return null;const t=this._header.centroid[2*this._featureIndex],s=this._header.centroid[2*this._featureIndex+1];e=new Wt.A([],[t,s])}else{const s=this._header.offsets.geometry[this._featureIndex],i=this._reader;if(0===s)return null;i.move(s);try{e=t?this._parseGeometryForDisplay(i):this._parseGeometry(i)}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;let i=this._readAttributeAtIndex(s.index);"esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i));const r=this._header.fields.isDateField(s.name);return e?null==i?i:r?new Date(i):i:i}_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 Wl(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],i=this._reader;i.move(s);const r=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}(i);return e.set(this._featureIndex,r),r}_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=Td(e.coords.length).decoded,i=e.clone(s),r=i.coords;let n=0;for(const t of i.lengths){for(let e=1;e<t;e++){const t=2*(n+e),s=2*(n+e-1);r[t]+=r[s],r[t+1]+=r[s+1]}n+=t}return this._cache.unquantGeometry=i,i}return this._cache.unquantGeometry}_parseGeometry(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];for(;e.pos()<i&&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(r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();e.pos()<s;)r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();break}default:e.skip()}return new Wt.A(n,r)}_parseGeometryForDisplay(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];let o=0,a=0,h=null,c=0;const l="esriGeometryPolygon"===this.geometryType;for(;e.pos()<i&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;){const t=e.getUInt32();r.push(t),o+=t}h=Td(2*o).delta;break}case 3:{e.getUInt32();const t=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,T.Lw)(h);for(const s of r)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 i=2,r=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 d=e.getSInt32(),p=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();i<s;){let s=e.getSInt32(),n=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const o=l+d,_=u+p;Ad(l,u,o,_,o+s,_+n)>=t?(c+=-.5*(o-l)*(_+u),r>1&&Ed(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p):(h[a++]=d,h[a++]=p,r++),l=o,u=_):(s+=d,n+=p),d=s,p=n,i++}r<3||o?a-=2*r:(c+=-.5*(l+d-l)*(u+p+u),Ed(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p,n.push(r)):(h[a++]=d,h[a++]=p,n.push(++r)))}else{let t=0,i=e.getSInt32(),r=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),h[a++]=i,h[a++]=r,t+=1;for(let n=1;n<s;n++){const s=e.getSInt32(),o=e.getSInt32(),l=i+s,u=r+o;c+=-.5*(l-i)*(u+r),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),n>2&&Ed(h[a-2],h[a-1],s,o)?(h[a-2]+=s,h[a-1]+=o):(h[a++]=s,h[a++]=o,t+=1),i=l,r=u}n.push(t)}break}default:e.skip()}return this._cache.area=c,n.length?new Wt.A(n,h):null!=h?this._createQuantizedExtrudedGeometry(h[0],h[1]):null}}class kd{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}class zd extends kd{constructor(t,e){super(t,e),this._portsOpen=async function(t){const e=new gd.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 ru.fromFeatureSet(s,this._metadata)}}class Od extends kd{async executeQuery(t,e){const{data:s}=await(0,ld.kS)(this.service.source,t,e),i=!t.quantizationParameters;return Fd.fromBuffer(s,this._metadata,i)}}class Rd extends kd{async executeQuery(t,e){const{source:s,queryMetadata:i}=this.service;if(null!=t.quantizationParameters&&!i.supportsQuantization){const i=t.clone(),r=(0,yd.VV)(i.quantizationParameters);i.quantizationParameters=null;const{data:n}=await(0,ld.eW)(s,i,this._metadata.spatialReference,e),o=(0,Wh.q3)(n,this._metadata.objectIdField);return(0,Wh.jH)(r,o),ru.fromOptimizedFeatureSet(o,this._metadata)}const{data:r}=await(0,ld.eW)(s,t,this._metadata.spatialReference,e);return"esriGeometryPoint"===this._metadata.geometryType&&(r.features=r.features?.filter((t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0}))),ru.fromFeatureSet(r,this._metadata)}}class Ld extends kd{async executeQuery(t,e){if(t.quantizationParameters&&!this.service.queryMetadata.supportsQuantization){const s=t.clone(),i=(0,yd.VV)(s.quantizationParameters);s.quantizationParameters=null;const r=await(0,xd.I)(this.service.source,t,e);return(0,Wh.jH)(i,r),ru.fromOptimizedFeatureSet(r,this._metadata)}const s=await(0,xd.I)(this.service.source,t,e);return ru.fromOptimizedFeatureSet(s,this._metadata)}}class Nd extends md{constructor(t,e,s,i,r){super(s),this._serviceInfo=t,this._queryInfo=e,this._metadata=i,this._eventLog=r,this._queue=new k.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 zd(t,e);case"ogc":return new Ld(t,e);case"feature-service":return t.queryMetadata.supportsFormatPBF&&(0,n.A)("featurelayer-pbf")?new Od(t,e):new Rd(t,e)}}(t,i)}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=Ol.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 i.A("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async queryByObjectId(t){if(0===t.length)return ru.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 i=await this._enqueue(s,this._options);t.joinAttributes(i)}async _enqueue(t,e){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:t,options:e}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class Dd extends Nd{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 Bd extends Qu{constructor(t,e,s,i,r,n){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._sourceTile=i,this._sourceTileDepth=r,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 Gd{constructor(t,e){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,(0,a.u7)(t.options,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class Ud extends Dd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new Gd(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:e,reader:i,sourceTile:r,sourceTileDepth:n,tile:o}=s,h=new Bd(i,e,o,r,n,!1);(0,a.Te)(t.options),this._addChunk(h)}}catch(t){s=t}const i=new Bd(ru.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let i=t.get(e.id);const r=!!i;if(i||(i=await this._fetchChunkInfo(t,e,s),t.set(e.id,i)),i.reader.exceededTransferLimit&&s<(0,n.A)("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield i)}async _fetchChunkInfo(t,e,s){const i=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:i});return{reader:await this._fetch(r,t.subscription.options),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}class Vd extends Qu{constructor(t,e,s,i,r){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._page=i,this._end=r,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 qd{constructor(t,e){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,(0,a.u7)(t.options,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))}resetAbortController(){this._controller=new AbortController}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 Wd extends Dd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new qd(t,this._options));const e=this._loadStates.get(t.key.id);let s;e.resetAbortController();try{await this._fetchPages(e)}catch(t){s=t}const i=new Vd(ru.empty(this._metadata),null,t.tile,-1,!0);if((0,a.G4)(e.options)||this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async _fetchPages(t){let e=0,s=t.pageStart,i=1;for(;e<20&&!t.done;){const r=[];for(let e=0;e<i;e++)r.push(this._fetchChunk(t,s++));const n=await Promise.all(r);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++,i=Math.min(i+1,4)}}async _fetchChunk(t,e){const s=t.subscription.tile,i=this._queryInfo.createPagedTileQuery(s,e),r=await this._fetch(i,t.options);return new Vd(r,i.inner.toJSON(),s,e,!1)}}class Yd extends Qu{constructor(t,e,s,i){super(),this._reader=t,this._queryJSON=e,this._page=s,this._end=i,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 jd extends Nd{constructor(t,e,s,i,r,n){super(t,e,s,r,n),this._random=new h.A(1e3),this._featureCount=i}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())),r=await Promise.all(s.map((t=>this._downloadPage(t)))),n=new Yd(ru.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=r.filter((t=>t));if(o.length)throw new i.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),i=new Yd(s,e.inner.toJSON(),t,!1);return(0,a.Te)(this._options),this._store.insert(i),null}catch(t){return t}}}class Xd{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]}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 $d="__esri_timestamp__";class Hd{constructor(t,e,s,i,r=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=i,this.store=t,this.objectIdField=e,this.purgeInterval=r,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 Xd(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,nc.qE)(t,0,1e3);this._trackIdToObservations.set(s,new Xd(e))}const i=this._trackIdToObservations.get(s),r=i?.enqueue(e);null!=r&&(this._addOrUpdated.has(r)?this._addOrUpdated.delete(r):this._removed.push(r))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const i=[];if(null!=e)for(const t of e){const e=this.store.removeById(t);null!=e&&i.push(e)}const r=[];if(null!=t){const i=new Set(e??[]);for(const e of t)i.has(e.objectId)||(e.attributes[$d]=s,this.store.add(e),r.push(e))}return!(!r.length&&!i?.length||(this.store.update(r,i),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,i=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<i&&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[$d]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}var Zd=s(30624);let Qd=class extends M.A{constructor(t){super(t)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,P._)([(0,C.MZ)()],Qd.prototype,"connection",void 0),(0,P._)([(0,C.MZ)()],Qd.prototype,"connectionStatus",null),(0,P._)([(0,C.MZ)()],Qd.prototype,"errorString",null),Qd=(0,P._)([(0,E.$)("esri.views.2d.layers.features.sources.StreamConnectionState")],Qd);class Kd{constructor(t,e){this._metadata=t,this._onUpdate=e,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return ru.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 Jd extends Qu{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 tp extends md{constructor(t,e,s,i,r){super(s),this._service=t,this._dataFilter=e,this._streamOptions=i,this._metadata=r,this._connectionState=new Qd,this._forceRefresh=!1,this.events=new tl.A;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=e;this._stagingStore=new Kd(this._metadata,(t=>this.events.emit("features-updated",t))),this._manager=new Hd(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 Jd(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,T.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:i,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,Zd.createConnection)(this._service.source,e,this._streamOptions.outSR,t,o,n,s,i,a),this._handlesGroup=(0,r.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 ep{constructor(t){this._onChange=t,this._chunks=new Map,this._chunksToRemove=[],this.events=new tl.A,this.featureAdapter=new Rl}destroy(){this.clear()}clear(){for(const t of this._chunks.values())this._chunksToRemove.push(t);this._chunks.clear(),null!=this._localEditChunk&&this._chunksToRemove.push(this._localEditChunk),this._localEditChunk=null}*chunks(){this._localEditChunk&&(yield this._localEditChunk),this._localOverridesChunk&&(yield this._localOverridesChunk),yield*this._chunks.values()}insert(t){(0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.insert`),this._localOverridesChunk?.overriddenIds.size&&t.reader.removeIds(this._localOverridesChunk.overriddenIds),this._localEditChunk?.overriddenIds.size&&this._localEditChunk.removeOverrides(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}applyLocalOverrides(t,e){null==this._localOverridesChunk&&(this._localOverridesChunk=new Ku(e,"localOverride")),this._localOverridesChunk.applyOverrides(t);for(const t of this._chunks.values())t.reader.removeIds(this._localOverridesChunk.overriddenIds),t.invalidate()}applyLocalEdit(t,e){null==this._localEditChunk&&(this._localEditChunk=new Ku(e,"localEdit")),this._localEditChunk.applyOverrides(t);for(const t of this._chunks.values())t.reader.removeIds(this._localEditChunk.overriddenIds),t.invalidate()}forEach(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i.copy()),e.add(s))}}}forEachUnsafe(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i),e.add(s))}}}forEachInBounds(t,e){const s=new Set;for(const i of this.chunks()){const r=i.queryFeaturesInBounds(t);for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r.copy()),s.add(t))}}}forEachBounds(t,e){const s=(0,el.vt)();for(const i of t)i.getBounds(s)&&e(s)}}var sp=s(32587),ip=s(79897);let rp=class extends M.A{constructor(t){super(t),this.debugName="",this._updatingHandles=new ip.U,this._idToUpdatingState=new sp.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,C.MZ)({constructOnly:!0})],rp.prototype,"debugName",void 0),(0,P._)([(0,C.MZ)({readOnly:!0})],rp.prototype,"updating",null),rp=(0,P._)([(0,E.$)("esri.views.2d.layers.support.UpdateTracking2D")],rp);class np{constructor(t,e,s,i,r){this.service=t,this._aggregateAdapter=e,this._subscriptions=s,this._onChange=i,this._connection=r,this._updateTracking=new rp({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._store=new ep(this._onChange),this._metadata=new Dl(t.metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((t=>t.close()))}get _eventLog(){return this._connection.eventLog}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 ud.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 il.d({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,cacheSpatialQueries:!0,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._eventLog.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.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._eventLog.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}getLocalEdit(t){return this._updateTracking.addPromise(this._getGetLocalEdit(t))}applyLocalEdit(t){this._didInvalidateData=!0,this._store.applyLocalEdit(t,this.metadata)}async update(t,e){const s=t.source,i=(0,V.Ui)(this._schema?.mutable,s.mutable);if(!i)return!1;if((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:i}),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)(i,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&(0,V.w2)(i,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(e);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(t){this._eventLog.onEvent({type:"updateFieldsError",error:t})}}return!1}return!(!(0,V.Mj)(i,"dataFilter")&&!(0,V.Mj)(i,"sourceRefreshVersion")||(await this._updateStrategy(e),0))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new fd(this._connection))}async _getGetLocalEdit(t){if(t.historicMoment&&"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=t.historicMoment,this._strategy.unsafeSetQueryHistoricMoment(new Date(t.historicMoment))),"edit-by-feature"===t.type){const e=[...t.added,...t.updated].map((t=>Qc.Om.fromJSON(t,this.metadata.objectIdField)));return{reader:ru.fromOptimizedFeatures(e,this.metadata),removed:this._resolveIdentifiers(t.removed)}}const e=this._resolveIdentifiers(t.removed);if(!t.updated.length&&!t.added.length)return{reader:ru.empty(this.metadata),removed:e};const s=this._resolveIdentifiers([...t.added,...t.updated]);return{reader:await this._strategy.queryByObjectId(s),removed:e}}_resolveIdentifiers(t){const e=[],s=[];for(const i of t)null!=i.objectId&&-1!==i.objectId?s.push(i.objectId):e.push(i.globalId);if(e.length){const t=new Set(e),i=this.metadata.globalIdField;if(null==i)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");this._store.forEachUnsafe((e=>{const r=e.readAttribute(i);t.has(r)&&s.push(e.getObjectId())}))}return s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,e={...t.query,f:"json"},s=(await(0,cd.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,i=t||e||s;if("stream"===this._schema.type){const t=new tp(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}const r=this.service,n=_d.fromSchema(r,this._schema,this._metadata),o=await this._supportSnapshotMode(r,n);return o?new jd(r,n,this._store,o.featureCount,this.metadata,this._eventLog):i?new Wd(r,n,this._store,this.metadata,this._eventLog):new Ud(r,n,this._store,this.metadata,this._eventLog)}async _updateStrategy(t){const e=await this._createStrategy();this._eventLog.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 i=Array.from(this._subscriptions.values());if(!i.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const r=Promise.all(i.map((t=>this._strategy.load(t).then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(r);try{s&&await r}catch(t){(0,a.jH)(t)}this._eventLog.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,i=s.snapshotInfo;if(!i||!i.supportsSnapshotMinThreshold||!i.snapshotCountThresholds)return null;const r=t.source,n=e.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,ld.gW)(r,n.inner,{query:n.customParameters})).data.count,{min:a,max:h}=i.snapshotCountThresholds;return o<=a||i.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}var op=s(71511);class ap{constructor(t,e){this._handles=new op.A,this._abortController=new AbortController,this._resolver=(0,a.Tw)(),this._isDone=!1,this._aborted=!1,this.tile=t,this._version=e,this._handles.add([])}destroy(){this.pause(),this._handles.destroy()}get key(){return this.tile.key}get version(){return this._version}set version(t){this._version=t}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get done(){return this._resolver.promise}get isDone(){return this._isDone}resolve(){this._isDone=!0,this._resolver.resolve()}get paused(){return this._aborted}resume(){this._abortController=new AbortController,this._aborted=!1}pause(){this._aborted||(this._aborted=!0,this._abortController.abort())}}var hp=s(98291),cp=s(27348);class lp{constructor(t,e){this.key=new p.A(0,0,0,0),this.bounds=(0,D.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 qu.A.fromBounds(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{$view:{scale:this.scale,timeZone:t}}}createChildTiles(){const t=this.key.getChildKeys(),e=hp.A.acquire();for(let s=0;s<t.length;s++)e[s]=new lp(this.tileInfoView,t[s]);return e}getQuantizationParameters(){return cp.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 up{constructor(t){this.inner=t,this.resolver=(0,a.Tw)()}}class dp{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._updateLocalEditsRequest=null,this._tileInfoView=null}onAttach(t){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const e=this._connection,s=u.A.fromJSON(t.tileInfoJSON);this._tileInfoView=new I(s),this._source=new np(t.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),e),this._processor=new hd(e,this._source),this._handles=(0,r.vE)([(0,c.wB)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),this._connection.layerView.setUpdating({data: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 i.A("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new i.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)}async updateSchema(t,e){return(0,n.A)("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new up({schema:t,version:e}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(t){const e=new up(t);return this._updateSubscriptionRequests.push(e),this._requestUpdate(),e.resolver.promise}updateHighlight(t){const e=new up(t);return this._updateHighlightRequests.push(e),this._requestUpdate(),e.resolver.promise}async onEdits(t){if(null!=this._updateLocalEditsRequest)throw new i.A("InternalError - Already processing an edit");this._updateLocalEditsRequest=new up(t);const e=this._updateLocalEditsRequest.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,i=Number.NEGATIVE_INFINITY;const r="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 i=s.getCursor();for(;i.next();){let e=1;if(null!=t.field){const s=i.readAttribute(t.field);e=r?-1*+s:+s+n}const s=i.readXForDisplay()/u,o=i.readYForDisplay()/u,a=Math.floor(s),p=Math.floor(o);if(a<0||p<0||a>=d||p>=d)continue;const _=((.5+a-s)*u)**2+((.5+p-o)*u)**2;if(_>h)continue;const f=e*(c*(1-_/h)**2);l[p+a*d]+=f}}for(let t=0;t<l.length;t++)s=Math.min(s,l[t]),i=Math.max(i,l[t])}return{max:i,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,i=[],r=e.map((t=>t.reader.getCursor())),n=new h.A,o=3*t.sampleSize;for(let a=0;a<o&&i.length<t.sampleSize;a++){const t=r[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),i.push(t.readLegacyFeatureWorldSpace()))}return i.length>=t.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.d)((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=this._doUpdate().finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(t){const e=t.tileId;if(this._subscriptions.has(e)){const s=this._subscriptions.get(e);return void(s.paused&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.resume`),s.resume(),s.version=t.version,this._source.onResume(s)))}(0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.subscribe`);const s=new lp(this._tileInfoView,e),i=new ap(s,t.version);this._subscriptions.set(e,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(t){const e=this._subscriptions.get(t);e&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.unsubscribe`),this._source.onUnsubscribe(e),this._processor.onUnsubscribe(e),this._subscriptions.delete(e.key.id),e.destroy())}_pauseSubscription(t){const e=this._subscriptions.get(t);e&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.pause`),e.pause())}async _doUpdate(){if((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data: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._updateLocalEditsRequest;if(this._updateLocalEditsRequest=null,null!=e){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",e.inner);const t=await this._source.getLocalEdit(e.inner);await this._processor.applyLocalEdit(t),this._source.applyLocalEdit(t),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.endEditOverride",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{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({data: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({data: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};try{const i=await this._source.update(t,e),r=Array.from(this._subscriptions.values());await this._processor.update(t,e,s,i,r)}catch(t){console.error(t)}(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);if((0,n.A)("featurelayer-query-pausing-enabled"))for(const e of t.pause)this._pauseSubscription(e)}}},44159:(t,e,s)=>{s.d(e,{A:()=>r});var i=s(93687);class r{static getId(t,e,s,i){return"object"==typeof t?`${t.level}/${t.row}/${t.col}/${t.world}`:`${t}/${e}/${s}/${i}`}constructor(t,e,s,i){this.set(t,e,s,i)}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,i){this.set(t,e,s,i)}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 r(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(t,e,s,i){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,i,r]=t.split("/");this.level=parseFloat(e),this.row=parseFloat(s),this.col=parseFloat(i),this.world=parseFloat(r)}else this.level=+t,this.row=+e,this.col=+s,this.world=+i||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new r(this.level-1,this.row>>1,this.col>>1,this.world)}getNeighborId(t,e){return`${this.level}/${this.row+e}/${this.col+t}/${this.world}`}getChildKeys(){const t=this.level+1,e=this.row<<1,s=this.col<<1,i=this.world;return[new r(t,e,s,i),new r(t,e,s+1,i),new r(t,e+1,s,i),new r(t,e+1,s+1,i)]}compareRowMajor(t){return this.row<t.row?-1:this.row>t.row?1:this.col<t.col?-1:this.col>t.col?1:0}}r.pool=new i.A(r,null,null,25,50)},46263:(t,e,s)=>{var i;s.d(e,{c:()=>i}),function(t){t[t.Pass=0]="Pass",t[t.Draw=1]="Draw"}(i||(i={}))},620:(t,e,s)=>{s.d(e,{O_:()=>n,vA:()=>r}),s(48163),s(87317),(0,s(91829).vt)();class i{constructor(t){this.message=t}toString(){return`AssertException: ${this.message}`}}function r(t,e){if(!t){e=e||"Assertion";const t=new Error(e).stack;throw new i(`${e} at ${t}`)}}function n(t,e,s,i){let r,n=(s[0]-t[0])/e[0],o=(i[0]-t[0])/e[0];n>o&&(r=n,n=o,o=r);let a=(s[1]-t[1])/e[1],h=(i[1]-t[1])/e[1];if(a>h&&(r=a,a=h,h=r),n>h||a>o)return!1;a>n&&(n=a),h<o&&(o=h);let c=(s[2]-t[2])/e[2],l=(i[2]-t[2])/e[2];return c>l&&(r=c,c=l,l=r),!(n>l||c>o||(l<o&&(o=l),o<0))}},89738:(t,e,s)=>{s.d(e,{e:()=>l}),s(44208);var i=s(97768),r=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,i.xt)(this._schedule),this._task=(0,i.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 i=new AbortController;let n=null;e&&(n=(0,r.u7)(e,(()=>i.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(t),this._queue.remove(t),this._scheduleNext()},a=(0,r.NY)(i.signal,(()=>{const e=this._processingItems.get(t);e&&e.controller.abort(),o(),h.reject((0,r.NK)())})),h=(0,r.Tw)();return this._deferreds.set(t,h),this._controllers.set(t,i),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,r.NK)("Removed from queue")),this._removeItem(t)),t}reset(){const t=[];this._processingItems.forEach((e=>t.push(e))),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,i=new c(t,s);this._processingItems.set(t,i);try{e=this.process(t,s.signal)}catch(t){this._processError(i,t)}(0,r.$X)(e)?(i.promise=e,e.then((t=>this._processResult(i,t)),(t=>this._processError(i,t)))):this._processResult(i,e)}get test(){}}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[1463],{9775:(t,e,s)=>{s.d(e,{A:()=>n});var i=s(62788),r=s(95488);class n{constructor(t=(t=>t.values().next().value)){this._peeker=t,this._observable=new r.I,this._items=new Set}get length(){return(0,i.gc)(this._observable),this._items.size}clear(){0!==this.length&&(this._items.clear(),this._observable.notify())}last(){if(0===this.length)return;let t;for(t of this._items);return t}peek(){if(0!==this.length)return this._peeker(this._items)}push(t){this.contains(t)||(this._items.add(t),this._observable.notify())}contains(t){return(0,i.gc)(this._observable),this._items.has(t)}pop(){if(0===this.length)return;const t=this.peek();return this._items.delete(t),this._observable.notify(),t}popLast(){if(0===this.length)return;const t=this.last();return this._items.delete(t),this._observable.notify(),t}remove(t){this.contains(t)&&(this._items.delete(t),this._observable.notify())}filter(t){const e=this.length;return this._items.forEach((e=>{t(e)||this._items.delete(e)})),e!==this._items.size&&this._observable.notify(),this}*[Symbol.iterator](){(0,i.gc)(this._observable),yield*this._items}}},32587:(t,e,s)=>{s.d(e,{A:()=>n});var i=s(62788),r=s(95488);class n{constructor(t){this._observable=new r.I,this._map=new Map(t)}get size(){return(0,i.gc)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(t){const e=this._map.delete(t);return e&&this._observable.notify(),e}entries(){return(0,i.gc)(this._observable),this._map.entries()}forEach(t,e){(0,i.gc)(this._observable),this._map.forEach(((s,i)=>t.call(e,s,i,this)),e)}get(t){return(0,i.gc)(this._observable),this._map.get(t)}has(t){return(0,i.gc)(this._observable),this._map.has(t)}keys(){return(0,i.gc)(this._observable),this._map.keys()}set(t,e){return this._map.set(t,e),this._observable.notify(),this}values(){return(0,i.gc)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.gc)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}},48163:(t,e,s)=>{function i(){return[0,0]}function r(t,e){return[t,e]}function n(){return r(1,1)}function o(){return r(1,0)}function a(){return r(0,1)}s.d(e,{Un:()=>h,fA:()=>r,vt:()=>i});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:i,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 i=0;i<s;++i)e[i]=t[i];return e},fromValues:r,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},37585:(t,e,s)=>{s.d(e,{Cc:()=>f,Io:()=>l,S8:()=>_,WQ:()=>n,e$:()=>g,hZ:()=>r,hs:()=>c,jb:()=>x,l0:()=>m});var i=s(34304);function r(t,e,s){return t[0]=e,t[1]=s,t}function n(t,e,s){return t[0]=e[0]+s[0],t[1]=e[1]+s[1],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,t[1]=e[1]*s,t}function l(t,e){const s=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(s*s+i*i)}function u(t,e){const s=e[0]-t[0],i=e[1]-t[1];return s*s+i*i}function d(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 _(t,e){const s=e[0],i=e[1];let r=s*s+i*i;return r>0&&(r=1/Math.sqrt(r),t[0]=e[0]*r,t[1]=e[1]*r),t}function f(t,e,s,i){const r=e[0],n=e[1];return t[0]=r+i*(s[0]-r),t[1]=n+i*(s[1]-n),t}function m(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r+s[4],t[1]=s[1]*i+s[3]*r+s[5],t}function g(t,e,s,i){const r=e[0]-s[0],n=e[1]-s[1],o=Math.sin(i),a=Math.cos(i);return t[0]=r*a-n*o+s[0],t[1]=r*o+n*a+s[1],t}const y=d,x=o,b=a,w=h,v=l,S=u,I=p;Object.freeze(Object.defineProperty({__proto__:null,add:n,angle:function(t,e){const s=t[0],i=t[1],r=e[0],n=e[1];let o=s*s+i*i;o>0&&(o=1/Math.sqrt(o));let a=r*r+n*n;a>0&&(a=1/Math.sqrt(a));const h=(s*r+i*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:function(t,e){return t[0]=e[0],t[1]=e[1],t},cross:function(t,e,s){const i=e[0]*s[1]-e[1]*s[0];return t[0]=t[1]=0,t[2]=i,t},dist:v,distance:l,div:w,divide:h,dot:function(t,e){return t[0]*e[0]+t[1]*e[1]},equals:function(t,e){const s=t[0],r=t[1],n=e[0],o=e[1],a=(0,i.FD)();return Math.abs(s-n)<=a*Math.max(1,Math.abs(s),Math.abs(n))&&Math.abs(r-o)<=a*Math.max(1,Math.abs(r),Math.abs(o))},exactEquals:function(t,e){return t[0]===e[0]&&t[1]===e[1]},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:y,length:d,lerp:f,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:b,multiply:a,negate:function(t,e){return t[0]=-e[0],t[1]=-e[1],t},normalize:_,projectAndScale:function(t,e,s,i,r){let n=e[0]-s[0],o=e[1]-s[1];const a=(i[0]*n+i[1]*o)*(r-1);return n=i[0]*a,o=i[1]*a,t[0]=e[0]+n,t[1]=e[1]+o,t},random:function(t,e){e=e||1;const s=2*(0,i.Ov)()*Math.PI;return t[0]=Math.cos(s)*e,t[1]=Math.sin(s)*e,t},rotate:g,round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},scale:c,scaleAndAdd:function(t,e,s,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t},set:r,sqrDist:S,sqrLen:I,squaredDistance:u,squaredLength:p,str:function(t){return"vec2("+t[0]+", "+t[1]+")"},sub:x,subtract:o,transformMat2:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[2]*r,t[1]=s[1]*i+s[3]*r,t},transformMat2d:m,transformMat3:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[3]*r+s[6],t[1]=s[1]*i+s[4]*r+s[7],t},transformMat4:function(t,e,s){const i=e[0],r=e[1];return t[0]=s[0]*i+s[4]*r+s[12],t[1]=s[1]*i+s[5]*r+s[13],t}},Symbol.toStringTag,{value:"Module"}))},79897:(t,e,s)=>{s.d(e,{U:()=>l});var i=s(90237),r=s(69622),n=s(36563),o=s(36708),a=s(11932),h=s(10107),c=s(40608);let l=class extends r.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:i=!1}={}){const r=++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:i?t=>e({added:[],removed:t.toArray()}):void 0})],r),(0,n.hA)((()=>this.removeHandles(r)))}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={},i){const r=++this._handleId;s.sync||this._installSyncUpdatingWatch(t,r);const o=i(t,e,s);return this.addHandles(o,r),(0,n.hA)((()=>this.removeHandles(r)))}_installSyncUpdatingWatch(t,e){const s=this._createSyncUpdatingCallback(),i=(0,o.wB)(t,s,{sync:!0,equals:()=>!1});return this.addHandles(i,e),i}_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,i._)([(0,h.MZ)({readOnly:!0})],l.prototype,"updating",void 0),l=(0,i._)([(0,c.$)("esri.core.support.UpdatingHandles")],l);const u=-42},10382:(t,e,s)=>{s.d(e,{A:()=>c});var i=s(36563),r=(s(44208),s(74887)),n=s(9775),o=s(72457),a=s(52268),h=s(61322);class c{constructor(){this._inUseClients=new Array,this._clients=new Array,this._clientPromises=new Array,this._ongoingJobsQueue=new n.A}destroy(){this.close()}get closed(){return!this._clients?.length}open(t,e){return new Promise(((s,i)=>{let n=!0;const o=t=>{(0,r.Te)(e.signal),n&&(n=!1,t())};this._clients.length=t.length,this._clientPromises.length=t.length,this._inUseClients.length=t.length;for(let n=0;n<t.length;++n){const a=t[n];(0,r.$X)(a)?this._clientPromises[n]=a.then((t=>(this._clients[n]=new h.default(t,e,this._ongoingJobsQueue),o(s),this._clients[n])),(()=>(o(i),null))):(this._clients[n]=new h.default(a,e,this._ongoingJobsQueue),this._clientPromises[n]=Promise.resolve(this._clients[n]),o(s))}}))}broadcast(t,e,s){const i=new Array(this._clientPromises.length);for(let r=0;r<this._clientPromises.length;++r){const n=this._clientPromises[r];i[r]=n.then((i=>i?.invoke(t,e,s)))}return i}close(){let t;for(;t=this._ongoingJobsQueue.pop();)t.resolver.reject((0,r.NK)(`Worker closing, aborting job calling '${t.methodName}'`));for(const t of this._clientPromises)t.then((t=>t?.close()));this._clients.length=0,this._clientPromises.length=0,this._inUseClients.length=0,(0,o.h)(this)}invoke(t,e,s){return this.apply(t,[e],s)}apply(t,e,s){const i=(0,r.Tw)();this._ongoingJobsQueue.push({methodName:t,data:e,invokeOptions:s,resolver:i});for(let t=0;t<this._clientPromises.length;t++){const e=this._clients[t];e?e.jobAdded():this._clientPromises[t].then((t=>t?.jobAdded()))}return i.promise}createInvokeProxy(t){return(0,a.L)(this,t)}on(t,e){return Promise.all(this._clientPromises).then((()=>(0,i.vE)(this._clients.map((s=>s.on(t,e))))))}openPorts(){return new Promise((t=>{const e=new Array(this._clientPromises.length);let s=e.length;for(let i=0;i<this._clientPromises.length;++i)this._clientPromises[i].then((r=>{r&&(e[i]=r.openPort()),0==--s&&t(e)}))}))}get test(){}}},72457:(t,e,s)=>{s.d(e,{h:()=>n,k:()=>r});const i=new FinalizationRegistry((t=>{t.close()}));function r(t,e){i.register(t,e,e)}function n(t){i.unregister(t)}},30624:(t,e,s)=>{s.r(e),s.d(e,{createConnection:()=>T});var i=s(90237),r=(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 p=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,i._)([(0,l.MZ)({readOnly:!0})],p.prototype,"connectionError",null),p=(0,i._)([(0,c.$)("esri.layers.support.StreamConnection")],p);const _=p;var f,m;(m=f||(f={}))[m.CONNECTING=0]="CONNECTING",m[m.OPEN=1]="OPEN",m[m.CLOSING=2]="CLOSING",m[m.CLOSED=3]="CLOSED";let g=class extends _{constructor(t){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._config=t,this._featureZScaler=(0,u.N)(e,i,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(i){const r=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 ${r}s`,i)),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 i=new WebSocket(t);i.onopen=()=>{if(i.onopen=null,this.destroyed)return i.onclose=null,void i.close();i.onclose=t=>this._onClose(t),i.onerror=t=>this._onError(t),this._setWebSocketJSONParseHandler(i),e(i)},i.onclose=t=>{i.onopen=i.onclose=null,s(t)}}))}async _handshake(t=1e4){const e=this._websocket;if(null==e)return;const s=(0,a.Tw)(),i=e.onmessage,{filter:r,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()),r&&a.filter!==r&&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=i;for(const t of this._outstandingMessages)e.send(JSON.stringify(t));this._outstandingMessages=[],s.resolve()},e.send(JSON.stringify({filter:r,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,i._)([(0,l.MZ)()],g.prototype,"connectionStatus",null),(0,i._)([(0,l.MZ)()],g.prototype,"errorString",void 0),g=(0,i._)([(0,c.$)("esri.layers.graphics.sources.connections.WebSocketConnection")],g);var y=s(80893),x=s(61956),b=s(65864),w=s(16930);const v={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends g{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:i}=this._config;this.destroyed||this._setFilter(s,i)}_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,r.A)(t.path,{query:e,responseType:"json"}),i=(await s).data;return this._serviceDefinition=i,i}_fetchWebSocketUrl(t,e){const s=t[0],{urls:i,token:r}=s,n=this._inferWebSocketBaseUrl(i);return(0,h.a6)(`${n}/subscribe`,{outSR:""+e.wkid,token:r})}_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 i=JSON.stringify({filter:this._serializeFilter(t,e)});let r=!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),r=!0,h.resolve())},s.send(i),setTimeout((()=>{r||(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],i=this._relatedFeatures.get(s);if(!i)return o.A.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",t),t;const{attributes:r,geometry:a}=i;for(const e in r)t.attributes[e]=r[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),i=this._queryArchive(e);await s;const r=await i;if(!r)return;for(const t of r.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(3161),s.e(2829),s.e(1147),s.e(1132),s.e(5494),s.e(4796),s.e(5894),s.e(9558),s.e(620),s.e(3600),s.e(1967)]).then(s.bind(s,13600))).default)({url:t}),{capabilities:i}=await e.load(),r=i.query.supportsMaxRecordCountFactor,n=i.query.supportsPagination,o=i.query.supportsCentroid,a=this._config.maxRecordCountFactor,h=e.capabilities.query.maxRecordCount,c=r?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),r&&(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=[],i=0){e.start=null!=e.num?i*e.num:null;const{data:r}=await(0,y.eW)(t,e,this._config.sourceSpatialReference);return r.exceededTransferLimit&&i<(this._config.maxQueryDepth??0)?(r.features.forEach((t=>s.push(t))),this._queryPages(t,e,s,i+1)):(s.forEach((t=>r.features.push(t))),r)}_addRelatedFeatures(t){const e=new Map,s=t.features,i=this._serviceDefinition.relatedFeatures.joinField;for(const t of s){const s=t.attributes[i];e.set(s,t)}this._relatedFeatures=e}};S=(0,i._)([(0,c.$)("esri.layers.graphics.sources.connections.GeoEventConnection")],S);const I=S;let P=class extends _{constructor(t){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:e,spatialReference:s,sourceSpatialReference:i}=t;this._featureZScaler=(0,u.N)(e,i,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 M(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,i,r,n,o,a,h){const c={source:t,sourceSpatialReference:e,spatialReference:s,geometryType:i,filter:M(r,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:h};return t?t.path.startsWith("wss://")||t.path.startsWith("ws://")?new g(c):new I(c):new P(c)}(0,i._)([(0,l.MZ)()],P.prototype,"connectionStatus",void 0),(0,i._)([(0,l.MZ)()],P.prototype,"errorString",void 0),P=(0,i._)([(0,c.$)("esri.layers.support.ClientSideConnection")],P)},91806:(t,e,s)=>{s.d(e,{A:()=>l});var i,r=s(90237),n=s(25482),o=s(10107),a=s(56507),h=(s(87811),s(44208),s(40608));let c=i=class extends n.oY{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 i({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,r._)([(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,r._)([(0,o.MZ)({type:a.jz,json:{write:!0}})],c.prototype,"level",void 0),(0,r._)([(0,o.MZ)({type:String,json:{write:!0}})],c.prototype,"levelValue",void 0),(0,r._)([(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,r._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"resolution",void 0),(0,r._)([(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,r._)([(0,o.MZ)({type:Number,json:{write:!0}})],c.prototype,"scale",void 0),c=i=(0,r._)([(0,h.$)("esri.layers.support.LOD")],c);const l=c},87045:(t,e,s)=>{s.d(e,{A:()=>I});var i,r=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),p=s(86738),_=s(16930),f=s(19419),m=s(21325),g=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=i=class extends o.oY{static create(t={}){const{resolutionFactor:e=1,scales:s,size:r=256,spatialReference:n=_.A.WebMercator,numLODs:o=24}=t;if(!(0,m.fn)(n)){const t=[];if(s)for(let e=0;e<s.length;e++){const i=s[e];t.push(new y.A({level:e,scale:i,resolution:i}))}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 i({dpi:96,lods:t,origin:new p.A(0,0,n),size:[r,r],spatialReference:n})}const h=(0,m.Vp)(n),c=t.origin?new p.A({x:t.origin.x,y:t.origin.y,spatialReference:n}):new p.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],i=e*l;u.push(new y.A({level:t,scale:e,resolution:i}))}else{let t=(0,m.EA)(n)?512/r*591657527.5917094:256/r*591657527.591555;const s=Math.ceil(o/e);u.push(new y.A({level:0,scale:t,resolution:t*l}));for(let i=1;i<s;i++){const s=t/2**e,r=s*l;u.push(new y.A({level:i,scale:s,resolution:r})),t=s}}return new i({dpi:96,lods:u,origin:c,size:[r,r],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,m.Vp)(t);return t.isWrappable&&!!s&&Math.abs(s.origin[0]-e.x)<=s.dx}return!1}readOrigin(t,e){return p.A.fromJSON({spatialReference:e.spatialReference,...t})}set lods(t){let e=0,s=0;const i=[],r=this._levelToLOD={};t&&(e=-1/0,s=1/0,t.forEach((t=>{i.push(t.scale),e=t.scale>e?t.scale:e,s=t.scale<s?t.scale:s,r[t.level]=t}))),this._set("scales",i),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),i=s+1;return e[s]/(e[s]/e[i])**(t-s)}scaleToZoom(t){const e=this.scales,s=e.length-1;let i=0;for(;i<s;i++){const s=e[i],r=e[i+1];if(s<=t)return i;if(r===t)return i+1;if(s>t&&r<t)return i+Math.log(s/t)/Math.log(s/r)}return i}tileAt(t,e,s,i){const r=this.lodAt(t);if(!r)return null;let n,o;if("number"==typeof e)n=e,o=s;else if((0,m.aI)(e.spatialReference,this.spatialReference))n=e.x,o=e.y,i=s;else{const t=(0,g.Cv)(e,this.spatialReference);if(null==t)return null;n=t.x,o=t.y,i=s}const a=r.resolution*this.size[0],h=r.resolution*this.size[1];return i||(i=new x.U(null,0,0,0,(0,f.vt)())),i.level=t,i.row=Math.floor((this.origin.y-o)/h+.001),i.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(i),i}updateTileInfo(t,e=i.ExtrapolateOptions.NONE){let s=this.lodAt(t.level);if(!s&&e===i.ExtrapolateOptions.POWER_OF_TWO){const e=this.lods[this.lods.length-1];e.level<t.level&&(s=e)}if(!s)return;const r=t.level-s.level,n=s.resolution*this.size[0]/2**r,o=s.resolution*this.size[1]/2**r;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:i}=s,r=i*this.size[0],n=i*this.size[1];return t[0]=this.origin.x+e.col*r,t[1]=this.origin.y-(e.row+1)*n,t[2]=t[0]+r,t[3]=t[1]+n,t}lodAt(t){return this._levelToLOD?.[t]??null}clone(){return i.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=[],r=this.lods.length-e;for(let t=0;t<r;t++){const i=t+e,{scale:r,resolution:n}=i>=0?this.lods[i]:{scale:2*this.lods[0].scale,resolution:2*this.lods[0].resolution};s.push(new y.A({level:t,scale:r,resolution:n}))}return new i({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 i=t[s];this._upsampleLevels[i.level]={parentLevel:e?e.level:-1,factor:e?e.resolution/i.resolution:0},e=i}}};var v,S;(0,r._)([(0,h.MZ)({type:Number,json:{write:!0}})],w.prototype,"compressionQuality",void 0),(0,r._)([(0,h.MZ)({type:Number,json:{write:!0}})],w.prototype,"dpi",void 0),(0,r._)([(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,r._)([(0,h.MZ)({readOnly:!0})],w.prototype,"isWrappable",null),(0,r._)([(0,h.MZ)({type:p.A,json:{write:!0}})],w.prototype,"origin",void 0),(0,r._)([(0,l.w)("origin")],w.prototype,"readOrigin",null),(0,r._)([(0,h.MZ)({type:[y.A],value:null,json:{write:!0}})],w.prototype,"lods",null),(0,r._)([(0,h.MZ)({readOnly:!0})],w.prototype,"scales",void 0),(0,r._)([(0,h.MZ)({cast:t=>Array.isArray(t)?t:"number"==typeof t?[t,t]:[256,256]})],w.prototype,"size",void 0),(0,r._)([(0,l.w)("size",["rows","cols"])],w.prototype,"readSize",null),(0,r._)([(0,d.K)("size",{cols:{type:c.jz},rows:{type:c.jz}})],w.prototype,"writeSize",null),(0,r._)([(0,h.MZ)({type:_.A,json:{write:!0}})],w.prototype,"spatialReference",void 0),w=i=(0,r._)([(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:()=>i});class i{constructor(t,e,s,i,r=void 0){this.id=t,this.level=e,this.row=s,this.col=i,this.extent=r}}},60694:(t,e,s)=>{s.d(e,{Fi:()=>l,HZ:()=>g,Jf:()=>m,LS:()=>y,Wo:()=>f,bd:()=>x,cr:()=>p,iz:()=>d,qg:()=>u,yG:()=>_});var i=s(84952),r=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,i.An)(t),s=e?.path.match(a)||e?.path.match(h);if(!s)return null;const[,r,o,c,l]=s,u=o.indexOf("/");return{title:p(-1!==u?o.slice(u+1):o),serverType:n[c.toLowerCase()],sublayer:null!=l&&""!==l?parseInt(l,10):null,url:{path:r}}}function d(t){const e=(0,i.An)(t).path.match(c);return e?{serviceUrl:e[1],sublayerId:Number(e[2])}:null}function p(t){return(t=t.replaceAll(/\s*[/_]+\s*/g," "))[0].toUpperCase()+t.slice(1)}function _(t,e){const s=[];if(t){const e=u(t);null!=e&&e.title&&s.push(e.title)}if(e){const t=p(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,i.$z)(t,!0);return!!e&&(e=e.toLowerCase(),e.endsWith(".arcgis.com")&&(e.startsWith("services")||e.startsWith("tiles")||e.startsWith("features")))}function m(t,e){return t?(0,i.UC)((0,i.zi)(t,e)):t}function g(t){let{url:e}=t;if(!e)return{url:e};e=(0,i.zi)(e,t.logger);const s=(0,i.An)(e),r=u(s.path);let n;if(null!=r)null!=r.sublayer&&null==t.layer.layerId&&(n=r.sublayer),e=r.url.path;else if(t.nonStandardUrlAllowed){const t=d(s.path);null!=t&&(e=t.serviceUrl,n=t.sublayerId)}return{url:(0,i.UC)(e),layerId:n}}function y(t,e,s,n,o){(0,r.w)(e,n,"url",o),n.url&&null!=t.layerId&&(n.url=(0,i.fj)(n.url,s,t.layerId.toString()))}function x(t){if(!t)return!1;const e=t.toLowerCase(),s=e.includes("/services/"),i=e.includes("/mapserver/wmsserver"),r=e.includes("/imageserver/wmsserver"),n=e.includes("/wmsserver");return s&&(i||r||n)}},58501:(t,e,s)=>{s.d(e,{q:()=>r});var i=s(62815);function r(t,e,s){if(!s?.features||!s.hasZ)return;const r=(0,i.N)(s.geometryType,e,t.outSpatialReference);if(null!=r)for(const t of s.features)r(t.geometry)}},83355:(t,e,s)=>{s.r(e),s.d(e,{default:()=>dp});var i=s(49186),r=s(36563),n=s(44208),o=s(26390),a=s(74887),h=s(87811),c=s(36708),l=s(90629),u=s(87045),d=s(21325),p=s(44159);function _(t,e){return[t,e]}function f(t,e,s){return t[0]=e,t[1]=s,t}const m=new p.A("0/0/0/0");class g{static create(t,e,s=null){const i=(0,d.Vp)(t.spatialReference),r=e.origin||_(t.origin.x,t.origin.y),n=_(t.size[0]*e.resolution,t.size[1]*e.resolution),o=_(-1/0,-1/0),a=_(1/0,1/0),h=_(1/0,1/0);null!=s&&(f(o,Math.max(0,Math.floor((s.xmin-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymax)/n[1]))),f(a,Math.max(0,Math.floor((s.xmax-r[0])/n[0])),Math.max(0,Math.floor((r[1]-s.ymin)/n[1]))),f(h,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:c,rows:l}=e;let u,p,m,y;return!s&&c&&l&&(f(o,c[0],l[0]),f(a,c[1],l[1]),f(h,c[1]-c[0]+1,l[1]-l[0]+1)),t.isWrappable?(u=_(Math.ceil(Math.round((i.valid[1]-i.valid[0])/e.resolution)/t.size[0]),h[1]),p=_(Math.floor((i.origin[0]-r[0])/n[0]),o[1]),m=_(u[0]+p[0]-1,a[1]),y=!0):(p=o,m=a,u=h,y=!1),new g(e.level,e.resolution,e.scale,r,o,a,h,n,p,m,u,y)}constructor(t,e,s,i,r,n,o,a,h,c,l,u){this.level=t,this.resolution=e,this.scale=s,this.origin=i,this.first=r,this.last=n,this.size=o,this.norm=a,this.worldStart=h,this.worldEnd=c,this.worldSize=l,this.wrap=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}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){return this.origin[0]+t*this.norm[0]}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 i=s?m.col:this.denormalizeCol(m.col,m.world),r=m.row;return function(t,e,s,i,r){t[0]=e,t[1]=s,t[2]=i,t[3]=r}(t,this.getXForColumn(i),this.getYForRow(r+1),this.getXForColumn(i+1),this.getYForRow(r)),t}getTileCoords(t,e,s=!1){m.set(e);const i=s?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(t)?f(t,this.getXForColumn(i),this.getYForRow(m.row)):(t.x=this.getXForColumn(i),t.y=this.getYForRow(m.row)),t}}var y=s(93687);class x{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:i}of this.spans)for(let r=s;r<=i;r++){const s=t.getWorldForColumn(r);yield new p.A(t.level,e,t.normalizeCol(r),s)}}forEach(t,e){const{spans:s,lodInfo:i}=this,{level:r}=i;if(0!==s.length)for(const{row:n,colFrom:o,colTo:a}of s)for(let s=o;s<=a;s++)t.call(e,r,n,i.normalizeCol(s),i.getWorldForColumn(s))}}x.pool=new y.A(x);class b{constructor(t,e,s){this.row=t,this.colFrom=e,this.colTo=s}}const w=new p.A("0/0/0/0");class v{static create(t,e){t[1]>e[1]&&([t,e]=[e,t]);const[s,i]=t,[r,n]=e,o=r-s,a=n-i,h=0!==a?o/a:0,c=(Math.ceil(i)-i)*h,l=(Math.floor(i)-i)*h;return new v(s,Math.floor(i),Math.ceil(n),h,o<0?c:l,o<0?l:c,o<0?r:s,o<0?s:r)}constructor(t,e,s,i,r,n,o,a){this.x=t,this.ymin=e,this.ymax=s,this.invM=i,this.leftAdjust=r,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 S=[[0,0],[0,0],[0,0],[0,0]];class I{constructor(t,e=null,s=t.lods[0].level,i=t.lods[t.lods.length-1].level){this.tileInfo=t,this.fullExtent=e,this.scales=[],this._infoByScale={},this._infoByLevel={};const r=t.lods.filter((t=>t.level>=s&&t.level<=i));this.minScale=r[0].scale,this.maxScale=r[r.length-1].scale;const n=this._lodInfos=r.map((s=>g.create(t,s,e)));r.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){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileBounds(t,w,s):t}getTileCoords(t,e,s=!1){w.set(e);const i=this._infoByLevel[w.level];return i?i.getTileCoords(t,w,s):t}getTileCoverage(t,e=192,s=!0,i="closest"){if(!s&&(t.scale>this.minScale||t.scale<this.maxScale))return null;const r="closest"===i?this.getClosestInfoForScale(t.scale):this.getSmallestInfoForScale(t.scale),n=x.pool.acquire(r),o=this._wrap;let a,h,c,l=1/0,u=-1/0;const d=n.spans;S[0][0]=S[0][1]=S[1][1]=S[3][0]=-e,S[1][0]=S[2][0]=t.size[0]+e,S[2][1]=S[3][1]=t.size[1]+e;for(const e of S)t.toMap(e,e),e[0]=r.getColumnForX(e[0]),e[1]=r.getRowForY(e[1]);const p=[];let _=3;for(let t=0;t<4;t++){if(S[t][1]===S[_][1]){_=t;continue}const e=v.create(S[t],S[_]);l=Math.min(e.ymin,l),u=Math.max(e.ymax,u),void 0===p[e.ymin]&&(p[e.ymin]=[]),p[e.ymin].push(e),_=t}if(null==l||null==u||u-l>100)return null;let f=[];for(a=l;a<u;){null!=p[a]&&(f=f.concat(p[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>=r.first[1]&&a<=r.last[1])if(o)if(r.size[0]<r.worldSize[0]){const t=Math.floor(c/r.worldSize[0]);for(let e=Math.floor(h/r.worldSize[0]);e<=t;e++)d.push(new b(a,Math.max(r.getFirstColumnForWorld(e),h),Math.min(r.getLastColumnForWorld(e),c)))}else d.push(new b(a,h,c));else h>r.last[0]||c<r.first[0]||(h=Math.max(h,r.first[0]),c=Math.min(c,r.last[0]),d.push(new b(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){w.set(t);const e=this._infoByLevel[w.level],s=this._lodInfos.indexOf(e)-1;return s<0?null:(this._getTileIdAtLOD(w,this._lodInfos[s],w),w.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){w.set(e);const s=this._infoByLevel[w.level],i=t.lodInfo;if(i.resolution>s.resolution){this._getTileIdAtLOD(w,i,w);const e=i.denormalizeCol(w.col,w.world);for(const s of t.spans)if(s.row===w.row&&s.colFrom<=e&&s.colTo>=e)return!0}if(i.resolution<s.resolution){const[e,r,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(w.col,w.world),h=i.getColumnForX(s.getXForColumn(a)),c=i.getRowForY(s.getYForRow(w.row)),l=i.getColumnForX(s.getXForColumn(a+1))-1,u=i.getRowForY(s.getYForRow(w.row+1))-1;return!(h>o||l<n||c>r||u<e)}const r=i.denormalizeCol(w.col,w.world);return t.spans.some((t=>t.row===w.row&&t.colFrom<=r&&t.colTo>=r))}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,d.Vp)(this.tileInfo.spatialReference),i=-s*(e.valid[1]-e.valid[0]);t[0]+=i,t[2]+=i}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 i=this._infoByLevel[s.level];return t.set(s),e.resolution<i.resolution?null:(e.resolution===i.resolution||(t.level=e.level,t.col=Math.floor(s.col*i.resolution/e.resolution+.01),t.row=Math.floor(s.row*i.resolution/e.resolution+.01)),t)}}var P=s(90237),M=s(69622),T=s(97768),C=s(10107),A=s(53966),E=s(40608),F=s(37585),k=s(89738);const z=new Set,O=[],R=new Map,L=[0,0];let N=class extends M.A{constructor(t){super(t),this._keyToItem=new Map,this.concurrency=6,this.strategy="scale-first",this.tileInfoView=null}initialize(){const{concurrency:t,process:e,strategy:s}=this;this._queue=new k.e({concurrency:t,process:(t,s)=>{const i=this._keyToItem.get(t);return e(i,{signal:s})},peeker:"scale-first"===s?t=>this._peekByScaleFirst(t):t=>this._peekByCenterFirst(t)})}destroy(){this.clear(),this._queue=(0,T.pR)(this._queue)}get length(){return this._queue?this._queue.length:0}get onGoingCount(){return this._keyToItem.size}abort(t){const e="string"==typeof t?t:t.id;this._queue.abort(e)}clear(){this._queue.clear(),this._keyToItem.clear()}has(t){return"string"==typeof t?this._keyToItem.has(t):this._keyToItem.has(t.id)}isOngoing(t){const e="string"==typeof t?t:t.id;return this.has(e)&&this._queue.isOngoing(e)}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),i=()=>{this._keyToItem.delete(e)};return this._keyToItem.set(e,t),s.then(i,i),s}reset(){this._queue.reset()}resume(){this._queue.resume()}_peekByScaleFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView;let s=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;t.forEach((t=>{const e=this._keyToItem.get(t),r=this.tileInfoView.getTileScale(e.key);R.has(r)||(R.set(r,[]),s=Math.max(r,s),i=Math.min(r,i)),R.get(r).push(e.key),z.add(r)}));let r=this.state.scale;R.has(r)||(function(t,e){t.length=0,e.forEach((e=>t.push(e)))}(O,z),O.sort(((t,e)=>t-e)),r=O.reduce(((t,e)=>Math.abs(e-r)<Math.abs(t-r)?e:t),O[0])),r=Math.min(r,s),r=Math.max(r,i);const n=R.get(r),o=e.getClosestInfoForScale(r),a=o.getColumnForX(this.state.center[0]),h=o.getRowForY(this.state.center[1]);return n.sort(((t,e)=>{const s=o.denormalizeCol(t.col,t.world),i=o.denormalizeCol(e.col,e.world);return Math.sqrt((a-s)*(a-s)+(h-t.row)*(h-t.row))-Math.sqrt((a-i)*(a-i)+(h-e.row)*(h-e.row))})),z.clear(),R.clear(),n[0].id}_peekByCenterFirst(t){if(!this.state)return t.values().next().value;const e=this.tileInfoView,s=this.state.center;let i,r=Number.POSITIVE_INFINITY;return t.forEach((t=>{const n=this._keyToItem.get(t);e.getTileCoords(L,n.key);const o=(0,F.Io)(L,s);o<r&&(r=o,i=n.key)})),i.id}};(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"concurrency",void 0),(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"process",void 0),(0,P._)([(0,C.MZ)()],N.prototype,"state",void 0),(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"strategy",void 0),(0,P._)([(0,C.MZ)({constructOnly:!0})],N.prototype,"tileInfoView",void 0),N=(0,P._)([(0,E.$)("esri.views.2d.tiling.TileQueue")],N);var D=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("",{ignoreConnectionErrors:!0}),this.container=this._client.createInvokeProxy("container",{ignoreConnectionErrors:!0}),this.eventLog=this._client.createInvokeProxy("eventLog",{ignoreConnectionErrors:!0})}}var U=s(93637),V=s(6797),q=s(16930);class W{constructor(t,e,s,i,r,n,o){this.instanceId=t,this.textureKey=e,this.indexStart=s,this.indexCount=i,this.vertexStart=r,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,i,r,n,o,a){t.push(e),t.push(s),t.push(i),t.push(r),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(),i=t.readInt32(),r=t.readInt32(),n=t.readInt32(),o=t.readInt32(),a=t.readInt32();return new W(e,s,i,r,n,o,a)}}function Y(t,e){if(null!==e){t.push(e.length);for(const s of e)s.serialize(t);return t}t.push(0)}function j(t,e,s){const i=t.readInt32(),r=new Array(i);for(let i=0;i<r.length;i++)r[i]=e.deserialize(t,s);return r}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),Y(t,this.records),t}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=new X(e,s);return i.records=j(t,W)??[],i}}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),i=new this._ctor(s);i.set(this._buffer,0),this._array=s,this._buffer=i,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 i=e;i!==s;i++)this.writeFixed(t._buffer[i])}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 i=6*s*Uint32Array.BYTES_PER_ELEMENT,r=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,i),this._vertices=new $(Uint32Array,r),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(),i=this._metrics.length?this._metrics.buffer():null;return t.push(e,s),{instanceId:this._instanceId,layout:this.layout,indices:e,vertices:s,metrics:i}}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._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,i){}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)}entityRecordCount(){return this._entities.getValue(this._entityRecordCountOffset)}entityEnd(){0===this.entityRecordCount()?this._entities.seek(this._entityIdIndex):this._entities.incr(this._entityCountOffset)}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 i=this._current.indexStart,r=this._current.writer.indexCount-i;return this._recordIndexStart=i,this._recordIndexCount=r,this._recordVertexStart=e,this._recordVertexCount=s,this._entities.incr(this._entityRecordCountOffset),W.write(this._entities,this._current.instanceId,this._current.textureKey,i,r,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 i=this._current.writer.indexWriter,r=this._current.writer.vertexWriter,n=this._recordIndexStart+this._recordIndexCount,o=this._recordVertexCount;for(let t=this._recordIndexStart;t!==n;t++){const e=i.getValue(t);i.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=r.getValue(t);r.push(e)}const l=this._current.writer.layout.position,u=l.packPrecisionFactor??1,d=l.offset/Uint32Array.BYTES_PER_ELEMENT,p=t*u,_=e*u;for(let t=s*a;t<=r.length;t+=a)r.i1616Add(t+d,p,_);this.recordEnd()}copyLastFrom(t,e,s){const i=t._entities.getValue(t._entityIdIndex);if(i!==this._entities.getValue(this._entityIdIndex)){const e=t._entities.getValueF32(t._entitySortKeyIndex);this.entityStart(i,e)}this.recordStart(t._current.instanceId,t._current.writer.layout,t._current.textureKey);const r=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*r;e!==l.length;e++){const t=l.getValue(e);h.push(t)}const u=this._current.writer.layout.position,d=u.packPrecisionFactor??1,p=u.offset/Uint32Array.BYTES_PER_ELEMENT,_=e*d,f=s*d;for(let t=n*r;t<=h.length;t+=r)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,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,this._copyBufferedDataIntoSelf=s&&this._bufferingEnabled&&0===t.level}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,i){this._bufferingEnabled&&this._addOverlap(t,e,s,i)}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,i)=>{const r=s.serialize(),n=1<<i,o=Q(n),a=K(n),h=function(t,e,s,i){const r=t.clone(),n=1<<r.level,o=r.col+e,a=r.row+s;return i&&o<0?(r.col=o+n,r.world-=1):o>=n?(r.col=o-n,r.world+=1):r.col=o,r.row=a,r}(new p.A(this.tileKey),o,a,t);e.message.push({tileId:h.id,...r.message}),e.transferList.push(...r.transferList)})),e}_addOverlap(t,e,s,i){const r=Math.min(B.CQ/2,s),n=Math.min(B.CQ/2,i),o=255^((t<0+r?148:t>=B.CQ-r?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;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],i=-Q(e)*B.CQ,r=-K(e)*B.CQ;s.copyLastFrom(this._meshes.self,i,r)}}}}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}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(),i=[];for(;s.next();)i.push(this._updateMeshWriterGroup(t,s));await Promise.all(i)}match(t,e){const s=t.getAttributeHash();return this._hashToGroup.get(s)}async _updateMeshWriterGroup(t,e){const s=e.readLegacyFeatureForDisplay(),i=e.getAttributeHash();if(this._hashToGroup.has(i))return;this._hashToGroup.set(i,null);const r=await t.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:s});if(!r)return;const n=await this._context.createMeshWriters(r.meshes);this._hashToGroup.set(i,n)}}class it 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),i=new it(s,e.isMaxInclusive);await Promise.all(e.intervals.map((async e=>{const s=await t.createMeshWriters(e.meshes);i.add(e,s)})));const r=await t.createMeshWriters(e.defaultSymbol);i.setDefault(r);const n=await t.createMeshWriters(e.backgroundFill);return i.setBackgroundFill(n),i}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}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:i}=this._intervals[t],r=s>=e.min,n=this._isMaxInclusive?s<=e.max:s<e.max;if(r&&n)return i}return null}}class rt 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)}})),i=await Promise.all(s);return new rt(i)}constructor(t){super(),this._labels=t}match(t,e){if(!this._labels.length)return null;const s=this._getLabels(e.$view.scale),i=[];for(const e of s)e.where&&!e.where(t)||i.push(...e.meshes);return i}_getLabels(t){return this._labels.filter((e=>this._validForTileScale(e,t)))}_validForTileScale(t,e){const s=e-e/4,i=e+e/2;return(!t.minScale||t.minScale>=s)&&(!t.maxScale||t.maxScale<=i)}}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],i=(await Promise.all(s)).filter((t=>!!t)),r=new nt(i,e.fieldDelimiter),n=await t.createMeshWriters(e.defaultSymbol);r.setDefault(n);const o=await t.createMeshWriters(e.backgroundFill);return r.setBackgroundFill(o),await Promise.all(e.map.map((async(e,s)=>{const i=await t.createMeshWriters(e.symbol);"<Null>"===e.value?r.setNullResult(i):r.add(e.value,i,s+1)}))),r}setNullResult(t){this._nullResult=t}getSortKey(t,e){const s=this._getValueFromFields(t,e);if(null==s||""===s||"<Null>"===s)return 0;const i=this._resultsMap.get(s.toString());return i?i.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}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 i=s.toString();return this._resultsMap.get(i)?.meshWriters}_getValueFromFields(t,e){const s=[];for(const i of this._fields){const r=i.read(t,e);null==r||""===r?s.push("<Null>"):s.push(r)}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 it.fromIntervalSchema(t,e);case"dictionary":return st.fromDictionaryRenderer(t,e);case"label":return rt.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,i=[];for(const r in e.renderers){const n=parseInt(r,10),o=ot(t,e.renderers[r]).then((t=>s.set(n,t)));i.push(o)}return await Promise.all(i),new at(s,e.subtypeField)}match(t,e){const s=t.readAttribute(this._subtypeField),i=this._subMatchers.get(s);return i?i.match(t,e):null}}class ht extends et{static async fromClusterSchema(t,e){const[s,i]=await Promise.all([ot(t,e.feature),ot(t,e.cluster)]);return new ht(s,i)}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),i=e.labels?await ot(t,e.labels):null;return new ct(s,i)}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 i=this._symbology.match(e,s);if(i){for(const r of i)r.enqueueRequest(t,e,s);if(this._labels){const i=this._labels.match(e,s);if(!i)return;for(const r of i)r.enqueueRequest(t,e,s)}}}write(t,e,s,i,r){const n=this._symbology.match(s,i);if(n){for(const o of n)o.write(t,e,s,i,r);if(t.entityRecordCount()>=1&&this._labels){const o=this._labels.match(s,i);if(!o)return;for(const a of o)a.setReferences(n),a.write(t,e,s,i,r)}}}getSortKey(t,e){return this._symbology.getSortKey(t,e)}}var lt=s(799),ut=s(15294),dt=s(94656),pt=s(63907),_t=s(4576),ft=s(34275);const mt=()=>A.A.getLogger("esri.views.webgl.BufferObject");class gt{static createIndex(t,e,s){return new gt(t,pt.NZ.ELEMENT_ARRAY_BUFFER,e,s)}static createVertex(t,e,s){return new gt(t,pt.NZ.ARRAY_BUFFER,e,s)}static createUniform(t,e,s){return new gt(t,pt.NZ.UNIFORM_BUFFER,e,s)}static createPixelPack(t,e=pt._U.STREAM_READ,s){const i=new gt(t,pt.NZ.PIXEL_PACK_BUFFER,e);return s&&i.setSize(s),i}static createPixelUnpack(t,e=pt._U.STREAM_DRAW,s){return new gt(t,pt.NZ.PIXEL_UNPACK_BUFFER,e,s)}static createTransformFeedback(t,e=pt._U.STATIC_DRAW,s){const i=new gt(t,pt.NZ.TRANSFORM_FEEDBACK_BUFFER,e);return i.setSize(s),i}constructor(t,e,s,i){this._context=t,this.bufferType=e,this.usage=s,this._glName=null,this._size=-1,this._indexType=void 0,t.instanceCounter.increment(pt.vt.BufferObject,this),this._glName=this._context.gl.createBuffer(),(0,dt.Y2)(this._context.gl),i&&this.setData(i)}get glName(){return this._glName}get size(){return this._size}get indexType(){return this._indexType}get usedMemory(){return this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER?this._indexType===pt.pe.UNSIGNED_INT?4*this._size:2*this._size:this._size}get _isVAOAware(){return this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER||this.bufferType===pt.NZ.ARRAY_BUFFER}dispose(){this._context?.gl?(this._glName&&(this._context.gl.deleteBuffer(this._glName),this._glName=null),this._context.instanceCounter.decrement(pt.vt.BufferObject,this),this._context=null):this._glName&&mt().warn("Leaked WebGL buffer object")}setSize(t,e=null){if(this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER&&null!=e)switch(this._indexType=e,e){case pt.pe.UNSIGNED_SHORT:t*=2;break;case pt.pe.UNSIGNED_INT:t*=4}this._setBufferData(t)}setData(t){if(!t)return;let e=t.byteLength;this.bufferType===pt.NZ.ELEMENT_ARRAY_BUFFER&&((0,ft.jq)(t)&&(e/=2,this._indexType=pt.pe.UNSIGNED_SHORT),(0,ft.XJ)(t)&&(e/=4,this._indexType=pt.pe.UNSIGNED_INT)),this._setBufferData(e,t)}_setBufferData(t,e=null){this._size=t;const s=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const i=this._context.gl;null!=e?i.bufferData(this.bufferType,e,this.usage):i.bufferData(this.bufferType,t,this.usage),(0,dt.Y2)(i),this._isVAOAware&&this._context.bindVAO(s)}setSubData(t,e,s,i){if(!t)return;const r=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const{gl:n}=this._context;n.bufferSubData(this.bufferType,e*t.BYTES_PER_ELEMENT,t,s,i-s),(0,dt.Y2)(n),this._isVAOAware&&this._context.bindVAO(r)}getSubData(t,e=0,s,i){if(s<0||i<0)return;const r=function(t){return(0,_t.Xj)(t)}(t)?t.BYTES_PER_ELEMENT:1;if(r*((s??0)+(i??0))>t.byteLength)return;e+r*(i??0)>this.usedMemory&&mt().warn("Potential problem getting subdata: requested data exceeds buffer size!");const n=this._context.gl;this.bufferType===pt.NZ.TRANSFORM_FEEDBACK_BUFFER?(this._context.bindBuffer(this,pt.NZ.TRANSFORM_FEEDBACK_BUFFER),n.getBufferSubData(pt.NZ.TRANSFORM_FEEDBACK_BUFFER,e,t,s,i),this._context.unbindBuffer(pt.NZ.TRANSFORM_FEEDBACK_BUFFER)):(this._context.bindBuffer(this,pt.NZ.COPY_READ_BUFFER),n.getBufferSubData(pt.NZ.COPY_READ_BUFFER,e,t,s,i),this._context.unbindBuffer(pt.NZ.COPY_READ_BUFFER))}async getSubDataAsync(t,e=0,s,i){await this._context.clientWaitAsync(),this.getSubData(t,e,s,i)}}var yt=s(36421),xt=s(42293);class bt{constructor(t,e){this._context=t,this._descriptor=e,this.type=yt.p.RenderBuffer,this._context.instanceCounter.increment(pt.vt.Renderbuffer,this);const s=this._context.gl;this.glName=s.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:i,height:r,internalFormat:n,multisampled:o}=e;o?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,n,i,r):s.renderbufferStorage(s.RENDERBUFFER,n,i,r),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,xt.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 i=this._context.gl;this._context.bindRenderbuffer(this),s.multisampled?i.renderbufferStorageMultisample(i.RENDERBUFFER,this.samples,s.internalFormat,s.width,s.height):i.renderbufferStorage(i.RENDERBUFFER,s.internalFormat,s.width,s.height),this._context.bindRenderbuffer(null)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(pt.vt.Renderbuffer,this),this._context=null)}}var wt=s(21231);class vt{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(pt.vt.FramebufferObject,this);const i=St(e)?e:new wt.g(this._context,e);if(this._colorAttachments.set(pt.Nm.COLOR_ATTACHMENT0,i),this._validateTextureDescriptor(i.descriptor),this._validateColorAttachmentPoint(pt.Nm.COLOR_ATTACHMENT0),null!=s)if(function(t){return St(t)||null!=t&&"pixelFormat"in t}(s))this._depthStencilTexture=St(s)?s:new wt.g(this._context,s),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=function(t){return null!=t&&"type"in t&&t.type===yt.p.RenderBuffer}(s)?s:new bt(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(pt.vt.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(pt.Nm.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(pt.Nm.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(pt.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&&St(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=pt.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=pt.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=pt.Nm.COLOR_ATTACHMENT0){const s=this._colorAttachments.get(e);s&&this._framebufferTexture2D(s.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case yt.p.Texture:return this._attachDepthStencilTexture(t);case yt.p.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==pt.Ab.DEPTH_STENCIL&&e.pixelFormat!==pt.Ab.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==pt.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,pt.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,pt.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,i=this._getGLAttachmentPoint(e);s.framebufferRenderbuffer(pt.R.FRAMEBUFFER,i,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,i=this._getGLAttachmentPoint(t.descriptor);s.framebufferRenderbuffer(pt.R.FRAMEBUFFER,i,s.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,s,i,r,n,o){(t<0||e<0||r<0||n<0)&&console.error("Offsets cannot be negative!"),(s<=0||i<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==pt.Ap.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||t+s>this.width||e+i>this.height||r+s>a.width||n+i>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,wt.g.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(wt.g.TEXTURE_UNIT_FOR_UPDATES),h.bindFramebuffer(this),h.gl.copyTexSubImage2D(pt.Ap.TEXTURE_2D,0,r,n,t,e,s,i),h.bindTexture(c,wt.g.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,s,i,r,n,o){(s<=0||i<=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,i,r,n,o)}async readPixelsAsync(t,e,s,i,r,n,o){const{gl:a}=this._context,h=gt.createPixelPack(this._context,pt._U.STREAM_READ,o.byteLength);this._context.bindBuffer(h),this._context.bindFramebuffer(this),a.readPixels(t,e,s,i,r,n,0),this._context.unbindBuffer(pt.NZ.PIXEL_PACK_BUFFER),await h.getSubDataAsync(o),h.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const s={width:t,height:e};It(s,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(s.width,s.height))),this._depthStencilTexture?.resize(s.width,s.height),this._initialized&&(It(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=pt.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,Pt(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,Pt(this._depthStencilTexture),t);(0,dt.en)()&&e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=s,this._initialized=!0}_framebufferTexture2D(t,e=pt.Nm.COLOR_ATTACHMENT0,s=pt.Ap.TEXTURE_2D,i=pt.R.FRAMEBUFFER,r=0){this._context.gl.framebufferTexture2D(i,e,s,t,r)}_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(pt.R.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=(0,T.WD)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,T.WD)(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==pt.Ap.TEXTURE_2D&&t.target!==pt.Ap.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),It(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){It(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 pt.yQ.DEPTH_COMPONENT16:case pt.yQ.DEPTH_COMPONENT24:case pt.yQ.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case pt.yQ.DEPTH24_STENCIL8:case pt.yQ.DEPTH32F_STENCIL8:case pt.yQ.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case pt.yQ.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(t){if(-1===vt._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;vt._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const e=t-pt.Nm.COLOR_ATTACHMENT0;e+1>vt._MAX_COLOR_ATTACHMENTS&&A.A.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${e+1}. Implementation supports up to ${vt._MAX_COLOR_ATTACHMENTS} color attachments`)}}function St(t){return null!=t&&"type"in t&&t.type===yt.p.Texture}function It(t,e){const s=Math.max(t.width,t.height);if(s>e){A.A.getLogger("esri.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const i=e/s;return t.width=Math.round(t.width*i),t.height=Math.round(t.height*i),!1}return!0}function Pt(t){return t.descriptor.target===pt.Ap.TEXTURE_CUBE_MAP?pt.Ap.TEXTURE_CUBE_MAP_POSITIVE_X:pt.Ap.TEXTURE_2D}vt._MAX_COLOR_ATTACHMENTS=-1;var Mt,Tt=s(11053),Ct={exports:{}};void 0!==(Mt=["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"])&&(Ct.exports=Mt);const At=(0,Tt.g)(Ct.exports);var Et,Ft={exports:{}};void 0!==(Et=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"])&&(Ft.exports=Et);const kt=(0,Tt.g)(Ft.exports);var zt,Ot,Rt={exports:{}};zt=Rt,void 0!==(Ot=["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"])&&(zt.exports=Ot);const Lt=(0,Tt.g)(Rt.exports);s(62298);var Nt=s(67171);function Dt(t,e,s){const i=new Nt.R(e.width,e.height);return i.dataType=e.dataType,e.depth&&(i.depth=e.depth),e.flipped&&(i.flipped=e.flipped),e.hasMipmap&&(i.hasMipmap=e.hasMipmap),i.internalFormat=e.internalFormat,e.isImmutable&&(i.isImmutable=e.isImmutable),e.isOpaque&&(i.isOpaque=e.isOpaque),e.maxAnisotropy&&(i.maxAnisotropy=e.maxAnisotropy),i.pixelFormat=e.pixelFormat,e.preMultiplyAlpha&&(i.preMultiplyAlpha=e.preMultiplyAlpha),e.samplingMode&&(i.samplingMode=e.samplingMode),e.target&&(i.target=e.target),i.uniform=e.uniform,e.unpackAlignment&&(i.unpackAlignment=e.unpackAlignment),e.wrapMode&&(i.wrapMode=e.wrapMode),new wt.g(t,i,s)}new Map;class Bt{}class Gt extends Bt{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=function(t){return"url"in t&&"urlHash"in t?{...t,url:""}:t}(t.resource),s=(0,lt.Wm)(JSON.stringify(e));return this._pendingIds.has(s)||(this._pendingIds.add(s),this._pendingRequests.push({...t,resourceId:s})),s}async fetchEnqueuedResources(){const t=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const e=await this._fetcher.fetch(t,this._abortOptions);for(let s=0;s<e.length;s++){const i=t[s].resourceId;this._resourceIdToResource.set(i,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 Ut;!function(t){t[t.Fill=0]="Fill",t[t.PatternFill=1]="PatternFill",t[t.ComplexFill=2]="ComplexFill",t[t.OutlineFill=3]="OutlineFill",t[t.PatternOutlineFill=4]="PatternOutlineFill",t[t.ComplexOutlineFill=5]="ComplexOutlineFill",t[t.Marker=6]="Marker",t[t.PieChart=7]="PieChart",t[t.Line=8]="Line",t[t.TexturedLine=9]="TexturedLine",t[t.Text=10]="Text",t[t.Label=11]="Label",t[t.Heatmap=12]="Heatmap",t[t.DotDensity=13]="DotDensity",t[t.Test=14]="Test"}(Ut||(Ut={}));var Vt=s(15585),qt=(s(83349),s(6774)),Wt=s(92722);function Yt(t,e,s,i,r,n,o){fe=0;const a=(i-s)*n,h=r&&r.length,c=h?(r[0]-s)*n:a;let l,u,d,p,_,f=jt(e,s,0,0,c,n,!0);if(f&&f.next!==f.prev){if(h&&(f=function(t,e,s,i,r,n){const o=new Array;for(let r=0,a=i.length;r<a;r++){const h=jt(t,e,0,i[r]*n,r<a-1?i[r+1]*n:s*n,n,!1);h===h.next&&(h.steiner=!0),o.push(Jt(h))}o.sort(he);for(const t of o)r=te(t,r);return r}(e,s,i,r,f,n)),a>80*n){l=d=e[0+s*n],u=p=e[1+s*n];for(let t=n;t<c;t+=n){const i=e[t+s*n],r=e[t+1+s*n];l=Math.min(l,i),u=Math.min(u,r),d=Math.max(d,i),p=Math.max(p,r)}_=Math.max(d-l,p-u),_=0!==_?1/_:0}$t(f,t,n,l,u,_,o,0)}}function jt(t,e,s,i,r,n,o){let a;if(o===function(t,e,s,i,r,n){let o=0;for(let s=i,a=r-n;s<r;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,i,r,n)>0)for(let s=i;s<r;s+=n)a=Qt(s+e*n,t[s+e*n],t[s+1+e*n],a);else for(let s=r-n;s>=i;s-=n)a=Qt(s+e*n,t[s+e*n],t[s+1+e*n],a);return a&&ae(a,a.next)&&(Kt(a),a=a.next),a}function Xt(t,e=t){if(!t)return t;let s,i=t;do{if(s=!1,i.steiner||!ae(i,i.next)&&0!==se(i.prev,i,i.next))i=i.next;else{if(Kt(i),i=e=i.prev,i===i.next)break;s=!0}}while(s||i!==e);return e}function $t(t,e,s,i,r,n,o,a){if(!t)return;!a&&n&&(t=ee(t,i,r,n));let h=t;for(;t.prev!==t.next;){const c=t.prev,l=t.next;if(n?Zt(t,i,r,n):Ht(t))e.push(c.index/s+o),e.push(t.index/s+o),e.push(l.index/s+o),Kt(t),t=l.next,h=l.next;else if((t=l)===h){a?1===a?$t(t=ce(t,e,s,o),e,s,i,r,n,o,2):2===a&&le(t,e,s,i,r,n,o):$t(Xt(t),e,s,i,r,n,o,1);break}}}function Ht(t){const e=t.prev,s=t,i=t.next;if(se(e,s,i)>=0)return!1;let r=t.next.next;const n=r;let o=0;for(;r!==t.prev&&(0===o||r!==n);){if(o++,re(e.x,e.y,s.x,s.y,i.x,i.y,r.x,r.y)&&se(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Zt(t,e,s,i){const r=t.prev,n=t,o=t.next;if(se(r,n,o)>=0)return!1;const a=r.x<n.x?r.x<o.x?r.x:o.x:n.x<o.x?n.x:o.x,h=r.y<n.y?r.y<o.y?r.y:o.y:n.y<o.y?n.y:o.y,c=r.x>n.x?r.x>o.x?r.x:o.x:n.x>o.x?n.x:o.x,l=r.y>n.y?r.y>o.y?r.y:o.y:n.y>o.y?n.y:o.y,u=oe(a,h,e,s,i),d=oe(c,l,e,s,i);let p=t.prevZ,_=t.nextZ;for(;p&&p.z>=u&&_&&_.z<=d;){if(p!==t.prev&&p!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&se(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,_!==t.prev&&_!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&se(_.prev,_,_.next)>=0)return!1;_=_.nextZ}for(;p&&p.z>=u;){if(p!==t.prev&&p!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,p.x,p.y)&&se(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;_&&_.z<=d;){if(_!==t.prev&&_!==t.next&&re(r.x,r.y,n.x,n.y,o.x,o.y,_.x,_.y)&&se(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function Qt(t,e,s,i){const r=pe.create(t,e,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Kt(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 Jt(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 te(t,e){const s=function(t,e){let s=e;const i=t.x,r=t.y;let n,o=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){const t=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=i&&t>o){if(o=t,t===i){if(r===s.y)return s;if(r===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(i===o)return n.prev;const a=n,h=n.x,c=n.y;let l,u=1/0;for(s=n.next;s!==a;)i>=s.x&&s.x>=h&&i!==s.x&&re(r<c?i:o,r,h,c,r<c?o:i,r,s.x,s.y)&&(l=Math.abs(r-s.y)/(i-s.x),(l<u||l===u&&s.x>n.x)&&ne(s,t)&&(n=s,u=l)),s=s.next;return n}(t,e);if(!s)return e;const i=de(s,t);return Xt(i,i.next),Xt(s,s.next)}function ee(t,e,s,i){let r;for(;r!==t;r=r.next){if(r=r||t,null===r.z&&(r.z=oe(r.x,r.y,e,s,i)),r.prev.next!==r||r.next.prev!==r)return r.prev.next=r,r.next.prev=r,ee(t,e,s,i);r.prevZ=r.prev,r.nextZ=r.next}return t.prevZ.nextZ=null,t.prevZ=null,function(t){let e,s=1;for(;;){let i,r=t;t=null,e=null;let n=0;for(;r;){n++,i=r;let o=0;for(;o<s&&i;o++)i=i.nextZ;let a=s;for(;o>0||a>0&&i;){let s;0===o?(s=i,i=i.nextZ,a--):0!==a&&i?r.z<=i.z?(s=r,r=r.nextZ,o--):(s=i,i=i.nextZ,a--):(s=r,r=r.nextZ,o--),e?e.nextZ=s:t=s,s.prevZ=e,e=s}r=i}if(e.nextZ=null,s*=2,n<2)return t}}(t)}function se(t,e,s){return(e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y)}function ie(t,e,s,i){return!!(ae(t,e)&&ae(s,i)||ae(t,i)&&ae(s,e))||se(t,e,s)>0!=se(t,e,i)>0&&se(s,i,t)>0!=se(s,i,e)>0}function re(t,e,s,i,r,n,o,a){return(r-o)*(e-a)-(t-o)*(n-a)>=0&&(t-o)*(i-a)-(s-o)*(e-a)>=0&&(s-o)*(n-a)-(r-o)*(i-a)>=0}function ne(t,e){return se(t.prev,t,t.next)<0?se(t,e,t.next)>=0&&se(t,t.prev,e)>=0:se(t,e,t.prev)<0||se(t,t.next,e)<0}function oe(t,e,s,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ae(t,e){return t.x===e.x&&t.y===e.y}function he(t,e){return t.x-e.x}function ce(t,e,s,i){let r=t;do{const n=r.prev,o=r.next.next;!ae(n,o)&&ie(n,r,r.next,o)&&ne(n,o)&&ne(o,n)&&(e.push(n.index/s+i),e.push(r.index/s+i),e.push(o.index/s+i),Kt(r),Kt(r.next),r=t=o),r=r.next}while(r!==t);return r}function le(t,e,s,i,r,n,o){let a=t;do{let t=a.next.next;for(;t!==a.prev;){if(a.index!==t.index&&ue(a,t)){let h=de(a,t);return a=Xt(a,a.next),h=Xt(h,h.next),$t(a,e,s,i,r,n,o,0),void $t(h,e,s,i,r,n,o,0)}t=t.next}a=a.next}while(a!==t)}function ue(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&&ie(s,s.next,t,e))return!0;s=s.next}while(s!==t);return!1}(t,e)&&ne(t,e)&&ne(e,t)&&function(t,e){let s=t,i=!1;const r=(t.x+e.x)/2,n=(t.y+e.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==t);return i}(t,e)}function de(t,e){const s=pe.create(t.index,t.x,t.y),i=pe.create(e.index,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}class pe{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 i=fe<_e.length?_e[fe++]:new pe;return i.index=t,i.x=e,i.y=s,i.prev=null,i.next=null,i.z=null,i.prevZ=null,i.nextZ=null,i.steiner=!1,i}}const _e=[];let fe=0;for(let t=0;t<8096;t++)_e.push(new pe);const me=new qt.O3(0,0,0,1,0),ge=new qt.O3(0,0,0,1,0);function ye(t,e,s){let i=0;for(let r=1;r<s;r++){const s=t[2*(e+r-1)],n=t[2*(e+r-1)+1];i+=(t[2*(e+r)]-s)*(t[2*(e+r)+1]+n)}return i}function xe(t,e,s,i,r){let n=0;for(let o=s;o<i;o+=3){const s=2*(t[o]-r),i=2*(t[o+1]-r),a=2*(t[o+2]-r);n+=Math.abs((e[s]-e[a])*(e[i+1]-e[s+1])-(e[s]-e[i])*(e[a+1]-e[s+1]))}return n}function be(t,e){if(null==t)return null;if(!function(t,e,s){let i=0;for(let e=0;e<t.lengths.length;e++){const r=t.lengths[e];for(let e=0;e<r;e++){const r=t.coords[2*(e+i)],n=t.coords[2*(e+i)+1];if(r<-128||r>s||n<-128||n>s)return!0}i+=r}return!1}(t,0,B.CQ+128))return t;me.setPixelMargin(e),me.reset(qt.dC.Polygon);let s=0;for(let e=0;e<t.lengths.length;e++){const i=t.lengths[e];let r=t.coords[2*(0+s)],n=t.coords[2*(0+s)+1];me.moveTo(r,n);for(let e=1;e<i;e++)r=t.coords[2*(e+s)],n=t.coords[2*(e+s)+1],me.lineTo(r,n);me.close(),s+=i}const i=me.result(!1);if(!i)return null;const r=[],n=[];for(const t of i){let e=0;for(const s of t)n.push(s.x),n.push(s.y),e++;r.push(e)}return new Wt.A(r,n)}me.setExtent(B.CQ),ge.setExtent(B.CQ);var we=s(4718),ve=s(51118),Se=s(65864);class Ie{static fromOptimized(t,e,s=!1,i=!1,r=1){return(new Pe).initialize(t,e,s,i,r)}static fromJSON(t,e=!1,s=!1){const[i,r]=Te(t);return(new Ce).initialize(i,r,e,s,1)}static fromOptimizedCIM(t,e,s=!1,i=!1,r=1){return(new Ae).initialize(t,e,s,i,r)}static fromJSONCIM(t,e=!1,s=!1,i=1){const[r,n]=Te(t);return(new Ee).initialize(r,n,e,s,i)}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,i=1){return(new Pe).initialize(new Wt.A,t,e,s,i)}static createEmptyJSON(t,e=!1,s=!1){return(new Ce).initialize([],t,e,s,1)}static createEmptyOptimizedCIM(t,e=!1,s=!1,i=1){return(new Ae).initialize(new Wt.A,t,e,s,i)}static createEmptyJSONCIM(t,e=!1,s=!1,i=1){return(new Ee).initialize([],t,e,s,i)}asJSON(){const t=(0,ve.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 i=t,r=e;for(;this.nextPoint();)s+=(t-this.x)*(e+this.y),t=this.x,e=this.y;return s+=(t-i)*(e+r),-.5*s}invertY(){this.yFactor*=-1}}class Pe extends Ie{constructor(){super(...arguments),this._end=-1}initialize(t,e,s,i,r){return this.hasZ=s,this.hasM=i,this.geometryType=e,this._stride=2+Number(s)+Number(i),this._geometry=t,this._pathIndex=-1,this._pathOffset=0,this._pointOffset=-this._stride,this._end=-1,this.yFactor=r,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))}pathLength(){const t=this._end,e=this._stride,s=this._geometry.coords;let i=0;for(let r=this._pathOffset+e;r<t;r+=e){const t=s[r-e],n=s[r-e+1],o=s[r]-t,a=s[r+1]-n;i+=Math.sqrt(o*o+a*a)}return i}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 i=0;i<this._stride;i++)if(t[e+i]!==t[s+i])return!1;return!0}clone(){return(new Pe).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._pathIndex<0||this._pathIndex>t.length-1?0:this._geometry.isPoint?1:t[this._pathIndex]}get totalSize(){return 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 Me(t){const e=[t.x,t.y];return t.z&&e.push(t.z),t.m&&e.push(t.m),e}function Te(t){return(0,Se.Bi)(t)?[t.rings,"esriGeometryPolygon"]:(0,Se.Rg)(t)?[t.paths,"esriGeometryPolyline"]:(0,Se.U9)(t)?[[t.points],"esriGeometryMultipoint"]:(0,Se.ZC)(t)?[[[[t.xmin,t.ymin],[t.xmin,t.ymax],[t.xmax,t.ymax],[t.xmax,t.ymin],[t.xmin,t.ymin]]],"esriGeometryEnvelope"]:(0,Se.fT)(t)?[[[Me(t)]],"esriGeometryPoint"]:[[],"esriGeometryPolyline"]}class Ce extends Ie{initialize(t,e,s,i,r){return this._paths=t,this.geometryType=e,this.hasZ=s,this.hasM=i,this._pathIndex=this._pointIndex=-1,this.yFactor=r,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 i=1;i<t;i++){const t=e[i-1],r=e[i],n=t[0],o=t[1],a=r[0]-n,h=r[1]-o;s+=Math.sqrt(a*a+h*h)}return s}startPath(){this._paths.push([])}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,ve.x)(t);for(const t of e)this.pushPath(t)}asOptimized(){const t=new Wt.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 Ce).initialize((0,we.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 Ae extends Pe{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r),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 Ae).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 Ee extends Ce{initialize(t,e,s,i,r){return super.initialize(t,e,s,i,r)}clone(){return(new Ee).initialize((0,we.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]}}let Fe;class ke{constructor(t){this._geometry=t}next(){const t=this._geometry;return this._geometry=null,t}}function ze(t,e){Fe||(Fe=new qt.O3(0,0,0,1));const s="esriGeometryPolygon"===t.geometryType,i=s?qt.dC.Polygon:qt.dC.LineString,r=s?3:2;let n,o;for(Fe.reset(i),Fe.setPixelMargin(e+1),Fe.setExtent(512);t.nextPath();)if(!(t.pathSize<r)){for(t.nextPoint(),n=t.x,o=-t.y,Fe.moveTo(n,o);t.nextPoint();)n=t.x,o=-t.y,Fe.lineTo(n,o);s&&Fe.close()}const a=Fe.result(!1);if(a){const e=Ie.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 Oe{static local(){return null===Oe.instance&&(Oe.instance=new Oe),Oe.instance}execute(t,e,s,i,r){return new Re(t,e,s)}}Oe.instance=null;class Re{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 i=e,r=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?(p=e,_=s):(p=t.x,_=t.y);const f=p-i,m=_-r,g=Math.sqrt(f*f+m*m);d>1&&g>0&&h>0&&(o*f+a*m)/g/h<=this._maxCosAngle&&t.setControlPointAt(d-1),1===d&&(c=f,l=m,u=g),g>0&&(i=p,r=_,o=f,a=m,h=g)}this._isClosed&&h>0&&u>0&&(o*c+a*l)/u/h<=this._maxCosAngle&&t.setControlPointAt(0)}}}class Le{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 Ne(t,e){t[4]=e}class De{constructor(t,e=!0,s=!0,i=0){this.isClosed=!1,this.geometryCursor=null,this.geometryCursor=!e&&"esriGeometryPolygon"===t.geometryType||!s&&"esriGeometryPolyline"===t.geometryType?null:t,this.geomUnitsPerPoint=i,this.iterateMultiPath=!1,this.iteratePath=!1,this.internalPlacement=new Le}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 Be{constructor(t,e,s,i=0){this.isClosed=!1,this._tileKey=null,this.inputGeometries=t,this.acceptPolygon=e,this.acceptPolyline=s,this.geomUnitsPerPoint=i,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;this._tileKey&&this.isClippingRequired(this.multiPathCursor)&&(this.multiPathCursor.reset(),this.multiPathCursor=ze(this.multiPathCursor,256))}for(;this.iteratePath||this.multiPathCursor.nextPath();){this.multiPathCursor.seekPathStart();const t=this.processPath(this.multiPathCursor);if(t)return t}this.multiPathCursor=null}}isClippingRequired(t){return!1}}const Ge=.03;class Ue{constructor(t=0,e=!1){}isEmpty(t){if(!t.nextPoint())return!0;let e,s,i,r;for(e=t.x,s=t.y;t.nextPoint();e=s,s=r)if(i=t.x,r=t.y,i!==e||r!==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,i){const r=s-t,n=i-e;return Math.sqrt(r*r+n*n)}getSegLength(t){const[[e,s],[i,r]]=t;return this.getLength(e,s,i,r)}getCoord2D(t,e,s,i,r){return[t+(s-t)*r,e+(i-e)*r]}getSegCoord2D(t,e){const[[s,i],[r,n]]=t;return this.getCoord2D(s,i,r,n,e)}getAngle(t,e,s,i,r){const n=s-t,o=i-e;return Math.atan2(o,n)}getAngleCS(t,e,s,i,r){const n=s-t,o=i-e,a=Math.sqrt(n*n+o*o);return a>0?[n/a,o/a]:[1,0]}getSegAngleCS(t,e){const[[s,i],[r,n]]=t;return this.getAngleCS(s,i,r,n,e)}cut(t,e,s,i,r,n){return[r<=0?[t,e]:this.getCoord2D(t,e,s,i,r),n>=1?[s,i]:this.getCoord2D(t,e,s,i,n)]}getSubCurve(t,e,s){const i=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");return this.appendSubCurve(i,t,e,s)?i:null}appendSubCurve(t,e,s,i){t.startPath(),e.seekPathStart();let r=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(r+h>s){const c=(s-r)/h;let l=1,u=!1;r+h>=i&&(l=(i-r)/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(r+h>i){const s=this.cut(o,a,e.x,e.y,0,(i-r)/h);s&&t.pushPoint(s[1]);break}t.pushXY(e.x,e.y)}r+=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,i,r,n,o=0;for(s=t.x,i=t.y;t.nextPoint();s=r,i=n){r=t.x,n=t.y;const a=this.getLength(s,i,r,n);if(0!==a){if(o+a>e){const t=(e-o)/a;return this.getCoord2D(s,i,r,n,t)}o+=a}}return null}offset(t,e,s,i,r){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 r=0;r<a;r++){const n=r===a-1?h?t[0]:null:t[r+1];if(o)if(n){const t=[n[0]-l[0],n[1]-l[1]];this.normalize(t);const r=[l[0]-o[0],l[1]-o[1]];this.normalize(r);const a=r[0]*t[1]-r[1]*t[0],h=r[0]*t[0]+r[1]*t[1];if(0===a&&1===h){l=n;continue}if(a>=0==e<=0){if(h<1){const s=[t[0]-r[0],t[1]-r[1]];this.normalize(s);const n=Math.sqrt((1+h)/2);if(n>1/i){const t=-Math.abs(e)/n;c.push([l[0]-s[0]*t,l[1]-s[1]*t])}}}else switch(s){case ut.xw.Mitered:{const s=Math.sqrt((1+h)/2);if(s>0&&1/s<i){const i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=Math.abs(e)/s;c.push([l[0]-i[0]*n,l[1]-i[1]*n]);break}}case ut.xw.Bevelled:c.push([l[0]+r[1]*e,l[1]-r[0]*e]),c.push([l[0]+t[1]*e,l[1]-t[0]*e]);break;case ut.xw.Rounded:if(h<1){c.push([l[0]+r[1]*e,l[1]-r[0]*e]);const s=Math.floor(2.5*(1-h));if(s>0){const i=1/s;let n=i;for(let o=1;o<s;o++,n+=i){const s=[r[1]*(1-n)+t[1]*n,-r[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 ut.xw.Square:default:if(a<0)c.push([l[0]+(r[1]+r[0])*e,l[1]+(r[1]-r[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),i=[t[0]-r[0],t[1]-r[1]];this.normalize(i);const n=e/s;c.push([l[0]-i[0]*n,l[1]-i[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 Ve=ut.oF.OpenEnded;class qe{static local(){return null===qe.instance&&(qe.instance=new qe),qe.instance}execute(t,e,s,i,r){return new We(t,e,s)}}qe.instance=null;class We extends Be{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new Ue,this._width=(void 0!==e.width?e.width:5)*s,this._arrowType=void 0!==e.geometricEffectArrowType?e.geometricEffectArrowType:void 0!==e.arrowType?e.arrowType:Ve,this._offsetFlattenError=Ge*s}processPath(t){const e=Ie.createEmptyOptimizedCIM(t.geometryType);switch(this._arrowType){case ut.oF.OpenEnded:default:this._constructSimpleArrow(e,t,!0);break;case ut.oF.Block:this._constructSimpleArrow(e,t,!1);break;case ut.oF.Crossed:this._constructCrossedArrow(e,t)}return e}_constructSimpleArrow(t,e,s){const i=e.pathLength();let r=this._width;i<2*r&&(r=i/2);const n=this._curveHelper.getSubCurve(e,0,i-r);if(!n||!n.nextPath())return;n.seekPathStart();const o=r/2;if(this._curveHelper.isEmpty(n))return;const a=(0,ve.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 i=this._width;s<3.732050807568877*i&&(i=s/3.732050807568877),e.seekPathStart();const r=this._curveHelper.getSubCurve(e,0,s-2.732050807568877*i);if(!r)return;r.nextPath();const n=i/2;if(this._curveHelper.isEmpty(r))return;const o=(0,ve.A)(r),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-i);if(!c)return;if(c.nextPath(),this._curveHelper.isEmpty(c))return;const l=(0,ve.A)(c),u=this._constructOffset(l,n);if(!u)return;const d=this._constructOffset(l,-n);if(!d)return;const p=u[u.length-1],_=this._constructArrowBasePoint(u,n/2);if(!_)return;const f=d[d.length-1],m=this._constructArrowBasePoint(d,-n/2);if(!m)return;e.seekInPath(e.pathSize-1);const g=[e.x,e.y];t.pushPath(a),t.nextPath(),t.nextPoint(),t.setControlPoint(),t.pushPoint(f),t.nextPoint(),t.setControlPoint(),t.pushPoint(m),t.nextPoint(),t.setControlPoint(),t.pushPoint(g),t.nextPoint(),t.setControlPoint(),t.pushPoint(_),t.nextPoint(),t.setControlPoint(),t.pushPoint(p),t.nextPoint(),t.setControlPoint(),t.pushPoints(h.reverse()),t.nextPoint(),t.setControlPoint(),t.reset()}_constructOffset(t,e){return this._curveHelper.offset(t,e,ut.xw.Rounded,4,this._offsetFlattenError)}_constructArrowBasePoint(t,e){if(!t||t.length<2)return null;const s=t[t.length-2],i=t[t.length-1],r=[i[0]-s[0],i[1]-s[1]];return this._curveHelper.normalize(r),[i[0]+r[1]*e,i[1]-r[0]*e]}}s(59456);class Ye{static local(){return null===Ye.instance&&(Ye.instance=new Ye),Ye.instance}execute(t,e,s,i,r,n){return new je(t,e,s,i,r,n)}}Ye.instance=null;class je{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new Ue,this._size=(void 0!==e.size?e.size:1)*s,this._maxInflateSize=n*s,this._offsetFlattenError=Ge*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=Ie.createEmptyOptimizedCIM(t.geometryType),s=(0,ve.x)(t)[0],i=this._curveHelper.offset(s,this._size,ut.xw.Rounded,4,this._offsetFlattenError);if(i)return e.pushPath(i),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 Ie.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._tileKey?ze(t,this._maxInflateSize):t;if(!s)continue;const i=e.buffer(q.A.WebMercator,s.asJSON(),this._size,1);return i?Ie.fromJSONCIM(i):null}return null}}class Xe{static local(){return null===Xe.instance&&(Xe.instance=new Xe),Xe.instance}execute(t,e,s,i,r){return new $e(t,e,s)}}Xe.instance=null;class $e{constructor(t,e,s){this._defaultPointSize=20,this._inputGeometries=t,this._geomUnitsPerPoint=s,this._rule=e.rule??ut.uQ.FullGeometry,this._defaultSize=this._defaultPointSize*s}next(){let t;for(;t=this._inputGeometries.next();){const e=this._processGeom((0,ve.x)(t));if(e?.length)return Ie.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,i){return[t[0]*e+s[0]*i,t[1]*e+s[1]*i]}_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 i=t[0]*e-t[1]*s,r=t[0]*s+t[1]*e;t[0]=i,t[1]=r}_makeCtrlPt(t){const e=[t[0],t[1]];return Ne(e,1),e}_addAngledTicks(t,e,s,i){const r=this._sub(s,e);this._normalize(r);const n=this._crossProduct(r,this._sub(i,e));let o;o=n>0?this._rightPerp(r):this._leftPerp(r);const a=Math.abs(n)/2,h=[];h.push([e[0]+(o[0]-r[0])*a,e[1]+(o[1]-r[1])*a]),h.push(e),h.push(s),h.push([s[0]+(o[0]+r[0])*a,s[1]+(o[1]+r[1])*a]),t.push(h)}_addBezier2(t,e,s,i,r){if(0==r--)return void t.push(i);const n=this._mid(e,s),o=this._mid(s,i),a=this._mid(n,o);this._addBezier2(t,e,n,a,r),this._addBezier2(t,a,o,i,r)}_addBezier3(t,e,s,i,r,n){if(0==n--)return void t.push(r);const o=this._mid(e,s),a=this._mid(s,i),h=this._mid(i,r),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,r,n)}_add90DegArc(t,e,s,i,r){const n=r??this._crossProduct(this._sub(s,e),this._sub(i,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 i=e[0],r=e[1],n=e[e.length-1],o=this._sub(i,r),a=this._norm(o);this._normalize(o);const h=Math.abs(this._crossProduct(o,this._sub(n,r)));let c=this._dotProduct(o,this._sub(n,r));c<.05*a?c=.05*a:c>.95*a&&(c=.95*a);const l=.5*h,u=this._leftPerp(o),d=[r[0]+o[0]*c,r[1]+o[1]*c],p=e.length-1,_=[];_.push(s?[-u[0],-u[1]]:u);let f=[-o[0],-o[1]];for(let t=1;t<p-1;t++){const s=this._sub(e[t+1],e[t]);this._normalize(s);const i=this._dotProduct(s,f),r=this._crossProduct(s,f),n=Math.sqrt((1+i)/2),o=this._sub(s,f);this._normalize(o),o[0]/=n,o[1]/=n,_.push(r<0?[-o[0],-o[1]]:o),f=s}_.push(this._rightPerp(f));for(let s=_.length-1;s>0;s--)t.push([e[s][0]+_[s][0]*l,e[s][1]+_[s][1]*l]);t.push([d[0]+_[0][0]*l,d[1]+_[0][1]*l]),t.push([d[0]+_[0][0]*h,d[1]+_[0][1]*h]),t.push(i),t.push([d[0]-_[0][0]*h,d[1]-_[0][1]*h]),t.push([d[0]-_[0][0]*l,d[1]-_[0][1]*l]);for(let s=1;s<_.length;s++)t.push([e[s][0]-_[s][0]*l,e[s][1]-_[s][1]*l])}_cp2(t,e,s){return t.length>=2?t[1]:this._add2(t[0],e*this._defaultSize,s*this._defaultSize)}_cp3(t,e,s,i){if(t.length>=3)return t[2];const r=this._mix(t[0],1-s,e,s),n=this._sub(e,t[0]);return this._normalize(n),this._rightPerpendicular(n),[r[0]+n[0]*i*this._defaultSize,r[1]+n[1]*i*this._defaultSize]}_arrowPath(t){if(t.length>2)return t;const e=t[0],s=this._cp2(t,-4,0),i=this._sub(e,s);this._normalize(i);const r=this._rightPerp(i);return[e,s,[e[0]+(r[0]-i[0])*this._defaultSize,e[1]+(r[1]-i[1])*this._defaultSize]]}_arrowLastSeg(t){const e=t[0],s=this._cp2(t,-4,0);let i;if(t.length>=3)i=t[t.length-1];else{const t=this._sub(e,s);this._normalize(t);const r=this._rightPerp(t);i=[e[0]+(r[0]-t[0])*this._defaultSize,e[1]+(r[1]-t[1])*this._defaultSize]}return[s,i]}_processGeom(t){if(!t)return null;const e=[];for(const s of t){if(!s||0===s.length)continue;const t=s.length;let i=s[0];switch(this._rule){case ut.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 ut.uQ.ReversedFirstSegment:{const t=this._cp2(s,0,-1);e.push([t,i]);break}case ut.uQ.PerpendicularToSecondSegment:{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 ut.uQ.SecondSegmentWithTicks:{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 ut.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 ut.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 ut.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 ut.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 ut.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 ut.uQ.HalfCircleExtended:{const r=this._cp2(s,0,-2),n=this._cp3(s,r,1,-1);let o;if(t>=4)o=s[3];else{const t=this._sub(i,r);o=this._add(n,t)}const a=this._dist(r,n)/2/.75,h=this._sub(r,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(r,h),r,4),u.push(i),e.push(u);break}case ut.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 ut.uQ.CoverageEdgesWithTicks:{const r=this._cp2(s,0,-1);let n,o;if(t>=3)n=s[2];else{const t=this._sub(r,i),e=this._leftPerp(t);n=[i[0]+e[0]-.25*t[0],i[1]+e[1]-.25*t[1]]}if(t>=4)o=s[3];else{const t=this._mid(i,r),e=this._sub(i,r);this._normalize(e),this._leftPerpendicular(e);const s=this._crossProduct(e,this._sub(n,t));this._rightPerpendicular(e),o=[n[0]+e[0]*s*2,n[1]+e[1]*s*2]}const a=this._sub(r,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,r))>0?this._rightPerp(a):this._leftPerp(a),c=[],c.push([r[0]+(h[0]+a[0])/3,r[1]+(h[1]+a[1])/3]),c.push(r),c.push(o),e.push(c);break}case ut.uQ.GapExtentWithDoubleTicks:{const r=this._cp2(s,0,2),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}this._addAngledTicks(e,i,r,this._mid(n,o)),this._addAngledTicks(e,n,o,this._mid(i,r));break}case ut.uQ.GapExtentMidline:{const r=this._cp2(s,2,0),n=this._cp3(s,r,0,1);let o;if(t>=4)o=s[3];else{const t=this._sub(r,i);o=this._add(n,t)}const a=[];a.push(this._mid(i,n)),a.push(this._mid(r,o)),e.push(a);break}case ut.uQ.Chevron:{const r=this._cp2(s,-1,-1);let n;if(t>=3)n=s[2];else{const t=this._sub(r,i);this._leftPerpendicular(t),n=this._add(i,t)}e.push([r,this._makeCtrlPt(i),n]);break}case ut.uQ.PerpendicularWithArc:{const r=this._cp2(s,0,-2),n=this._cp3(s,r,.5,-1),o=this._sub(r,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),t>=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 p=[r[0]+u[0]*h,r[1]+u[1]*h];u=this._sub(r,p);const _=Math.cos(Math.PI/18);let f=Math.sin(Math.PI/18);h<0&&(f=-f),d=[i,r];for(let t=1;t<=9;t++)this._rotateDirect(u,_,f),d.push(this._add(p,u));e.push(d);break}case ut.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 ut.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]),Ne(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 ut.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 ut.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 ut.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 ut.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 ut.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 ut.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 ut.uQ.CircleWithArc:{let r=this._cp2(s,3,0);const n=this._cp3(s,r,.5,-1);let o,a;if(t>=4)o=s[3],a=this._crossProduct(this._sub(o,r),this._sub(n,r))>0;else{o=r,a=this._crossProduct(this._sub(o,i),this._sub(n,i))>0;const t=24*this._geomUnitsPerPoint,e=this._sub(o,i);this._normalize(e,t);const s=Math.sqrt(2)/2;this._rotateDirect(e,s,a?s:-s),r=this._add(i,e)}const h=this._sub(r,i),c=Math.cos(Math.PI/18),l=Math.sin(Math.PI/18),u=[r];for(let t=1;t<=36;t++)this._rotateDirect(h,c,l),u.push(this._add(i,h));this._add90DegArc(u,r,o,n,a),Ne(u[u.length-8],1),e.push(u);break}case ut.uQ.DoubleJog:{let r,n=this._cp2(s,-3,1),o=this._cp3(s,n,-1,-.5);if(t>=4)r=s[3];else{const t=i;i=n,r=o;const e=this._dist(i,t),s=this._dist(r,t);let a=30*this._geomUnitsPerPoint;.5*e<a&&(a=.5*e),.5*s<a&&(a=.5*s),n=this._mix(i,a/e,t,(e-a)/e),o=this._mix(r,a/s,t,(s-a)/s)}const a=this._mid(i,n),h=this._mid(r,o),c=this._dist(i,n),l=this._dist(o,r);let u=Math.min(c,l)/8;u=Math.min(u,24*this._geomUnitsPerPoint);const d=Math.cos(Math.PI/4);let p=this._sub(i,n);this._normalize(p,u),this._crossProduct(p,this._sub(r,n))>0?this._rotateDirect(p,d,-d):this._rotateDirect(p,d,d);let _=[];_.push(n),_.push(this._add(a,p)),_.push(this._sub(a,p)),_.push(i),e.push(_),p=this._sub(r,o),this._normalize(p,u),this._crossProduct(p,this._sub(i,o))<0?this._rotateDirect(p,d,d):this._rotateDirect(p,d,-d),_=[],_.push(o),_.push(this._add(h,p)),_.push(this._sub(h,p)),_.push(r),e.push(_);break}case ut.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 ut.uQ.LineExcludingLastSegment:{const t=this._arrowPath(s),i=[];let r=t.length-2;for(;r--;)i.push(t[r]);e.push(i);break}case ut.uQ.MultivertexArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!1),e.push(i);break}case ut.uQ.CrossedArrow:{const t=this._arrowPath(s),i=[];this._addArrow(i,t,!0),e.push(i);break}case ut.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 ut.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 ut.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 ut.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 ut.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],i=[this._clone(s)];i.push(this._add(s,[n[0]/4,n[1]/4])),e.push(i)}break}case ut.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 ut.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 p=[];p.push([u[0]+l[0]*(h+d)-o[0]*d,u[1]+l[1]*(h+d)-o[1]*d]),p.push([u[0]+l[0]*h,u[1]+l[1]*h]),p.push([u[0]-l[0]*h,u[1]-l[1]*h]),p.push([u[0]-l[0]*(h+d)-o[0]*d,u[1]-l[1]*(h+d)-o[1]*d]),e.push(p),e.push([u,i]);break}case ut.uQ.FullGeometry:default:e.push(s)}}return e}}class He{static local(){return null===He.instance&&(He.instance=new He),He.instance}execute(t,e,s,i,r){return new Ze(t,e,s)}}He.instance=null;class Ze extends Be{constructor(t,e,s){super(t,!0,!0),this._curveHelper=new Ue,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:i}=this,r=t.pathLength(),n=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._invert){if(0!==e||0!==s||0!==i)if(e+s+i>=r)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*(r-i),.5*(r+i)),this._curveHelper.appendSubCurve(n,t,r-s,s)}else if(0===e&&0===s&&0===i)for(n.startPath();t.nextPoint();)n.pushXY(t.x,t.y);else e+s+i<r&&(0===i?this._curveHelper.appendSubCurve(n,t,e,r-s):(this._curveHelper.appendSubCurve(n,t,e,.5*(r-i)),this._curveHelper.appendSubCurve(n,t,.5*(r+i),r-s)));return 0===n.totalSize?null:n}}var Qe,Ke=s(95108);class Je{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 i=Math.abs(t[e]);s&&i<1e-7&&(i=1e-7),this._values.push(i),this._length+=i}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 ts{constructor(){this.pt=null,this.ca=0,this.sa=0}}!function(t){t[t.FAIL=0]="FAIL",t[t.END=1]="END",t[t.CONTINUE=2]="CONTINUE"}(Qe||(Qe={}));class es{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 ss extends Ue{constructor(t=0,e=!1){super(t,e),this._tolerance=Ge,this._currentPosition=new es}updateTolerance(t){this._tolerance=Ge*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=Qe.FAIL){const s=new es;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=Qe.FAIL){const i=new es;if(!this._nextPosition(t,i,null,s))return!1;i.copyTo(this._currentPosition),e.pt=this._getPoint(i);const[r,n]=this._getAngleCS(i);return e.ca=r,e.sa=n,!0}nextCurve(t){if(0===t)return null;const e=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");e.startPath(),e.nextPath();const s=new es;return this._nextPosition(t,s,e,Qe.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,i){if(this._currentPosition.isPathEnd)return!1;let r=this._currentPosition.abscissa;for(this._currentPosition.segmentLength>0&&(r/=this._currentPosition.segmentLength),this._currentPosition.copyTo(e);e.abscissa+t*this._partLengthRatio>e.segmentLength+this._tolerance;){if(s){if(0===s.pathSize)if(0===r){const t=e.segment[0];s.pushXY(t[0],t[1])}else s.pushPoint(this.getSegCoord2D(e.segment,r));const t=e.segment[1];s.pushXY(t[0],t[1])}if(r=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 i!==Qe.FAIL&&(e.segmentLength=this.getSegLength(e.segment),e.isPartEnd=!0,i===Qe.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===r?s.pushPoint(e.segment[0]):s.pushPoint(this.getSegCoord2D(e.segment,r)));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 is=s(93397);class rs{static local(){return null===rs.instance&&(rs.instance=new rs),rs.instance}execute(t,e,s,i,r){return new ns(t,e,s,i)}}rs.instance=null;class ns extends Be{constructor(t,e,s,i){super(t,!0,!0),this._firstCurve=null,this._walker=new ss,this._walker.updateTolerance(s),this._endings=e.lineDashEnding,this._customDashPos=-(e.offsetAlongLine??0)*s,this._offsetAtEnd=(e.customEndingOffset??0)*s,this._tileKey=i;let r=(0,is.K3)(e).dashTemplate;r.length%2&&(r=[...r,...r]);let n=0;for(let t=0;t<r.length;t++){let e=Math.abs(r[t]);e<1e-7&&(e=1e-7),n+=e}this._patternLength=n,this._numOfDashesPerPattern=r.length/2,this._pattern=new Je,this._pattern.init(r,!0),this._pattern.scale(s)}processPath(t){if(0===this._pattern.length()){this.iteratePath=!1;const e=(0,ve.A)(t);return Ie.fromJSONCIM({paths:[e]})}if(!this.iteratePath){let e=!0;switch(this._endings){case ut.yS.HalfPattern:case ut.yS.HalfGap:default:this._pattern.extPtGap=0;break;case ut.yS.FullPattern:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.firstValue());break;case ut.yS.FullGap:this.isClosed||(this._pattern.extPtGap=.5*this._pattern.lastValue());break;case ut.yS.NoConstraint:this.isClosed||(e=!1);break;case ut.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,ve.A)(t);return Ie.fromJSONCIM({paths:[e]})}if(!this._walker.init(t,this._pattern,e)){const e=(0,ve.A)(t);return Ie.fromJSONCIM({paths:[e]})}}let e;if(this.iteratePath)e=this._pattern.nextValue();else{let t;switch(this._endings){case ut.yS.HalfPattern:default:t=.5*this._pattern.firstValue();break;case ut.yS.HalfGap:t=.5*-this._pattern.lastValue();break;case ut.yS.FullGap:t=-this._pattern.lastValue();break;case ut.yS.FullPattern:t=0;break;case ut.yS.NoConstraint:case ut.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 i=!1;for(;t>=e;)t-=e,e=this._pattern.nextValue(),i=!i;e-=t,i?(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}isClippingRequired(t){const e=(0,ve.x)(t);let s=0;for(const t of e)s+=(0,Ke.Yl)(t);return Math.round(this._numOfDashesPerPattern*(s/this._patternLength))>1e3}}class os{static local(){return null===os.instance&&(os.instance=new os),os.instance}execute(t,e,s,i,r,n){return new as(t,e,s,i,r,n)}}os.instance=null;class as{constructor(t,e,s,i,r,n){switch(this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._maxInflateSize=n*s,this._width=(void 0!==e.width?e.width:2)*s,e.method){case ut.M1.Mitered:case ut.M1.Bevelled:case ut.M1.Rounded:case ut.M1.TrueBuffer:case ut.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:Ie.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._tileKey?ze(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.buffer(q.A.WebMercator,s.asJSON(),-this._width,1);if(i)for(const t of i.rings)if(t){s.startPath();for(const e of t.reverse())s.pushXY(e[0],s.yFactor*e[1])}return s}}return null}}class hs{static local(){return null===hs.instance&&(hs.instance=new hs),hs.instance}execute(t,e,s,i,r){return new cs(t,e,s)}}hs.instance=null;class cs extends Be{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new Ue,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=Ie.createEmptyOptimizedCIM("esriGeometryPolyline");if(this._curveHelper.isEmpty(t))return null;t.seekInPath(0);const s=t.x,i=t.y;t.seekInPath(t.pathSize-1);const r=t.x,n=t.y,o=[r-s,n-i];this._curveHelper.normalize(o);const a=s+(r-s)*this._position/100,h=i+(n-i)*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,i],u,d,[r,n]]),e}}class ls{static local(){return null===ls.instance&&(ls.instance=new ls),ls.instance}execute(t,e,s,i,r){return new us(t,e,s)}}ls.instance=null;class us{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 ds{static local(){return null===ds.instance&&(ds.instance=new ds),ds.instance}execute(t,e,s,i,r,n){return new ps(t,e,s,i,r,n)}}ds.instance=null;class ps{constructor(t,e,s,i,r,n){this._inputGeometries=t,this._tileKey=i,this._geometryEngine=r,this._curveHelper=new Ue,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=Ge*s}next(){let t;for(;t=this._inputGeometries.next();){if(0===this._offset)return t.clone();if("esriGeometryEnvelope"===t.geometryType){if(this._method===ut.xw.Rounded&&this._offset>0){const e=(0,ve.A)(t),s=this._curveHelper.offset(e,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=Ie.createEmptyOptimizedCIM(t.geometryType);return e.pushPath(s),e}return null}const e=t.asJSON();if((0,Se.ZC)(e)&&Math.min(e.xmax-e.xmin,e.ymax-e.ymin)+2*this._offset>0)return Ie.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._tileKey?ze(t,this._maxInflateSize):t.clone();if(!s)continue;const i=e.offset(q.A.WebMercator,s.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return i?Ie.fromJSONCIM(i):null}return null}}class _s{static local(){return null===_s.instance&&(_s.instance=new _s),_s.instance}execute(t,e,s,i,r){return new fs(t,e,s)}}_s.instance=null;class fs{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 ms(t.clone());t=this._inputGeometries.next()}return null}}function ms(t){for(;t.nextPath();)for(let e=0;e<t.pathSize/2;e++){t.seekInPath(e);const s=t.x,i=t.y;t.seekInPath(t.pathSize-e-1);const r=t.x,n=t.y;t.x=s,t.y=i,t.seekInPath(e),t.x=r,t.y=n}return t.reset(),t}var gs=s(537);class ys{static local(){return null===ys.instance&&(ys.instance=new ys),ys.instance}execute(t,e,s,i,r){return new xs(t,e,s)}}ys.instance=null;class xs{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,gs.z8)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._rotate(t.clone(),s,i)}t=this._inputGeometries.next()}return null}_rotate(t,e,s){const i=Math.cos(this._rotateAngle),r=Math.sin(this._rotateAngle);for(;t.nextPath();)for(;t.nextPoint();){const n=t.x-e,o=t.y-s;t.x=e+n*i-o*r,t.y=s+n*r+o*i}return t.reset(),t}}class bs{static local(){return null===bs.instance&&(bs.instance=new bs),bs.instance}execute(t,e,s,i,r){return new ws(t,e,s)}}bs.instance=null;class ws{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,gs.z8)(t),s=(e[2]+e[0])/2,i=(e[3]+e[1])/2;return t.reset(),this._scaleCursor(t.clone(),s,i)}}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 vs{static local(){return null===vs.instance&&(vs.instance=new vs),vs.instance}execute(t,e,s,i,r){return new Ss(t,e,s)}}vs.instance=null;class Ss{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 Je,this._pattern.addValue(this._period),this._pattern.addValue(this._period),this._walker=new ss,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=Ie.createEmptyOptimizedCIM(t.geometryType);for(;t.nextPath();){e.startPath();const s=t.pathLength();if(this._walker.init(t,this._pattern))switch(this._style){case ut.WE.Sinus:default:this._constructCurve(e,s,!1);break;case ut.WE.Square:this._constructSquare(e,s);break;case ut.WE.Triangle:this._constructTriangle(e,s);break;case ut.WE.Random:this._constructCurve(e,s,!0)}else for(;t.nextPoint();)e.pushXY(t.x,t.y)}return e}_constructCurve(t,e,s){let i=Math.round(e/this._period);0===i&&(i=1);const r=16*i+1,n=e/i,o=this._period/16,a=1/r,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,p=.75-Math.random()/2,_=new ts;this._walker.curPointAndAngle(_),t.pushPoint(_.pt);let f=0;for(;;){if(!this._walker.nextPointAndAngle(o,_)){t.pushPoint(this._walker.getPathEnd());break}{const e=f;let i;if(f+=a,s){const t=this._height/2*(1+.3*Math.sin(d*h*e+c));i=t*Math.sin(h*e+l),i+=t*Math.sin(p*h*e+u),i/=2}else i=.5*this._height*Math.sin(.5*h*e);t.pushXY(_.pt[0]-i*_.sa,_.pt[1]+i*_.ca)}}}_constructSquare(t,e){Math.round(e/this._period);let s=!0;for(;;){let e=!1;if(this._walker.curPositionIsValid()){const i=new ts;this._walker.curPointAndAngle(i);const r=new ts;if(this._walker.nextPointAndAngle(this._period,r)){const n=new ts;this._walker.nextPointAndAngle(this._period,n)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(i.pt[0]-this._height/2*i.sa,i.pt[1]+this._height/2*i.ca),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.ca),t.pushXY(r.pt[0]+this._height/2*r.sa,r.pt[1]-this._height/2*r.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 i=new ts;this._walker.curPointAndAngle(i);const r=new ts;if(this._walker.nextPointAndAngle(this._period/2,r)){const n=new ts;this._walker.nextPointAndAngle(this._period,n)&&(this._walker.nextPosition(this._period/2)&&(s?(t.pushPoint(i.pt),s=!1):t.pushPoint(i.pt),t.pushXY(r.pt[0]-this._height/2*r.sa,r.pt[1]+this._height/2*r.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 Is{static local(){return null===Is.instance&&(Is.instance=new Is),Is.instance}execute(t,e,s,i,r){return new Ps(t,e,s)}}Is.instance=null;class Ps extends De{constructor(t,e,s){super(t),this._geometryWalker=new ss,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 Je,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===ut.e_.WithFullGap&&this.isClosed?this._endings=ut.e_.WithMarkers:this._endings=this._originalEndings,this._pattern.extPtGap=0;let s,i=!0;switch(this._endings){case ut.e_.NoConstraint:s=-this._position,s=this._adjustPosition(s),i=!1;break;case ut.e_.WithHalfGap:default:s=-this._pattern.lastValue()/2;break;case ut.e_.WithFullGap:s=-this._pattern.lastValue(),this._pattern.extPtGap=this._pattern.lastValue();break;case ut.e_.WithMarkers:s=0;break;case ut.e_.Custom:s=-this._position,s=this._adjustPosition(s),this._pattern.extPtGap=.5*this._offsetAtEnd}if(!this._geometryWalker.init(t,this._pattern,i))return null;this._pattern.reset();let r=0;for(;s>r;)s-=r,r=this._pattern.nextValue();r-=s,e=r,this.iteratePath=!0}const s=new ts;return this._geometryWalker.nextPointAndAngle(e,s)?this._endings===ut.e_.WithFullGap&&this._geometryWalker.isPathEnd()?(this.iteratePath=!1,null):this._endings===ut.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 Ms{static local(){return null===Ms.instance&&(Ms.instance=new Ms),Ms.instance}execute(t,e,s,i,r){return new Ts(t,e,s)}}Ms.instance=null;class Ts extends De{constructor(t,e,s){super(t,!1,!0),this._curveHelper=new Ue,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 ut.$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 ut.$2.JustBegin:e=this._atExtremities(t,this._position,!0);break;case ut.$2.JustEnd:e=this._atExtremities(t,this._position,!1);case ut.$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 i=0,[r,n]=[0,0],[o,a]=[t.x,t.y];for(;s?t.nextPoint():t.prevPoint();){r=o,n=a,o=t.x,a=t.y;const s=this._curveHelper.getLength(r,n,o,a);if(i+s>e){const t=(e-i)/s,[h,c]=this._curveHelper.getAngleCS(r,n,o,a,t),l=this._curveHelper.getCoord2D(r,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}i+=s}}return null}}class Cs{static local(){return null===Cs.instance&&(Cs.instance=new Cs),Cs.instance}execute(t,e,s,i,r){return new As(t,e,s)}}Cs.instance=null;class As extends De{constructor(t,e,s){super(t),this._walker=new ss,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 Je,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,i=this._beginGap+s;e=i-this._prevPos,this._prevPos=i,this.iteratePath=!0}const s=new ts;if(!this._walker.nextPointAndAngle(e,s,Qe.END))return this.iteratePath=!1,null;this.internalPlacement.setTranslate(s.pt[0]-this._offset*s.sa,s.pt[1]+this._offset*s.ca);const i=this._isFirst&&this._flipFirst;let r,n;return this._angleToLine?(r=s.ca,n=s.sa):(r=1,n=0),i&&(r=-r,n=-n),this.internalPlacement.setRotateCS(r,n),this._isFirst=!1,this._posCount--,0===this._posCount&&(this.iteratePath=!1),this.internalPlacement}}const Es=512,Fs=24,ks=1e-6;class zs{static local(){return null===zs.instance&&(zs.instance=new zs),zs.instance}execute(t,e,s,i,r){return new Os(t,e,s,i,r)}}zs.instance=null;class Os{constructor(t,e,s,i,r){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??ut.Q1.Fixed,this._gridType===ut.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!=i){const[t,e,s,r]=i.split("/"),n=parseFloat(t),o=parseFloat(e),a=parseFloat(s),h=parseFloat(r);this._graphicOriginX=-(h*2**n+a)*Es,this._graphicOriginY=o*Es,this._testInsidePolygon=!0}this._internalPlacement=new Le,this._calculateMinMax(t),this._geometryCursor=t}}next(){return this._geometryCursor?this._nextInside():null}_buildRandomValues(){if(!Os._randValues){Os._randValues=[];for(let t=0;t<Fs;t++)for(let t=0;t<Fs;t++)Os._randValues.push(this._randomLCG.getFloat()),Os._randValues.push(this._randomLCG.getFloat())}}_calculateMinMax(t){let e,s,i,r,n,o,a,h,c,l,u,d,p,_;this._xMin=0,this._xMax=0,this._yMin=0,this._yMax=0,a=h=p=u=Number.MAX_VALUE,c=l=_=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?(i=this._cosAngle*e-this._sinAngle*s,r=this._sinAngle*e+this._cosAngle*s):(i=e,r=s),a=Math.min(a,i),c=Math.max(c,i),h=Math.min(h,r),l=Math.max(l,r),u=Math.min(u,n),d=Math.max(d,n),p=Math.min(p,o),_=Math.max(_,o);u=u!==Number.MAX_VALUE?u:-512-this._stepY,d=d!==-Number.MAX_VALUE?d:this._stepY,p=p!==Number.MAX_VALUE?p:-this._stepX,_=_!==-Number.MAX_VALUE?_:Es+this._stepX;const m=d-u,g=_-p;if(this._verticalSubdivision=m>=g,this._polygonMin=this._verticalSubdivision?u:p,this._testInsidePolygon){let t=0-this._graphicOriginX-this._offsetX-this._stepX,e=Es-this._graphicOriginX-this._offsetX+this._stepX,s=-512-this._graphicOriginY-this._offsetY-this._stepY,i=0-this._graphicOriginY-this._offsetY+this._stepY;if(f){const r=[[t,s],[t,i],[e,s],[e,i]];t=s=Number.MAX_VALUE,e=i=-Number.MAX_VALUE;for(const n of r){const r=this._cosAngle*n[0]-this._sinAngle*n[1],o=this._sinAngle*n[0]+this._cosAngle*n[1];t=Math.min(t,r),e=Math.max(e,r),s=Math.min(s,o),i=Math.max(i,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,i):i}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,i,r){t.reset();const n=new Map,o=this._verticalSubdivision,a=o?r-i:s-e;let h=Math.ceil(a/10);if(h<=1)return;const c=Math.floor(a/h);let l,u,d,p,_,f,m,g,y,x,b;for(h++,this._delta=c,o?(y=-512-2*this._stepY,x=2*this._stepY,b=i):(y=-2*this._stepX,x=Es+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=p){if(d=t.x,p=t.y,o){if(u===p||u<y&&p<y||u>x&&p>x)continue;_=Math.min(u,p),f=Math.max(u,p)}else{if(l===d||l<y&&d<y||l>x&&d>x)continue;_=Math.min(l,d),f=Math.max(l,d)}for(;_<f;)m=Math.floor((_-b)/c),Rs(m,l,u,d,p,n),_+=c;g=Math.floor((f-b)/c),g>m&&Rs(g,l,u,d,p,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,i;if(this._currentX++,this._gridType===ut.Q1.Random){const r=(this._currentX%Fs+Fs)%Fs,n=(this._currentY%Fs+Fs)%Fs;s=this._graphicOriginX+t+this._stepX*this._randomness*(.5-Os._randValues[n*Fs+r])*2/3,i=this._graphicOriginY+e+this._stepY*this._randomness*(.5-Os._randValues[n*Fs+r+1])*2/3}else s=this._graphicOriginX+this._cosAngle*t+this._sinAngle*e,i=this._graphicOriginY-this._sinAngle*t+this._cosAngle*e;if(!this._testInsidePolygon||this._isInsidePolygon(s,i,this._geometryCursor))return this._internalPlacement.setTranslate(s,i),this._internalPlacement}}_isInsidePolygon(t,e,s){if(null==this._accelerationMap)return function(t,e,s){let i,r,n,o,a=0;for(t+=ks,e+=ks,s.reset();s.nextPath();)if(s.nextPoint())for(i=s.x,r=s.y;s.nextPoint();i=n,r=o)n=s.x,o=s.y,r>e!=o>e&&((n-i)*(e-r)-(o-r)*(t-i)>0?a++:a--);return 0!==a}(t,e,s);t+=ks,e+=ks;const i=this._verticalSubdivision,r=i?e:t,n=Math.floor((r-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],i){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 Rs(t,e,s,i,r,n){let o=n.get(t);o||(o=[],n.set(t,o)),o.push([[e,s],[i,r]])}class Ls{static local(){return null===Ls.instance&&(Ls.instance=new Ls),Ls.instance}execute(t,e,s,i,r){return new Ns(t,e,s)}}Ls.instance=null;class Ns extends De{constructor(t,e,s){super(t),this._curveHelper=new Ue,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===ut.ip.SegmentMidpoint){if(this.iteratePath||(this.iteratePath=!0),t.nextPoint()){let[e,s]=[t.x,t.y],[i,r]=[0,0];for(;t.nextPoint();){i=t.x,r=t.y;const n=this._curveHelper.getLength(e,s,i,r);if(n<this._epsilon){e=i,s=r;continue}const o=.5+this._position/n,[a,h]=this._curveHelper.getAngleCS(e,s,i,r,o),c=this._curveHelper.getCoord2D(e,s,i,r,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===ut.ip.LineEnd;return this.onLine(t,e,s)}onLine(t,e,s){let i,r=!1;switch(this._relativeTo){case ut.ip.LineMiddle:default:t.seekPathStart(),i=t.pathLength()/2+e;break;case ut.ip.LineBeginning:i=e;break;case ut.ip.LineEnd:i=e,r=!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>i){const t=(i-n)/s,[c,l]=this._curveHelper.getAngleCS(e,o,a,h,t),u=this._curveHelper.getCoord2D(e,o,a,h,t),d=r?-this._offset:this._offset;return this.internalPlacement.setTranslate(u[0]-d*l,u[1]+d*c),this._angleToLine&&(r?this.internalPlacement.setRotateCS(-c,-l):this.internalPlacement.setRotateCS(c,l)),this.internalPlacement}e=a,o=h,n+=s}}return null}}class Ds{static local(){return null===Ds.instance&&(Ds.instance=new Ds),Ds.instance}execute(t,e,s,i,r){return new Bs(t,e,s)}}Ds.instance=null;class Bs extends De{constructor(t,e,s){super(t),this._curveHelper=new Ue,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],i=e[1];if(0!==this._offset){const t=Math.cos(e[2]),r=Math.sin(e[2]);s-=this._offset*r,i+=this._offset*t}return this.internalPlacement.setTranslate(s,i),this._tagIterator++,this.internalPlacement}_preparePath(t){this._tags.length=0,this._tagIterator=0,t.seekPathStart();const e=t.isClosed();let s=0,i=!1,r=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,p=t.getControlPoint();(this._angleToLine||0!==this._offset)&&(r=this._curveHelper.getAngle(o,a,u,d,0)),c?(c=!1,e?(s=r,i=h):(this._endPoints||this._controlPoints&&h)&&this._tags.push([o,a,r])):h?this._controlPoints&&this._tags.push([o,a,Gs(n,r)]):this._regularVertices&&this._tags.push([o,a,Gs(n,r)]),(this._angleToLine||0!==this._offset)&&(n=this._curveHelper.getAngle(o,a,u,d,1)),l=t.nextPoint(),l||(e?p||i?this._controlPoints&&this._tags.push([u,d,Gs(n,s)]):this._regularVertices&&this._tags.push([u,d,Gs(n,s)]):(this._endPoints||this._controlPoints&&p)&&this._tags.push([u,d,n])),o=u,a=d,h=p}}this._tagIterator=0}}function Gs(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),Vs=s(12176);function qs(t){if(0===t.totalSize)return null;const e=(0,gs.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 i=0,r=0;t.reset();for(let e=0;t.nextPath();e++){const s=t.getCurrentRingArea();s>r&&(r=s,i=e)}if(t.seekPath(i),0===t.pathSize)return null;t.seekPathStart();const n=(0,gs.B$)(t);if(Math.abs(r)<=2*s*s)return[(n[0]+n[2])/2,(n[1]+n[3])/2];t.seekPathStart();const o=(0,Us.w2)(t,(0,D.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=Ys(o,t,!0);0===u.distance&&(l=!0,a[0][0]=o[0],a[0][1]=o[1],u=Ys(o,t,!1)),h[0]=u.distance,c[0]=0;const d=[NaN,NaN];let p=!1,_=.25,f=-1,m=NaN;do{if(m=NaN,a[1]=js(t,ti(n[0],n[2],_),0,e),isNaN(a[1][0])||isNaN(a[1][1])||(u=Ys(a[1],t,!1),m=u.distance),!isNaN(m)&&m>s&&Ws(a[1],t))p=!0,h[1]=m,c[1]=ei(a[1],o);else if(!isNaN(m)&&m>f&&(f=m,d[0]=a[1][0],d[1]=a[1][1]),_-=.01,_<.1){if(!(f>=0))break;p=!0,h[1]=f,a[1][0]=d[0],a[1][1]=d[1],c[1]=ei(a[1],o)}}while(!p);p=!1,_=.5,f=-1;let g=.01,y=1;do{if(m=NaN,a[2]=js(t,ti(n[0],n[2],_),0,e),isNaN(a[2][0])||isNaN(a[2][1])||(u=Ys(a[2],t,!1),m=u.distance),!isNaN(m)&&m>s&&Ws(a[2],t))p=!0,h[2]=m,c[2]=ei(a[2],o);else if(!isNaN(m)&&m>f)f=m,d[0]=a[2][0],d[1]=a[2][1];else if(m>f&&(f=m,d[0]=a[2][0],d[1]=a[2][1]),_=.5+g*y,g+=.01,y*=-1,_<.3||_>.7){if(!(f>=0))break;p=!0,h[2]=f,a[2][0]=d[0],a[2][1]=d[1],c[2]=ei(a[2],o)}}while(!p);p=!1,_=.75,f=-1;do{if(m=NaN,a[3]=js(t,ti(n[0],n[2],_),0,e),isNaN(a[3][0])||isNaN(a[3][1])||(u=Ys(a[3],t,!1),m=u.distance),!isNaN(m)&&m>s&&Ws(a[3],t))p=!0,h[3]=m,c[3]=ei(a[3],o);else if(m>f&&(f=m,d[0]=a[3][0],d[1]=a[3][1]),_+=.01,_>.9){if(!(f>=0))break;p=!0,h[3]=f,a[3][0]=d[0],a[3][1]=d[1],c[3]=ei(a[3],o)}}while(!p);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];si(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 Ws(t,e){let s,i,r,n,o=0;for(e.reset();e.nextPath()&&e.nextPoint();)for(s=e.x,i=e.y;e.nextPoint();s=r,i=n)r=e.x,n=e.y,i>t[1]!=n>t[1]&&((r-s)*(t[1]-i)-(n-i)*(t[0]-s)>0?o++:o--);return 0!==o}function Ys(t,e,s){if(s&&Ws(t,e))return{coord:t,distance:0};let i=1/0,r=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,Ke.gR)(h,t,o,a);const s=ei(t,h);s<i&&(i=s,r=h[0],n=h[1])}return{coord:[r,n],distance:Math.sqrt(i)}}function js(t,e,s,i){const r=[e,0];let n=1/0,o=1/0,a=!1,h=!1;const c=[[e,i[1]-1],[e,i[3]+1]],l=[0,0],u=[0,0],d=[0,0],p=[[0,0],[0,0]],_=(0,D.vt)();for(t.reset();t.nextPath()&&t.nextPoint();)if(!(t.pathSize<2))for(p[0][0]=t.x,p[0][1]=t.y;t.nextPoint();p[0][0]=p[1][0],p[0][1]=p[1][1]){if(p[1][0]=t.x,p[1][1]=t.y,null===Xs(_,p))continue;if(u[0]=c[0][0],u[1]=c[0][1],d[0]=c[1][0],d[1]=c[1][1],0===Ks(_,u,d))continue;if(!(0,Vs.Ql)(c[0],c[1],p[0],p[1],l))continue;const e=l[1];n>o?e<n&&(n=e,a=!0):e<o&&(o=e,h=!0)}return a&&h?r[1]=(n+o)/2:r[0]=r[1]=NaN,r}function Xs(t,e){if(e.length<2)return null;t||(t=(0,D.vt)());const[s,i]=e[0],[r,n]=e[1];return t[0]=Math.min(s,r),t[1]=Math.min(i,n),t[2]=Math.max(s,r),t[3]=Math.max(i,n),t}const $s=1,Hs=4,Zs=3,Qs=12;function Ks(t,e,s){let i=Js(e,t),r=Js(s,t);const n=t[0],o=t[1],a=t[2],h=t[3];if(i&r)return 0;if(!(i|r))return 4;const c=(i?1:0)|(r?2:0);do{const c=s[0]-e[0],l=s[1]-e[1];if(c>l)i&Zs?(i&$s?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Js(e,t)):r&Zs?(r&$s?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Js(s,t)):i?(i&Hs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Js(e,t)):(r&Hs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Js(s,t));else if(i&Qs?(i&Hs?(e[0]+=c*(o-e[1])/l,e[1]=o):(e[0]+=c*(h-e[1])/l,e[1]=h),i=Js(e,t)):r&Qs?(r&Hs?(s[0]+=c*(o-s[1])/l,s[1]=o):(s[0]+=c*(h-s[1])/l,s[1]=h),r=Js(s,t)):i?(i&$s?(e[1]+=l*(n-e[0])/c,e[0]=n):(e[1]+=l*(a-e[0])/c,e[0]=a),i=Js(e,t)):(r&$s?(s[1]+=l*(n-s[0])/c,s[0]=n):(s[1]+=l*(a-s[0])/c,s[0]=a),r=Js(s,t)),i&r)return 0}while(i|r);return c}function Js(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 ti(t,e,s){return t+(e-t)*s}function ei(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])}function si(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;const s=isNaN(t),i=isNaN(e);return s<i?-1:s>i?1:0}class ii{static local(){return null===ii.instance&&(ii.instance=new ii),ii.instance}execute(t,e,s,i,r){return new ri(t,e,s)}}ii.instance=null;class ri{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:ut.YI.OnPolygon,this._internalPlacement=new Le}next(){const t=this._geometryCursor;return this._geometryCursor=null,t?this._polygonCenter(t):null}_polygonCenter(t){let e=!1;switch(this._method){case ut.YI.CenterOfMass:{const s=(0,Us.TP)(t);s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}break;case ut.YI.BoundingBoxCenter:{const s=(0,gs.z8)(t);s&&(this._internalPlacement.setTranslate((s[2]+s[0])/2+this._offsetX,(s[3]+s[1])/2+this._offsetY),e=!0)}break;case ut.YI.OnPolygon:default:{const s=qs(t);null!==s&&(this._internalPlacement.setTranslate(s[0]+this._offsetX,s[1]+this._offsetY),e=!0)}}return e?this._internalPlacement:null}}function ni(t){if(!t)return null;switch(t.type){case"CIMGeometricEffectAddControlPoints":return Oe.local();case"CIMGeometricEffectArrow":return qe.local();case"CIMGeometricEffectBuffer":return Ye.local();case"CIMGeometricEffectControlMeasureLine":return Xe.local();case"CIMGeometricEffectCut":return He.local();case"CIMGeometricEffectDashes":return rs.local();case"CIMGeometricEffectDonut":return os.local();case"CIMGeometricEffectJog":return hs.local();case"CIMGeometricEffectMove":return ls.local();case"CIMGeometricEffectOffset":return ds.local();case"CIMGeometricEffectReverse":return _s.local();case"CIMGeometricEffectRotate":return ys.local();case"CIMGeometricEffectScale":return bs.local();case"CIMGeometricEffectWave":return vs.local()}return null}new(s(32488).A),s(11831),s(92602),new Map,new Set,s(28076),s(5760);var oi=s(34304);function ai(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t}function hi(t,e,s){const i=e[0],r=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],p=s[4],_=s[5];return t[0]=i*c+n*l,t[1]=r*c+o*l,t[2]=i*u+n*d,t[3]=r*u+o*d,t[4]=i*p+n*_+a,t[5]=r*p+o*_+h,t}function ci(t,e,s){const i=e[0],r=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]=i*l+n*c,t[1]=r*l+o*c,t[2]=i*-c+n*l,t[3]=r*-c+o*l,t[4]=a,t[5]=h,t}function li(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i,t[1]=r,t[2]=n,t[3]=o,t[4]=i*c+n*l+a,t[5]=r*c+o*l+h,t}function ui(t,e){const s=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=s,t[2]=-s,t[3]=i,t[4]=0,t[5]=0,t}function di(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 pi=hi,_i=di;function fi(){const t=new Float32Array(6);return t[0]=1,t[3]=1,t}function mi(t,e,s,i){const r=e[i],n=e[i+1];t[i]=s[0]*r+s[2]*n+s[4],t[i+1]=s[1]*r+s[3]*n+s[5]}function gi(t,e,s,i=0,r=0,n=2){const o=r||e.length/n;for(let r=i;r<o;r++)mi(t,e,s,r*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],i=t[1],r=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],p=e[5],_=(0,oi.FD)();return Math.abs(s-h)<=_*Math.max(1,Math.abs(s),Math.abs(h))&&Math.abs(i-c)<=_*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(r-l)<=_*Math.max(1,Math.abs(r),Math.abs(l))&&Math.abs(n-u)<=_*Math.max(1,Math.abs(n),Math.abs(u))&&Math.abs(o-d)<=_*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(a-p)<=_*Math.max(1,Math.abs(a),Math.abs(p))},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:ui,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:ai,invert:function(t,e){const s=e[0],i=e[1],r=e[2],n=e[3],o=e[4],a=e[5];let h=s*n-i*r;return h?(h=1/h,t[0]=n*h,t[1]=-i*h,t[2]=-r*h,t[3]=s*h,t[4]=(r*a-n*o)*h,t[5]=(i*o-s*a)*h,t):null},mul:pi,multiply:hi,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,i){return t[0]=e[0]+s[0]*i,t[1]=e[1]+s[1]*i,t[2]=e[2]+s[2]*i,t[3]=e[3]+s[3]*i,t[4]=e[4]+s[4]*i,t[5]=e[5]+s[5]*i,t},rotate:ci,scale:function(t,e,s){const i=e[0],r=e[1],n=e[2],o=e[3],a=e[4],h=e[5],c=s[0],l=s[1];return t[0]=i*c,t[1]=r*c,t[2]=n*l,t[3]=o*l,t[4]=a,t[5]=h,t},set:function(t,e,s,i,r,n,o){return t[0]=e,t[1]=s,t[2]=i,t[3]=r,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:_i,subtract:di,translate:li},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:fi,createView:function(t,e){return new Float32Array(t,e,6)},fromValues:function(t,e,s,i,r,n){const o=new Float32Array(6);return o[0]=t,o[1]=e,o[2]=s,o[3]=i,o[4]=r,o[5]=n,o},transform:mi,transformMany:gi},Symbol.toStringTag,{value:"Module"}));var yi=s(88340);const xi=()=>A.A.getLogger("esri.views.2d.engine.webgl.alignmentUtils");var bi,wi;function vi(t){if(!t)return bi.Center;switch(t){case"Left":case"left":return bi.Left;case"Right":case"right":return bi.Right;case"Justify":return xi().warnOnce("Horizontal alignment 'justify' is not implemented. Falling back to 'center'."),bi.Center;case"Center":case"center":return bi.Center}}function Si(t){if(!t)return wi.Center;switch(t){case"Top":case"top":return wi.Top;case"Center":case"middle":return wi.Center;case"Baseline":case"baseline":return wi.Baseline;case"Bottom":case"bottom":return wi.Bottom}}!function(t){t[t.Left=-1]="Left",t[t.Center=0]="Center",t[t.Right=1]="Right"}(bi||(bi={})),function(t){t[t.Top=1]="Top",t[t.Center=0]="Center",t[t.Bottom=-1]="Bottom",t[t.Baseline=2]="Baseline"}(wi||(wi={}));var Ii=s(18989);class Pi{constructor(t,e,s,i){this.computedX=0,this.computedY=0,this.center=(0,yi.fA)(t,e),this.centerT=(0,yi.vt)(),this.halfWidth=s/2,this.halfHeight=i/2,this.width=s,this.height=i}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 Pi(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]),i=Math.abs(t.centerT[1]-this.centerT[1]),r=(t.halfWidth+this.halfWidth+e)/s,n=(t.halfHeight+this.halfHeight+e)/i,o=Math.min(r,n);return Math.log2(o)}extend(t){const e=Math.min(this.xmin,t.xmin),s=Math.min(this.ymin,t.ymin),i=Math.max(this.xmax,t.xmax)-e,r=Math.max(this.ymax,t.ymax)-s,n=e+i/2,o=s+r/2;this.width=i,this.height=r,this.halfWidth=i/2,this.halfHeight=r/2,this.x=n,this.y=o}static deserialize(t){const e=t.readF32(),s=t.readF32(),i=t.readInt32(),r=t.readInt32();return new Pi(e,s,i,r)}}const Mi=Math.PI/180;class Ti{constructor(t,e,s,i){this._rotationT=fi(),this._xBounds=0,this._yBounds=0,this.minZoom=0,this.maxZoom=255,this._bounds=null;const r=s.rect,n=new Float32Array(8);t*=i,e*=i;const o=s.code?r.width*i:s.metrics.width,a=s.code?r.height*i: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(r),this._scale=i,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,ui(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,i=Math.abs(t)*this._scale,r=new Float32Array(8);r[0]=this.x,r[1]=this.y,r[2]=this.x+s,r[3]=this.y,r[4]=this.x,r[5]=this.y+i,r[6]=this.x+s,r[7]=this.y+i,gi(r,r,hi(fi(),this._rotationT,this._transform));let n=1/0,o=1/0,a=0,h=0;for(let t=0;t<4;t++){const e=r[2*t],s=r[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 Pi(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=hi(fi(),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,F.l0)(this._offsets.topLeft,this._offsets.topLeft,t),(0,F.l0)(this._offsets.topRight,this._offsets.topRight,t),(0,F.l0)(this._offsets.bottomLeft,this._offsets.bottomLeft,t),(0,F.l0)(this._offsets.bottomRight,this._offsets.bottomRight,t)}_setTextureCoords({x:t,y:e,width:s,height:i}){this._texcoords={topLeft:[t,e],topRight:[t+s,e],bottomLeft:[t,e+i],bottomRight:[t+s,e+i]}}}const Ci=(t,e)=>({code:0,page:0,sdf:!0,rect:new Ii.A(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function Ai(t,e){return t.forEach((t=>(0,F.l0)(t,t,e))),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class Ei{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;hi(e,ui(fi(),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 i=s.scale,r="underline"===s.decoration?26:16,n=t[0].textureBinding;for(const s of e){const e=s.startX*i,o=s.startY*i,a=(s.width+s.glyphWidthEnd)*i;t.push(new Ti(e,o+r*i,Ci(a,n),1))}}shapeBackground(t){const e=(1.5+(this._borderLineSizePx||0))/2,s=this._borderLineSizePx?e:0,{xmin:i,ymin:r,xmax:n,ymax:o,x:a,y:h,width:c,height:l}=this.bounds,u=[i-8,r-8],d=[n+8,r-8],p=[i-8,o+8],_=[n+8,o+8],f=Ai([[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),m=Ai([[p[0]+s,p[1]-s],[_[0]-s,_[1]-s],[p[0]-e,p[1]+e],[_[0]+e,_[1]+e]],t),g=Ai([[u[0]-e,u[1]-e],[u[0]+s,u[1]+s],[p[0]-e,p[1]+e],[p[0]+s,p[1]-s]],t),y=Ai([[d[0]-s,d[1]+s],[d[0]+e,d[1]-e],[_[0]-s,_[1]-s],[_[0]+e,_[1]+e]],t),x={main:Ai([u,d,p,_],t),top:f,bot:m,left:g,right:y};return[new Pi(a,h,c+2*e,l+2*e),x]}get boundsT(){const t=this.bounds,e=(0,F.hZ)((0,yi.vt)(),t.x,t.y);if((0,F.l0)(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new Pi(e[0],e[1],s,s)}return new Pi(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,r=0;for(const n of t)e=Math.min(e,n.xTopLeft),s=Math.min(s,n.yTopLeft),i=Math.max(i,n.xBottomRight),r=Math.max(r,n.yBottomRight);const n=i-e,o=r-s;return new Pi(e+n/2,s+o/2,n,o)}_createGlyphTransform(t,e){const s=Mi*e.angle,i=fi(),r=(0,yi.vt)();return li(i,i,(0,F.hZ)(r,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?ci(i,i,s):(li(i,i,(0,F.hZ)(r,t.x,t.y)),ci(i,i,s),li(i,i,(0,F.hZ)(r,-t.x,-t.y))),i}}class Fi{constructor(t,e,s,i,r,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=i,this.yMin=r,this.yMax=n}}const ki=t=>10===t,zi=t=>32===t;var Oi=s(39829);Math.PI,s(59868);var Ri=s(13195);function Li(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,is.$w)(t.offsetX)),Math.abs((0,is.$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 Ni(t){if(!t)return 0;let e=0;for(const s of t)e+=Li(s);return e}Math.PI,Math.PI;const Di=96/72;class Bi{static executeEffects(t,e,s,i){const r=Di,n=Ni(t);let o=new ke(e);for(const e of t){const t=ni(e);t&&(o=t.execute(o,e,r,s,i,n))}return o}static applyEffects(t,e,s){if(!t)return e;const i=Ni(t);let r,n=new ke(Ie.fromJSONCIM(e));for(const e of t){const t=ni(e);t&&(n=t.execute(n,e,1,null,s,i))}const o=[];let a=null;for(;r=n.next();)o.push(...(0,ve.x)(r)),a=r.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let Gi=null;function Ui(){return Gi}const Vi=new Float32Array(1),qi=new Uint32Array(Vi.buffer);function Wi(t){const e=function(t){return Vi[0]=t,qi[0]}(t),s=e>>>31;let i=e>>>23&255,r=8388607&e;return i-=127,i>15?s<<15|31744:i<-25?0:(i<-14&&(r+=8388608,r/=2**(-14-i),i=-15),i+=15,r/=8192,r=function(t,e){const s=Math.floor(t),i=t-s;return s<1023&&(i>.5||.5===i&&s%2==1)?s+1:s}(r),s<<15|i<<10|r)}function Yi(t,e,s,i,r,n,o){if(t.primitiveName===e)for(const e in t)if(e===s){let s=i?.readWithDefault(r,n,t[e]&&o);return"text"===t.type&&(s=s.toString()),void(t[e]=s)}if("type"in t&&null!=t.type)switch(t.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(t.symbolLayers)for(const a of t.symbolLayers)Yi(a,e,s,i,r,n,o);break;case"CIMHatchFill":t.lineSymbol&&Yi(t.lineSymbol,e,s,i,r,n,o);break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if("CIMVectorMarker"===t.type&&t.markerGraphics)for(const a of t.markerGraphics)Yi(a,e,s,i,r,n,o),Yi(a.symbol,e,s,i,r,n,o)}}function ji(t){const e=t.width;return null!=t.effects?256:Math.max(1.25*e,8)}function Xi(t){switch(t){case pt.pe.BYTE:case pt.pe.UNSIGNED_BYTE:return 1;case pt.pe.SHORT:case pt.pe.UNSIGNED_SHORT:case pt.pe.HALF_FLOAT:return 2;case pt.pe.FLOAT:case pt.pe.INT:case pt.pe.UNSIGNED_INT:return 4}}class $i{static fromVertexSpec(t,e){const{attributes:s,optionalAttributes:i}=t;let r,n,o;const a=[];for(const t in s){const e=s[t];"position"===e.pack?r={...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 i)if(!0===e[t]){const e=i[t];a.push({...e,name:t})}const h=function(t){const e=[],s=[],i=[];for(const r of t){const t=Xi(r.type)*r.count;switch(t%2||t%4||4){case 4:e.push(r);continue;case 2:s.push(r);continue;case 1:i.push(r);continue;default:throw new Error("Found unexpected dataType byte count")}}return e.push(...s),e.push(...i),e}(a),c=[];let l=8,u=1;for(const t of h)c.push({...t,offset:l}),l+=Xi(t.type)*t.count,t.packAlternating&&(u=Math.max(t.packAlternating.count,u));const d=Uint32Array.BYTES_PER_ELEMENT,p=l%d;return new $i(r,n,o,c,l+(p?d-p:0),u)}constructor(t,e,s,i,r,n){this.position=t,this.id=e,this.bitset=s,this.standardAttributes=i,this.stride=r,this.packVertexCount=n,i.push(s),this._attributes=[t,e,s,...i]}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 Hi{static fromVertexSpec(t,e){const s=$i.fromVertexSpec(t,e);return new Hi(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,i,r,n){for(let t=0;t<this._spec.packVertexCount;t++){const o=t*this._spec.stride;this._packPosition(s,i,o),this._packId(e,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const t=a.packTessellation(n,r);this._pack(t,a,o)}for(const t of this._spec.standardAttributes)if(null!=t.packTessellation){const e=t.packTessellation(n,r);this._pack(e,t,o)}else if(t.packAlternating?.packTessellation){const e=t.packAlternating.packTessellation(n,r);for(let s=0;s<this._spec.packVertexCount;s++){const i=e[s];this._pack(i,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 i=s.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++)this._pack(i,s,t*this._spec.stride)}else if(s.packAlternating?.pack){const i=s.packAlternating.pack(t,e);for(let t=0;t<this._spec.packVertexCount;t++){const e=i[t];this._pack(e,s,t*this._spec.stride)}}}_packPosition(t,e,s){const{offset:i}=this._spec.position,r=this._spec.position.packPrecisionFactor??1,n=function(t,e){return 65535&t|e<<16}(t*r,e*r);this._dataView.setUint32(s+i,n,!0)}_packId(t,e){const s=t*(this._spec.id.packPrecisionFactor??1),i=4278190080&this._dataView.getUint32(e+this._spec.id.offset,!0);this._dataView.setUint32(e+this._spec.id.offset,s|i,!0)}_pack(t,e,s){!function(t,e,s,i){const r=s.packPrecisionFactor??1;switch(s.type){case pt.pe.BYTE:if(1===s.count)t.setInt8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;t.setInt8(i+s.offset+o,e[n]*r)}break;case pt.pe.UNSIGNED_BYTE:if(1===s.count)t.setUint8(i+s.offset,e*r);else for(let n=0;n<s.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;t.setUint8(i+s.offset+o,e[n]*r)}break;case pt.pe.SHORT:if(1===s.count)t.setInt16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;t.setInt16(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.UNSIGNED_SHORT:if(1===s.count)t.setUint16(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.INT:if(1===s.count)t.setInt32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;t.setInt32(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.UNSIGNED_INT:if(1===s.count)t.setUint32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;t.setUint32(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.FLOAT:if(1===s.count)t.setFloat32(i+s.offset,e*r,!0);else for(let n=0;n<s.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;t.setFloat32(i+s.offset+o,e[n]*r,!0)}break;case pt.pe.HALF_FLOAT:if(1===s.count)t.setUint16(i+s.offset,Wi(e*r),!0);else for(let n=0;n<s.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;t.setUint16(i+s.offset+o,Wi(e[n]*r),!0)}}}(this._dataView,t,e,s)}}class Zi{constructor(t,e,s,i){this._instanceId=t,this._evaluator=e,this._enabledOptionalAttributes=s,this._viewParams=i,this._evaluator.evaluator=t=>this.vertexSpec.createComputedParams(t)}get _vertexPack(){if(!this._cachedVertexPack){const t=Hi.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}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(){Gi=await Promise.all([s.e(9930),s.e(9940)]).then(s.bind(s,47559))}()}enqueueRequest(t,e,s){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(t,e,s)}write(t,e,s,i,r){this.ensurePacked(e,s,i);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(t,s,void 0,r);const o=s.readGeometryForDisplay()?.clone();if(!o)return;const a=Ie.fromOptimizedCIM(o,s.geometryType),h=Ui();a.invertY();const c=t.id||"",l=Bi.executeEffects(n,a,c,h);let u;for(;u=l.next();)u.invertY(),this._write(t,s,u,r)}ensurePacked(t,e,s){if(!this._evaluator.hasDynamicProperties)return;const i=this._evaluator.evaluateMeshParams(t,e,s);this._vertexPack.pack(i,this._viewParams)}_writeVertex(t,e,s,i,r){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(t,e,s,i,n,r)}}const Qi=(0,n.A)("featurelayer-fast-triangulation-enabled");class Ki extends Zi{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,Vt.F)()])}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),t.recordEnd())}_clip(t){return t?be(t,this.hasEffects?256:8):null}_writeGeometry(t,e,s){const i=s.maxLength>100,r=[],n=this.createTesselationParams(e);if(!i&&Qi&&function(t,e){const{coords:s,lengths:i,hasIndeterminateRingOrder:r}=e,n=t;if(r)return!1;let o=0;for(let t=0;t<i.length;){let e=t,r=i[t],a=ye(s,o,r);const h=[];for(;++e<i.length;){const t=i[e],n=ye(s,o+r,t);if(!(n>0))break;a+=n,h.push(o+r),r+=t}const c=n.length;Yt(n,s,o,o+r,h,2,0);const l=xe(n,s,c,n.length,0),u=Math.abs(a);if(Math.abs((l-u)/Math.max(1e-7,u))>1e-5)return n.length=0,!1;t=e,o+=r}return!0}(r,s))return void(r.length&&this._writeVertices(t,e,s.coords,n,r));const o=function(t){const{coords:e,lengths:s}=t,{buffer:i}=(0,Vt.l)(e,s);return i}(s);this._writeVertices(t,e,o,n)}_writeVertices(t,e,s,i,r){const n=e.getDisplayId(),o=t.vertexCount(),a=this.hasEffects;let h=0;if(r)for(const e of r){const r=s[2*e],o=s[2*e+1];a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}else for(let e=0;e<s.length;e+=2){const r=Math.round(s[e]),o=Math.round(s[e+1]);a&&t.recordBounds(r,o,0,0),this._writeVertex(t,n,r,o,i),h++}t.indexEnsureSize(h);for(let e=0;e<h;e++)t.indexWrite(e+o)}}const Ji={createComputedParams:t=>t,optionalAttributes:{},attributes:{id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:pt.pe.FLOAT,count:1,packTessellation:({inverseArea:t})=>t}}};class tr extends Ki{constructor(){super(...arguments),this.vertexSpec=Ji}createTesselationParams(t){return{inverseArea:1/t.readGeometryArea()}}}var er=s(68197);function sr(t,e){return[!!t?.minScale&&e.scaleToZoom(t.minScale)||0,!!t?.maxScale&&e.scaleToZoom(t.maxScale)||100]}function ir(t){return 1<<t}function rr(t){let e=0;for(const[s,i]of t)i&&(e|=1<<s);return e}function nr(t){let e;if(!t)return[0,0,0,0];if("string"==typeof t){const s=er.A.fromString(t);if(!s)return A.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new i.A("mapview:mesh-processing","Unable to parse string into color",{color:t})),[0,0,0,0];e=s.toArray()}else e=t;const[s,r,n,o]=e;return[s*(o/255),r*(o/255),n*(o/255),o]}function or(t,e){return Math.round(Math.min(Math.sqrt(t*e),255))}function ar(t,e){return Math.round(t*e)/e}const hr={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:pt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}},attributes:{id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)}}};class cr extends Ki{constructor(){super(...arguments),this.vertexSpec=hr}createTesselationParams(t){return null}}const lr={createComputedParams:t=>t,optionalAttributes:hr.optionalAttributes,attributes:{...hr.attributes,tlbr:{count:4,type:pt.pe.UNSIGNED_SHORT,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.hM,n=e.y+B.hM;return[r,n,r+s,n+i]}},inverseRasterizationScale:{count:1,type:pt.pe.BYTE,packPrecisionFactor:16,pack:({sprite:t})=>1/t.rasterizationScale}}};class ur extends cr{constructor(){super(...arguments),this.vertexSpec=lr}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),t.recordEnd()}}var dr,pr;(pr=dr||(dr={}))[pr.Geographic=0]="Geographic",pr[pr.Arithmatic=1]="Arithmatic";const _r=1.1,fr=1,mr=1e-5,gr=.05,yr=1e-30,xr=2;function br(t){const{sprite:e,aspectRatio:s,scaleProportionally:i}=t,r=(0,l.Lz)(t.height),n=r>0?r:e.height;let o=r*s;return o<=0?o=e.width:i&&(o*=e.width/e.height),{width:o,height:n}}function wr(t){const{applyRandomOffset:e,sampleAlphaOnly:s}=t;return rr([[xr,e],[4,s]])}const vr={createComputedParams:t=>t,optionalAttributes:lr.optionalAttributes,attributes:{...lr.attributes,bitset:{count:1,type:pt.pe.UNSIGNED_BYTE,pack:wr},width:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).width},height:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).height},offset:{count:2,type:pt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),-(0,l.Lz)(e)]},scale:{count:2,type:pt.pe.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:t,scaleY:e})=>[t,e]},angle:{count:1,type:pt.pe.UNSIGNED_BYTE,pack:({angle:t})=>(0,Ri.wV)(t)}}};class Sr extends ur{constructor(){super(...arguments),this.vertexSpec=vr}}var Ir=s(83773);class Pr{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0}}const Mr={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:pt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}},attributes:{id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)},offset:{type:pt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[ar(t,16),ar(e,16)]},normal:{type:pt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:t,normalY:e})=>[ar(t,16),ar(e,16)]},halfWidth:{type:pt.pe.HALF_FLOAT,count:1,pack:({width:t})=>(0,l.Lz)(.5*t)},referenceHalfWidth:{type:pt.pe.HALF_FLOAT,count:1,pack:({referenceWidth:t})=>(0,l.Lz)(.5*t)}}};class Tr{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0}}class Cr extends Zi{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Mr,this._currentWrite=new Tr,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new Pr,this._initializeTessellator()}writeLineVertices(t,e,s){const i=this._getLines(e);null!=i&&this._writeVertices(t,s,i)}_initializeTessellator(){this._lineTessellator=new Ir.i(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(t,e,s){const i=s??Ie.fromFeatureSetReaderCIM(e);i&&this._writeGeometry(t,e,i)}_writeGeometry(t,e,s,i){t.recordStart(this.instanceId,this.attributeLayout,i),this.writeLineVertices(t,s,e),t.recordEnd()}_getLines(t){return function(t,e){ge.setPixelMargin(e);const s=ge,i=-e,r=B.CQ+e;let n=[],o=!1;if(!t.nextPath())return null;let a=!0;for(;a;){t.seekPathStart();const e=[];if(!t.pathSize)return null;s.reset(qt.dC.LineString),t.nextPoint();let h=t.x,c=t.y;if(o)s.moveTo(h,c);else{if(h<i||h>r||c<i||c>r){o=!0;continue}e.push({x:h,y:c})}let l=!1;for(;t.nextPoint();)if(h=t.x,c=t.y,o)s.lineTo(h,c);else{if(h<i||h>r||c<i||c>r){l=!0;break}e.push({x:h,y:c})}if(l)o=!0;else{if(o){const t=s.resultWithStarts();if(t)for(const e of t)n.push(e)}else n.push({line:e,start:0});a=t.nextPath(),o=!1}}return n=n.filter((t=>t.line.length>1)),0===n.length?null:n}(t,ji(this.evaluatedMeshParams))}_writeVertices(t,e,s){const{_currentWrite:i,_tessellationOptions:r,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:h,miterLimit:c,hasSizeVV:u}=n,d=(0,l.Lz)(.5*o);r.halfWidth=d,r.capType=function(t){switch(t){case"butt":case ut.uT.Butt:return ut.xR.BUTT;case"round":case ut.uT.Round:return ut.xR.ROUND;case"square":case ut.uT.Square:return ut.xR.SQUARE}}(a),r.joinType=function(t){switch(t){case"bevel":case ut.wd.Bevel:return ut.JO.BEVEL;case"miter":case ut.wd.Miter:return ut.JO.MITER;case"round":case ut.wd.Round:return ut.JO.ROUND}}(h),r.miterLimit=c;const p=!u;i.out=t,i.id=e.getDisplayId(),i.vertexCount=0,i.indexCount=0,i.vertexFrom=t.vertexCount(),i.vertexBounds=p&&d<B.Gh?0:1;for(const{line:t,start:e}of s)r.initialDistance=e%65535,this._lineTessellator.tessellate(t,r,p)}_writeTesselatedVertex(t,e,s,i,r,n,o,a,h,c,l){const{out:u,id:d,vertexBounds:p}=this._currentWrite;return this.hasEffects&&u.recordBounds(t,e,p,p),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=h,this._tessParams.normalY=c,this._tessParams.directionX=r,this._tessParams.directionY=n,this._tessParams.distance=l,this._writeVertex(u,d,t,e,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(t,e,s){const{out:i}=this._currentWrite;i.indexEnsureSize(3),i.indexWrite(t),i.indexWrite(e),i.indexWrite(s),this._currentWrite.indexCount+=3}}const Ar={createComputedParams:t=>t,optionalAttributes:Mr.optionalAttributes,attributes:{...Mr.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)}}},Er={createComputedParams:t=>t,optionalAttributes:Mr.optionalAttributes,attributes:{...Mr.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>rr([[0,!0]])},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>nr(t)}}};class Fr extends Cr{constructor(){super(...arguments),this.vertexSpec=Er}}class kr extends cr{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Ar,this._lineMeshWriter=this._createOutlineWriter(t,e,s,i)}_createOutlineWriter(t,e,s,i){return new Fr(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);r&&(t.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,Ie.fromOptimizedCIM(r,"esriGeometryPolyline"),e),t.recordEnd())}_clip(t){return t?be(t,ji(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 zr=s(46263),Or=s(620);class Rr{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 Lr extends Rr{constructor(){super(...arguments),this.vertex=new Br,this.fragment=new Br,this.attributes=new Gr,this.varyings=new Ur,this.extensions=new Vr,this.constants=new qr}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(t,e=!0){const s=this.extensions.generateSource(t),i=this.attributes.generateSource(t),r=this.varyings.generateSource(t),n="vertex"===t?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),h="vertex"===t?Wr:function(t=!0){return`#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${t?"out vec4 fragColor;":""}\n`}(e),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${i.join("\n")}\n${r.join("\n")}\n${a.join("\n")}`}generateBindPass(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Pass];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Pass];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r)=>{for(let n=0;n<i;++n)s[n](t,e,r)}}generateBindDraw(t){const e=new Map;this.vertex.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Draw];s&&e.set(t.name,s)})),this.fragment.uniforms.entries.forEach((t=>{const s=t.bind[zr.c.Draw];s&&e.set(t.name,s)}));const s=Array.from(e.values()),i=s.length;return(e,r,n)=>{for(let o=0;o<i;++o)s[o](t,e,r,n)}}}class Nr{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 i.A(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else A.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 Dr{constructor(){this._entries=new Array}add(t){this._entries.push(t)}generateSource(){return this._entries}}class Br extends Rr{constructor(){super(...arguments),this.uniforms=new Nr,this.code=new Dr,this.constants=new qr}get builder(){return this}}class Gr{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 Ur{constructor(){this._entries=new Map}add(t,e){this._entries.has(t)&&(0,Or.vA)(this._entries.get(t)===e),this._entries.set(t,e)}generateSource(t){const e=new Array;return this._entries.forEach(((s,i)=>e.push("vertex"===t?`out ${s} ${i};`:`in ${s} ${i};`))),e}}class Vr{constructor(){this._entries=new Set}add(t){this._entries.add(t)}generateSource(t){const e="vertex"===t?Vr.ALLOWLIST_VERTEX:Vr.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((t=>e.includes(t))).map((t=>`#extension ${t} : enable`))}}Vr.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],Vr.ALLOWLIST_VERTEX=[];class qr{constructor(){this._entries=new Set}add(t,e,s){let i="ERROR_CONSTRUCTOR_STRING";switch(e){case"float":i=qr._numberToFloatStr(s);break;case"int":i=qr._numberToIntStr(s);break;case"bool":i=s.toString();break;case"vec2":i=`vec2(${qr._numberToFloatStr(s[0])}, ${qr._numberToFloatStr(s[1])})`;break;case"vec3":i=`vec3(${qr._numberToFloatStr(s[0])}, ${qr._numberToFloatStr(s[1])}, ${qr._numberToFloatStr(s[2])})`;break;case"vec4":i=`vec4(${qr._numberToFloatStr(s[0])}, ${qr._numberToFloatStr(s[1])}, ${qr._numberToFloatStr(s[2])}, ${qr._numberToFloatStr(s[3])})`;break;case"ivec2":i=`ivec2(${qr._numberToIntStr(s[0])}, ${qr._numberToIntStr(s[1])})`;break;case"ivec3":i=`ivec3(${qr._numberToIntStr(s[0])}, ${qr._numberToIntStr(s[1])}, ${qr._numberToIntStr(s[2])})`;break;case"ivec4":i=`ivec4(${qr._numberToIntStr(s[0])}, ${qr._numberToIntStr(s[1])}, ${qr._numberToIntStr(s[2])}, ${qr._numberToIntStr(s[3])})`;break;case"mat2":case"mat3":case"mat4":i=`${e}(${Array.prototype.map.call(s,(t=>qr._numberToFloatStr(t))).join(", ")})`}return this._entries.add(`const ${e} ${t} = ${i};`),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 Wr="precision highp float;\nprecision highp sampler2D;";function Yr(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 jr{constructor(){this.uid=jr.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 jr&&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 Xr(t){return"object"==typeof t?t.clone():t}jr.NodeCount=0;class $r extends jr{constructor(){super(...arguments),this.shaderType="primitive-node"}}class Hr extends jr{constructor(t){super(),this.child=t,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const t=new Hr(Xr(this.child));return this.cloneInto(t),t}}class Zr extends jr{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 Zr(this.property,Xr(this.target),this.returnType);return this.cloneInto(t),t}}class Qr extends jr{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=Xr(this.ifTrue),e=this.ifFalse?Xr(this.ifFalse):null,s=new Qr(this.condition,t,e);return this.cloneInto(s),s}}class Kr extends jr{constructor(t,e,s,i){super(),this.captureList=t,this.returnType=e,this.generator=i,this.shaderType="block-node",s&&(this.subgraph=new Hr(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]=Xr(this.captureList[e]);const e=new Kr(t,this.returnType,this.subgraph?Xr(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(e),e}}class Jr extends jr{constructor(t,e,s,i,r,n=!1){super(),this.token=t,this._children=e,this.isInfix=s,this.isPropertyAccess=i,this.returnType=r,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const t=new Jr(this.token,this._children.map(Xr),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(t),t}}var tn,en,sn,rn,nn,on,an,hn,cn,ln,un,dn,pn,_n;function fn(t){return new Proxy(t,{get(e,s){if("constructor"===s)return new Proxy(e.constructor,{construct:(t,e,s)=>fn(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=>Gn[t]));throw new Error("Unable to find type family")}(t.type);return jn(t,s,e[s.length-1])}}})}function mn(t){return new Proxy(t,{construct:(t,e,s)=>fn(new t(...e))})}class gn extends Error{}let yn=tn=class extends $r{constructor(t,e){super(),this.elementType=t,this.size=e,this.children=[],this.type="array"}clone(){const t=new tn(this.elementType,this.size);return super.cloneInto(t),t}get(t){if("number"==typeof t){const e=new zn(t);return e.isImplicit=!0,jn(this,e,this.elementType.constructor)}return jn(this,t,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,i=t.size){const r=new zn(s).setMutable().setDebugName("FindIndexIterator"),n=e(t.get(r)).setDebugName("FindIndexPredicate"),o=Kn({iter:r},zn,n,(({out:t,iter:e,subgraph:s})=>`\n${t} = -1;\n\nfor (; ${e} < ${i}; ${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,i=t.size){const r=Kn({array:t},zn,null,(({out:t,array:r})=>`\n${t} = -1;\nfor (int i = ${s}; i < ${i}; i++) {\n bool condition;\n ${e({array:r,i:"i",out:"condition"})}\n if (condition) {\n ${t} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return r}(this,t,e,s)}static ofType(t,e){const s={construct:(s,i)=>new tn(new t,e)};return new Proxy(tn,s)}};yn.type="array",yn=tn=(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 jn(t,`[${e}]`,t.elementType.constructor)}}})}(new t(...e))})}],yn);class xn extends $r{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const t=new xn;return t.children=this.children.map(Xr),super.cloneInto(t),t}}xn.type="sampler2D";class bn extends $r{constructor(t){super(),this.type="float",this.children=[t]}clone(){const t=new bn(Xr(this.children[0]));return super.cloneInto(t),t}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}}bn.type="float";let wn=en=class extends $r{constructor(t,e){super(),this.type="vec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new en(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}get 0(){return jn(this,"[0]",bn)}get 1(){return jn(this,"[1]",bn)}get 2(){throw new gn}get 3(){throw new gn}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}};wn.type="vec2",wn=en=(0,P._)([mn],wn);let vn=sn=class extends $r{constructor(t,e,s){super(),this.type="vec3",this.children=[t,e,s].filter((t=>null!=t))}get 0(){return jn(this,"[0]",bn)}get 1(){return jn(this,"[1]",bn)}get 2(){return jn(this,"[2]",bn)}get 3(){throw new gn}clone(){const t=new sn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}};vn.type="vec3",vn=sn=(0,P._)([mn],vn);let Sn=rn=class extends $r{constructor(t,e,s,i){super(),this.type="vec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new rn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}get 0(){return jn(this,"[0]",bn)}get 1(){return jn(this,"[1]",bn)}get 2(){return jn(this,"[2]",bn)}get 3(){return jn(this,"[3]",bn)}multiply(t){return eo(this,"number"==typeof t?Fn(t,bn):t)}divide(t){return so(this,"number"==typeof t?Fn(t,bn):t)}add(t){return io(this,"number"==typeof t?Fn(t,bn):t)}subtract(t){return ro(this,"number"==typeof t?Fn(t,bn):t)}};Sn.type="vec4",Sn=rn=(0,P._)([mn],Sn);let In=nn=class extends $r{constructor(t){super(),this.type="uint",this.children=[t]}clone(){const t=new nn(Xr(this.children[0]));return super.cloneInto(t),t}};In.type="uint",In=nn=(0,P._)([mn],In);let Pn=on=class extends $r{constructor(t,e){super(),this.type="uvec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new on(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}};Pn.type="uvec2",Pn=on=(0,P._)([mn],Pn);let Mn=an=class extends $r{constructor(t,e,s){super(),this.type="uvec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new an(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}};Mn.type="uvec3",Mn=an=(0,P._)([mn],Mn);let Tn=hn=class extends $r{constructor(t,e,s,i){super(),this.type="uvec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new hn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}};Tn.type="uvec4",Tn=hn=(0,P._)([mn],Tn);class Cn extends $r{constructor(t){super(),this.type="bool",this.children=[t]}and(t){return lo(this,t)}or(t){return co(this,t)}clone(){const t=new Cn(Xr(this.children[0]));return super.cloneInto(t),t}}Cn.type="bool";let An=cn=class extends $r{constructor(t,e){super(),this.type="bvec2",this.children=[t,e].filter((t=>null!=t))}all(){return uo(this)}any(){return po(this)}clone(){const t=new cn(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}};An.type="bvec2",An=cn=(0,P._)([mn],An);let En=ln=class extends $r{constructor(t,e,s){super(),this.type="bvec3",this.children=[t,e,s].filter((t=>null!=t))}all(){return uo(this)}any(){return po(this)}clone(){const t=new ln(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}};function Fn(t,e){return"number"==typeof t?new e(t):t}En.type="bvec3",En=ln=(0,P._)([mn],En);let kn=un=class extends $r{constructor(t,e,s,i){super(),this.type="bvec4",this.children=[t,e,s,i].filter((t=>null!=t))}all(){return uo(this)}any(){return po(this)}clone(){const t=new un(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}};kn.type="bvec4",kn=un=(0,P._)([mn],kn);class zn extends $r{constructor(t){super(),this.type="int",this.children=[t]}multiply(t){return eo(this,Fn(t,zn))}add(t){return io(this,Fn(t,zn))}subtract(t){return ro(this,Fn(t,zn))}divide(t){return so(this,Fn(t,zn))}clone(){const t=new zn(Xr(this.children[0]));return super.cloneInto(t),t}}zn.type="int";let On=dn=class extends $r{constructor(t,e){super(),this.type="ivec2",this.children=[t,e].filter((t=>null!=t))}clone(){const t=new dn(Xr(this.children[0]),Xr(this.children[1]));return super.cloneInto(t),t}};On.type="ivec2",On=dn=(0,P._)([mn],On);let Rn=pn=class extends $r{constructor(t,e,s){super(),this.type="ivec3",this.children=[t,e,s].filter((t=>null!=t))}clone(){const t=new pn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]));return super.cloneInto(t),t}};Rn.type="ivec3",Rn=pn=(0,P._)([mn],Rn);let Ln=_n=class extends $r{constructor(t,e,s,i){super(),this.type="ivec4",this.children=[t,e,s,i].filter((t=>null!=t))}clone(){const t=new _n(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}};Ln.type="ivec4",Ln=_n=(0,P._)([mn],Ln);class Nn extends $r{constructor(t,e,s,i){super(),this.type="mat2",this.children=[t,e,s,i]}clone(){const t=new Nn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]));return super.cloneInto(t),t}}Nn.type="mat2";class Dn extends $r{static identity(){return new Dn(1,0,0,0,1,0,0,0,1)}static fromRotation(t){const e=Io(t),s=fo(t);return new Dn(s,e,0,Qn(e),s,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h){super(),this.type="mat3",this.children=[t,e,s,i,r,n,o,a,h]}add(t){return io(this,t)}multiply(t){return eo(this,t)}clone(){const t=new Dn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]),Xr(this.children[4]),Xr(this.children[5]),Xr(this.children[6]),Xr(this.children[7]),Xr(this.children[8]));return super.cloneInto(t),t}}Dn.type="mat3";class Bn extends $r{static identity(){return new Bn(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f){super(),this.type="mat4",this.children=[t,e,s,i,r,n,o,a,h,c,l,u,d,p,_,f]}static fromColumns(t,e,s,i){return new Bn(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,s.x,s.y,s.z,s.w,i.x,i.y,i.z,i.w)}multiply(t){return eo(this,t)}clone(){const t=new Bn(Xr(this.children[0]),Xr(this.children[1]),Xr(this.children[2]),Xr(this.children[3]),Xr(this.children[4]),Xr(this.children[5]),Xr(this.children[6]),Xr(this.children[7]),Xr(this.children[8]),Xr(this.children[9]),Xr(this.children[10]),Xr(this.children[11]),Xr(this.children[12]),Xr(this.children[13]),Xr(this.children[14]),Xr(this.children[15]));return super.cloneInto(t),t}}Bn.type="mat4";const Gn={float:bn,vec2:wn,vec3:vn,vec4:Sn,int:zn,ivec2:On,ivec3:Rn,ivec4:Ln,uint:In,uvec2:Pn,uvec3:Mn,uvec4:Tn,bool:Cn,bvec2:An,bvec3:En,bvec4:kn},Un=(...t)=>new zn(...t),Vn=(...t)=>new bn(...t),qn=(...t)=>new wn(...t),Wn=(...t)=>new Sn(...t),Yn=(...t)=>new Dn(...t);function jn(t,e,s){const i=new s(new Zr(e,t,s));return i.isImplicit=!0,i}function Xn(t,e,s,i=null){if(i){const r=new i,n=new i(new Jr(t,[e,s],!0,!1,r));return n.isImplicit=!0,n}if("float"===e.type||"int"===e.type){const i=new s.constructor(new Jr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}if(("mat2"===e.type||"mat3"===e.type||"mat4"===e.type)&&"float"!==s.type){const i=new s.constructor(new Jr(t,[e,s],!0,!1,s.constructor));return i.isImplicit=!0,i}const r=new e.constructor(new Jr(t,[e,s],!0,!1,e.constructor));return r.isImplicit=!0,r}function $n(t,e,s=e.constructor){const i=new s(new Jr(t,[e],!1,!1,s));return i.isImplicit=!0,i}function Hn(t,e,s,i=e.constructor){const r=new i(new Jr(t,[e,s],!1,!1,i));return r.isImplicit=!0,r}function Zn(t,e,s,i,r=e.constructor){const n=new r(new Jr(t,[e,s,i],!1,!1,r));return n.isImplicit=!0,n}function Qn(t){return eo(t,Vn(-1))}function Kn(t,e,s,i){return new e(new Kr(t,e,s,i))}function Jn(t,e,s){const i="function"==typeof e?e():e,r="function"==typeof s?s():s,n=new i.constructor(new Qr(t,i,r));return n.isImplicit=!0,n}function to(...t){const e=t.map((([t,e])=>"function"==typeof e?[t,e()]:[t,e])),s=e[0][1].constructor,i=e.findIndex((t=>!0===t[0]));if(-1===i)throw new Error("A cond must have a fallthrough case with `true`/; ");const r=e.slice(0,i),n=e[i][1],o=new s(r.reduceRight(((t,e)=>Jn(e[0],e[1],t)),n));return o.isImplicit=!0,o}function eo(t,e){return Xn("*",t,e)}function so(t,e){return Xn("/",t,e)}function io(t,e){return Xn("+",t,e)}function ro(t,e){return Xn("-",t,e)}function no(t,e){return Xn("==",t,e,Cn)}function oo(t,e){return Xn("<=",t,e,Cn)}function ao(t,e){return Xn(">",t,e,Cn)}function ho(t,e){return Xn(">=",t,e,Cn)}function co(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Xn("||",t,e,Cn)}(t,e)),t[0])}function lo(...t){return t.length<=1?t[0]:t.slice(1).reduce(((t,e)=>function(t,e){return Xn("&&",t,e,Cn)}(t,e)),t[0])}function uo(t){return $n("all",t,Cn)}function po(t){return $n("any",t,Cn)}function _o(t,e,s){return Zn("clamp",t,e,s,t.constructor)}function fo(t){return $n("cos",t)}function mo(t,e){return Hn("dot",t,e,bn)}function go(t){return $n("fract",t)}function yo(t){return $n("length",t,bn)}function xo(t,e){return Hn("max",t,e)}function bo(t,e){return Hn("min",t,e)}function wo(t,e,s){return Zn("mix",t,e,s)}function vo(t,e){return Hn("mod",t,e)}function So(t){return"bool"===t.type?$n("!",t):$n("not",t)}function Io(t){return $n("sin",t)}function Po(t,e){return Hn("step",t,e,e.constructor)}function Mo(t,e){return Hn("texture2D",t,e,Sn)}function To(t,e,s){const i=e.split("\n");for(const e of i)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 Co{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 i=t.getEmit(e);if(i)return i;switch(e.shaderType){case"scope-node":i=this._writeScopeNode(t,e);break;case"primitive-node":i=this._writePrimitiveNode(t,e,s);break;case"function-node":i=this._writeFunctionNode(t,e);break;case"property-access-node":i=this._writePropertyAccessNode(t,e);break;case"text-node":i=e.text;break;case"block-node":i=this._writeBlockNode(t,e);break;case"condition-node":i=this._writeConditionNode(t,e)}return t.setEmit(e,i),i}_writeScopeNode(t,e){const s=new e.child.constructor;s.setDebugName(e.debugInfo.name);const i=this._write(t,s,!0);return To(t,`{ /*ScopeStart: ${e.uid} ${e.debugInfo.name}*/`),t.indent+=2,To(t,`${i} = ${this._write(t,e.child)};`),t.indent-=2,To(t,`} /*ScopeEnd: ${e.uid} ${e.debugInfo.name}*/`),i}_writeConditionNode(t,e){const s=new e.ifTrue.constructor,i=this._write(t,s,!0);To(t,`if (${this._write(t,e.condition)}) {`),t.indent+=2;const r=t.createSubgraphContext(),n=this._write(r,e.ifTrue);if(t.body+=r.body,n&&To(t,`${i} = ${n};`),t.indent-=2,To(t,"}"),e.ifFalse){To(t,"else {"),t.indent+=2;const s=t.createSubgraphContext(),r=this._write(s,e.ifFalse);t.body+=s.body,r&&To(t,`${i} = ${r};`),t.indent-=2,To(t,"}")}return i}_writeBlockNode(t,e){const{captureList:s,generator:i,returnType:r}=e,n={};for(const e in s){if(!s[e])continue;const i=this._write(t,s[e]);n[e]=i}const o=new r,a=this._write(t,o,!0);if(n.out=a,e.subgraph){const s=t.createSubgraphContext(),i=this._write(s,e.subgraph.child),r=s.body;n.subgraph={varName:i,body:r}}const h=i(n);return To(t,"{\n"),t.indent+=2,To(t,h),t.indent-=2,To(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}`}_writeFunctionNode(t,e){const s=e.returnType.type;if(e.isInfix){const[i,r]=e.children.map((e=>this._write(t,e))),n=this._createVarName(t,e);return To(t,`${s.padEnd(5)} ${n} = ${i} ${e.token} ${r};`,e.uid),n}const i=e.children.map((e=>this._write(t,e))).join(", "),r=this._createVarName(t,e);return To(t,`${s.padEnd(5)} ${r} = ${e.token}(${i});`,e.uid),r}_writePrimitiveNode(t,e,s=!1){const i=t.getInput(e);if(i)return i.isUsed=!0,i.variableName;const r=1===e.children.length&&e.children[0]?.type===e.type;if(e.isImplicit||r)return this._write(t,e.children[0]);const n=this._createVarName(t,e);if(s)return To(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?(To(t,`${e.type.padEnd(5)} ${n} = [${a}];`,e.uid),n):o?`${e.type}(${a})`:(To(t,`${e.type.padEnd(5)} ${n} = ${e.type}(${a});`,e.uid),n)}}class Ao{constructor(t,e,s){this.variableName=t,this.variableInputType=e,this.node=s,this.type="shader-input",this.isUsed=!1}clone(){return new Ao(this.variableName,this.variableInputType,Xr(this.node))}}class Eo{constructor(t,e,s){this.outVariableName=t,this.outVariableType=e,this.node=s,this.type="shader-output"}clone(){const t=new Eo(this.outVariableName,this.outVariableType,Xr(this.node));return t.variableName=this.variableName,t}}class Fo{static createVertex(t,e,s,i,r,n){const o=[];for(const e in t){const i=t[e],r=s.get(e);r?o.push(new Ao(r,"builtin",i)):o.push(new Ao("a_"+e,"attribute",i))}for(const t of i){const e=t.uniformHydrated;o.push(new Ao(t.uniformName,"uniform",e))}const a=[];for(const t in e){const s=e[t];"glPosition"===t?a.push(new Eo("gl_Position","builtin",s)):"glPointSize"===t?a.push(new Eo("gl_PointSize","builtin",s)):a.push(new Eo("v_"+t,"varying",s))}return new Fo(o,a,r,n)}static createFragment(t,e,s,i,r,n){const o=[],a=Array.from(r.rootOutputNodes());for(const e in t){const i=t[e],r=s.get(e);if(r){o.push(new Ao(r,"builtin",i));continue}const n=a.find((t=>t.node===i));n&&o.push(new Ao(n.outVariableName,n.outVariableType,i))}for(const t of i){const e=t.uniformHydrated;o.push(new Ao(t.uniformName,"uniform",e))}const h=[];for(const t in e){const i=e[t],r=s.get(t);if("discard"===t)h.push(new Eo(null,"discard",i));else{if(!r)throw new Error(`Member ${t} in shader fragment output shoule be tagged as builtin`);h.push(new Eo(r,"builtin",i))}}return new Fo(o,h,n)}constructor(t,e,s,i){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=i}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 Fo([],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("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}];`):t[e].code.add(`${s.variableInputType.padEnd(10)} ${s.node.type.padEnd(9)} ${s.variableName};`))}}const ko=["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"],zo=!1;var Oo=999,Ro=9999,Lo=0,No=1,Do=2,Bo=3,Go=4,Uo=5,Vo=6,qo=7,Wo=8,Yo=9,jo=10,Xo=11,$o=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Ho(t){return function(t){var e=function(){var t,e,s,i=0,r=0,n=Oo,o=[],a=[],h=1,c=0,l=0,u=!1,d=!1,p="";return function(t){return a=[],null!==t?f(t.replace?t.replace(/\r\n/g,"\n"):t):(o.length&&_(o.join("")),n=jo,_("(eof)"),a)};function _(t){t.length&&a.push({type:$o[n],data:t,position:l,line:h,column:c})}function f(e){var o;for(i=0,s=(p+=e).length;t=p[i],i<s;){switch(o=i,n){case Lo:i=x();break;case No:case Do:i=y();break;case Bo:i=b();break;case Go:i=S();break;case Xo:i=v();break;case Uo:i=I();break;case Ro:i=P();break;case Yo:i=g();break;case Oo:i=m()}o!==i&&("\n"===p[o]?(c=0,++h):++c)}return r+=i,p=p.slice(i),a}function m(){return o=o.length?[]:o,"/"===e&&"*"===t?(l=r+i-1,n=Lo,e=t,i+1):"/"===e&&"/"===t?(l=r+i-1,n=No,e=t,i+1):"#"===t?(n=Do,l=r+i,i):/\s/.test(t)?(n=Yo,l=r+i,i):(u=/\d/.test(t),d=/[^\w_]/.test(t),l=r+i,n=u?Go:d?Bo:Ro,i)}function g(){return/[^\s]/g.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function y(){return"\r"!==t&&"\n"!==t||"\\"===e?(o.push(t),e=t,i+1):(_(o.join("")),n=Oo,i)}function x(){return"/"===t&&"*"===e?(o.push(t),_(o.join("")),n=Oo,i+1):(o.push(t),e=t,i+1)}function b(){if("."===e&&/\d/.test(t))return n=Uo,i;if("/"===e&&"*"===t)return n=Lo,i;if("/"===e&&"/"===t)return n=No,i;if("."===t&&o.length){for(;w(o););return n=Uo,i}if(";"===t||")"===t||"("===t){if(o.length)for(;w(o););return _(t),n=Oo,i+1}var s=2===o.length&&"="!==t;if(/[\w_\d\s]/.test(t)||s){for(;w(o););return n=Oo,i}return o.push(t),e=t,i+1}function w(t){for(var e,s,i=0;;){if(e=kt.indexOf(t.slice(0,t.length+i).join("")),s=kt[e],-1===e){if(i--+t.length>0)continue;s=t.slice(0,1).join("")}return _(s),l+=s.length,(o=o.slice(s.length)).length}}function v(){return/[^a-fA-F0-9]/.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function S(){return"."===t||/[eE]/.test(t)?(o.push(t),n=Uo,e=t,i+1):"x"===t&&1===o.length&&"0"===o[0]?(n=Xo,o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function I(){return"f"===t&&(o.push(t),e=t,i+=1),/[eE]/.test(t)||"-"===t&&/[eE]/.test(e)?(o.push(t),e=t,i+1):/[^\d]/.test(t)?(_(o.join("")),n=Oo,i):(o.push(t),e=t,i+1)}function P(){if(/[^\d\w_]/.test(t)){var s=o.join("");return n=At.indexOf(s)>-1?Wo:Lt.indexOf(s)>-1?qo:Vo,_(o.join("")),n=Oo,i}return o.push(t),e=t,i+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 Qo(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 Ko(t,e,s,i){i=i||s;for(const r of t)if("ident"===r.type&&r.data===s)return i in e?e[i]++:e[i]=0,Ko(t,e,i+"_"+e[i],i);return s}function Jo(t,e,s="afterVersion"){function i(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 r={data:"\n",type:"whitespace"},n=e=>e<t.length&&/[^\r\n]$/.test(t[e].data);let o=function(t){let e=-1,r=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)?++r:/#endif\s*.*/.test(a.data)&&--r),"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=i(t,o);if(null===e)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,e)}e<n&&0===r&&(e=o)}return e+1}(t);n(o-1)&&t.splice(o++,0,r);for(const s of e)t.splice(o++,0,s);n(o-1)&&n(o)&&t.splice(o,0,r)}function ta(t,e,s,i="lowp"){Jo(t,[{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 ea(t,e,s,i,r="lowp"){Jo(t,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:i.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{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 sa(t,e){let s,i,r=-1;for(let n=e;n<t.length;n++){const e=t[n];if("operator"===e.type&&("["===e.data&&(s=n),"]"===e.data)){i=n;break}"integer"===e.type&&(r=parseInt(e.data,10))}return s&&i&&t.splice(s,i-s+1),r}function ia(t,e){if(t.startsWith("#version 300"))return t;const s=function(t){return zo?ra.get(t):null}(t);if(null!=s)return s;const i=Ho(t);if("300 es"===function(t,e="100",s="300 es"){const i=/^\s*#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const r of t)if("preprocessor"===r.type){const t=i.exec(r.data);if(t){const i=t[1].replaceAll(/\s{2,}/g," ");if(i===s)return i;if(i===e)return r.data="#version "+s,e;throw new Error("unknown glsl version: "+i)}}return t.splice(0,0,{type:"preprocessor",data:"#version "+s},{type:"whitespace",data:"\n"}),null}(i,"100","300 es"))return t;let r=null,n=null;const o={},a={};for(let t=0;t<i.length;++t){const s=i[t];switch(s.type){case"keyword":e===pt.Co.VERTEX_SHADER&&"attribute"===s.data?s.data="in":"varying"===s.data&&(s.data=e===pt.Co.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(s.data.trim())&&(s.data=s.data.replaceAll(/(2D|Cube|EXT)/g,"")),e===pt.Co.FRAGMENT_SHADER&&"gl_FragColor"===s.data&&(r||(r=Ko(i,o,"fragColor"),ta(i,r,"vec4")),s.data=r),e===pt.Co.FRAGMENT_SHADER&&"gl_FragData"===s.data){const e=sa(i,t+1),r=Ko(i,o,"fragData");ea(i,r,"vec4",e,"mediump"),s.data=r}else e===pt.Co.FRAGMENT_SHADER&&"gl_FragDepthEXT"===s.data&&(n||(n=Ko(i,o,"gl_FragDepth")),s.data=n);break;case"ident":if(ko.includes(s.data)){if(e===pt.Co.VERTEX_SHADER&&Qo(i,t))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");s.data in a||(a[s.data]=Ko(i,o,s.data)),s.data=a[s.data]}}}for(let t=i.length-1;t>=0;--t){const e=i[t];if("preprocessor"===e.type){const s=e.data.match(/#extension\s+(.*):/);if(s?.[1]&&Zo.has(s[1].trim())){const e=i[t+1];i.splice(t,e&&"whitespace"===e.type?2:1)}const r=e.data.match(/#ifdef\s+(.*)/);r?.[1]&&Zo.has(r[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 zo&&ra.set(t,e),e}(t,function(t){return t.map((t=>"eof"!==t.type?t.data:"")).join("")}(i))}const ra=new Map;class na{constructor(t,e,s,i,r=new Map,n=[]){this._context=t,this._locations=i,this._uniformBlockBindings=r,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=ia(e,pt.Co.VERTEX_SHADER),s=ia(s,pt.Co.FRAGMENT_SHADER),this._vShader=oa(this._context,pt.Co.VERTEX_SHADER,e),this._fShader=oa(this._context,pt.Co.FRAGMENT_SHADER,s),ha.enabled&&(this._linesOfCode=e.match(/\n/g).length+s.match(/\n/g).length+2,this._context.instanceCounter.increment(pt.vt.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(pt.vt.Shader,this),(0,dt.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,dt.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(pt.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(pt.vt.Uniform,t))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(e.decrement(pt.vt.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),t.deleteShader(this._vShader),this._vShader=null,e.decrement(pt.vt.Shader,this)),this._fShader&&(t.deleteShader(this._fShader),this._fShader=null),this._glName&&(t.deleteProgram(this._glName),this._glName=null,e.decrement(pt.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(pt.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){aa(this._nameToUniform1v,t,e)&&this._context.gl.uniform1iv(this._getUniformLocation(t),e)}setUniform2iv(t,e){aa(this._nameToUniform2,t,e)&&this._context.gl.uniform2iv(this._getUniformLocation(t),e)}setUniform3iv(t,e){aa(this._nameToUniform3,t,e)&&this._context.gl.uniform3iv(this._getUniformLocation(t),e)}setUniform4iv(t,e){aa(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){aa(this._nameToUniform1v,t,e)&&this._context.gl.uniform1fv(this._getUniformLocation(t),e)}setUniform2f(t,e,s){const i=this._nameToUniform2.get(t);void 0===i?(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),this._nameToUniform2.set(t,[e,s])):e===i[0]&&s===i[1]||(this._context.gl.uniform2f(this._getUniformLocation(t),e,s),i[0]=e,i[1]=s)}setUniform2fv(t,e){aa(this._nameToUniform2,t,e)&&this._context.gl.uniform2fv(this._getUniformLocation(t),e)}setUniform3f(t,e,s,i){const r=this._nameToUniform3.get(t);void 0===r?(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),this._nameToUniform3.set(t,[e,s,i])):e===r[0]&&s===r[1]&&i===r[2]||(this._context.gl.uniform3f(this._getUniformLocation(t),e,s,i),r[0]=e,r[1]=s,r[2]=i)}setUniform3fv(t,e){const s=this._getUniformLocation(t);null!=s&&aa(this._nameToUniform3,t,e)&&this._context.gl.uniform3fv(s,e)}setUniform4f(t,e,s,i,r){const n=this._nameToUniform4.get(t);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),this._nameToUniform4.set(t,[e,s,i,r])):void 0!==n&&e===n[0]&&s===n[1]&&i===n[2]&&r===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(t),e,s,i,r),n[0]=e,n[1]=s,n[2]=i,n[3]=r)}setUniform4fv(t,e){const s=this._getUniformLocation(t);null!=s&&aa(this._nameToUniform4,t,e)&&this._context.gl.uniform4fv(s,e)}setUniformMatrix3fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&aa(this._nameToUniformMatrix3,t,e)&&this._context.gl.uniformMatrix3fv(i,s,e)}setUniformMatrix4fv(t,e,s=!1){const i=this._getUniformLocation(t);null!=i&&aa(this._nameToUniformMatrix4,t,e)&&this._context.gl.uniformMatrix4fv(i,s,e)}stop(){}}function oa(t,e,s){const i=t.gl,r=i.createShader(e);return i.shaderSource(r,s),i.compileShader(r),(0,dt.Xc)()&&!i.getShaderParameter(r,i.COMPILE_STATUS)&&(console.error("Compile error in ".concat(e===pt.Co.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(i.getShaderInfoLog(r)),console.error(function(t){let e=2;return t.replaceAll("\n",(()=>"\n"+function(t){return t>=1e3?t.toString():(" "+t).slice(-3)}(e++)+":"))}(s))),r}function aa(t,e,s){const i=t.get(e);if(!i)return t.set(e,Array.from(s)),!0;const r=s.length;if(i.length!==r)return t.set(e,Array.from(s)),!0;for(let t=0;t<r;++t){const e=s[t];if(i[t]!==e){for(i[t]=e;t<r;++t)i[t]=s[t];return!0}}return!1}const ha={enabled:!1};function ca(t,e,s){const r=e.length;if(r!==s){const n=new i.A("Invalid Uniform",`Invalid length, expected ${s} but got ${r}`,{uniformName:t,values:e});A.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}class la{constructor(t,e,s,i,r,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=t,this.fragmentShader=e,this._locations=s,this._locationInfo=i,this._uniformBindings=r,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:i}=t;s[e]=`v_${i}`}this._program=new na(t,this.vertexShader,this.fragmentShader,e,new Map,s)}const s=this._program;t.useProgram(s);for(const i of this._uniformBindings){const{shaderModulePath:r,uniformName:n,uniformType:o,uniformArrayLength:a}=i,h=(0,U.wc)(r,e);if(null==h){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${r}`)}switch("array"===o?i.uniformArrayElementType:o){case"sampler2D":{const{unit:e,texture:i}=h;if(s.setUniform1i(n,e),"type"in i)t.bindTexture(i,e);else{const s=Dt(t,i.descriptor,i.data);t.bindTexture(s,e)}break}case"int":if(!a){s.setUniform1i(n,h);break}ca(i.uniformName,h,a),s.setUniform1iv(n,h);break;case"float":if(!a){s.setUniform1f(n,h);break}ca(i.uniformName,h,a),s.setUniform1fv(n,h);break;case"vec2":if(!a){s.setUniform2f(n,h[0],h[1]);break}ca(i.uniformName,h,a),s.setUniform2fv(n,h.flat());break;case"vec3":if(!a){s.setUniform3f(n,h[0],h[1],h[2]);break}ca(i.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}ca(i.uniformName,h,a),s.setUniform4fv(n,h.flat());break;case"mat3":s.setUniformMatrix3fv(n,h.flat());break;case"mat4":s.setUniformMatrix4fv(n,h.flat());break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function ua(t){return new t}function da(t,e,s){const i=t.constructor[e]??[];t.constructor.hasOwnProperty(e)||Object.defineProperty(t.constructor,e,{value:i.slice()}),t.constructor[e].push(s)}function pa(t,e){return(s,i)=>{da(s,"locations",{typeCtor:e,propertyKey:i,parameterIndex:null,index:t})}}const _a=t=>(e,s,i)=>{da(e,"inputs",{inputCtor:t,propertyKey:s,parameterIndex:i})},fa=t=>(e,s)=>{da(e,"uniforms",{typeCtor:t,propertyKey:s})},ma=t=>(e,s)=>{da(e,"options",{typeCtor:t,propertyKey:s})},ga=(t,e)=>{da(t,"defines",{propertyKey:e})},ya=(t,e)=>(s,i)=>{s.constructor.builtins.push({builtin:t,propertyKey:i,typeCtor:e})};class xa{}xa.builtins=[],(0,P._)([ya("gl_VertexID",zn)],xa.prototype,"glVertexID",void 0);class ba{}class wa{}wa.builtins=[],(0,P._)([ya("gl_FragCoord",Sn)],wa.prototype,"glFragCoord",void 0),(0,P._)([ya("gl_PointCoord",wn)],wa.prototype,"glPointCoord",void 0);class va{}(0,P._)([(t,e)=>{da(t,"builtins",{builtin:"gl_FragColor",propertyKey:e})}],va.prototype,"glFragColor",void 0);class Sa{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class Ia{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)?A.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),i=this.computeAttributes;this._locationInfo={hash:s,locations:t,computeAttributeMap:i}}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,i){try{const{vertex:r,fragment:n,uniformBindings:o}=this._generateShaders(t,e,s,i);return new la(r,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(t){return new la("","",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,i){const r=Object.keys(t).map((e=>`${e}.${t[e]}`)).join("."),n=Object.keys(s).map((t=>`${t}.${s[t]}`)).join("."),o=Object.keys(i).map((t=>`${t}.${i[t]}`)).join("."),a=Object.keys(e).filter((t=>this.optionPropertyKeys.has(t)&&e[t])).join(".");return`${this.constructor.name}.${r}.${n}.${o}.${a}`}_generateShaders(t,e,s,i){const r=[];this._setDefines(s),this._setOptionalUniforms(r,e),this._setRequiredUniforms(r);const n=this._hydrateVertexInput(i),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)Yr(d,u[t]);const p=this._getVertexInputBuiltins(),_=Fo.createVertex({...n,...a},c,p,r,this.transformFeedbackBindings,d);(new Co).write(_);const f=this._getFragmentInputBuiltins(u);f.set("glPointCoord","gl_PointCoord");const m=Fo.createFragment(l,u,f,r,_,this.transformFeedbackBindings);(new Co).write(m);const g=this._createShaderBuilder(_,m),y=g.generate("vertex",!1),x=g.generate("fragment",!1);return this.logShader&&(console.log(y),console.log(x)),{vertex:y,fragment:x,uniformBindings:r}}_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 i of s._uniforms??[]){const r=ua(i.typeCtor),n=`u_${e.propertyKey}_${i.propertyKey}`,o=r.type,a=[e.propertyKey,i.propertyKey].join(".");if("type"in i.typeCtor&&"array"===i.typeCtor.type){const e=r;t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:e.size,uniformArrayElementType:e.elementType.type,uniformHydrated:r})}else t.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:r});s[i.propertyKey]=r}return s}_hydrateVertexInput(t){const e=this.vertexInput.inputCtor,s=e.locations.reduce(((e,s)=>!1===t[s.propertyKey]?e:{...e,[s.propertyKey]:ua(s.typeCtor)}),{});for(const{propertyKey:t,typeCtor:i}of e.builtins){const e=ua(i);s[t]=e}return s}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((t,e)=>({...t,[e.propertyKey]:ua(e.typeCtor)})),{})}_injectPackPrecisionFactor(t,e){const s={};for(const i in t){const r=t[i],n=e[i];if(n){if("float"!==r.type&&"vec2"!==r.type&&"vec3"!==r.type&&"vec4"!==r.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${r.type}`);s[i]=r.divide(new bn(n))}else s[i]=r}return s}_injectComputePackPrecisionFactor(t,e){const s={},i=new Map;for(const t in this.computeAttributes)for(const e of this.computeAttributes[t]??[])i.set(e,t);for(const r in t){const n=t[r],o=i.get(r);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[r]=n.divide(new bn(a))}else s[r]=n}return s}_hydrateFragmentInput(t){const e={};for(const s in t)e[s]=t[s];for(const{propertyKey:t,typeCtor:s}of wa.builtins){const i=ua(s);e[t]=i}return e}_getVertexInputBuiltins(){const t=this.vertexInput.inputCtor,e=new Map;for(const{builtin:s,propertyKey:i}of t.builtins)e.set(i,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 Lr;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`)}}let Pa=class extends M.A{constructor(){super(...arguments),this.color=new er.A([0,255,255]),this.haloOpacity=1,this.fillOpacity=.25,this.multiHighlightEnabled=!1}equals(t){return this.color.equals(t.color)&&(this.haloColor||this.color).equals(t.haloColor||t.color)&&this.haloOpacity===t.haloOpacity&&this.fillOpacity===t.fillOpacity&&this.multiHighlightEnabled===t.multiHighlightEnabled}};(0,P._)([(0,C.MZ)({type:er.A})],Pa.prototype,"color",void 0),(0,P._)([(0,C.MZ)({type:er.A})],Pa.prototype,"haloColor",void 0),(0,P._)([(0,C.MZ)()],Pa.prototype,"haloOpacity",void 0),(0,P._)([(0,C.MZ)()],Pa.prototype,"fillOpacity",void 0),(0,P._)([(0,C.MZ)()],Pa.prototype,"multiHighlightEnabled",void 0),Pa=(0,P._)([(0,E.$)("esri.views.2d.support.HighlightOptions")],Pa);const Ma=Pa,Ta={selection:t=>new Ma({color:new er.A([t.color.r/2,t.color.g/2,t.color.b/2,t.color.a])}),highlight:t=>t,popup:t=>new Ma({color:new er.A([t.color.g,t.color.b,t.color.r,t.color.a])})},Ca=Object.keys(Ta);function Aa(t){const e=Vn(12.9898),s=Vn(78.233),i=Vn(43758.5453);return go(Io(vo(mo(t,qn(e,s)),Vn(3.14))).multiply(i))}function Ea(t){return no(t,Vn(yr))}function Fa(t,e){const s=Vn(2**e);return vo(function(t){return $n("floor",t)}(t.divide(s)),Vn(2))}function ka(t,e){return Fa(t,e+Ca.length)}class za extends Sa{getVisualVariableData(t){if(!this._vvData){const e=this.getAttributeDataCoords(t);this._vvData=Mo(this.visualVariableData,e).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(t){if(!this._uv){const e=function(t){const e=Fa(t.z,7),s=Vn(1).subtract(e),i=t.xyz.subtract(((...t)=>new vn(...t))(0,0,Vn(128)));return s.multiply(t).add(e.multiply(i))}(t),s=this.size,i=Un(e.x),r=Un(e.y).multiply(Un(256)),n=Un(e.z).multiply(Un(256)).multiply(Un(256)),o=Vn(i.add(r).add(n)),a=vo(o,s),h=o.subtract(a).divide(s);this._uv=new wn(a,h).add(.5).divide(s)}return this._uv}getFilterData(t){const e=this.getAttributeDataCoords(t);return Mo(this.filterFlags,e).setDebugName("storage0")}getAnimationData(t){const e=this.getAttributeDataCoords(t);return Mo(this.animation,e).setDebugName("storage1")}getVVData(t){return this.getVisualVariableData(t)}getDataDrivenData0(t){const e=this.getAttributeDataCoords(t);return Mo(this.dataDriven0,e).setDebugName("storage30")}getDataDrivenData1(t){const e=this.getAttributeDataCoords(t);return Mo(this.dataDriven1,e).setDebugName("storage31")}getDataDrivenData2(t){const e=this.getAttributeDataCoords(t);return Mo(this.dataDriven2,e).setDebugName("storage32")}getGPGPUData(t){const e=this.getAttributeDataCoords(t);return Mo(this.gpgpu,e).setDebugName("storage4")}getFilterFlags(t){return(0,n.A)("webgl-ignores-sampler-precision")?function(t){return $n("ceil",t)}(this.getFilterData(t).x.multiply(Vn(255))):this.getFilterData(t).x.multiply(Vn(255))}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._)([fa(xn)],za.prototype,"filterFlags",void 0),(0,P._)([fa(xn)],za.prototype,"animation",void 0),(0,P._)([fa(xn)],za.prototype,"gpgpu",void 0),(0,P._)([fa(xn)],za.prototype,"visualVariableData",void 0),(0,P._)([fa(xn)],za.prototype,"dataDriven0",void 0),(0,P._)([fa(xn)],za.prototype,"dataDriven1",void 0),(0,P._)([fa(xn)],za.prototype,"dataDriven2",void 0),(0,P._)([fa(bn)],za.prototype,"size",void 0);class Oa extends Sa{}(0,P._)([fa(bn)],Oa.prototype,"activeReasons",void 0),(0,P._)([fa(bn)],Oa.prototype,"highlightAll",void 0);class Ra extends Sa{}(0,P._)([fa(wn)],Ra.prototype,"position",void 0),(0,P._)([fa(bn)],Ra.prototype,"distance",void 0),(0,P._)([fa(bn)],Ra.prototype,"smallSymbolDistance",void 0),(0,P._)([fa(bn)],Ra.prototype,"smallSymbolSizeThreshold",void 0);class La extends Sa{}(0,P._)([fa(Dn)],La.prototype,"displayViewScreenMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"displayViewMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"displayMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"viewMat3",void 0),(0,P._)([fa(Dn)],La.prototype,"tileMat3",void 0),(0,P._)([fa(bn)],La.prototype,"displayZoomFactor",void 0),(0,P._)([fa(bn)],La.prototype,"requiredZoomFactor",void 0),(0,P._)([fa(wn)],La.prototype,"tileOffset",void 0),(0,P._)([fa(bn)],La.prototype,"currentScale",void 0),(0,P._)([fa(bn)],La.prototype,"currentZoom",void 0),(0,P._)([fa(bn)],La.prototype,"metersPerSRUnit",void 0),(0,P._)([fa(bn)],La.prototype,"rotation",void 0),(0,P._)([fa(bn)],La.prototype,"pixelRatio",void 0);class Na extends xa{}(0,P._)([pa(0,vn)],Na.prototype,"id",void 0),(0,P._)([pa(1,bn)],Na.prototype,"bitset",void 0),(0,P._)([pa(2,wn)],Na.prototype,"pos",void 0);class Da extends ba{}(0,P._)([pa(14,wn)],Da.prototype,"nextPos1",void 0),(0,P._)([pa(15,wn)],Da.prototype,"nextPos2",void 0);class Ba extends wa{}class Ga extends Ia{clip(t,e){let s=new bn(0);const i=this.storage.getFilterFlags(t);if(s=s.add(Vn(2).multiply(Vn(1).subtract(ka(i,0)))),this.inside?s=s.add(Vn(2).multiply(Vn(1).subtract(ka(i,1)))):this.outside?s=s.add(Vn(2).multiply(ka(i,1))):this.highlight&&(s=s.add(Vn(2).multiply(Vn(1).subtract(this._checkHighlight(i))))),null!=e){const t=new bn(1).subtract(Po(e.x,this.view.currentZoom)),i=Po(e.y,this.view.currentZoom);s=s.add(new bn(2).multiply(t.add(i)))}return s}getFragmentOutput(t,e,s=new bn(1/255)){const i=new va;return i.glFragColor=this._maybeWriteHittest(e)??this._maybeHighlight(t,s)??t,i}_maybeHighlight(t,e){return this.highlight?new Sn(t.rgb,Po(e,t.a)):null}_checkHighlight(t){let e=this._checkHighlightBit(t,0);for(let s=1;s<Ca.length;s++)e=e.add(this._checkHighlightBit(t,s));return Po(new bn(.1),e.add(this.highlight.highlightAll))}_checkHighlightBit(t,e){return function(t,e){return Fa(t,e)}(t,e).multiply(Fa(this.highlight.activeReasons,e))}maybeRunHittest(t,e,s){if(null==this.hittestRequest)return null;let i=Jn(ao(this.hittest(t,e,s),this.hittestRequest.distance),new bn(2),new bn(0));const r=function(t){return t.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(t.id));i=i.add(this.clip(t.id,t.zoomRange));const n=new Sn(new bn(1/255),0,0,0);return{glPointSize:new bn(1),glPosition:new Sn(r,i,1),color:n}}_maybeWriteHittest(t){return null!=this.hittestRequest?t.color:null}}function Ua(t,e,s){const i=s.subtract(e),r=_o(function(t,e){return mo(t,function(t){return $n("normalize",t)}(e))}(t.subtract(e),i).divide(yo(i)),new bn(0),new bn(1));return function(t,e){return Hn("distance",t,e,bn)}(t,e.add(r.multiply(s.subtract(e))))}function Va(t,e,s,i){return no(function(t){const e=function(t){return $n("abs",t)}(t);return Po(e.x.add(e.y).add(e.z),new bn(1.05))}(function(t,e,s,i){const r=new Dn(s.x.multiply(i.y).subtract(i.x.multiply(s.y)),i.x.multiply(e.y).subtract(e.x.multiply(i.y)),e.x.multiply(s.y).subtract(s.x.multiply(e.y)),s.y.subtract(i.y),i.y.subtract(e.y),e.y.subtract(s.y),i.x.subtract(s.x),e.x.subtract(i.x),s.x.subtract(e.x)),n=e.x.multiply(s.y.subtract(i.y)),o=s.x.multiply(i.y.subtract(e.y)),a=i.x.multiply(e.y.subtract(s.y)),h=n.add(o).add(a);return new bn(1).divide(h).multiply(r.multiply(new vn(1,t)))}(t,e,s,i)),new bn(1))}function qa(t){return t.distance.add(1)}function Wa(t,e,s){const{viewMat3:i,tileMat3:r}=t.view,n=i.multiply(r),o=n.multiply(new vn(e.pos,1)),a=n.multiply(new vn(s.nextPos1,1)),h=n.multiply(new vn(s.nextPos2,1));return function(t,e,s,i){const r=function(t,e){return t.x.multiply(e.y).subtract(e.x.multiply(t.y))}(s.subtract(e),i.subtract(e)),n=lo(function(t,e){return Xn("<",t,e,Cn)}(r,new bn(gr)),ao(r,new bn(-gr)));return to([lo(So(n),Va(t.xy,e,s,i)),new bn(-1)],[!0,()=>{const r=Ua(t,e,s),n=Ua(t,s,i),o=Ua(t,i,e);return bo(bo(r,n),o)}])}(t.hittestRequest.position,o.xy,a.xy,h.xy)}(0,P._)([ga],Ga.prototype,"inside",void 0),(0,P._)([ga],Ga.prototype,"outside",void 0),(0,P._)([ma(Oa)],Ga.prototype,"highlight",void 0),(0,P._)([fa(za)],Ga.prototype,"storage",void 0),(0,P._)([fa(La)],Ga.prototype,"view",void 0),(0,P._)([ma(Ra)],Ga.prototype,"hittestRequest",void 0);class Ya extends Sa{getColor(t,e,s){return to([co(Ea(t),s),e],[oo(t,this.values.first()),this.colors.first()],[ho(t,this.values.last()),this.colors.last()],[!0,()=>{const e=this.values.findIndex((e=>ao(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.colors.get(i),this.colors.get(e),n)}])}}(0,P._)([fa(yn.ofType(Sn,8))],Ya.prototype,"colors",void 0),(0,P._)([fa(yn.ofType(bn,8))],Ya.prototype,"values",void 0);class ja extends Sa{getOpacity(t){return to([Ea(t),new bn(1)],[oo(t,this.opacityValues.first()),this.opacities.first()],[ho(t,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const e=this.opacityValues.findIndex((e=>ao(e,t))),s=this.opacityValues.get(e),i=e.subtract(1),r=this.opacityValues.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.opacities.get(i),this.opacities.get(e),n)}])}}function Xa(t){return null!=t.visualVariableSizeMinMaxValue||null!=t.visualVariableSizeScaleStops||null!=t.visualVariableSizeStops||null!=t.visualVariableSizeUnitValue}function $a(t,e,s,i=new Cn(!1)){if(null==t.visualVariableColor)return s;const r=t.storage.getColorValue(e);return t.visualVariableColor.getColor(r,s,i)}function Ha(t,e){if(null==t.visualVariableOpacity)return new bn(1);const s=t.storage.getOpacityValue(e);return t.visualVariableOpacity.getOpacity(s)}(0,P._)([fa(yn.ofType(bn,8))],ja.prototype,"opacities",void 0),(0,P._)([fa(yn.ofType(bn,8))],ja.prototype,"opacityValues",void 0);class Za extends Na{}(0,P._)([pa(3,Sn)],Za.prototype,"color",void 0),(0,P._)([pa(4,wn)],Za.prototype,"zoomRange",void 0);class Qa extends Ga{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=Ha(this,t.id),i=$a(this,t.id,t.color).multiply(s),r=this.view.displayViewScreenMat3.multiply(new vn(t.pos.xy,1)),n=this.clip(t.id,t.zoomRange);return{glPosition:new Sn(r.xy,n,1),color:i,...this.maybeRunHittest(t,e,null)}}fragment(t){return this.getFragmentOutput(t.color,t,new bn(0))}hittest(t,e){return Wa(this,t,e)}}(0,P._)([ma(Ya)],Qa.prototype,"visualVariableColor",void 0),(0,P._)([ma(ja)],Qa.prototype,"visualVariableOpacity",void 0),(0,P._)([(0,P.a)(0,_a(Za)),(0,P.a)(1,_a(Da))],Qa.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(Ba))],Qa.prototype,"fragment",null);class Ka extends Sa{getPatternOffsetAtTileOrigin(t,e=new bn(0),s=new bn(1)){const i=new wn(16777216).divide(t);let r=t.multiply(go(this.maxIntsToLocalOrigin.multiply(i))).add(this.tileOffsetFromLocalOrigin).subtract(new bn(.5).multiply(t));return r=new wn(r.x.multiply(s).subtract(r.y.multiply(e)),r.x.multiply(e).add(r.y.multiply(s))),vo(r,t)}}(0,P._)([fa(wn)],Ka.prototype,"tileOffsetFromLocalOrigin",void 0),(0,P._)([fa(wn)],Ka.prototype,"maxIntsToLocalOrigin",void 0);class Ja extends Sa{}(0,P._)([fa(wn)],Ja.prototype,"size",void 0),(0,P._)([fa(xn)],Ja.prototype,"texture",void 0);class th extends Za{}function eh(t,e){const s=t.view.requiredZoomFactor,i=new wn(e.width,e.height),r=i.multiply(e.scale).multiply(s),n=e.angle.multiply(.024543692606171875),o=Io(n),a=fo(n),h=function(t,e,s,i,r){const n=no(Fa(r,xr),Vn(1)),o=function(t){return mo(t,Wn(255/256,255/65536,255/16777216,255/4294967296))}(new Sn(t,0));return Jn(n,Yn(i.divide(e.x),s.divide(e.y),0,Qn(s.divide(e.x)),i.divide(e.y),0,Aa(qn(o,0)),Aa(qn(0,o)),1),Yn(i.divide(e.x),s.divide(e.y),0,Qn(s.divide(e.x)),i.divide(e.y),0,0,0,1))}(e.id,r,o,a,e.bitset),c=t.localTileOffset.getPatternOffsetAtTileOrigin(i,o,a),l=s.multiply(e.scale).multiply(e.offset.subtract(c)).divide(r),u=new vn(e.pos,1),d=h.multiply(u).xy.subtract(l),p=e.tlbr.divide(t.mosaicInfo.size.xyxy);let _=Fa(e.bitset,4);return null!=t.visualVariableColor&&(_=Jn(Ea(t.storage.getColorValue(e.id)),new bn(0),_)),{tileTextureCoord:d,tlbr:p,sampleAlphaOnly:_}}function sh(t,e){const s=vo(e.tileTextureCoord,new bn(1)),i=wo(e.tlbr.xy,e.tlbr.zw,s);let r=Mo(t.mosaicInfo.texture,i);return r=Jn(ao(e.sampleAlphaOnly,new bn(.5)),r.aaaa,r),e.color.multiply(r)}(0,P._)([pa(5,Sn)],th.prototype,"tlbr",void 0),(0,P._)([pa(6,bn)],th.prototype,"width",void 0),(0,P._)([pa(7,bn)],th.prototype,"height",void 0),(0,P._)([pa(8,wn)],th.prototype,"offset",void 0),(0,P._)([pa(9,wn)],th.prototype,"scale",void 0),(0,P._)([pa(10,bn)],th.prototype,"angle",void 0);class ih extends Qa{vertex(t,e){return{...super.vertex(t,e),...eh(this,t)}}fragment(t){const e=sh(this,t);return this.getFragmentOutput(e,t,new bn(0))}}(0,P._)([fa(Ja)],ih.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],ih.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(th)),(0,P.a)(1,_a(Da))],ih.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(class extends Ba{}))],ih.prototype,"fragment",null);class rh extends Sa{getSize(t,e){const s=this.minMaxValueAndSize.xy,i=this.minMaxValueAndSize.zw;return Jn(Ea(t),e,(()=>{const e=_o(t.subtract(s.x).divide(s.y.subtract(s.x)),new bn(0),new bn(1));return i.x.add(e.multiply(i.y.subtract(i.x)))}))}}(0,P._)([fa(Sn)],rh.prototype,"minMaxValueAndSize",void 0);class nh extends Sa{getSizeForViewScale(t){return to([oo(t,this.values.first()),this.sizes.first()],[ho(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>ao(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.sizes.get(i),this.sizes.get(e),n)}])}}(0,P._)([fa(yn.ofType(bn,8))],nh.prototype,"sizes",void 0),(0,P._)([fa(yn.ofType(bn,8))],nh.prototype,"values",void 0);class oh extends Sa{getSize(t,e){const s=to([Ea(t),e],[oo(t,this.values.first()),this.sizes.first()],[ho(t,this.values.last()),this.sizes.last()],[!0,()=>{const e=this.values.findIndex((e=>ao(e,t))),s=this.values.get(e),i=e.subtract(1),r=this.values.get(i),n=t.subtract(r).divide(s.subtract(r));return wo(this.sizes.get(i),this.sizes.get(e),n)}]);return Jn(Ea(s),e,s)}}(0,P._)([fa(yn.ofType(bn,8))],oh.prototype,"sizes",void 0),(0,P._)([fa(yn.ofType(bn,8))],oh.prototype,"values",void 0);class ah extends Sa{getSize(t,e){return Jn(Ea(t),e,t.multiply(this.unitValueToPixelsRatio))}}(0,P._)([fa(bn)],ah.prototype,"unitValueToPixelsRatio",void 0);class hh extends Na{}(0,P._)([pa(3,Sn)],hh.prototype,"color",void 0),(0,P._)([pa(4,wn)],hh.prototype,"offset",void 0),(0,P._)([pa(5,wn)],hh.prototype,"normal",void 0),(0,P._)([pa(6,bn)],hh.prototype,"halfWidth",void 0),(0,P._)([pa(7,bn)],hh.prototype,"referenceHalfWidth",void 0),(0,P._)([pa(8,wn)],hh.prototype,"zoomRange",void 0);class ch extends Ba{}class lh extends Sa{}function uh(t){return xo(new bn(_r).multiply(Po(t,new bn(fr))),new bn(1))}function dh(t,e){const{id:s,offset:i,pos:r,normal:n,zoomRange:o}=e,{displayViewScreenMat3:a,displayViewMat3:h}=t.view,c=$a(t,s,e.color),l=Ha(t,s),u=function(t,e){const{id:s,halfWidth:i,referenceHalfWidth:r}=e;if(Xa(t)){const e=function(t,e,s){if(Xa(t)){const i=t.storage.getSizeValue(e);return t.visualVariableSizeMinMaxValue?.getSize(i,s)??t.visualVariableSizeScaleStops?.getSizeForViewScale(t.view.currentScale)??t.visualVariableSizeStops?.getSize(i,s)??t.visualVariableSizeUnitValue?.getSize(i,s)}return s}(t,s,new bn(2).multiply(r));return new bn(.5).multiply(i.divide(xo(r,new bn(mr)))).multiply(e)}return i}(t,e),d=new bn(.5).multiply(t.antialiasingControls.antialiasing),p=xo(u.add(d),new bn(.45)).add(new bn(.1).multiply(d)),_=uh(p).multiply(p).multiply(i),f=h.multiply(new vn(_,new bn(0))),m=a.multiply(new vn(r,new bn(1))).add(f),g=new bn(2).multiply(Po(u,new bn(0))).add(t.clip(s,o)),y=new Sn(m.xy,g,1);return{color:c,opacity:l,halfWidth:p,normal:n,scaledOffset:_,scaledHalfWidth:u,glPosition:new Sn(y.xy,g,1)}}function ph(t,e){const{opacity:s,color:i}=t,r=function(t,e){const{halfWidth:s,normal:i}=t,r=uh(s),n=yo(i).multiply(s);return _o(r.multiply(s.subtract(n)).divide(e.add(r).subtract(new bn(1))),new bn(0),new bn(1))}(t,e);return s.multiply(i).multiply(r)}(0,P._)([fa(bn)],lh.prototype,"antialiasing",void 0),(0,P._)([fa(bn)],lh.prototype,"blur",void 0);class _h extends Ga{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(t,e){const s=dh(this,t);return{...s,...this.maybeRunHittest(t,e,s.halfWidth)}}fragment(t){const e=ph(t,this.antialiasingControls.blur);return this.getFragmentOutput(e,t)}hittest(t,e,s){const{viewMat3:i,tileMat3:r}=this.view,n=i.multiply(r),o=n.multiply(new vn(t.pos,1)),a=n.multiply(new vn(e.nextPos1,1)),h=n.multiply(new vn(e.nextPos2,1)),{distance:c,smallSymbolDistance:l,smallSymbolSizeThreshold:u}=this.hittestRequest,d=Po(s,u.multiply(.5)).multiply(c.subtract(l)),p=this.hittestRequest.position;return bo(Ua(p,o.xy,a.xy),Ua(p,o.xy,h.xy)).subtract(s).add(d)}}(0,P._)([fa(lh)],_h.prototype,"antialiasingControls",void 0),(0,P._)([ma(Ya)],_h.prototype,"visualVariableColor",void 0),(0,P._)([ma(ja)],_h.prototype,"visualVariableOpacity",void 0),(0,P._)([ma(rh)],_h.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([ma(nh)],_h.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([ma(oh)],_h.prototype,"visualVariableSizeStops",void 0),(0,P._)([ma(ah)],_h.prototype,"visualVariableSizeUnitValue",void 0),(0,P._)([(0,P.a)(0,_a(hh)),(0,P.a)(1,_a(Da))],_h.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(ch))],_h.prototype,"fragment",null);class fh extends Na{}(0,P._)([pa(3,wn)],fh.prototype,"offset",void 0),(0,P._)([pa(4,Sn)],fh.prototype,"color",void 0),(0,P._)([pa(5,wn)],fh.prototype,"normal",void 0),(0,P._)([pa(6,bn)],fh.prototype,"halfWidth",void 0),(0,P._)([pa(7,bn)],fh.prototype,"referenceHalfWidth",void 0),(0,P._)([pa(8,wn)],fh.prototype,"zoomRange",void 0);class mh extends ch{}function gh(t,e,s){const{id:i,bitset:r}=e,n=Fa(r,0),o=ao(n,new bn(.5)),a=dh(t,e),h=Jn(o,a.halfWidth,new bn(0)),c=Ha(t,i),l=$a(t,i,e.color),u=Jn(o,e.color,l.multiply(c)),d=t.view.displayViewScreenMat3.multiply(new vn(e.pos.xy,1)),p=t.clip(e.id),_=new Sn(d.xy,p,1),f=Jn(o,a.glPosition,_),m=s&&t.maybeRunHittest(e,s,o);return{isOutline:n,color:u,opacity:new bn(1),halfWidth:h,normal:a.normal,glPosition:f,...m}}class yh extends Ga{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,P._)([fa(lh)],yh.prototype,"antialiasingControls",void 0),(0,P._)([ma(Ya)],yh.prototype,"visualVariableColor",void 0),(0,P._)([ma(ja)],yh.prototype,"visualVariableOpacity",void 0),(0,P._)([ma(rh)],yh.prototype,"visualVariableSizeMinMaxValue",void 0),(0,P._)([ma(nh)],yh.prototype,"visualVariableSizeScaleStops",void 0),(0,P._)([ma(oh)],yh.prototype,"visualVariableSizeStops",void 0),(0,P._)([ma(ah)],yh.prototype,"visualVariableSizeUnitValue",void 0);class xh extends yh{vertex(t,e){return gh(this,t,e)}fragment(t){const{color:e,isOutline:s}=t,i=ao(s,new bn(.5)),r=Jn(i,ph(t,this.antialiasingControls.blur),e),n=Jn(i,new bn(1/255),new bn(0));return this.getFragmentOutput(r,t,n)}hittest(t,e,s){return Jn(s,qa(this.hittestRequest),Wa(this,t,e))}}(0,P._)([(0,P.a)(0,_a(fh)),(0,P.a)(1,_a(Da))],xh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(mh))],xh.prototype,"fragment",null);class bh extends Za{}function wh(t,e){const s=e.tlbr.xy,i=e.tlbr.zw,r=i.x.subtract(s.x),n=s.y.subtract(i.y),o=new wn(r,n).multiply(e.inverseRasterizationScale),a=o.multiply(t.view.requiredZoomFactor),h=function(t){const e=new bn(1),s=new bn(0);return new Dn(e.divide(t.x),s.divide(t.y),0,Qn(s.divide(t.x)),e.divide(t.y),0,0,0,1)}(a),c=t.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),l=new vn(e.pos,1);return{tileTextureCoord:h.multiply(l).xy.subtract(c),tlbr:e.tlbr.divide(t.mosaicInfo.size.xyxy)}}function vh(t,e){const s=vo(t.tileTextureCoord,new bn(1)),i=wo(t.tlbr.xy,t.tlbr.zw,s),r=Mo(e.texture,i);return t.color.multiply(r)}(0,P._)([pa(5,Sn)],bh.prototype,"tlbr",void 0),(0,P._)([pa(6,bn)],bh.prototype,"inverseRasterizationScale",void 0);class Sh extends Qa{vertex(t,e){return{...super.vertex(t,e),...wh(this,t)}}fragment(t){const e=vh(t,this.mosaicInfo);return this.getFragmentOutput(e,t,new bn(0))}}(0,P._)([fa(Ja)],Sh.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],Sh.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(bh)),(0,P.a)(1,_a(Da))],Sh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(class extends Ba{}))],Sh.prototype,"fragment",null);class Ih extends fh{}(0,P._)([pa(9,Sn)],Ih.prototype,"tlbr",void 0),(0,P._)([pa(10,bn)],Ih.prototype,"inverseRasterizationScale",void 0);class Ph extends mh{}class Mh extends xh{vertex(t,e){return{...gh(this,t,e),...wh(this,t)}}fragment(t){const{isOutline:e}=t,s=ao(e,new bn(.5)),i=Jn(s,ph(t,this.antialiasingControls.blur),vh(t,this.mosaicInfo)),r=Jn(s,new bn(1/255),new bn(0));return this.getFragmentOutput(i,t,r)}}(0,P._)([fa(Ja)],Mh.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],Mh.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(Ih)),(0,P.a)(1,_a(Da))],Mh.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(Ph))],Mh.prototype,"fragment",null);const Th=1/16;class Ch extends Na{}(0,P._)([pa(3,Sn)],Ch.prototype,"color",void 0),(0,P._)([pa(4,Sn)],Ch.prototype,"tlbr",void 0),(0,P._)([pa(5,bn)],Ch.prototype,"angle",void 0),(0,P._)([pa(6,bn)],Ch.prototype,"aux1",void 0),(0,P._)([pa(7,bn)],Ch.prototype,"aux2",void 0),(0,P._)([pa(8,wn)],Ch.prototype,"aux3",void 0),(0,P._)([pa(9,wn)],Ch.prototype,"aux4",void 0),(0,P._)([pa(10,wn)],Ch.prototype,"zoomRange",void 0);class Ah extends yh{vertex(t,e){const{aux1:s,aux2:i,aux3:r,aux4:n}=t,o={...t,width:s,height:i,offset:r,scale:n.multiply(Th)},a=gh(this,{...t,halfWidth:s,referenceHalfWidth:i,offset:r,normal:n.subtract(128).multiply(Th)}),h=eh(this,o),c=ao(a.isOutline,new bn(.5));return{...a,...h,...this.maybeRunHittest(t,e,c)}}fragment(t){const{isOutline:e}=t,s=ao(e,new bn(.5)),i=Jn(s,ph(t,this.antialiasingControls.blur),sh(this,t)),r=Jn(s,new bn(1/255),new bn(0));return this.getFragmentOutput(i,t,r)}hittest(t,e,s){return Jn(s,qa(this.hittestRequest),Wa(this,t,e))}}(0,P._)([fa(Ja)],Ah.prototype,"mosaicInfo",void 0),(0,P._)([fa(Ka)],Ah.prototype,"localTileOffset",void 0),(0,P._)([(0,P.a)(0,_a(Ch)),(0,P.a)(1,_a(Da))],Ah.prototype,"vertex",null),(0,P._)([(0,P.a)(0,_a(class extends Ph{}))],Ah.prototype,"fragment",null);const Eh=vr,Fh=Er,kh={createComputedParams:t=>t,optionalAttributes:Eh.optionalAttributes,attributes:{...Eh.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>wr(t)},aux1:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).width},aux2:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>br(t).height},aux3:{count:2,type:pt.pe.HALF_FLOAT,pack:({offsetX:t,offsetY:e})=>[(0,l.Lz)(t),(0,l.Lz)(e)]},aux4:{count:2,type:pt.pe.UNSIGNED_BYTE,pack:({scaleX:t,scaleY:e})=>[16*t,16*e]}}},zh={createComputedParams:t=>t,optionalAttributes:Eh.optionalAttributes,attributes:{...Eh.attributes,color:Fh.attributes.color,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>rr([[0,!0]])},aux1:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.width)},aux2:{count:1,type:pt.pe.HALF_FLOAT,pack:t=>(0,l.Lz)(.5*t.referenceWidth)},aux3:{count:2,type:pt.pe.HALF_FLOAT,packTessellation:({extrusionOffsetX:t,extrusionOffsetY:e})=>[t,e]},aux4:{count:2,type:pt.pe.UNSIGNED_BYTE,packTessellation:({normalX:t,normalY:e})=>[16*t+128,16*e+128]}}};class Oh extends Fr{constructor(){super(...arguments),this.vertexSpec=zh}}class Rh extends kr{constructor(){super(...arguments),this.vertexSpec=kh}_createOutlineWriter(t,e,s,i){return new Oh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,Ie.fromOptimizedCIM(r,"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 Lh={optionalAttributes:lr.optionalAttributes,createComputedParams:t=>t,attributes:{...lr.attributes,...Ar.attributes}},Nh={optionalAttributes:lr.optionalAttributes,createComputedParams:t=>t,attributes:{...lr.attributes,...Er.attributes}};class Dh extends Fr{constructor(){super(...arguments),this.vertexSpec=Nh}}class Bh extends kr{constructor(){super(...arguments),this.vertexSpec=Lh}_createOutlineWriter(t,e,s,i){return new Dh(t,e,s,i)}_write(t,e,s){const i=s?.asOptimized()??e.readGeometryForDisplay(),r=this._clip(i);if(!r)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;t.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(t,e,r),this._lineMeshWriter.writeLineVertices(t,Ie.fromOptimizedCIM(r,"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 Gh={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1},offset:{type:pt.pe.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};class Uh extends Zi{constructor(){super(...arguments),this.vertexSpec=Gh}_write(t,e){t.recordStart(this.instanceId,this.attributeLayout);const s=e.getDisplayId();if("esriGeometryPoint"===e.geometryType){const i=e.readXForDisplay(),r=e.readYForDisplay();this._writeQuad(t,s,i,r)}else if("esriGeometryMultipoint"===e.geometryType){const i=e.readGeometryForDisplay();i?.forEachVertex(((e,i)=>{e>=0&&e<=512&&i>=0&&i<=512&&this._writeQuad(t,s,e,i)}))}t.recordEnd()}_writeQuad(t,e,s,i){const r=t.vertexCount();this._writeVertex(t,e,s,i),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}var Vh=s(91869),qh=s(48163),Wh=s(90708);const Yh=8388607,jh=t=>t&Yh;class Xh{constructor(t,e,s,i,r,n,o,a,h=[]){this.entityTexel=t,this.anchorX=e,this.anchorY=s,this.directionX=i,this.directionY=r,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)),Y(t,this.bounds)}static deserialize(t){const e=t.readInt32(),s=t.readF32(),i=t.readF32(),r=t.readF32(),n=t.readF32(),o=t.readF32(),a=t.readF32(),h=t.readF32(),c=t.readF32(),l=t.readF32(),u=j(t,Pi)??[];return new Xh(e,s,i,r,n,o,a,{size:h,offsetX:c,offsetY:l},u)}}const $h=1024;function Hh(t,e,s){return t[0]=e[0]-s[0],t[1]=e[1]-s[1],t}function Zh(t,e){return Math.sqrt(t*t+e*e)}function Qh(t){const e=Zh(t[0],t[1]);t[0]/=e,t[1]/=e}function Kh(t,e){return Zh(t[0]-e[0],t[1]-e[1])}function Jh(t){return t.length-1}function tc(t,e,s=1){let[i,r]=function(t,e){return t[e+1]}(t,e);return[i,r]=[Math.round(i),Math.round(r)],Math.sqrt(i*i+r*r)*s}class ec{constructor(t,e,s,i,r){this._segments=t,this._index=e,this._distance=s,this._xStart=i,this._yStart=r,this._done=!1}static create(t){return new ec(t,0,0,t[0][0],t[0][1])}clone(){return new ec(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<Jh(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 i=this.backwardLength;for(;this.prev();){if(i+this.length>t)return this._seekBackwards(t-i);i+=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 sc(t,e,s,i=!0){const r=function(t){let e=0;for(let s=0;s<Jh(t);s++)e+=tc(t,s);return e}(t),n=ec.create(t),o=r/2;if(!i)return n.seek(o),void(Math.abs(n.x)<$h&&Math.abs(n.y)<$h&&s(n.clone(),0,o+0*e,r));const a=Math.max((r-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)<$h&&Math.abs(n.y)<$h&&s(n.clone(),t,o+t*e,r),n.seek(e)}function ic(t,e){const s=e;for(let e=0;e<t.length;e++){let i=t[e];rc(i,s);const r=[];r.push(i[0]);for(let t=1;t<i.length;t++){const[e,s]=i[t-1],[n,o]=i[t],a=n-e,h=o-s;r.push([a,h])}t[e]=r,i=r}return t}function rc(t,e){const s=1e-6;if(e<=0)return;const i=t.length;if(i<3)return;const r=[];let n=0;r.push(0);for(let e=1;e<i;e++)n+=Kh(t[e],t[e-1]),r.push(n);e=Math.min(e,.2*n);const o=[];o.push(t[0][0]),o.push(t[0][1]);const a=t[i-1][0],h=t[i-1][1],c=Hh([0,0],t[0],t[1]);Qh(c),t[0][0]+=e*c[0],t[0][1]+=e*c[1],Hh(c,t[i-1],t[i-2]),Qh(c),t[i-1][0]+=e*c[0],t[i-1][1]+=e*c[1];for(let t=1;t<i;t++)r[t]+=e;r[i-1]+=e;const l=.5*e;for(let n=1;n<i-1;n++){let a=0,h=0,c=0;for(let i=n-1;i>=0&&!(r[i+1]<r[n]-l);i--){const o=l+r[i+1]-r[n],u=r[i+1]-r[i],d=r[n]-r[i]<l?1:o/u;if(Math.abs(d)<s)break;const p=d*d,_=d*o-.5*p*u,f=d*u/e,m=t[i+1],g=t[i][0]-m[0],y=t[i][1]-m[1];a+=f/_*(m[0]*d*o+.5*p*(o*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*o+.5*p*(o*y-u*m[1])-p*d*u*y/3),c+=f}for(let o=n+1;o<i&&!(r[o-1]>r[n]+l);o++){const i=l-r[o-1]+r[n],u=r[o]-r[o-1],d=r[o]-r[n]<l?1:i/u;if(Math.abs(d)<s)break;const p=d*d,_=d*i-.5*p*u,f=d*u/e,m=t[o-1],g=t[o][0]-m[0],y=t[o][1]-m[1];a+=f/_*(m[0]*d*i+.5*p*(i*g-u*m[0])-p*d*u*g/3),h+=f/_*(m[1]*d*i+.5*p*(i*y-u*m[1])-p*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<i;e++)t[e][0]=o[s++],t[e][1]=o[s++]}var nc=s(34727);class oc{static getPlacement(t,e,s,i,r,n){const o=function(t){if(!t)return null;switch(t.type){case"CIMMarkerPlacementAlongLineSameSize":return Is.local();case"CIMMarkerPlacementAtExtremities":return Ms.local();case"CIMMarkerPlacementAtRatioPositions":return Cs.local();case"CIMMarkerPlacementInsidePolygon":return zs.local();case"CIMMarkerPlacementOnLine":return Ls.local();case"CIMMarkerPlacementOnVertices":return Ds.local();case"CIMMarkerPlacementPolygonCenter":return ii.local()}return null}(s);return o?(-1===e&&t.invertY(),o.execute(t,s,i,r,n)):null}}class ac{constructor(t){const{offsetX:e,offsetY:s,postAngle:i,fontSize:r,scaleFactor:n,transforms:o}=t;if(this.offsetX=e,this.offsetY=s,this.postAngle=i,this.fontSize=Math.min(r,96),this.transforms=o,o&&o.infos.length>1){const t=(0,is.zb)(r,i,!1,e,s,o);this.fontSize=Math.min(t.size,96),this.postAngle=t.rotation,this.offsetX=t.offsetX,this.offsetY=t.offsetY}n&&(this.fontSize*=n,this.offsetX*=n,this.offsetY*=n)}}const hc=[4,4],cc=[16,4],lc={topLeft:cc,topRight:cc,bottomLeft:cc,bottomRight:cc},uc=[4,2],dc=[4,6],pc={topLeft:uc,topRight:uc,bottomLeft:dc,bottomRight:dc},_c={topLeft:uc,topRight:dc,bottomLeft:uc,bottomRight:dc},fc={topLeft:dc,topRight:dc,bottomLeft:hc,bottomRight:hc},mc={topLeft:hc,topRight:hc,bottomLeft:dc,bottomRight:dc},gc={topLeft:dc,topRight:hc,bottomLeft:dc,bottomRight:hc},yc={topLeft:hc,topRight:dc,bottomLeft:hc,bottomRight:dc},xc={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:pt.pe.UNSIGNED_SHORT,count:2,packPrecisionFactor:B.fq,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||28]},clipAngle:{type:pt.pe.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>wc(t||0)},referenceSymbol:{type:pt.pe.BYTE,count:4,packPrecisionFactor:1,packTessellation:(t,e)=>{if(!t.referenceBounds)return[0,0,0,0];const s=function(t){switch(t){case bi.Right:case"right":return-1;case bi.Center:case"center":return 0;case bi.Left:case"left":return 1;default:return console.debug(`Found invalid horizontal alignment ${t}`),0}}(e.horizontalAlignment),i=function(t){switch(t){case wi.Top:case"top":return 1;case wi.Center:case"middle":return 0;case wi.Bottom:case wi.Baseline:case"baseline":case"bottom":return-1;default:return console.debug(`Found invalid vertical alignment ${t}`),0}}(e.verticalAlignment),{offsetX:r,offsetY:n,size:o}=t.referenceBounds;return[(0,l.Lz)(r),-(0,l.Lz)(n),(0,l.Lz)(o),s+1<<2|i+1]}}},attributes:{pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>rr([[0,t],[3,!!e]])},offset:{type:pt.pe.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},textureUV:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:s,topLeft:i,topRight:r}=t;return[i,r,e,s]}}},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontSize:{type:pt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t})=>(0,l.Lz)(t)},referenceSize:{type:pt.pe.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:t},{referenceSize:e})=>(0,l.Lz)(e??t)},haloColor:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>nr(t)},haloFontSize:{type:pt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:t})=>(0,l.Lz)(t)}}};class bc extends Zi{constructor(){super(...arguments),this.vertexSpec=xc,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,s){super.ensurePacked(t,e,s),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new ac(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,s){const i=this._getShaping();if(!i)return;const r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,s);if(s?.nextPath())return s.nextPoint(),this._writeGlyphs(t,r,s.x,s.y,i,0);if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[n,o]=s.coords;return this._writeGlyphs(t,r,n,o,i,0)}if("esriGeometryMultipoint"===e.geometryType){const s=e.readGeometryForDisplay();return void s?.forEachVertex(((e,s)=>this._writeGlyphs(t,r,e,s,i,0)))}const n=e.readXForDisplay(),o=e.readYForDisplay();return this._writeGlyphs(t,r,n,o,i,0)}_writePlacedTextMarkers(t,e,s,i){const r=i??Ie.fromFeatureSetReaderCIM(e);if(!r)return;const n=oc.getPlacement(r,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,Ui());if(!n)return;const o=e.getDisplayId();let a=n.next();for(;null!=a;){const e=a.tx,i=-a.ty,r=-a.getAngle();this._writeGlyphs(t,o,e,i,s,r),a=n.next()}}_getShaping(t){const e=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const i=Math.round((0,l.Lz)(e.fontSize)),r=(0,l.Lz)(e.offsetX),n=(0,l.Lz)(e.offsetY),o=(0,nc.qE)((0,l.Lz)(s.lineWidth),B.GR,B.cp),a=B.DY*(0,nc.qE)(s.lineHeightRatio,.25,4);return function(t,e){const s=e.scale,i=new Array,{glyphs:r,isRightToLeft:n}=t,o=function(t,e,s){const i=new Array,r=1/s.scale,n=s.maxLineWidth*r,o=e?t.length-1:0,a=e?-1:t.length,h=e?-1:1;let c=o,l=0,u=0,d=c,p=d,_=0,f=1/0,m=0;for(;c!==a;){const{code:e,metrics:s}=t[c],r=Math.abs(s.top);if(ki(e)||zi(e)||(f=Math.min(f,r),m=Math.max(m,r+s.height)),ki(e))c!==o&&(i.push(new Fi(t,d,c-h,l,f,m)),f=1/0,m=0),l=0,d=c+h,p=c+h,u=0;else if(zi(e))p=c+h,u=0,_=s.advance,l+=s.advance;else if(l>n){if(p!==d){const e=p-2*h;l-=_,i.push(new Fi(t,d,e,l-u,f,m)),f=1/0,m=0,d=p,l=u}else i.push(new Fi(t,d,c-h,l,f,m)),f=1/0,m=0,d=c,p=c,l=0;l+=s.advance,u+=s.advance}else l+=s.advance,u+=s.advance;c+=h}const g=new Fi(t,d,c-h,l,f,m);return g.start>=0&&g.end<t.length&&i.push(g),i}(r,n,e),a=o.length?function(t,e){let s=0;for(let e=0;e<t.length;e++){const{width:i}=t[e];s=Math.max(i,s)}const i="underline"===e.decoration?4:0,r=t[0].yMin;return{x:0,y:r,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-r,width:s}}(o,e):{x:0,y:0,height:0,width:0},h=vi(e.horizontalAlignment),c=Si(e.verticalAlignment),l=c===wi.Baseline?1:0,u=l?0:c-1,d=(1-l)*-a.y+u*(a.height/2)+-22*(l?1:0);for(let t=0;t<o.length;t++){const{start:n,end:a,width:c}=o[t];let l=-1*(h+1)*(c/2)-3;const u=t*e.lineHeight+d-3;o[t].startX=l,o[t].startY=u;for(let t=n;t<=a;t++){const e=r[t];if(ki(e.code))continue;const n=new Ti(l+e.metrics.left,u-e.metrics.top,e,s);l+=e.metrics.advance,i.push(n)}}return new Ei(i,o,e)}(s.glyphs,{scale:i/B.eG,angle:e.postAngle,xOffset:r,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,i,r,n,o,a){const h=this.evaluatedMeshParams,c=this._textMeshTransformProps,u=c.fontSize,d=(0,l.Lz)(c.offsetX),p=(0,l.Lz)(c.offsetY),[_,f]=sr(h.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const m=r.bounds,g=s+m.x+d,y=i+m.y-p,x=2*(h.minPixelBuffer?h.minPixelBuffer/u:1),b=Math.max(m.width,m.height)*x;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),t.recordBounds(g,y,b,b),this._writeTextBox(t,e,s,i,r.textBox,o,a),t.recordEnd());for(const n of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(g,y,b,b);const{texcoords:r,offsets:c}=n;this._writeQuad(t,e,s,i,{texcoords:r,offsets:c,fontSize:u,color:nr(h.color),isBackground:!1,referenceBounds:o,minZoom:_,maxZoom:f,...a}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,s,i,r,n,o){const a=this.evaluatedMeshParams,{fontSize:h}=this._textMeshTransformProps,{boxBackgroundColor:c,boxBorderLineColor:l}=a,u={isBackground:!0,fontSize:h,referenceBounds:n,...o};c&&(this._writeQuad(t,e,s,i,{texcoords:lc,offsets:r.main,color:nr(c),...u}),l||(this._writeQuad(t,e,s,i,{texcoords:fc,offsets:r.top,color:nr(c),...u}),this._writeQuad(t,e,s,i,{texcoords:mc,offsets:r.bot,color:nr(c),...u}),this._writeQuad(t,e,s,i,{texcoords:gc,offsets:r.left,color:nr(c),...u}),this._writeQuad(t,e,s,i,{texcoords:yc,offsets:r.right,color:nr(c),...u}))),l&&(this._writeQuad(t,e,s,i,{texcoords:pc,offsets:r.top,color:nr(l),...u}),this._writeQuad(t,e,s,i,{texcoords:pc,offsets:r.bot,color:nr(l),...u}),this._writeQuad(t,e,s,i,{texcoords:_c,offsets:r.left,color:nr(l),...u}),this._writeQuad(t,e,s,i,{texcoords:_c,offsets:r.right,color:nr(l),...u}))}_writeQuad(t,e,s,i,r){const n=t.vertexCount();this._writeVertex(t,e,s,i,r),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 wc=t=>Math.round(t*(254/360)),vc=(0,Vh.Bj)((t=>{let e=0;if(0===t)return 1/0;for(;!(t%2);)e++,t/=2;return e}));class Sc extends bc{constructor(){super(...arguments),this._zoomLevel=0}_write(t,e,s,i){if(this._zoomLevel=i||0,null!=s)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(e.geometryType){case"esriGeometryPoint":{const s=e.readXForDisplay(),i=e.readYForDisplay();return this._writePoint(t,s,i,e)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const s=e.readCentroidForDisplay();if(!s)return;const[i,r]=s.coords;return this._writePoint(t,i,r,e)}case"esriGeometryPolyline":this._writeLines(t,e)}}_writePoint(t,e,s,i){const r=this._getShaping();if(!r)return;let n=this._getPointReferenceBounds();n||(n={offsetX:0,offsetY:0,size:0});const o=r.boundsT,a=vi(this.evaluatedMeshParams.horizontalAlignment),h=Si(this.evaluatedMeshParams.verticalAlignment),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0,u=jh(i.getDisplayId());t.metricStart(new Xh(u,e,s,a,h,c,l,n)),t.metricBoxWrite(o),this._writeGlyphs(t,i.getDisplayId(),e,s,r,0,n),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:i}=this.evaluatedMeshParams,r=this.evaluatedMeshParams.repeatLabelDistance||128,n=this._getShaping("middle");if(!n)return;const o=(t,e,s,i)=>this._placeSubdivGlyphs(t,e,s,i),a=(n.bounds.width+r)/2;this._current={out:t,id:e.getDisplayId(),shaping:n,zoomRange:sr(s,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null},this._verticalPlacement="bottom"===i?"above":"top"===i?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(e,o,a):this._writeCenterAlong(e,o,a)}_writeAboveAndBelowAlong(t,e,s){const{repeatLabel:i,fontSize:r}=this.evaluatedMeshParams,{shaping:n}=this._current,o=(0,l.Lz)(r),a=t.readGeometryForDisplay();if(!a)return;const h=new Wt.A;(0,Wh.kz)(h,a,!1,!1,"esriGeometryPolyline",1);const c=Ic(new Wt.A,h,o),u=Ic(new Wt.A,h,-o),d=(0,Wh.zv)(u,"esriGeometryPolyline",!1,!1),p=ic((0,Wh.zv)(c,"esriGeometryPolyline",!1,!1).paths,n.bounds.width),_=ic(d.paths,n.bounds.width);this._current.offsetDirection="above";for(const t of p)sc(t,s,e,!!i);this._current.offsetDirection="below";for(const t of _)sc(t,s,e,!!i)}_writeCenterAlong(t,e,s){const{repeatLabel:i}=this.evaluatedMeshParams,{shaping:r}=this._current,n=ic(t.readLegacyGeometryForDisplay().paths,r.bounds.width);for(const t of n)sc(t,s,e,!!i)}_placeSubdivGlyphs(t,e,s,i){const{allowOverrun:r,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],h=vc(e),c=this._current.shaping.bounds.width/2,l=Math.sqrt(o||128)/2,u=Math.min(s,i-s),d=this._current.shaping.isMultiline?28:Math.log2(u/(l+c/2)),p=0===e?d:Math.min(h,d),_=Math.max(a,this._zoomLevel+1-p),f=this._zoomLevel-_,m=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===e&&this._placeStraight(t,_):r&&f<0?this._placeStraightAlong(t,a):"parallel"===n?this._placeStraightAlong(t,_):"curved"===n&&this._placeCurved(t,_,m)}_placeStraight(t,e){const{out:s,id:i,shaping:r,referenceBounds:n}=this._current,{x:o,y:a}=t,h=jh(i),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Xh(h,t.x,t.y,0,0,c,l,null)),s.metricBoxWrite(r.boundsT);const u=t.angle*(180/Math.PI)%360,d=(t.angle*(180/Math.PI)+180)%360;this._writeGlyphs(s,i,o,a,r,0,n,{clipAngle:u,mapAligned:!0,isLineLabel:!0,minZoom:e}),this._writeGlyphs(s,i,o,a,r,0,n,{clipAngle:d,mapAligned:!0,isLineLabel:!0,minZoom:e}),s.metricEnd()}_placeCurved(t,e,s){const{out:i,id:r}=this._current,n=t.clone(),o=t.angle*(180/Math.PI)%360,a=(t.angle*(180/Math.PI)+180)%360,h=jh(r),c=this.evaluatedMeshParams.scaleInfo?.maxScale??0,l=this.evaluatedMeshParams.scaleInfo?.minScale??0;i.metricStart(new Xh(h,t.x,t.y,0,0,c,l,null)),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)),i.metricEnd()}_placeStraightAlong(t,e){const{out:s,id:i,shaping:r,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;if(r.glyphs.length>0&&(a||h)){const a=Math.max(e,n[0],0),h=Math.min(28,n[1]),c=ui(fi(),-t.angle),p={minZoom:a,maxZoom:h,clipAngle:u,mapAligned:!0,isLineLabel:!0},_=(0,l.Lz)(this.evaluatedMeshParams.offsetX),f=(0,l.Lz)(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e=(0,yi.fA)(_,-1*f),[n,a]=r.shapeBackground(li(fi(),c,e));s.recordStart(this.instanceId,this.attributeLayout,r.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,i,t.x,t.y,a,o,p),s.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e=(0,yi.fA)(_,f),[n,a]=r.shapeBackground(li(fi(),c,e));p.clipAngle=d,s.recordStart(this.instanceId,this.attributeLayout,r.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,i,t.x,t.y,a,o,p),s.recordEnd()}}const p=jh(i),_=this.evaluatedMeshParams.scaleInfo?.maxScale??0,f=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Xh(p,t.x,t.y,0,0,_,f,null)),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,i,r,n){const o=t.clone();let a=t.backwardLength+0;for(;o.prev()&&!(a>=i);)this._placeOnSegment(o,e,a,s,-1,r,n),a+=o.length+0}_placeForward(t,e,s,i,r,n){const o=t.clone();let a=t.remainingLength+0;for(;o.next()&&!(a>=i);)this._placeOnSegment(o,e,a,s,1,r,n),a+=o.length+0}_placeFirst(t,e,s,i,r=!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,p=Math.abs(u.x+u.width/2-a.bounds.x),_=Math.max(0,this._zoomLevel+Math.log2(p/(d+0))),f=Math.max(e,r?0:_);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,i,c,!0),s&&this._isVisible(u.minZoom,u.maxZoom)&&n.metricBoxWrite(u.bounds)}}_placeOnSegment(t,e,s,i,r,n,o){const{out:a,id:h,shaping:c,referenceBounds:l}=this._current,u=c.glyphs,d=t.dx/t.length,p=t.dy/t.length,_={x:t.x+s*-r*d,y:t.y+s*-r*p};for(const d of u){const u=d.x>c.bounds.x?n:1-n;if(!(u&&1===r||!u&&-1===r))continue;const p=Math.abs(d.x+d.width/2-c.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(p/s)-.1),m=Math.max(i,this._zoomLevel+Math.log2(p/(s+t.length+0)));if(0!==f&&(d.angle=t.angle+(1-n)*Math.PI,d.minZoom=m,d.maxZoom=f,this._writeLineGlyph(a,h,_.x,_.y,c.bounds,d,o,l,!0),n&&this._isVisible(d.minZoom,d.maxZoom))){const s=d.bounds,i=t.x-e.x,r=t.y-e.y,n=new Pi(s.center[0]+i,s.center[1]+r,s.width,s.height);a.metricBoxWrite(n)}}}_writeLineGlyph(t,e,s,i,r,n,o,a,h){const c=s+r.x,l=i+r.y,u=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(r.width,r.height)*u;t.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),t.recordBounds(c,l,d,d);const{texcoords:p,offsets:_}=n,f=this._textMeshTransformProps.fontSize;this._writeQuad(t,e,s,i,{texcoords:p,offsets:_,fontSize:f,color:nr(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=this._zoomLevel;return t<=s&&s<=e}}function Ic(t,e,s){const{coords:i,lengths:r}=e,n=(0,qh.vt)(),o=(0,qh.vt)(),a=(0,qh.vt)(),h=(0,qh.vt)(),c=(0,qh.vt)(),l=(0,qh.vt)();let u=0;for(let e=0;e<r.length;e++){const d=r[e];for(let e=0;e<d;e++){const r=2*(e+u-1),p=2*(e+u),_=2*(e+u+1);e>0?(0,F.hZ)(n,i[r],i[r+1]):(0,F.hZ)(n,0,0),(0,F.hZ)(o,i[p],i[p+1]),e<d-1?(0,F.hZ)(a,i[_],i[_+1]):(0,F.hZ)(a,0,0),0===e?(0,F.hZ)(h,0,0):((0,F.jb)(h,o,n),(0,F.S8)(h,h),(0,F.hZ)(h,h[1],-h[0])),e===d-1?(0,F.hZ)(c,0,0):((0,F.jb)(c,a,o),(0,F.S8)(c,c),(0,F.hZ)(c,c[1],-c[0])),(0,F.WQ)(l,h,c),(0,F.S8)(l,l);const f=l[0]*c[0]+l[1]*c[1];0!==f&&(0,F.hs)(l,l,f),(0,F.hs)(l,l,s),t.coords.push(o[0]+l[0],o[1]+l[1])}t.lengths.push(d),u+=d}return t}const Pc={createComputedParams:t=>t,optionalAttributes:Mr.optionalAttributes,attributes:{...Mr.attributes,bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:t,shouldScaleDash:e,isSDF:s})=>rr([[4,t],[2,e],[3,s]])},tlbr:{type:pt.pe.UNSIGNED_SHORT,count:4,pack:({sprite:t})=>{const{rect:e,width:s,height:i}=t,r=e.x+B.hM,n=e.y+B.hM;return[r,n,r+s,n+i]}},accumulatedDistance:{type:pt.pe.UNSIGNED_SHORT,count:1,packTessellation:({distance:t})=>t},segmentDirection:{type:pt.pe.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:t,directionY:e})=>[t,e]}}};class Mc extends Cr{constructor(t,e,s,i){super(t,e,s,i),this.vertexSpec=Pc,this._tessellationOptions.textured=!0}_write(t,e,s){const i=s??Ie.fromFeatureSetReaderCIM(e);if(!i)return;const{sprite:r}=this.evaluatedMeshParams;this._writeGeometry(t,e,i,r?.textureBinding)}}class Tc{static from(t){return"width"in t?this.fromSimpleMeshParams(t):this.fromComplexMeshParams(t)}static fromSimpleMeshParams(t){const e=new Tc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects),{type:s,width:i,height:r,angle:n,alignment:o,outlineSize:a,referenceSize:h,sprite:c,overrideOutlineColor:u}=t;return e.rawWidth=(0,l.Lz)(i),e.rawHeight=(0,l.Lz)(r),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.sizeRatio=c.sdf?2:1,e._computeSize(t,!1),e}static fromComplexMeshParams(t){const e=new Tc(t.sprite,t.color,t.outlineColor,t.minPixelBuffer,t.placement,t.scaleInfo,t.effects);let{alignment:s,transforms:i,size:r,scaleX:n,anchorX:o,anchorY:a,angle:h,colorLocked:c,frameHeight:u,widthRatio:d,offsetX:p,offsetY:_,outlineSize:f,referenceSize:m,scaleFactor:g,sizeRatio:y,isAbsoluteAnchorPoint:x,rotateClockwise:b,scaleSymbolsProportionally:w,sprite:v}=t;if(i&&i.infos.length>0){const t=(0,is.zb)(r,h,b,p,_,i);r=t.size,h=t.rotation,p=t.offsetX,_=t.offsetY,b=!1}g&&(r*=g,p*=g,_*=g);const S=n*(v.width/v.height);e.alignment=s,e.rawHeight=(0,l.Lz)(r),e.rawWidth=e.rawHeight*S,e.referenceSize=(0,l.Lz)(m),e.sizeRatio=y,e.angle=h,e.rotateClockwise=b,e.anchorX=o,e.anchorY=a,e.offsetX=(0,l.Lz)(p),e.offsetY=(0,l.Lz)(_),x&&r&&(v.sdf?e.anchorX=o/(r*d):e.anchorX=o/(r*S),e.anchorY=a/r);const I=w&&u?r/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,i,r,n,o){this.sprite=t,this.color=e,this.outlineColor=s,this.minPixelBuffer=i,this.placement=r,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.alignment=ut.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:i}=t,r=!!s.sdf,{rawWidth:n,rawHeight:o,sizeRatio:a,outlineSize:h}=this,c=n*a,l=o*a;if(r&&!i){const t=e&&n>o?c:n,s=o,i=h+2;this.computedWidth=Math.min(t+i,c),this.computedHeight=Math.min(s+i,l)}else this.computedWidth=c,this.computedHeight=l;const u=r?Math.max(s.width,s.height)/Math.max(c,l):1,d=.5*(c-this.computedWidth)*u,p=.5*(l-this.computedHeight)*u,_=s.rect.x+B.hM+d,f=s.rect.y+B.hM+p,m=_+s.width-2*d,g=f+s.height-2*p;this.texXmin=Math.floor(_),this.texYmin=Math.floor(f),this.texXmax=Math.ceil(m),this.texYmax=Math.ceil(g),this.computedWidth*=(this.texXmax-this.texXmin)/(m-_),this.computedHeight*=(this.texYmax-this.texYmin)/(g-f),this.anchorX*=c/this.computedWidth,this.anchorY*=l/this.computedHeight}}const Cc=0,Ac=1,Ec=2,Fc=3,kc=4,zc=128/Math.PI;const Oc={createComputedParams:t=>Tc.from(t),optionalAttributes:{zoomRange:{type:pt.pe.SHORT,count:2,packPrecisionFactor:B.fq,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}},attributes:{pos:{type:pt.pe.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:({sprite:t,alignment:e,scaleSymbolsProportionally:s,overrideOutlineColor:i,colorLocked:r})=>{let n=0;return t.sdf&&(n|=ir(Cc)),e===ut.C1.MAP&&(n|=ir(Ac)),s&&(n|=ir(Ec)),i&&(n|=ir(Fc)),r&&(n|=ir(kc)),n}},offset:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({angle:t,computedWidth:e,computedHeight:s,anchorX:i,anchorY:r,offsetX:n,offsetY:o,rotateClockwise:a})=>{const h=function(t,e,s,i,r=!1){const n=fi(),o=r?1:-1;return ai(n),(e||s)&&li(n,n,[e,-s]),i&&ci(n,n,.017453292519944444*o*-i),n}(0,n,o,-t,a),c=-(.5+i)*e,l=-(.5-r)*s,u=[c,l],d=[c+e,l],p=[c,l+s],_=[c+e,l+s];return(0,F.l0)(u,u,h),(0,F.l0)(d,d,h),(0,F.l0)(p,p,h),(0,F.l0)(_,_,h),[u,d,p,_]}}},textureUV:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:t,texXmin:e,texYmax:s,texYmin:i})=>[[e,i],[t,i],[e,s],[t,s]]}},color:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:t})=>nr(t)},outlineColor:{type:pt.pe.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>nr(t)},sizing:{type:pt.pe.UNSIGNED_BYTE,count:4,pack:({rawWidth:t,rawHeight:e,outlineSize:s,referenceSize:i})=>[or(Math.max(t,e),128),or(s,128),or(i,128),0]},placementAngle:{type:pt.pe.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:t})=>function(t){return function(t,e){return t%=256,Math.abs(t>=0?t:t+256)}(t*zc)}(t)},sizeRatio:{type:pt.pe.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sizeRatio:t})=>t}}};class Rc extends Zi{constructor(){super(...arguments),this.vertexSpec=Oc}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(t,e,s){const i=this.evaluatedMeshParams.sprite?.textureBinding,r=e.getDisplayId();t.recordStart(this.instanceId,this.attributeLayout,i);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),h=this.evaluatedMeshParams.offsetX,c=-this.evaluatedMeshParams.offsetY;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(t,e,s,o,a);else if(s?.nextPath()){s.nextPoint();const e=s.x,i=s.y;t.recordBounds(e+h,i+c,o,a),this._writeQuad(t,r,e,i)}else if("esriGeometryPolygon"===e.geometryType){const s=e.readCentroidForDisplay();if(!s)return;const[i,n]=s.coords;t.recordBounds(i+h,n+c,o,a),this._writeQuad(t,r,i,n)}else if("esriGeometryPoint"===e.geometryType){const s=e.readXForDisplay(),i=e.readYForDisplay();t.recordBounds(s+h,i+c,o,a),this._writeQuad(t,r,s,i)}else{const s=e.readGeometryForDisplay();s?.forEachVertex(((e,s)=>{t.recordBounds(e+h,s+c,o,a),Math.abs(e)>$h||Math.abs(s)>$h||this._writeQuad(t,r,e,s)}))}t.recordEnd()}_writePlacedMarkers(t,e,s,i,r){const n=s??Ie.fromFeatureSetReaderCIM(e)?.clone();if(!n)return;const o=oc.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,l.Lz)(1),t.id,Ui());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)>$h||Math.abs(s)>$h){h=o.next();continue}const n=-h.getAngle();t.recordBounds(e+c,s+u,i,r),this._writeQuad(t,a,e,s,n),h=o.next()}}_writeQuad(t,e,s,i,r){const n=t.vertexCount(),o=null==r?null:{placementAngle:r};this._writeVertex(t,e,s,i,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)}}function Lc(t){return Math.floor(function(t,e){let s;if("string"==typeof t)s=(0,lt.Wm)(t+`-seed(${e})`);else{let i=12;s=t^e;do{s=107*(s>>8^s)+i|0}while(0!=--i)}return(1+s/(1<<31))/2}(t,Nc)*Dc)}const Nc=53290320,Dc=10;class Bc{destroy(){}}class Gc extends Bc{constructor(t){super(),this._value=t}resize(t){}read(t,e){return this._value}readWithDefault(t,e,s){return this._value}referencesScale(){return!1}referencesGeometry(){return!1}}async function Uc(t,e,s=!1){const{defaultValue:i,valueExpressionInfo:r,value:n}=e;if(r){const{expression:n}=r,o=await t.createComputedField({expression:n},s);return o?{...e,computed:o,defaultValue:i}:null}return{...e,computed:new Gc(n),defaultValue:i}}async function Vc(t,e){const{defaultValue:s,valueExpressionInfo:i}=e,{expression:r}=i,n=await t.createComputedField({expression:r});return n?{...e,computed:n,defaultValue:s}:null}const qc=t=>"boolean"!=typeof t&&"number"!=typeof t&&"valueExpressionInfo"in t,Wc=t=>t.some((t=>{for(const e in t){const s=t[e];if(qc(s))return!0}return!1}));class Yc{static async create(t,e,s){const i={},r=new Map,n=new Map,o=new Map,a=new Map,h=new Map;for(const c in s){const l=s[c];if(null!=l&&"object"==typeof l)if(Array.isArray(l)){if("object"==typeof l[0])throw new Error(`InternalError: Cannot handle ${c}. Nested array params are not supported`);i[c]=l}else if("valueExpressionInfo"in l){if(l.value){i[c]=l.value;continue}const e=await Vc(t,l);if(!e){i[c]=l.defaultValue;continue}r.set(c,e),i[c]=null}else switch(l.type){case"cim-effect-infos":if(l.effectInfos.some((t=>t.overrides.length))){n.set(c,{effects:await Promise.all(l.effectInfos.map((async e=>{const s=e.overrides.map((e=>Uc(t,e)));return{effect:e.effect,compiledOverrides:(await Promise.all(s)).filter(_t.Ru)}})))});break}i[c]=l.effectInfos.map((t=>t.effect));break;case"cim-marker-placement-param":l.overrides.length&&o.set(c,{placementInfo:l,compiledOverrides:(await Promise.all(l.overrides.map((e=>Uc(t,e))))).filter(_t.Ru)}),i[c]=l.placement;break;case"text-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>Uc(t,e,l.useLegacyLabelEvaluationRules)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(_t.Ru),rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"sprite-rasterization-param":{if(l.overrides.length){const e=l.overrides.map((e=>Uc(t,e)));a.set(c,{compiledOverrides:(await Promise.all(e)).filter(_t.Ru),rasterizationParam:l,objectIdToResourceId:new Map});continue}if("animated"===l.resource.type){a.set(c,{compiledOverrides:[],rasterizationParam:l,objectIdToResourceId:new Map});continue}const s={type:"cim-rasterization-info",resource:l.resource};i[c]=await e.fetchResourceImmediate(s)??null;break}case"cim-marker-transform-param":{const{params:e}=l;if(Wc(e)){const s={compiledMarkerInfos:[]};await Promise.all(e.map((async e=>{const i={props:{}};for(const s in e)if(qc(e[s])){const r=await Vc(t,e[s]);i.compiledExpressionMap||(i.compiledExpressionMap=new Map);const n=i.compiledExpressionMap;r&&n.set(s,r)}else i.props[s]=e[s];s.compiledMarkerInfos.push(i)}))),h.set(c,s)}else i[c]={type:"cim-marker-transform-info",infos:e};break}default:i[c]=l}else i[c]=l}return new Yc(s,i,r,n,o,a,h)}constructor(t,e,s,i,r,n,o){this.inputMeshParams=t,this._resolvedMeshParams=e,this._dynamicProperties=s,this._dynamicEffectProperties=i,this._dynamicPlacementProperties=r,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this.evaluator=t=>t}get hasDynamicProperties(){return!!(this._dynamicProperties.size||this._dynamicAsyncProperties.size||this._dynamicEffectProperties.size||this._dynamicTransformProperties.size||this._dynamicPlacementProperties.size)}get evaluatedMeshParams(){return this._evaluatedMeshParams||(this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams)),this._evaluatedMeshParams}enqueueRequest(t,e,s){for(const r of this._dynamicAsyncProperties.values()){const n=(0,we.o8)(r.rasterizationParam.resource);"animated"===r.rasterizationParam.resource.type&&r.rasterizationParam.resource.randomizeStartTime&&(n.primitiveName="__RESERVED__PRIMITIVE__NAME__",n.startGroup=Lc(e.getObjectId()||0));for(const{primitiveName:t,propertyName:o,computed:a,defaultValue:h,valueExpressionInfo:c}of r.compiledOverrides)try{Yi(n,"animated"===r.rasterizationParam.resource.type?n.primitiveName:t,o,a,e,s,h)}catch(e){A.A.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new i.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});r.objectIdToResourceId.set(e.getObjectId(),o)}}evaluateMeshParams(t,e,s){for(const[t,i]of this._dynamicProperties.entries())this._resolvedMeshParams[t]=i.computed.readWithDefault(e,s,i.defaultValue);for(const[t,i]of this._dynamicPlacementProperties.entries())for(const{computed:r,defaultValue:n,propertyName:o}of i.compiledOverrides){const a=r.readWithDefault(e,s,n);i.placementInfo.placement[o]=a,this._resolvedMeshParams[t]=i.placementInfo.placement}for(const[t,i]of this._dynamicEffectProperties.entries())for(const r of i.effects){for(const{computed:t,defaultValue:i,propertyName:n}of r.compiledOverrides){const o=t.readWithDefault(e,s,i);r.effect[n]=o}this._resolvedMeshParams[t]=i.effects.map((t=>t.effect))}for(const[t,i]of this._dynamicTransformProperties.entries()){const r={type:"cim-marker-transform-info",infos:[]};for(const t of i.compiledMarkerInfos){const i={...t.props};if(t.compiledExpressionMap)for(const[r,n]of t.compiledExpressionMap){const t=n.computed.readWithDefault(e,s,n.defaultValue);i[r]="number"==typeof t||"boolean"==typeof t?t:n.defaultValue}r.infos.push(i)}this._resolvedMeshParams[t]=r}for(const[s,i]of this._dynamicAsyncProperties.entries()){const r=i.objectIdToResourceId.get(e.getObjectId());if(null==r)continue;const n=t.getResource(r);this._resolvedMeshParams[s]=n}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}}const jc={createComputedParams:t=>t,optionalAttributes:{},attributes:{pos:{type:pt.pe.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:pt.pe.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:t=>0},offset:{type:pt.pe.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:t})=>{const e=(0,l.Lz)(t),s=-e/2,i=-e/2;return[[s,i],[s+e,i],[s,i+e],[s+e,i+e]]}}},texCoords:{type:pt.pe.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:pt.pe.UNSIGNED_BYTE,count:2,pack:({size:t})=>[t,t]},referenceSize:{type:pt.pe.UNSIGNED_BYTE,count:1,pack:({size:t})=>(0,l.Lz)(t)},zoomRange:{type:pt.pe.UNSIGNED_BYTE,count:2,pack:({scaleInfo:t},{tileInfo:e})=>sr(t,e)}}};class Xc extends Zi{constructor(){super(...arguments),this.vertexSpec=jc}_write(t,e){const s=e.getDisplayId(),i=this.evaluatedMeshParams.minPixelBuffer,r=Math.max((0,l.Lz)(this.evaluatedMeshParams.size),i);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,r,r);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 $c{async createMeshWriter(t,e,s,i){const r=this._getMeshWriter(i.techniqueType),n=await Yc.create(t,e,i.inputParams),o=new r(i.id,n,i.optionalAttributes,s);return await o.loadDependencies(),o}_getMeshWriter(t){switch(t){case Ut.Fill:return cr;case Ut.DotDensity:return tr;case Ut.ComplexFill:return Sr;case Ut.PatternFill:return ur;case Ut.OutlineFill:return kr;case Ut.PatternOutlineFill:return Bh;case Ut.ComplexOutlineFill:return Rh;case Ut.Marker:return Rc;case Ut.PieChart:return Xc;case Ut.Text:return bc;case Ut.Line:return Cr;case Ut.TexturedLine:return Mc;case Ut.Heatmap:return Uh;case Ut.Label:return Sc;case Ut.Test:throw new Error("Internal Error: Found invalid mesh writer")}}}class Hc{constructor(t,e,s,i){this.storage=t,this.proxy=e,this.viewParams=s,this.registry=i}async createMeshWriters(t){const e=t.map((t=>this.registry.createMeshWriter(this.storage,this.proxy,this.viewParams,t)));return Promise.all(e)}}class Zc{constructor(t){this._outstandingMessages=[],this._queue=new k.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 Qc=s(43334),Kc=s(31464);class Jc{static async create(t,e){if("count"===e.statisticType){const t=new Gc(1);return new Jc(e.name,e.alias,e.type,e.statisticType,t)}const s=await t.createComputedField({expression:e.onStatisticExpression?.expression,field:e.onStatisticField});return new Jc(e.name,e.alias,e.type,e.statisticType,s)}constructor(t,e,s,i,r){this.name=t,this.alias=e,this.type=s,this.statisticType=i,this.computed=r}}var tl=s(65529),el=s(70328),sl=s(37730),il=s(17970);class rl{constructor(t){this.subscription=t,this.handledChunks=new Set}destroy(){}}class nl{constructor(t,e){this._source=t,this._attributeStore=e,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}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(){}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 ol extends nl{constructor(t,e,s,i){super(t,e),this.spatialReference=s,this.aggregateFields=i,this.events=new tl.A,this.featureAdapter=sl.T}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new il.d({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}removeChunks(t){}forEach(t){return this.forEachAggregateWorldSpace(t)}forEachInBounds(t,e){}forEachBounds(t,e){const s=(0,el.vt)();for(const i of t){const t=(0,Wh.jQ)(s,i.geometry,!1,!1);t&&e(t)}}}class al{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.clear=s,this.end=i,this.debugInfo=r,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 hl{constructor(t,e,s,i,r){this.subscription=t,this.reader=e,this.remove=s,this.end=i,this.debugInfo=r,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 cl extends Bc{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)}referencesScale(){return!1}referencesGeometry(){return!1}}var ll=s(71386);function ul(t,e,s){if(null==t)return null;const i=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;try{return t.evaluate({...s,$feature:i},t.services)}catch(t){return A.A.getLogger("esri.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",t),null}}function dl(t){return null==t||t===1/0||t===-1/0||"number"==typeof t&&isNaN(t)}function pl(t,e,s,i){if(null==t)return null!=i?i:null;const r=e.readArcadeFeature();e.contextTimeZone=s.$view?.timeZone;const n=t.evaluate({...s,$feature:r},t.services);return dl(n)?null!=i?i:null:n}class _l extends Bc{static async create(t,e){const s=await(0,ll.Ad)(t,e.spatialReference,e.fields),i=(0,lt.Wm)(t);return new _l(s,i)}constructor(t,e){super(),this._compiled=t,this._cacheKey=e}resize(t){}read(t,e){return this.referencesScale()||"system"!==e.$view.timeZone?ul(this._compiled,t,e):this._readCached(t,e)}readWithDefault(t,e,s){return this.referencesScale()||"system"!==e.$view.timeZone?pl(this._compiled,t,e,s):this._readWithDefaultCached(t,e,s)}referencesScale(){return this._compiled?.referencesScale()??!1}referencesGeometry(){return this._compiled?.referencesGeometry()??!1}_readCached(t,e){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const s=ul(this._compiled,t,e);return t.setCachedValue(s),s}_readWithDefaultCached(t,e,s){if(t.setCache(this._cacheKey),t.hasCachedValue())return t.getCachedValue();const i=pl(this._compiled,t,e,s);return t.setCachedValue(i),i}}var fl=s(97770),ml=s(18047),gl=s(56721),yl=s(30524),xl=s(32730);class bl extends Bc{static async create(t,e){const s=(0,xl.lc)(t);return new bl((t=>s.replaceAll(/{[^}]*}/g,(e=>{const s=e.slice(1,-1),i=t.metadata.fieldsIndex.get(s);if(null==i)return e;const r=t.readAttribute(s);return null==r?"":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:i,min:r}=(0,gl.A5)(e),n=+t;if(null!=r&&null!=i&&r<=n&&n<=i)return s.name}let i=t;return(0,yl.vE)(e)?i=(0,fl.Yq)(i,(0,fl.J2)("short-date")):(0,yl.WA)(e)&&(i=(0,ml.ZV)(+i)),i||""}(r,i)}))))}constructor(t){super(),this._evaluator=t}resize(t){}read(t,e){return this._evaluator(t)}readWithDefault(t,e,s){const i=this._evaluator(t);return dl(i)?s:i}referencesScale(){return!1}referencesGeometry(){return!1}}class wl extends Bc{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)}referencesScale(){return!1}referencesGeometry(){return!1}_readNormalized(t){const e=t.readAttribute(this._field);if(null==e)return null;const{normalizationField:s,normalizationTotal:i,normalizationType:r}=this._normalizationInfo,n=t.readAttribute(s);switch(r??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?e/n:void 0:null;case"esriNormalizeByLog":return Math.log(e)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return i?e/i*100:null}}}class vl{static fromBuffer(t,e){return new vl(t,e)}static create(t,e=4294967295){const s=new Uint32Array(Math.ceil(t/32));return new vl(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,i=e;for(;s%32&&s!==i;){if(this.has(s))return!0;s++}for(;i%32&&s!==i;){if(this.has(s))return!0;i--}if(s===i)return!1;for(let t=s/32;t!==i/32;t++)if(this._buf[t])return!0;return!1}set(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]|=i}setRange(t,e){let s=t,i=e;for(;s%32&&s!==i;)this.set(s++);for(;i%32&&s!==i;)this.set(i--);if(s!==i)for(let t=s/32;t!==i/32;t++)this._buf[t]=4294967295}unset(t){const e=this._mask&t,s=this._getIndex(e),i=1<<e%32;this._buf[s]&=4294967295^i}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 vl(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],i=32*e;if(s)for(;s;)1&s&&t(i),s>>>=1,i++}}countSet(){let t=0;return this.forEachSet((e=>{t++})),t}}var Sl=s(39516);const Il=()=>A.A.getLogger("esri.views.2d.layers.features.support.whereUtils"),Pl={getAttribute:(t,e)=>t.readAttribute(e)};async function Ml(t,e){try{const s=await(0,Sl.G)(t,e);if(!s.isStandardized){const t=new i.A("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",s);Il().error(t)}return e=>{const i=e.readArcadeFeature();try{return s.testFeature(i,Pl)}catch(e){return Il().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),!0}}}catch(e){return Il().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",t),t=>!0}}const Tl=()=>A.A.getLogger("esri.views.2d.layers.features.support.ComputedAttributeStorage"),Cl=4294967295;function Al(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(s)}class El{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(vl.create(this._allocatedSize,Yh)),t+1}async createComputedField(t,e=!1){if(t.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return e?bl.create(t.expression,this.compilationOptions):await _l.create(t.expression,this.compilationOptions)}catch(e){const s=new i.A("featurelayer","Failed to compile arcade expression",{error:e,expression:t.expression});return Tl().error(s),null}if(t.normalizationType||t.normalizationField)return new wl(t.field,t);if(t.field)return new cl(t.field);const s=new i.A("featurelayer","Unable to create computed field. No expression or field found",{info:t});return Tl().error(s),null}async createWhereClause(t){return t?Ml(t,this.compilationOptions.fields):null}getBitset(t){return this._bitsets[t-1]}getComputedNumeric(t,e){return this.getComputedNumericAtIndex(t&Yh,0)}setComputedNumeric(t,e,s){return this.setComputedNumericAtIndex(t&Yh,s,0)}getComputedString(t,e){return this.getComputedStringAtIndex(t&Yh,0)}setComputedString(t,e,s){return this.setComputedStringAtIndex(t&Yh,0,s)}getComputedNumericAtIndex(t,e){const s=t&Yh;return this._ensureNumeric(e,s),this._numerics[e][s]}setComputedNumericAtIndex(t,e,s){const i=t&Yh;this._ensureNumeric(e,i),this._numerics[e][i]=s}getPackedChunkId(t){const e=t&Yh;return this._ensureInstanceId(e),this._instanceIds[e]}setPackedChunkId(t,e){const s=t&Yh;this._ensureInstanceId(s),this._instanceIds[s]=e}getComputedStringAtIndex(t,e){const s=t&Yh;return this._ensureString(e,s),this._strings[e][s]}setComputedStringAtIndex(t,e,s){const i=t&Yh;this._ensureString(e,i),this._strings[e][i]=s}getXMin(t){return this._bounds[4*(t&Yh)]}getYMin(t){return this._bounds[4*(t&Yh)+1]}getXMax(t){return this._bounds[4*(t&Yh)+2]}getYMax(t){return this._bounds[4*(t&Yh)+3]}setBounds(t,e,s=!1){const i=t&Yh;if(!s&&!this._dirtyBitset.has(t))return this._bounds[4*i]!==Cl;this._dirtyBitset.unset(t);const r=e.readGeometryWorldSpace();if(Al(this._bounds,4*i+4,0),!r||!r.coords.length)return this._bounds[4*i]=Cl,this._bounds[4*i+1]=Cl,this._bounds[4*i+2]=Cl,this._bounds[4*i+3]=Cl,!1;let n=1/0,o=1/0,a=-1/0,h=-1/0;return r.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*i]=n,this._bounds[4*i+1]=o,this._bounds[4*i+2]=a,this._bounds[4*i+3]=h,!0}getBounds(t,e){const s=this.getXMin(e),i=this.getYMin(e),r=this.getXMax(e),n=this.getYMax(e);return(0,el.BI)(t,s,i,r,n),s!==Cl}_ensureNumeric(t,e){this._numerics[t]||(this._numerics[t]=[]),Al(this._numerics[t],e,0)}_ensureInstanceId(t){Al(this._instanceIds,t,0)}_ensureString(t,e){this._strings[t]||(this._strings[t]=[]),Al(this._strings[t],e,null)}}var Fl=s(58727),kl=s(62660),zl=s(86420),Ol=s(61956);class Rl{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()}}Rl.Shared=new Rl;class Ll{constructor(t){this._geometryBounds=(0,D.vt)(),this._idToVisibility=new Map,this._serviceInfo=t}static async create(t){const e=new Ll(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=[],i=new Set(t);return this._idToVisibility.forEach(((t,r)=>{const n=!!(1&this._idToVisibility.get(r)),o=i.has(r);!n&&o?e.push(r):n&&!o&&s.push(r),this._idToVisibility.set(r,o?3:0)})),{show:e,hide:s}}createQuery(){const{geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r}=this;return Ol.A.fromJSON({geometry:t,spatialRel:e,where:s,timeExtent:i,objectIds:r})}async update(t,e){this._hash=JSON.stringify(t);const s=await(0,Fl.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 Ml(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",i=await(0,kl.xt)(s,e,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,gs.Rg)(this._geometryBounds,e),this._spatialQueryOperator=i,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,zl.I)(this._serviceInfo.timeInfo,t.timeExtent,Rl.Shared);else{const e=new i.A("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",t.timeExtent);A.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}}var Nl=s(95466);class Dl{static minimal(t,e,s=[]){return new Dl({geometryType:t,fields:s,objectIdField:e,subtypes:null,subtypeField:null,types:null,globalIdField:null,spatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null})}constructor(t){this._options=t,this._fieldsIndex="fieldsIndex"in t?Nl.A.fromJSON(t.fieldsIndex):new Nl.A(t.fields),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 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 Bl=s(66131),Gl=s(44729),Ul=s(15032),Vl=s(27647),ql=s(56400);class Wl{constructor(t){this._valid=vl.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 Yl=(0,n.A)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],jl=Yl[0],Xl=Yl[1],$l=Yl[2],Hl=Yl[3],Zl=(0,n.A)("featurelayer-simplify-payload-size-factors")??[1,2,4],Ql=Zl[0],Kl=Zl[1],Jl=Zl[2],tu=(0,n.A)("featurelayer-simplify-mobile-factor")??2,eu=(0,n.A)("esri-mobile"),su=4294967295;class iu{constructor(t){this.metadata=t,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(t,e){let s=1;const i=eu?tu:1;e>4e6?s=Jl*i:e>1e6?s=Kl*i:e>5e5?s=Ql*i:e>1e5&&(s=i);let r=0;return t>4e3?r=Hl*s:t>2e3?r=$l*s:t>100?r=Xl:t>15&&(r=jl),r}parseTimestampOffset(t){return t}getBounds(t){if(function(t,e,s){if(!(t.length>e))for(;t.length<=e;)t.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===su)return!1;if(0===this.getBoundsXMin()){const e=this.readGeometryWorldSpace();if(!e)return this.setBoundsXMin(su),!1;let s=1/0,i=1/0,r=-1/0,n=-1/0;return e.forEachVertex(((t,e)=>{s=Math.min(s,t),i=Math.min(i,e),r=Math.max(r,t),n=Math.max(n,e)})),this.setBoundsXMin(s),this.setBoundsYMin(i),this.setBoundsXMax(r),this.setBoundsYMax(n),(0,el.BI)(t,s,i,r,n),!0}const e=this.getBoundsXMin(),s=this.getBoundsYMin(),i=this.getBoundsXMax(),r=this.getBoundsYMax();return(0,el.BI)(t,e,s,i,r),!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 i=s._readAttribute(t,e);if(void 0!==i)return i}}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)}removeIds(t){if(null==this._objectIdToIndex){const t=new Map,e=this.getCursor();for(;e.next();){const s=e.getObjectId();(0,T.Lw)(s),t.set(s,e.getIndex())}this._objectIdToIndex=t}const e=this._objectIdToIndex;for(const s of t.values())e.has(s)&&this._removeAtIndex(e.get(s))}readOptimizedFeatureWorldSpace(){const t=this.readGeometryWorldSpace(),e=this.readAttributes(),s=this.readCentroidWorldSpace(),i=new Qc.Om(t,e,s);return i.objectId=this.getObjectId(),i.displayId=this.getDisplayId(),i}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,Wh.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}readGeometryWorldSpace(){let t=this._readGeometry();if(t||(t=this._createGeometryFromServerCentroid()),!t)return null;const e=t.clone(),s=this.getInTransform();return null!=s&&(0,Wh.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(),i=this.getInTransform();return null!=i&&(0,Wh.Ch)(s,s,this.hasZ,this.hasM,i),s}setCache(t){let e=this._caches.get(t);null==e&&(e=new Wl(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,Wh.zv)(t,this.geometryType,this.hasZ,this.hasM),s=(0,Se.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)?Bl.lY.unknownDateJSToArcadeDate(e):Bl.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 Gl.n.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Ul.k.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Bl.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 Gl.n.fromReader(s._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return Ul.k.fromReader(s._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return Bl.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(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(t){if(null==this.getInTransform())return(0,Vl.Q)(new Wt.A,t,this.hasM,this.hasZ);const e=Ie.fromOptimized(t,this.geometryType);e.yFactor*=-1;const s=qs(e);return s?(s[1]*=-1,new Wt.A([],s)):null}copyInto(t){t._joined=this._joined,t._deleted=this._deleted,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,Wh.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 Wt.A([5],[t-1,e,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(t,e){return new Wt.A([2],[t-1,e+1,1,-1])}_removeAtIndex(t){null==this._deleted&&(this._deleted=vl.create(this.getSize())),this._deleted.set(t)}}class ru extends iu{static fromFeatures(t,e){const{objectIdField:s,geometryType:i}=e,r=(0,Wh.Di)([],t,i,!1,!1,s);for(let e=0;e<r.length;e++)r[e].displayId=t[e].displayId;return ru.fromOptimizedFeatures(r,e)}static fromFeatureSet(t,e){const s=(0,Wh.q3)(t,e.objectIdField);return ru.fromOptimizedFeatureSet(s,e)}static fromOptimizedFeatureSet(t,e){const s=ru.fromOptimizedFeatures(t.features,e);return s._exceededTransferLimit=t.exceededTransferLimit,s._transform=t.transform,s._fieldsIndex=new Nl.A(t.fields),s}static fromOptimizedFeatures(t,e,s){const i=new ru(t,e);return i._fieldsIndex=e.fieldsIndex,i._transform=s,i}static empty(t){return new ru([],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]}removeIds(t){const e=new Set(t);this._features=this._features.filter((t=>!(null!=t.objectId&&e.has(t.objectId))))}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 ru(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,Qc.N3)(this._current)?(0,Wh.Rk)(this._current.geometry,2):0}_readX(){return(0,Qc.N3)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,Qc.N3)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,Qc.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;let i=this._current.attributes[s.name];return null==i?i:("esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i)),e&&this.fields.isDateField(t)?new Date(i):i)}_readAttributes(){return this._current.attributes}copyInto(t){super.copyInto(t),t._featureIndex=this._featureIndex,t._transform=this._transform,t._fieldsIndex=this._fieldsIndex}}class nu extends rl{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,Wh.Ch)(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}class ou extends ol{static async create(t,e,s,i,r){const n=new El({spatialReference:e}),o=await Promise.all(t.fields.map((async t=>Jc.create(n,t)))),a=t.featureFilter?await Ll.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,Kc.Nk)(e,q.A.WGS84),new ou(t,a,r,o,e,s,i)}constructor(t,e,s,i,r,n,o){super(n,o,r,i),this._schema=t,this._featureFilter=e,this._timeZone=s,this._metadata=new Dl({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:t.fields,globalIdField:null,spatialReference:n.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(t){return new nu(t,this._attributeStore)}async*applyLocalEdit(t){for(const t of this._sendStates.values()){t.reset();const e=new al(t.subscription,ru.empty(this._source.metadata),!0,!1,{});yield e}}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._sendStates.values())for(const e of t.featuresWorldSpace()){const{objectId:t,displayId:n}=e,o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._sendStates.values())for(const r of t.featuresWorldSpace())e.has(r.displayId)&&!s.has(r.objectId)&&(r.geometry&&i.push({...(0,Wh.oN)(r,this._metadata.geometryType,!1,!1),displayId:r.displayId}),s.add(r.objectId));return{features:[],aggregates:i}}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(){if(this._source.chunks().length)for(const t of this._sendStates.values())yield*this._update(t,this._source)}forEachAggregateWorldSpace(t){for(const e of this._sendStates.values())for(const s of e.featuresWorldSpace())t(s)}_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,timeZone:this._timeZone,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,timeZone:this._timeZone,scale:s}}}}async*_update(t,e){const{handledChunks:s,subscription:i,bins:r,featureCache:n}=t,o=i.tile;if(t.done)return;for(const i of e.chunks()){if(s.has(i.chunkId))continue;s.add(i.chunkId);const e=i.queryInfo;if("tileId"in e){const t=new p.A(e.tileId);if(t.level!==o.level||t.world!==o.key.world)continue}i.getAggregateIndex(this._createIndexOptions(t.tile)).putBounded(r,t.tile.extent,t.tile.resolution)}const a=[],h=i.tile.transform,c=i.tile.key.level;for(const t of r.values()){let e=n.get(t.id);if(!e){const s=t.getGeometry(this.spatialReference,h);e=new Qc.Om(s,t.getAttributes(),null),s||(e.centroid=t.getGeometricCentroid(this.spatialReference,h)),e.objectId=t.id,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=ru.fromOptimizedFeatures(a,this._metadata,h),u=l.getCursor(),d=t.subscription.tile.createArcadeEvaluationOptions(this._timeZone);for(;u.next();)this._attributeStore.setAttributeData(u.getDisplayId(),u,d);const _=new hl(t.subscription,l,[],t.done,{});yield _}}class au{constructor(t){this._statistics=t}get statistics(){return this._statistics}}const hu=Math.PI/180;class cu{static create(t){return new cu(t.map((t=>function(t){switch(t.statisticType){case"min":return new uu(t);case"max":return new du(t);case"avg":return new _u(t);case"avg_angle":return new fu(t);case"sum":case"count":return new pu(t);case"mode":return new mu(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],i=t._statistics[e];if(s.field.name!==i.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");s.merge(i)}}clone(){return new cu(this._statistics.map((t=>t.clone())))}}class lu{constructor(t){this.field=t}insert(t,e){if(!this.field.computed)return;const s=this.field.computed.read(t,e);dl(s)||this._insertValue(s)}}class uu extends lu{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 uu(this.field);return t.value=this.value,t}}class du extends lu{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 du(this.field);return t.value=this.value,t}}class pu extends lu{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(t){this.value+=t}merge(t){this.value+=t.value}clone(){const t=new pu(this.field);return t.value=this.value,t}}class _u extends lu{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 _u(this.field);return t._total=this._total,t._count=this._count,t}}class fu extends lu{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*hu),this._y=this._y+Math.sin(t*hu),this._count+=1}merge(t){this._x+=t._x,this._y+=t._y,this._count+=t._count}clone(){const t=new fu(this.field);return t._x=this._x,t._y=this._y,t._count=this._count,t}}class mu extends lu{constructor(){super(...arguments),this._frequencies=new Map}get value(){let t,e=0;for(const[s,i]of this._frequencies.entries())i>e&&(e=i,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 mu(this.field);return t._frequencies=new Map(this._frequencies),t}}class gu extends au{static createId(t,e){return`${t}.${e}`}static create(t,e,s,i){return new gu(t,e,cu.create(s),i)}constructor(t,e,s,i){super(s),this.gridX=t,this.gridY=e,this._worldUnitsPerCell=i,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return gu.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 gu(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,i){0===this._count?this._firstFeatureAttributes=t.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=s,this._yWorldTotal+=i,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,Wh.IE)(t,this.centroidXWorld)}getCentroidY(t){return null==t?this.centroidYWorld:(0,Wh.B2)(t,this.centroidYWorld)}getGeometry(t,e){const s=this.gridX*this._worldUnitsPerCell,i=this.gridY*this._worldUnitsPerCell,r=new Wt.A([4],[s,i,s+this._worldUnitsPerCell,i,s+this._worldUnitsPerCell,i+this._worldUnitsPerCell,s,i+this._worldUnitsPerCell]);if(null!=e){const t=new Wt.A;return(0,Wh.Nl)(t,r,!1,!1,"esriGeometryPolygon",e)}return r}getCentroid(t){const e=new Wt.A([],[this.centroidXWorld,this.centroidYWorld]);if(null!=t){const s=new Wt.A;return(0,Wh.Nl)(s,e,!1,!1,"esriGeometryPoint",t)}return e}getGeometricCentroid(t,e){const s=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,i=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,r=new Wt.A([],[s,i]);if(null!=e){const t=new Wt.A;return(0,Wh.Nl)(t,r,!1,!1,"esriGeometryPoint",e)}return r}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 yu=s(83047);class xu{constructor(t){this._options=t}insert(t,e){const s=t.getCursor(),i={$view:{scale:this._options.scale,timeZone:this._options.timeZone}};for(;s.next();)this._insertFeature(s,i,e)}_insertFeature(t,e,s){const{featureFilter:i}=this._options;if(null!==i&&!i.check(t))return;let r=0,n=0;if("esriGeometryPoint"===t.geometryType)r=t.readXWorldSpace(),n=t.readYWorldSpace();else{if(s){const e=t.readCentroidForDisplay();if(null==e)return;const[s,i]=e.coords;if(s<0||s>B.CQ||i<0||i>B.CQ)return}const e=t.readCentroidWorldSpace();if(null==e)return;r=e.coords[0],n=e.coords[1]}this._insert(t,r,n,e)}}function bu(t,e){return(0,yu.GA)(t)*yu.dy*96/e}class wu extends xu{constructor(t){super(t),this._cells=new Map,this._pixelsPerMapUnit=bu(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 i=[e.xmin,e.ymin,e.xmax,e.ymax],[r,n,o,a]=i,h=Math.floor(r*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 i=`${s}.${e}`,r=this._cells.get(i);if(!r)continue;const n=t.get(r.id);n?r&&!t.has(r.id)&&n.merge(r):t.set(r.id,r.clone())}}_insert(t,e,s,i){const r=e*this._pixelsPerMapUnit,n=s*this._pixelsPerMapUnit,o=Math.floor(r/this._options.cellSize),a=Math.floor(n/this._options.cellSize);this._getCellOrCreate(o,a).insert(t,i,e,s)}_getCellOrCreate(t,e){const s=gu.createId(t,e);let i=this._cells.get(s);if(!i){const r=1*this._options.cellSize/this._pixelsPerMapUnit;i=gu.create(t,e,this._options.fields,r),this._cells.set(s,i)}return i}}class vu{constructor(t,e){this.inner=t,this.displayId=e}}class Su extends rl{constructor(t){super(t),this.didSend=!1,this.done=!1}}class Iu{constructor(t,e,s,i,r){this._level=t,this._scale=e,this._indexOptions=s,this._clusterRadius=i,this._store=r,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 Qc.Om(e,t.inner.getAttributes(),null);s.objectId=t.inner.id,s.displayId=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 i={xMin:1/0,yMin:1/0,xMax:-1/0,yMax:-1/0},r=bu(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]*r/n),o=Math.floor(e[1]*r/n),a=Math.ceil(e[2]*r/n),h=Math.ceil(e[3]*r/n);i.xMin=Math.min(i.xMin,s),i.yMin=Math.min(i.yMin,o),i.xMax=Math.max(i.xMax,a),i.yMax=Math.max(i.yMax,h)}return null!=this._lastCellBounds&&i.xMin===this._lastCellBounds.xMin&&i.yMin===this._lastCellBounds.yMin&&i.yMin===this._lastCellBounds.yMin&&i.yMax===this._lastCellBounds.yMax||(s=!0,this._lastCellBounds=i),s&&this._clusterCells(i),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,i=[],r=s.tile.transform;for(const t of this._clusters.values()){let e=t.inner.getCentroidX(r);const n=t.inner.getCentroidY(r),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 Wt.A([],[e,n]),r=new Qc.Om(s,t.inner.getAttributes(),null);r.geometry.coords[0]-=B.CQ,r.objectId=h,r.displayId=c,i.push(r);const o=new Wt.A([],[e,n]),a=new Qc.Om(o,t.inner.getAttributes(),null);a.geometry.coords[0]+=B.CQ,a.objectId=h,a.displayId=c,i.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 Wt.A([],[e,n]),r=new Qc.Om(s,t.inner.getAttributes(),null);r.objectId=h,r.displayId=c,i.push(r)}}return ru.fromOptimizedFeatures(i,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 i=this._clusterRadius*(1/bu(this._indexOptions.spatialReference,this._scale)),r=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 vu(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-r;t<=s.gridY+r;t++)for(let e=s.gridX-r;e<=s.gridX+r;e++){if(t===s.gridY&&e===s.gridX)continue;const r=this._cells.get(gu.createId(e,t));if(!r||n.has(r.id))continue;const c=Math.abs(r.centroidXWorld-a),l=Math.abs(r.centroidYWorld-h);c<i&&l<i&&(o.inner.merge(r),n.add(r.id))}}for(const t of s)this._store.releaseDisplayIdForObjectId(t)}_updateAggregateStatistics(t,e){let s=!1;for(const i of e.statistics.values()){if("esriFieldTypeString"===i.field.type)continue;const e=i.value,r=i.field,n=t.get(r.name);if(n){const{minValue:t,maxValue:i}=n,r=Math.min(n.minValue,e),o=Math.max(n.maxValue,e);t===r&&i===o||(n.minValue=r,n.maxValue=o,s=!0)}else t.set(r.name,{minValue:e,maxValue:e}),s=!0}return s}}class Pu extends ol{static async create(t,e,s,i,r,n){const o=new El({spatialReference:s}),a={type:"grid",fields:await Promise.all(e.fields.map((async t=>Jc.create(o,t)))),spatialReference:s,featureFilter:e.featureFilter?await Ll.create({geometryType:i.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:i.metadata.timeInfo,fieldsIndex:i.metadata.fieldsIndex,spatialReference:s,filterJSON:e.featureFilter}):null,cellSize:e.clusterRadius/4,timeZone:n};return new Pu(t,e.clusterRadius,a,e.fields,i,r)}constructor(t,e,s,i,r,n){super(r,n,s.spatialReference,s.fields),this._connection=t,this._clusterRadius=e,this._indexOptions=s,this._cellsPerScale=new Map,this._metadata=new Dl({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fields:[...i,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],globalIdField:null,spatialReference:r.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 Su(t)}async*applyLocalEdit(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 i=new Map(t.map((t=>[e(t),t]))),r=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const t of n.clusters()){const e=i.get(t.inner.id);if(null==e){if(1===t.inner.count){const e=i.get(t.inner.firstObjectId);if(null!=e){const n=s(t.displayId,e,t.inner.firstObjectId);r.push(n),i.delete(t.inner.firstObjectId)}}}else{const n=s(t.displayId,e,t.inner.id);r.push(n),i.delete(t.inner.id)}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[],r=[],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,Wh.oN)(t,this._metadata.geometryType,!1,!1);if(s.add(t.displayId),1===e.attributes.cluster_count){i.push({...e,displayId:t.displayId});continue}r.push({...e,displayId:t.displayId})}return{features:i,aggregates:r}}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 i=Array.from(this._sendStates.values()).filter((t=>t.done)).map((t=>t.subscription.tile.key)),r=new Set(i);for(const t of this._sendStates.values()){if(this._source.updateTracking.updating){if(i.some((e=>e.containsChild(t.subscription.tile.key))))continue;if(t.subscription.tile.key.getChildKeys().every((t=>r.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 Iu(t,e,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(e,s)),s}async*_update(t,e,s){if(t.done)return;const i=e.createAggregateFeatures(t,this._metadata);this.events.emit("changed"),t.done=!s.updateTracking.updating;const r=i.getCursor(),n=t.subscription.tile.createArcadeEvaluationOptions(this._indexOptions.timeZone);for(;r.next();)this._attributeStore.setAttributeData(r.getDisplayId(),r,n);const o=new al(t.subscription,i,!0,t.done,{});yield o}}var Mu=s(11006);function Tu(t,e){if(!(this instanceof Tu))return new Tu(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 Cu(t,e,s){if(!s)return e.indexOf(t);for(var i=0;i<e.length;i++)if(s(t,e[i]))return i;return-1}function Au(t,e){Eu(t,0,t.children.length,e,t)}function Eu(t,e,s,i,r){r||(r=Gu(null)),r.minX=1/0,r.minY=1/0,r.maxX=-1/0,r.maxY=-1/0;for(var n,o=e;o<s;o++)n=t.children[o],Fu(r,t.leaf?i(n):n);return r}function Fu(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 ku(t,e){return t.minX-e.minX}function zu(t,e){return t.minY-e.minY}function Ou(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Ru(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Lu(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 Nu(t,e){var s=Math.max(t.minX,e.minX),i=Math.max(t.minY,e.minY),r=Math.min(t.maxX,e.maxX),n=Math.min(t.maxY,e.maxY);return Math.max(0,r-s)*Math.max(0,n-i)}function Du(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function Bu(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Gu(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Uu(t,e,s,i,r){for(var n,o=[e,s];o.length;)(s=o.pop())-(e=o.pop())<=i||(n=e+Math.ceil((s-e)/i/2)*i,(0,Mu.q)(t,n,e,s,r),o.push(e,n,n,s))}Tu.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,s=[],i=this.toBBox;if(!Bu(t,e))return s;for(var r,n,o,a,h=[];e;){for(r=0,n=e.children.length;r<n;r++)o=e.children[r],Bu(t,a=e.leaf?i(o):o)&&(e.leaf?s.push(o):Du(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(!Bu(t,e))return!1;for(var i,r,n,o,a=[];e;){for(i=0,r=e.children.length;i<r;i++)if(n=e.children[i],Bu(t,o=e.leaf?s(n):n)){if(e.leaf||Du(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 i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var r=this.data;this.data=i,i=r}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},insert:function(t){return null!=t&&this._insert(t,this.data.height-1),this},clear:function(){return this.data=Gu([]),this},remove:function(t,e){if(null==t)return this;for(var s,i,r,n,o=this.data,a=this.toBBox(t),h=[],c=[];o||h.length;){if(o||(o=h.pop(),i=h[h.length-1],s=c.pop(),n=!0),o.leaf&&-1!==(r=Cu(t,o.children,e)))return o.children.splice(r,1),h.push(o),this._condense(h),this;n||o.leaf||!Du(o,a)?i?(s++,o=i.children[s],n=!1):o=null:(h.push(o),c.push(s),s=0,i=o,o=o.children[0])}return this},toBBox:function(t){return t},compareMinX:ku,compareMinY:zu,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,i){var r,n=s-e+1,o=this._maxEntries;if(n<=o)return Au(r=Gu(t.slice(e,s+1)),this.toBBox),r;i||(i=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,i-1))),(r=Gu([])).leaf=!1,r.height=i;var a,h,c,l,u=Math.ceil(n/o),d=u*Math.ceil(Math.sqrt(o));for(Uu(t,e,s,d,this.compareMinX),a=e;a<=s;a+=d)for(Uu(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),r.children.push(this._build(t,h,l,i-1));return Au(r,this.toBBox),r},_chooseSubtree:function(t,e,s,i){for(var r,n,o,a,h,c,l,u;i.push(e),!e.leaf&&i.length-1!==s;){for(l=u=1/0,r=0,n=e.children.length;r<n;r++)h=Ou(o=e.children[r]),(c=Lu(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 i=this.toBBox,r=s?t:i(t),n=[],o=this._chooseSubtree(r,this.data,e,n);for(o.children.push(t),Fu(o,r);e>=0&&n[e].children.length>this._maxEntries;)this._split(n,e),e--;this._adjustParentBBoxes(r,n,e)},_split:function(t,e){var s=t[e],i=s.children.length,r=this._minEntries;this._chooseSplitAxis(s,r,i);var n=this._chooseSplitIndex(s,r,i),o=Gu(s.children.splice(n,s.children.length-n));o.height=s.height,o.leaf=s.leaf,Au(s,this.toBBox),Au(o,this.toBBox),e?t[e-1].children.push(o):this._splitRoot(s,o)},_splitRoot:function(t,e){this.data=Gu([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Au(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,s){var i,r,n,o,a,h,c,l;for(h=c=1/0,i=e;i<=s-e;i++)o=Nu(r=Eu(t,0,i,this.toBBox),n=Eu(t,i,s,this.toBBox)),a=Ou(r)+Ou(n),o<h?(h=o,l=i,c=a<c?a:c):o===h&&a<c&&(c=a,l=i);return l},_chooseSplitAxis:function(t,e,s){var i=t.leaf?this.compareMinX:ku,r=t.leaf?this.compareMinY:zu;this._allDistMargin(t,e,s,i)<this._allDistMargin(t,e,s,r)&&t.children.sort(i)},_allDistMargin:function(t,e,s,i){t.children.sort(i);var r,n,o=this.toBBox,a=Eu(t,0,e,o),h=Eu(t,s-e,s,o),c=Ru(a)+Ru(h);for(r=e;r<s-e;r++)n=t.children[r],Fu(a,t.leaf?o(n):n),c+=Ru(a);for(r=s-e-1;r>=e;r--)n=t.children[r],Fu(h,t.leaf?o(n):n),c+=Ru(h);return c},_adjustParentBBoxes:function(t,e,s){for(var i=s;i>=0;i--)Fu(e[i],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():Au(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 Vu{static fromReader(t){const e=[],s=t.copy(),i=(0,el.vt)();for(;s.next();)s.getBounds(i)&&e.push(s.getIndex());const r=Tu(9,(t=>(s.setIndex(t),{minX:s.getBoundsXMin(),minY:s.getBoundsYMin(),maxX:s.getBoundsXMax(),maxY:s.getBoundsYMax()})));return r.load(e),new Vu(r)}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 qu=s(5443),Wu=s(79258);function Yu(t,e,s,i){if(i.isWebMercator){const i=(0,nc.KJ)(t/Wu.$O.radius),r=i-360*Math.floor((i+180)/360),n=[0,0];return ju(n,0,(0,nc.KJ)(Math.PI/2-2*Math.atan(Math.exp(-e/Wu.$O.radius))),r,s),n}const r=(0,Kc.Cv)({x:t,y:e},i,q.A.WGS84);if(!r)return null;const n=[0,0];return ju(n,0,r.y,r.x,s),n}function ju(t,e,s,i,r){r%2&&(r+=1);let n=0,o=0,a=-90,h=90,c=-180,l=180;for(let t=0;t<r/2;t++){for(let e=0;e<5;e++){const s=(c+l)/2,r=i>s?1:0;n|=r<<29-(e+5*t),c=(1-r)*c+r*s,l=(1-r)*s+r*l}for(let e=0;e<5;e++){const i=(a+h)/2,r=s>i?1:0;o|=r<<29-(e+5*t),a=(1-r)*a+r*i,h=(1-r)*i+r*h}}t[2*e]=n,t[2*e+1]=o}new Float64Array(2),new Float64Array(2);class Xu extends au{static create(t,e,s,i){const r=cu.create(t),n=new Array(32);for(let t=0;t<n.length;t++)n[t]=null;return new Xu(r,e,s,i,n)}constructor(t,e,s,i,r){super(t),this.xNode=e,this.yNode=s,this.depth=i,this.children=r,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 Xu(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,i,r,n){this._count+=1,this._xWorldTotal+=e,this._yWorldTotal+=s,this._xGeohashTotal+=i,this._yGeohashTotal+=r,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(),[i,r,n,o]=s,a=(0,Kc.Cv)({rings:[[[i,r],[i,o],[n,o],[n,r],[i,r]]]},q.A.WGS84,t),h=(0,Wh.Ye)(new Wt.A,a,!1,!1);return null!=e?(0,Wh.Nl)(new Wt.A,h,!1,!1,"esriGeometryPolygon",e,!1,!1):h}getGeometricCentroid(t,e){const s=this._getLngLatBounds(),[i,r,n,o]=s,a=(0,Kc.Cv)({x:(i+n)/2,y:(r+o)/2},q.A.WGS84,t),h=(0,Wh.qN)(new Wt.A,a);return null!=e?(0,Wh.Nl)(new Wt.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,i,r,n){if(i>=s)return this;const o=1-i%2,a=3*o+2*(1-o),h=2*o+3*(1-o),c=30-r-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,i+1,r+a,n+h)}_getLngLatBounds(){const t=this.depth,e=Math.ceil(t/2),s=Math.floor(t/2),i=30-(3*e+2*s),r=30-(2*e+3*s);return function(t,e){let s=-90,i=90,r=-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,p=(3*h+7*(1-h)<<l&t.geohashY)>>l;for(let t=3*h+2*(1-h)-1;t>=0;t--){const e=(r+n)/2,s=d&1<<t?1:0;r=(1-s)*r+s*e,n=(1-s)*e+s*n}for(let t=u-1;t>=0;t--){const e=(s+i)/2,r=p&1<<t?1:0;s=(1-r)*s+r*e,i=(1-r)*e+r*i}}return[r,s,n,i]}({geohashX:this.xNode<<i,geohashY:this.yNode<<r},this.depth)}}class $u{constructor(t){this._fields=t,this._size=0,this._depth=0,this._root=Xu.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,i,r,n,o){let a=this._root,h=0,c=0,l=0;for(;null!==a;){if(a.insert(t,e,s,i,r,o),h>=n)return;const u=Math.ceil((h+1)/2),d=Math.floor((h+1)/2),p=1-h%2,_=30-(3*u+2*d),f=30-(2*u+3*d),m=(i&7*p+3*(1-p)<<_)>>_,g=(r&3*p+7*(1-p)<<f)>>f,y=m+g*(8*p+4*(1-p));c=c<<3*p+2*(1-p)|m,l=l<<2*p+3*(1-p)|g,null==a.children[y]&&(a.children[y]=Xu.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:i}=t;let r=this._root;for(;null!==r;){const t=r.depth,n=r.xNode,o=r.yNode;if(t>=i){e.push(r),r=r.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),p=~((1<<u)-1),_=(s.xLL&d)>>l,f=(s.yLL&p)>>u,m=(s.xTR&d)>>l,g=(s.yTR&p)>>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,_),S=Math.max(x,f),I=Math.min(b,m),P=Math.min(w,g);let M=null,T=null;for(let t=S;t<=P;t++)for(let e=v;e<=I;e++){const s=e-y+(t-x)*(8*c+4*(1-c)),i=r.children[s];i&&(M||(M=i,M.next=r.next),T&&(T.next=i),T=i,i.next=r.next)}r=M||r.next}return e}}class Hu extends xu{constructor(t){super(t),this._tree=new $u(this._options.fields)}put(t){throw new Error("Geohash tree does not support put")}putBounded(t,e,s){const{geohashLevel:i,spatialReference:r}=this._options,n=function(t,e,s,i){const r=[t.xmin,t.ymin,t.xmax,t.ymax],n=Oi.A.fromExtent(qu.A.fromBounds(r,i)),o=(0,Kc.Cv)(n,i,q.A.WGS84,{densificationStep:64*e});if(!o)return null;const a=(0,Wh.Ye)(new Wt.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),p=Math.max(...c),_=Yu(l,u,s,q.A.WGS84),f=Yu(d,p,s,q.A.WGS84);return _&&f?{bounds:r,geohashBounds:{xLL:_[0],yLL:_[1],xTR:f[0],yTR:f[1]},level:s}:null}(e,s,i,r);null!=n&&this._tree.putBins(t,n)}_insert(t,e,s,i){const{geohashLevel:r,spatialReference:n}=this._options,o=Yu(e,s,r,n);o&&this._tree.insert(t,e,s,o[0],o[1],r,i)}}class Zu extends iu{static from(t,e){return new Zu(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,[i,r]=t.translate;return this._displayTranslationX=-i/e,this._displayScaleX=1/e,this._displayTranslationY=r/s,this._displayScaleY=1/-s,void(this._displayTransform=t)}const[s,i]=e.scale,[r,n]=e.translate,[o,a]=t.scale,[h,c]=t.translate;if(this._displayScaleX=s/o,this._displayTranslationX=(r-h)/o,this._displayScaleY=i/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 Zu(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}_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(){const t=this._reader.readGeometryForDisplay();if(!this._displayTransform)return t;const e=new Wt.A;return(0,Wh.Nl)(e,t,this.hasZ,this.hasM,this.geometryType,this._displayTransform),e.deltaDecode()}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,Wh.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 Qu{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._aggregateIndex=null,this._aggregateIndexHash=null,this._spatialIndex=null}queryFeaturesInBounds(t){const e=this._getSpatialIndex().search(t);return Zu.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 wu(t);break;case"geohash":this._aggregateIndex=new Hu(t)}this._aggregateIndex.insert(this.reader,this.isTiled)}return this._aggregateIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=Vu.fromReader(this.reader)),this._spatialIndex}}class Ku extends Qu{constructor(t,e){super(),this.metadata=t,this.removed=new Set,this.overriddenIds=new Set,this._features=[],this.chunkId=e,this.normalizedChunkId=e}get reader(){return ru.fromOptimizedFeatures(this._features,this.metadata)}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(t){super.invalidate();const{reader:e,removed:s}=t,i=[],r=new Set,n=e.getCursor(),o=new Set(s);for(this.overriddenIds.clear();n.next();){const t=n.readOptimizedFeatureWorldSpace(),e=t.objectId;i.push(t),r.add(e),this.overriddenIds.add(e),this.removed.delete(e)}for(const t of this._features){const e=t.objectId;o.has(e)||r.has(e)||(i.push(t),this.overriddenIds.add(e))}this._features=i;for(const t of r.values())this.removed.delete(t);for(const t of s)this.removed.add(t),this.overriddenIds.add(t)}removeOverrides(t){const e=t.reader.getCursor(),s=new Set;for(;e.next();){const t=e.getObjectId();this.overriddenIds.has(t)&&(s.add(t),this.overriddenIds.delete(t))}this._features=this._features.filter((t=>!s.has(t.objectId)))}getTileReader(t){if(!this._features.length)return null;const e=this.queryFeaturesInBounds(t.bounds);return e.setTransformForDisplay(t.transform),e}}class Ju extends rl{}class td extends nl{constructor(t,e,s){super(t,e),this._timeZone=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(){this.handledChunksForAttributeData.clear()}onSubscribe(t){super.onSubscribe(t),this._evalOptions=t.tile.createArcadeEvaluationOptions(this._timeZone)}createState(t){return new Ju(t)}get aggregateQueryEngine(){return null}displayMap(t,e,s){const i=new Map(t.map((t=>[e(t),t]))),r=[];for(const t of this._source.chunks()){const e=t.reader.getCursor();for(;e.next();){const t=e.getObjectId(),n=e.getDisplayId(),o=i.get(t);if(null!=o){const e=s(n,o,t);r.push(e),i.delete(t)}}}return r}getDisplayFeatures(t){const e=new Set(t),s=new Set,i=[];for(const t of this._source.chunks()){const r=t.reader.getCursor();for(;r.next();){const t=r.getObjectId(),n=r.getDisplayId();e.has(n)&&!s.has(t)&&(i.push({...r.readLegacyFeatureWorldSpace(),displayId:n}),s.add(t))}}return{features:i,aggregates:[]}}async*applyLocalEdit(t){const e=[],s=t.reader.getCursor();for(;s.next();){const t=s.getObjectId();e.push(t);const i=this._attributeStore.createDisplayIdForObjectId(t);s.setDisplayId(i),this._attributeStore.setAttributeData(i,s,this._evalOptions)}const i=this.getDisplayIds(e),r=this.getDisplayIds(t.removed),n=new Ku(this._source.metadata,"localEdit");n.applyOverrides(t),this.handledChunks.add(n.chunkId),this.handledChunksForAttributeData.add(n.chunkId),this.handledChunksForIdCreation.add(n.chunkId);for(const t of this._sendStates.values())t.handledChunks.add(n.chunkId),yield new hl(t.subscription,null,i,!1,n.queryInfo);for(const t of this._sendStates.values()){const e=n.getTileReader(t.subscription.tile);yield new hl(t.subscription,e,r,!1,n.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 i of this._source.chunks()){const{chunkId:r}=i;if(s.has(r))continue;s.add(r);const n=i.getTileReader(e.tile);n&&(yield new al(t.subscription,n,!1,i.end,i.queryInfo))}}}class ed{constructor(t){this.data=t,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class sd{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 ed((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)))}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 id=()=>A.A.getLogger("esri.views.layers.2d.features.support.AttributeStore"),rd=(id(),()=>null),nd=(0,n.A)("esri-shared-array-buffer");(0,n.A)("esri-atomics");class od{constructor(t,e,s){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:i,layout:r,textureOnly:n}=e;this.textureOnly=n||!1,this.pixelType=i,this.layout=r,this._resetRange(),this.size=t,this.isLocal=s,n||(this.data=this._initData(i,t))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]&=~e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(t,e){const s=this.data;for(let i=0;i<this.size*this.size;i++)s[i*this.texelSize+t]|=255&e;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(t,e,s){const i=this.data;for(const r of s)i[r*this.texelSize+t]|=e,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)}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=jh(t);return this.data[s*this.texelSize+e]}setData(t,e,s){const i=jh(t),r=1<<e;this.layout&r?null!=this.data&&(this.data[i*this.texelSize+e]=s,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)):id().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 i=!this.isLocal,r=this.pixelType,n=this.layout,o=this.data;return{start:t,end:e,data:i&&o.slice(t*s,(e+1)*s)||null,pixelType:r,layout:n}}_initData(t,e){const s=ArrayBuffer,r=function(t){switch(t){case pt.ld.UNSIGNED_BYTE:return Uint8Array;case pt.ld.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case pt.ld.FLOAT:return Float32Array;default:return void A.A.getLogger("esri.views.2d.engine.webgl.Utils").error(new i.A("webgl-utils",`Unable to handle type ${t}`))}}(t),n=new r(new s(e*e*4*r.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 ad{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._referencesScale=!1,this._referencesGeometry=!1,this._initialized=!1,this.version=0,this._idGenerator=new sd,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const t=pt.ld.FLOAT;rd(`Creating AttributeStore ${nd?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:pt.ld.UNSIGNED_BYTE,layout:1},{pixelType:pt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:pt.ld.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15},{pixelType:t,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get referencesScale(){return this._referencesScale}get referencesGeometry(){return this._referencesGeometry}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(t){return this._idGenerator.createIdForObjectId(t)}releaseDisplayIdForObjectId(t){return this._idGenerator.releaseIdForObjectId(t)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}releaseAllIds(){this._idGenerator.releaseAll()}async update(t,e,s,i,r=0){const o=(0,V.Ui)(this._schema,t);if(this.version=r,o&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${r}] 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?Ll.create({geometryType:s.geometryType,hasM:!1,hasZ:!1,timeInfo:s.timeInfo,fieldsIndex:s.fieldsIndex,spatialReference:i??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._referencesGeometry=this._referencesGeometry||(s?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(s?.referencesScale()??!1)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:t.subtypeField,map:new Map},this._referencesScale=!1,this._referencesGeometry=!1;for(const s in t.bindings){const i=t.bindings[s];await Promise.all(i.map((async t=>{const i=await this._bind(e,t,parseInt(s,10));this._referencesGeometry=this._referencesGeometry||(i?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(i?.referencesScale()??!1)})))}}}setHighlight(t,e){const s=this._getBlock(0);s.unsetComponentAllTexels(0,(1<<Ca.length)-1);for(const{displayId:e,highlightFlags:i}of t){if(null==e)continue;const t=jh(e);s.setComponent(0,i,[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,i){const r=jh(t);this._ensureSizeForTexel(r),this._getBlock(e).setData(t,s,i)}getData(t,e,s){return this._getBlock(e).getData(t,s)}getHighlightFlags(t){return this._idsToHighlight.get(t)||0}unsetAttributeData(t){const e=jh(t);this._getBlock(0).setData(e,0,0)}setAttributeData(t,e,s){const i=jh(t);this._ensureSizeForTexel(i),this._getBlock(0).setData(i,0,this.getFilterFlags(e));const r=this._attributeComputeInfo;let n=null;r&&(n=r.isSubtype?r.map.get(e.readAttribute(r.subtypeField)):r.map,n?.size&&n.forEach(((t,r)=>{const n=1*r%4,o=Math.floor(1*r/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=yr),a.setData(i,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 i=await t.createComputedField(e),{valueRepresentation:r}=e,n=this._attributeComputeInfo;if(n.isSubtype){const t=n.map.get(s)??new Map;t.set(e.binding,{field:i,valueRepresentation:r}),n.map.set(s,t)}else n.map.set(e.binding,{field:i,valueRepresentation:r});return i}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(B.dV.Animation),this._getBlock(B.dV.GPGPU),{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;rd(`Initializing AttributeBlock at index ${t}`);const s=new od(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;rd("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 id().error(new i.A("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}isVisible(t){return!!(this._getBlock(0).getData(t,0)&1<<Ca.length)}getFilterFlags(t){let e=0;for(let s=0;s<this._filters.length;s++){const i=!!(1<<s),r=this._filters[s];e|=(!i||null==r||r.check(t)?1:0)<<s}let s=0;if(this._idsToHighlight.size){const e=t.getObjectId();s=this.getHighlightFlags(e)}return e<<Ca.length|s}}class hd{constructor(t,e){this._connection=t,this._source=e,this._version=1,this._registry=new $c,this._proxy=new Gt({fetch:(t,e)=>this._connection.layerView.fetch(t,e),fetchDictionary:(t,e)=>this._connection.layerView.fetchDictionary(t,e)}),this._attributeStore=new ad({isLocal:!1,update:t=>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:[]}}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,i,r){const o=t.processor,a=(0,U.bD)(this._schema?.storage,o.storage),h=(0,U.bD)(this._schema?.mesh.properties,o.mesh.properties),c=(0,U.bD)(this._schema?.mesh.factory,o.mesh.factory),l=(0,U.bD)(this._schema?.mesh.strategy,o.mesh.strategy),u=h||c||l;if(!a&&!u&&!i)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 d=q.A.fromJSON(this._source.service.outSpatialReference),p=new El({fields:this._source.metadata.fieldsIndex,spatialReference:d});if(await this._attributeStore.update(o.storage,p,this._source.metadata,d,e),this._strategy?.invalidateAttributeData(),!i&&!u)return;(l||h)&&await this._updateStrategy(o.mesh.strategy,d,r,o.mesh.properties.timeZone),this._updateSortKey(p,"sortKey"in o.mesh.properties?o.mesh.properties.sortKey:null);const _=new Hc(p,this._proxy,s,this._registry);return(c||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await ct.create(_,o.mesh.factory)),this._invalidate(),this._version=e,this._connection.container.updateRenderState(this._version)}async applyLocalEdit(t){if(!this._strategy)return;const e=this._strategy.applyLocalEdit(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 i of t){let t=s.get(i.id);null==t&&(t=new Zc({concurrency:16,process:t=>this._process(t)}),s.set(i.id,t));const r=t.push(i).catch((t=>(0,a.jH)(t)));e.push(r)}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,i){switch(this._strategy?.destroy(),t.type){case"feature":this._strategy=new td(this._source,this._attributeStore,i);break;case"binning":this._strategy=await ou.create(t,e,this._source,this._attributeStore,i);break;case"cluster":this._strategy=await Pu.create(this._connection,t,e,this._source,this._attributeStore,i)}for(const t of s)this._strategy.onSubscribe(t)}async _updateSortKey(t,e){if(this._sortInfo=(0,T.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(this._schema?.mesh.properties.timeZone)),i=e.tile.tileInfoView.tileInfo.isWrappable,{message:r,transferList:o}=s.serialize(i),h={objectIdMap:null,inner:t.createMessage(r,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(this._schema.mesh.properties.timeZone);for(;e.next();)this._factory.enqueueWriterRequests(this._proxy,e,s);await this._proxy.fetchEnqueuedResources()}async _write(t,e){const s=t.subscription.tile,i=t.reader?.getCursor(),r=i?.getSize()??0,n=s.tileInfoView.tileInfo.isWrappable,o=new J(s.key,this._strategy.enablePixelBuffering,n,r);if(!i)return o;const a=s.createArcadeEvaluationOptions(this._schema.mesh.properties.timeZone);for(;i.next();){const t=this._getSortKeyValue(i,e);o.entityStart(i.getDisplayId(),t),this._factory.write(o,this._proxy,i,a,s.level),o.entityEnd()}return o}_getSortKeyValue(t,e){if(!this._sortInfo)return 0;const{computed:s,order:i,byRenderer:r}=this._sortInfo,n=r?this._factory.getSortKey(t,e):s?.read(t,e);return null==n||isNaN(n)?0:n*("asc"===i?-1:1)}}var cd=s(78888),ld=s(80893);class ud{static from(t){let e=0,s=0,i=0;return t.forEach((t=>{const r=t._readGeometry();r&&(s+=r.isPoint?1:r.lengths.reduce(((t,e)=>t+e),0),i+=r.isPoint?1:r.lengths.length,e+=1)})),new ud(e,s,i)}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 dd=s(60945),pd=s(60694);class _d{static fromSchema(t,e,s){const i="feature"===e.type?e.mutable.dataFilter.queryScaleRanges:[];return new _d(function(t,e,s){const i=t.orderByFields??s.objectIdField+" ASC",r=t.source,n={returnCentroid:!(null!==r&&"object"==typeof r&&"path"in r&&(0,pd.Wo)(r.path))&&"esriGeometryPolygon"===s.geometryType,returnGeometry:!0,timeReferenceUnknownClient:s.timeReferenceUnknownClient??void 0,outSpatialReference:q.A.fromJSON(t.outSpatialReference),orderByFields:[i],where:e.mutable.dataFilter.definitionExpression??"1=1",outFields:e.mutable.availableFields};if("feature"===e.type){const{gdbVersion:t,historicMoment:s,timeExtent:i}=e.mutable.dataFilter;return{...n,gdbVersion:t,historicMoment:s?new Date(s):null,timeExtent:i?dd.A.fromJSON(i):null,outFields:e.mutable.availableFields}}return n}(t,e,s),i,s.subtypeField,e.mutable.dataFilter.customParameters,s.geometryType,t.queryMetadata)}constructor(t,e,s,i,r,n){this._queryParams=t,this._queryScaleRanges=e,this._subtypeField=s,this._customParameters=i,this._geometryType=r,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){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),i=[];for(const s of t)e.hasField(s)||i.push(s);if(0===i.length)return null;s.outFields=i}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 Ol.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),i=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})`;i.where=(0,Sl.m)(i.where,t)}}return i.quantizationParameters=e.quantizationParameters??t.getQuantizationParameters(),i.resultType="tile",i.geometry=t.extent,this._queryMetadata.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset=t.resolution*(0,n.A)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(i.maxAllowableOffset=t.resolution,"esriGeometryPolyline"===this._geometryType&&(i.maxAllowableOffset*=(0,n.A)("feature-polyline-generalization-factor"))),i.defaultSpatialReferenceEnabled=this._queryMetadata.supportsDefaultSpatialReference,i.compactGeometryEnabled=this._queryMetadata.supportsCompactGeometry,this._queryMetadata.supportsMaxRecordCountFactor&&(i.maxRecordCountFactor=4),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 fd=class extends M.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)),i=Math.round(this._updateInfo.websocket/(e/1e3));this._resetUpdateInfo(t),this._layerView.emitEvent({name:"update-rate",event:{client:s,websocket:i}})}}_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,C.MZ)()],fd.prototype,"_strategy",void 0),fd=(0,P._)([(0,E.$)("esri.views.2d.layers.features.sources.StreamMessenger")],fd);class md{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 queryOverride(t){throw new Error("InternalError: LoadStrategy does not support fetching")}async queryByObjectId(t){throw new Error("InternalError: LoadStrategy does not support fetching")}}var gd=s(10382),yd=s(62577),xd=s(75321),bd=s(51624),wd=s(53655);const vd=268435455;class Sd{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 Id=268435455,Pd=128e3,Md={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(Pd),decoded:new Int32Array(Pd)}};function Td(t){return t<=Md.small.delta.length?Md.small:(t<=Md.large.delta.length||(Md.large.delta=new Int32Array(Math.round(1.25*t)),Md.large.decoded=new Int32Array(Math.round(1.25*t))),Md.large)}function Cd(t){for(;t.next();){if(1===t.tag())return t.getMessage();t.skip()}return null}function Ad(t,e,s,i,r,n){return.5*Math.abs(t*i+s*n+r*e-t*n-s*e-r*i)}function Ed(t,e,s,i){return 0==t*i-s*e&&t*s+e*i>0}class Fd extends iu{static fromBuffer(t,e,s=!1){const r=e.geometryType,n=function(t){try{const e=2,s=new bd.A(new Uint8Array(t),new DataView(t));for(;s.next();){if(s.tag()===e)return Cd(s.getMessage());s.skip()}}catch(t){const e=new i.A("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:t});A.A.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(e)}return null}(t),o=function(t,e,s=!1){const r=t.asUnsafe(),n=r.pos(),o=new Sd;let a=0,h=0,c=null,l=null,u=null,d=!1;const p=[];for(;r.next();)switch(r.tag()){case 1:c=r.getString();break;case 3:l=r.getString();break;case 12:u=r.processMessage(wd.ae);break;case 9:if(o.exceededTransferLimit=r.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]=vd}break;case 13:{const t=r.processMessage(wd.cn);t.index=a++,p.push(t);break}case 15:{const t=r.getLength(),i=r.pos()+t;if(!o.exceededTransferLimit){const t=o.offsets.geometry,e=o.centroid;t.push(0),e.push(vd),e.push(vd)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=s?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=h*a;for(;r.pos()<i&&r.next();)switch(r.tag()){case 1:{d?o.offsets.attributes[n++]=r.pos():o.offsets.attributes.push(r.pos());const t=r.getLength();r.skipLen(t);break}case 2:if(e){const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}}else{o.offsets.geometry[h]=r.pos();const t=r.getLength();o.vertexCount+=t,r.skipLen(t)}break;case 4:{const t=r.getLength(),e=r.pos()+t;for(;r.pos()<e&&r.next();)switch(r.tag()){case 3:{r.getUInt32();const t=r.getSInt64(),e=r.getSInt64();o.centroid[2*h]=t,o.centroid[2*h+1]=e;break}default:r.skip()}break}default:r.skip()}h++,o.hasFeatures=!0;break}default:r.skip()}const _=c||l;if(!_)throw new i.A("FeatureSet has no objectId or globalId field name");return o.fields=new Nl.A(p),o.featureCount=h,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(_)?.index,o.transform=u,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),r.move(n),o}(n,"esriGeometryPoint"===r,s);return new Fd(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,centroid:void 0,legacyFeature:void 0,optFeature: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._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=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 Fd(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._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_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===Id?null:new Wt.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]===Id)return null;const t=this._header.centroid[2*this._featureIndex],s=this._header.centroid[2*this._featureIndex+1];e=new Wt.A([],[t,s])}else{const s=this._header.offsets.geometry[this._featureIndex],i=this._reader;if(0===s)return null;i.move(s);try{e=t?this._parseGeometryForDisplay(i):this._parseGeometry(i)}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;let i=this._readAttributeAtIndex(s.index);"esriFieldTypeTimestampOffset"===this.fields.get(t)?.type&&(i=this.parseTimestampOffset(i));const r=this._header.fields.isDateField(s.name);return e?null==i?i:r?new Date(i):i:i}_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 Wl(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],i=this._reader;i.move(s);const r=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}(i);return e.set(this._featureIndex,r),r}_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=Td(e.coords.length).decoded,i=e.clone(s),r=i.coords;let n=0;for(const t of i.lengths){for(let e=1;e<t;e++){const t=2*(n+e),s=2*(n+e-1);r[t]+=r[s],r[t+1]+=r[s+1]}n+=t}return this._cache.unquantGeometry=i,i}return this._cache.unquantGeometry}_parseGeometry(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];for(;e.pos()<i&&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(r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();e.pos()<s;)r.push(e.getSInt64()),r.push(e.getSInt64()),this.hasZ&&e.getSInt64(),this.hasM&&e.getSInt64();break}default:e.skip()}return new Wt.A(n,r)}_parseGeometryForDisplay(t){const e=t.asUnsafe(),s=e.getLength(),i=e.pos()+s,r=[],n=[];let o=0,a=0,h=null,c=0;const l="esriGeometryPolygon"===this.geometryType;for(;e.pos()<i&&e.next();)switch(e.tag()){case 2:{const t=e.getUInt32(),s=e.pos()+t;for(;e.pos()<s;){const t=e.getUInt32();r.push(t),o+=t}h=Td(2*o).delta;break}case 3:{e.getUInt32();const t=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,T.Lw)(h);for(const s of r)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 i=2,r=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 d=e.getSInt32(),p=e.getSInt32();for(this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();i<s;){let s=e.getSInt32(),n=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32();const o=l+d,_=u+p;Ad(l,u,o,_,o+s,_+n)>=t?(c+=-.5*(o-l)*(_+u),r>1&&Ed(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p):(h[a++]=d,h[a++]=p,r++),l=o,u=_):(s+=d,n+=p),d=s,p=n,i++}r<3||o?a-=2*r:(c+=-.5*(l+d-l)*(u+p+u),Ed(h[a-2],h[a-1],d,p)?(h[a-2]+=d,h[a-1]+=p,n.push(r)):(h[a++]=d,h[a++]=p,n.push(++r)))}else{let t=0,i=e.getSInt32(),r=e.getSInt32();this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),h[a++]=i,h[a++]=r,t+=1;for(let n=1;n<s;n++){const s=e.getSInt32(),o=e.getSInt32(),l=i+s,u=r+o;c+=-.5*(l-i)*(u+r),this.hasZ&&e.getSInt32(),this.hasM&&e.getSInt32(),n>2&&Ed(h[a-2],h[a-1],s,o)?(h[a-2]+=s,h[a-1]+=o):(h[a++]=s,h[a++]=o,t+=1),i=l,r=u}n.push(t)}break}default:e.skip()}return this._cache.area=c,n.length?new Wt.A(n,h):null!=h?this._createQuantizedExtrudedGeometry(h[0],h[1]):null}}class kd{constructor(t,e){this.service=t,this._metadata=e}destroy(){}}class zd extends kd{constructor(t,e){super(t,e),this._portsOpen=async function(t){const e=new gd.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 ru.fromFeatureSet(s,this._metadata)}}class Od extends kd{async executeQuery(t,e){const{data:s}=await(0,ld.kS)(this.service.source,t,e),i=!t.quantizationParameters;return Fd.fromBuffer(s,this._metadata,i)}}class Rd extends kd{async executeQuery(t,e){const{source:s,queryMetadata:i}=this.service;if(null!=t.quantizationParameters&&!i.supportsQuantization){const i=t.clone(),r=(0,yd.VV)(i.quantizationParameters);i.quantizationParameters=null;const{data:n}=await(0,ld.eW)(s,i,this._metadata.spatialReference,e),o=(0,Wh.q3)(n,this._metadata.objectIdField);return(0,Wh.jH)(r,o),ru.fromOptimizedFeatureSet(o,this._metadata)}const{data:r}=await(0,ld.eW)(s,t,this._metadata.spatialReference,e);return"esriGeometryPoint"===this._metadata.geometryType&&(r.features=r.features?.filter((t=>{if(null!=t.geometry){const e=t.geometry;return Number.isFinite(e.x)&&Number.isFinite(e.y)}return!0}))),ru.fromFeatureSet(r,this._metadata)}}class Ld extends kd{async executeQuery(t,e){if(t.quantizationParameters&&!this.service.queryMetadata.supportsQuantization){const s=t.clone(),i=(0,yd.VV)(s.quantizationParameters);s.quantizationParameters=null;const r=await(0,xd.I)(this.service.source,t,e);return(0,Wh.jH)(i,r),ru.fromOptimizedFeatureSet(r,this._metadata)}const s=await(0,xd.I)(this.service.source,t,e);return ru.fromOptimizedFeatureSet(s,this._metadata)}}class Nd extends md{constructor(t,e,s,i,r){super(s),this._serviceInfo=t,this._queryInfo=e,this._metadata=i,this._eventLog=r,this._queue=new k.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 zd(t,e);case"ogc":return new Ld(t,e);case"feature-service":return t.queryMetadata.supportsFormatPBF&&(0,n.A)("featurelayer-pbf")?new Od(t,e):new Rd(t,e)}}(t,i)}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=Ol.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 i.A("featurelayer-query","Encountered errors when downloading fields",{errors:s})}async queryByObjectId(t){if(0===t.length)return ru.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 i=await this._enqueue(s,this._options);t.joinAttributes(i)}async _enqueue(t,e){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:t,options:e}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class Dd extends Nd{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 Bd extends Qu{constructor(t,e,s,i,r,n){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._sourceTile=i,this._sourceTileDepth=r,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 Gd{constructor(t,e){this.subscription=t,this._tileIdToResult=new Map,this._controller=new AbortController,(0,a.u7)(t.options,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))}get(t){return this._tileIdToResult.get(t)}set(t,e){this._tileIdToResult.set(t,e)}get options(){return{signal:this._controller.signal}}}class Ud extends Dd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new Gd(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:e,reader:i,sourceTile:r,sourceTileDepth:n,tile:o}=s,h=new Bd(i,e,o,r,n,!1);(0,a.Te)(t.options),this._addChunk(h)}}catch(t){s=t}const i=new Bd(ru.empty(this._metadata),null,t.tile,null,-1,!0);if(this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async*_fetchChunkInfos(t,e,s){let i=t.get(e.id);const r=!!i;if(i||(i=await this._fetchChunkInfo(t,e,s),t.set(e.id,i)),i.reader.exceededTransferLimit&&s<(0,n.A)("featurelayer-query-max-depth"))for(const i of e.createChildTiles())yield*this._fetchChunkInfos(t,i,s+1);else r||(yield i)}async _fetchChunkInfo(t,e,s){const i=t.subscription.tile.getQuantizationParameters(),r=this._queryInfo.createTileQuery(e,{returnExceededLimitFeatures:!1,quantizationParameters:i});return{reader:await this._fetch(r,t.subscription.options),queryJSON:r.inner.toJSON(),tile:t.subscription.tile,sourceTile:e,sourceTileDepth:s}}}class Vd extends Qu{constructor(t,e,s,i,r){super(),this._reader=t,this._queryJSON=e,this._tile=s,this._page=i,this._end=r,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 qd{constructor(t,e){this.subscription=t,this._pages=new Set,this._controller=new AbortController,this._done=!1,(0,a.u7)(t.options,(()=>this._controller.abort())),(0,a.u7)(e,(()=>this._controller.abort()))}resetAbortController(){this._controller=new AbortController}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 Wd extends Dd{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(t){this._loadStates.has(t.key.id)||this._loadStates.set(t.key.id,new qd(t,this._options));const e=this._loadStates.get(t.key.id);let s;e.resetAbortController();try{await this._fetchPages(e)}catch(t){s=t}const i=new Vd(ru.empty(this._metadata),null,t.tile,-1,!0);if((0,a.G4)(e.options)||this._addChunk(i),s)throw s}unload(t){super.unload(t),this._loadStates.delete(t.key.id)}async _fetchPages(t){let e=0,s=t.pageStart,i=1;for(;e<20&&!t.done;){const r=[];for(let e=0;e<i;e++)r.push(this._fetchChunk(t,s++));const n=await Promise.all(r);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++,i=Math.min(i+1,4)}}async _fetchChunk(t,e){const s=t.subscription.tile,i=this._queryInfo.createPagedTileQuery(s,e),r=await this._fetch(i,t.options);return new Vd(r,i.inner.toJSON(),s,e,!1)}}class Yd extends Qu{constructor(t,e,s,i){super(),this._reader=t,this._queryJSON=e,this._page=s,this._end=i,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 jd extends Nd{constructor(t,e,s,i,r,n){super(t,e,s,r,n),this._random=new h.A(1e3),this._featureCount=i}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())),r=await Promise.all(s.map((t=>this._downloadPage(t)))),n=new Yd(ru.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=r.filter((t=>t));if(o.length)throw new i.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),i=new Yd(s,e.inner.toJSON(),t,!1);return(0,a.Te)(this._options),this._store.insert(i),null}catch(t){return t}}}class Xd{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]}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 $d="__esri_timestamp__";class Hd{constructor(t,e,s,i,r=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=i,this.store=t,this.objectIdField=e,this.purgeInterval=r,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 Xd(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,nc.qE)(t,0,1e3);this._trackIdToObservations.set(s,new Xd(e))}const i=this._trackIdToObservations.get(s),r=i?.enqueue(e);null!=r&&(this._addOrUpdated.has(r)?this._addOrUpdated.delete(r):this._removed.push(r))}checkForUpdates(){const t=this._getToAdd(),e=this._getToRemove(),s=performance.now();s-this._lastPurge>=this.purgeInterval&&(this._purge(s),this._lastPurge=s);const i=[];if(null!=e)for(const t of e){const e=this.store.removeById(t);null!=e&&i.push(e)}const r=[];if(null!=t){const i=new Set(e??[]);for(const e of t)i.has(e.objectId)||(e.attributes[$d]=s,this.store.add(e),r.push(e))}return!(!r.length&&!i?.length||(this.store.update(r,i),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,i=this._maxAge-s;this.store.forEach((t=>{t.attributes[e]<i&&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[$d]<s&&this._removed.push(t.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((t,e)=>{0===t.size&&this._trackIdToObservations.delete(e)}))}}var Zd=s(30624);let Qd=class extends M.A{constructor(t){super(t)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,P._)([(0,C.MZ)()],Qd.prototype,"connection",void 0),(0,P._)([(0,C.MZ)()],Qd.prototype,"connectionStatus",null),(0,P._)([(0,C.MZ)()],Qd.prototype,"errorString",null),Qd=(0,P._)([(0,E.$)("esri.views.2d.layers.features.sources.StreamConnectionState")],Qd);class Kd{constructor(t,e){this._metadata=t,this._onUpdate=e,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return ru.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 Jd extends Qu{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 tp extends md{constructor(t,e,s,i,r){super(s),this._service=t,this._dataFilter=e,this._streamOptions=i,this._metadata=r,this._connectionState=new Qd,this._forceRefresh=!1,this.events=new tl.A;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=e;this._stagingStore=new Kd(this._metadata,(t=>this.events.emit("features-updated",t))),this._manager=new Hd(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 Jd(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,T.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:i,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,Zd.createConnection)(this._service.source,e,this._streamOptions.outSR,t,o,n,s,i,a),this._handlesGroup=(0,r.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 ep{constructor(t){this._onChange=t,this._chunks=new Map,this._chunksToRemove=[],this.events=new tl.A,this.featureAdapter=new Rl}destroy(){this.clear()}clear(){for(const t of this._chunks.values())this._chunksToRemove.push(t);this._chunks.clear(),null!=this._localEditChunk&&this._chunksToRemove.push(this._localEditChunk),this._localEditChunk=null}*chunks(){this._localEditChunk&&(yield this._localEditChunk),this._localOverridesChunk&&(yield this._localOverridesChunk),yield*this._chunks.values()}insert(t){(0,n.A)("esri-2d-update-debug")&&console.debug(`Chunk[${t.chunkId}] SourceChunkStore.insert`),this._localOverridesChunk?.overriddenIds.size&&t.reader.removeIds(this._localOverridesChunk.overriddenIds),this._localEditChunk?.overriddenIds.size&&this._localEditChunk.removeOverrides(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}applyLocalOverrides(t,e){null==this._localOverridesChunk&&(this._localOverridesChunk=new Ku(e,"localOverride")),this._localOverridesChunk.applyOverrides(t);for(const t of this._chunks.values())t.reader.removeIds(this._localOverridesChunk.overriddenIds),t.invalidate()}applyLocalEdit(t,e){null==this._localEditChunk&&(this._localEditChunk=new Ku(e,"localEdit")),this._localEditChunk.applyOverrides(t);for(const t of this._chunks.values())t.reader.removeIds(this._localEditChunk.overriddenIds),t.invalidate()}forEach(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i.copy()),e.add(s))}}}forEachUnsafe(t){const e=new Set;for(const s of this.chunks()){const i=s.reader.getCursor();for(;i.next();){const s=i.getObjectId();e.has(s)||(t(i),e.add(s))}}}forEachInBounds(t,e){const s=new Set;for(const i of this.chunks()){const r=i.queryFeaturesInBounds(t);for(;r.next();){const t=r.getObjectId();s.has(t)||(e(r.copy()),s.add(t))}}}forEachBounds(t,e){const s=(0,el.vt)();for(const i of t)i.getBounds(s)&&e(s)}}var sp=s(32587),ip=s(79897);let rp=class extends M.A{constructor(t){super(t),this.debugName="",this._updatingHandles=new ip.U,this._idToUpdatingState=new sp.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,C.MZ)({constructOnly:!0})],rp.prototype,"debugName",void 0),(0,P._)([(0,C.MZ)({readOnly:!0})],rp.prototype,"updating",null),rp=(0,P._)([(0,E.$)("esri.views.2d.layers.support.UpdateTracking2D")],rp);class np{constructor(t,e,s,i,r){this.service=t,this._aggregateAdapter=e,this._subscriptions=s,this._onChange=i,this._connection=r,this._updateTracking=new rp({debugName:"FeatureSource"}),this._didInvalidateData=!1,this._store=new ep(this._onChange),this._metadata=new Dl(t.metadata)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy(),"memory"===this.service.type&&this.service.source.map((t=>t.close()))}get _eventLog(){return this._connection.eventLog}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 ud.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 il.d({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:this.service.outSpatialReference,cacheSpatialQueries:!0,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._eventLog.onEvent({type:"subscribe",tile:t.tile.id});const e=this._strategy?.load(t);e&&(e.then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.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._eventLog.onEvent({type:"unsubscribe",tile:t.tile.id}),this._strategy?.unload(t)}getLocalEdit(t){return this._updateTracking.addPromise(this._getGetLocalEdit(t))}applyLocalEdit(t){this._didInvalidateData=!0,this._store.applyLocalEdit(t,this.metadata)}async update(t,e){const s=t.source,i=(0,V.Ui)(this._schema?.mutable,s.mutable);if(!i)return!1;if((0,n.A)("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.update`,{changes:i}),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)(i,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&(0,V.w2)(i,"availableFields")){if(await this._queryLastEditDateChanged()||this._didInvalidateData)this._didInvalidateData=!1,await this._updateStrategy(e);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(t){this._eventLog.onEvent({type:"updateFieldsError",error:t})}}return!1}return!(!(0,V.Mj)(i,"dataFilter")&&!(0,V.Mj)(i,"sourceRefreshVersion")||(await this._updateStrategy(e),0))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new fd(this._connection))}async _getGetLocalEdit(t){if(t.historicMoment&&"feature"===this._schema.type&&(this._schema.mutable.dataFilter.historicMoment=t.historicMoment,this._strategy.unsafeSetQueryHistoricMoment(new Date(t.historicMoment))),"edit-by-feature"===t.type){const e=[...t.added,...t.updated].map((t=>Qc.Om.fromJSON(t,this.metadata.objectIdField)));return{reader:ru.fromOptimizedFeatures(e,this.metadata),removed:this._resolveIdentifiers(t.removed)}}const e=this._resolveIdentifiers(t.removed);if(!t.updated.length&&!t.added.length)return{reader:ru.empty(this.metadata),removed:e};const s=this._resolveIdentifiers([...t.added,...t.updated]);return{reader:await this._strategy.queryByObjectId(s),removed:e}}_resolveIdentifiers(t){const e=[],s=[];for(const i of t)null!=i.objectId&&-1!==i.objectId?s.push(i.objectId):e.push(i.globalId);if(e.length){const t=new Set(e),i=this.metadata.globalIdField;if(null==i)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");this._store.forEachUnsafe((e=>{const r=e.readAttribute(i);t.has(r)&&s.push(e.getObjectId())}))}return s}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this.service.source,e={...t.query,f:"json"},s=(await(0,cd.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,i=t||e||s;if("stream"===this._schema.type){const t=new tp(this.service,this._schema.mutable.dataFilter,this._store,{outSR:this.service.outSpatialReference},this.metadata);return this._streamMessenger.strategy=t,t}const r=this.service,n=_d.fromSchema(r,this._schema,this._metadata),o=await this._supportSnapshotMode(r,n);return o?new jd(r,n,this._store,o.featureCount,this.metadata,this._eventLog):i?new Wd(r,n,this._store,this.metadata,this._eventLog):new Ud(r,n,this._store,this.metadata,this._eventLog)}async _updateStrategy(t){const e=await this._createStrategy();this._eventLog.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 i=Array.from(this._subscriptions.values());if(!i.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const r=Promise.all(i.map((t=>this._strategy.load(t).then((()=>this._eventLog.onEvent({type:"loaded",tile:t.tile.id}))).catch((e=>this._eventLog.onEvent({type:"error",tile:t.tile.id,error:e}))))));this._updateTracking.addPromise(r);try{s&&await r}catch(t){(0,a.jH)(t)}this._eventLog.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,i=s.snapshotInfo;if(!i||!i.supportsSnapshotMinThreshold||!i.snapshotCountThresholds)return null;const r=t.source,n=e.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,ld.gW)(r,n.inner,{query:n.customParameters})).data.count,{min:a,max:h}=i.snapshotCountThresholds;return o<=a||i.supportsSnapshotMaxThreshold&&o<h?{featureCount:o}:null}}var op=s(71511);class ap{constructor(t,e){this._handles=new op.A,this._abortController=new AbortController,this._resolver=(0,a.Tw)(),this._isDone=!1,this._aborted=!1,this.tile=t,this._version=e,this._handles.add([])}destroy(){this.pause(),this._handles.destroy()}get key(){return this.tile.key}get version(){return this._version}set version(t){this._version=t}get signal(){return this._abortController.signal}get options(){return{signal:this._abortController.signal}}get done(){return this._resolver.promise}get isDone(){return this._isDone}resolve(){this._isDone=!0,this._resolver.resolve()}get paused(){return this._aborted}resume(){this._abortController=new AbortController,this._aborted=!1}pause(){this._aborted||(this._aborted=!0,this._abortController.abort())}}var hp=s(98291),cp=s(27348);class lp{constructor(t,e){this.key=new p.A(0,0,0,0),this.bounds=(0,D.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 qu.A.fromBounds(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{$view:{scale:this.scale,timeZone:t}}}createChildTiles(){const t=this.key.getChildKeys(),e=hp.A.acquire();for(let s=0;s<t.length;s++)e[s]=new lp(this.tileInfoView,t[s]);return e}getQuantizationParameters(){return cp.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 up{constructor(t){this.inner=t,this.resolver=(0,a.Tw)()}}class dp{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._updateLocalEditsRequest=null,this._tileInfoView=null}onAttach(t){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.onAttach");const e=this._connection,s=u.A.fromJSON(t.tileInfoJSON);this._tileInfoView=new I(s),this._source=new np(t.service,this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),e),this._processor=new hd(e,this._source),this._handles=(0,r.vE)([(0,c.wB)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),this._connection.layerView.setUpdating({data: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 i.A("no-queryEngine","No query engine defined");return t}get aggregates(){const t=this._processor?.aggregateQueryEngine;if(!t)throw new i.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)}async updateSchema(t,e){return(0,n.A)("esri-2d-update-debug")&&this._updateSchemaRequest&&console.error("InternalError: Schema already updating"),this._updateSchemaRequest=new up({schema:t,version:e}),this._requestUpdate(),this._updateSchemaRequest.resolver.promise}updateSubscriptions(t){const e=new up(t);return this._updateSubscriptionRequests.push(e),this._requestUpdate(),e.resolver.promise}updateHighlight(t){const e=new up(t);return this._updateHighlightRequests.push(e),this._requestUpdate(),e.resolver.promise}async onEdits(t){if(null!=this._updateLocalEditsRequest)throw new i.A("InternalError - Already processing an edit");this._updateLocalEditsRequest=new up(t);const e=this._updateLocalEditsRequest.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,i=Number.NEGATIVE_INFINITY;const r="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 i=s.getCursor();for(;i.next();){let e=1;if(null!=t.field){const s=i.readAttribute(t.field);e=r?-1*+s:+s+n}const s=i.readXForDisplay()/u,o=i.readYForDisplay()/u,a=Math.floor(s),p=Math.floor(o);if(a<0||p<0||a>=d||p>=d)continue;const _=((.5+a-s)*u)**2+((.5+p-o)*u)**2;if(_>h)continue;const f=e*(c*(1-_/h)**2);l[p+a*d]+=f}}for(let t=0;t<l.length;t++)s=Math.min(s,l[t]),i=Math.max(i,l[t])}return{max:i,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,i=[],r=e.map((t=>t.reader.getCursor())),n=new h.A,o=3*t.sampleSize;for(let a=0;a<o&&i.length<t.sampleSize;a++){const t=r[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),i.push(t.readLegacyFeatureWorldSpace()))}return i.length>=t.sampleSize?i:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.d)((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=this._doUpdate().finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(t){const e=t.tileId;if(this._subscriptions.has(e)){const s=this._subscriptions.get(e);return void(s.paused&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.resume`),s.resume(),s.version=t.version,this._source.onResume(s)))}(0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.subscribe`);const s=new lp(this._tileInfoView,e),i=new ap(s,t.version);this._subscriptions.set(e,i),this._source.onSubscribe(i),this._processor.onSubscribe(i)}_unsubscribe(t){const e=this._subscriptions.get(t);e&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.unsubscribe`),this._source.onUnsubscribe(e),this._processor.onUnsubscribe(e),this._subscriptions.delete(e.key.id),e.destroy())}_pauseSubscription(t){const e=this._subscriptions.get(t);e&&((0,n.A)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.pause`),e.pause())}async _doUpdate(){if((0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data: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._updateLocalEditsRequest;if(this._updateLocalEditsRequest=null,null!=e){(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",e.inner);const t=await this._source.getLocalEdit(e.inner);await this._processor.applyLocalEdit(t),this._source.applyLocalEdit(t),(0,n.A)("esri-2d-update-debug")&&console.debug("Pipeline.endEditOverride",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{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({data: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({data: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};try{const i=await this._source.update(t,e),r=Array.from(this._subscriptions.values());await this._processor.update(t,e,s,i,r)}catch(t){console.error(t)}(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);if((0,n.A)("featurelayer-query-pausing-enabled"))for(const e of t.pause)this._pauseSubscription(e)}}},44159:(t,e,s)=>{s.d(e,{A:()=>r});var i=s(93687);class r{static getId(t,e,s,i){return"object"==typeof t?`${t.level}/${t.row}/${t.col}/${t.world}`:`${t}/${e}/${s}/${i}`}constructor(t,e,s,i){this.set(t,e,s,i)}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,i){this.set(t,e,s,i)}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 r(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(t,e,s,i){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,i,r]=t.split("/");this.level=parseFloat(e),this.row=parseFloat(s),this.col=parseFloat(i),this.world=parseFloat(r)}else this.level=+t,this.row=+e,this.col=+s,this.world=+i||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new r(this.level-1,this.row>>1,this.col>>1,this.world)}getNeighborId(t,e){return`${this.level}/${this.row+e}/${this.col+t}/${this.world}`}getChildKeys(){const t=this.level+1,e=this.row<<1,s=this.col<<1,i=this.world;return[new r(t,e,s,i),new r(t,e,s+1,i),new r(t,e+1,s,i),new r(t,e+1,s+1,i)]}compareRowMajor(t){return this.row<t.row?-1:this.row>t.row?1:this.col<t.col?-1:this.col>t.col?1:0}}r.pool=new i.A(r,null,null,25,50)},46263:(t,e,s)=>{var i;s.d(e,{c:()=>i}),function(t){t[t.Pass=0]="Pass",t[t.Draw=1]="Draw"}(i||(i={}))},620:(t,e,s)=>{s.d(e,{O_:()=>n,vA:()=>r}),s(48163),s(87317),(0,s(91829).vt)();class i{constructor(t){this.message=t}toString(){return`AssertException: ${this.message}`}}function r(t,e){if(!t){e=e||"Assertion";const t=new Error(e).stack;throw new i(`${e} at ${t}`)}}function n(t,e,s,i){let r,n=(s[0]-t[0])/e[0],o=(i[0]-t[0])/e[0];n>o&&(r=n,n=o,o=r);let a=(s[1]-t[1])/e[1],h=(i[1]-t[1])/e[1];if(a>h&&(r=a,a=h,h=r),n>h||a>o)return!1;a>n&&(n=a),h<o&&(o=h);let c=(s[2]-t[2])/e[2],l=(i[2]-t[2])/e[2];return c>l&&(r=c,c=l,l=r),!(n>l||c>o||(l<o&&(o=l),o<0))}},89738:(t,e,s)=>{s.d(e,{e:()=>l}),s(44208);var i=s(97768),r=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,i.xt)(this._schedule),this._task=(0,i.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 i=new AbortController;let n=null;e&&(n=(0,r.u7)(e,(()=>i.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(t),this._queue.remove(t),this._scheduleNext()},a=(0,r.NY)(i.signal,(()=>{const e=this._processingItems.get(t);e&&e.controller.abort(),o(),h.reject((0,r.NK)())})),h=(0,r.Tw)();return this._deferreds.set(t,h),this._controllers.set(t,i),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,r.NK)("Removed from queue")),this._removeItem(t)),t}reset(){const t=[];this._processingItems.forEach((e=>t.push(e))),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,i=new c(t,s);this._processingItems.set(t,i);try{e=this.process(t,s.signal)}catch(t){this._processError(i,t)}(0,r.$X)(e)?(i.promise=e,e.then((t=>this._processResult(i,t)),(t=>this._processError(i,t)))):this._processResult(i,e)}get test(){}}}}]);