@arcgis/core 4.29.0-next.20240213 → 4.29.0-next.20240214

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 (60) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/122af262edb8e13d5472.js +1 -0
  3. package/assets/esri/core/workers/chunks/{cc1c958aad790a44048b.js → 1ca28af7c516d8283bb0.js} +1 -1
  4. package/assets/esri/core/workers/chunks/1f8a0fb32b96e50f5909.js +1 -0
  5. package/assets/esri/core/workers/chunks/5638d95e600ff271c5b1.js +1 -0
  6. package/assets/esri/core/workers/chunks/5aef1e898618f8dda2c9.js +1 -0
  7. package/assets/esri/core/workers/chunks/66f21348fb68c83b9dc3.js +1108 -0
  8. package/assets/esri/core/workers/chunks/{eb2d6f1ee63b40ae0736.js → 774b655498289b1b36bb.js} +1 -1
  9. package/assets/esri/core/workers/chunks/7e0031822b94d2477a21.js +1 -0
  10. package/assets/esri/core/workers/chunks/{f03d62ab7806b68d0b62.js → 9fbf61675e2a5374f754.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{1c6914ded7db720f7bf7.js → daf6eab5dd198ca9a67b.js} +1 -1
  12. package/assets/esri/core/workers/chunks/ebb294c82207f3ff9f04.js +1 -0
  13. package/assets/esri/core/workers/chunks/{e4da908079417cc2f495.js → ee0c77889059815a31b2.js} +1 -1
  14. package/chunks/vec32.js +1 -1
  15. package/interfaces.d.ts +11 -17
  16. package/package.json +1 -1
  17. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  18. package/support/revision.js +1 -1
  19. package/symbols/cim/cimAnalyzer.js +1 -1
  20. package/symbols/cim/defaultCIMValues.js +1 -1
  21. package/symbols/cim/utils.js +1 -1
  22. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  23. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  24. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  25. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  26. package/views/2d/layers/features/Processor.js +1 -1
  27. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  28. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  29. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  30. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  31. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  32. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  33. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  34. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  35. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  36. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  37. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +9 -7
  38. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceConstants.js +5 -0
  39. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
  40. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  41. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  42. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  43. package/views/SceneView.js +1 -1
  44. package/views/View.js +1 -1
  45. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  46. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  47. package/widgets/Editor/EditorViewModel.js +1 -1
  48. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  49. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  50. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  51. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  52. package/widgets/FeatureTable.js +1 -1
  53. package/widgets/Sketch/SketchViewModel.js +1 -1
  54. package/assets/esri/core/workers/chunks/00b9e92f8df245a83921.js +0 -1
  55. package/assets/esri/core/workers/chunks/02ee044597c89c86b934.js +0 -1
  56. package/assets/esri/core/workers/chunks/42ab9c282bb267c3db03.js +0 -1
  57. package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +0 -1
  58. package/assets/esri/core/workers/chunks/50cdc59426ba859027e2.js +0 -1
  59. package/assets/esri/core/workers/chunks/5dbb3ef6fdd25ac632ad.js +0 -1
  60. package/assets/esri/core/workers/chunks/968808e99f08677152cb.js +0 -1106
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[4496],{17012:(e,t,r)=>{r.d(t,{e:()=>c});var s,i,n,o=r(8528),a={exports:{}};s=a,i=function(){function e(e,r,i){i=i||2;var n,o,a,l,u,h,d,_=r&&r.length,p=_?r[0]*i:e.length,f=t(e,0,p,i,!0),m=[];if(!f||f.next===f.prev)return m;if(_&&(f=c(e,r,f,i)),e.length>80*i){n=a=e[0],o=l=e[1];for(var g=i;g<p;g+=i)(u=e[g])<n&&(n=u),(h=e[g+1])<o&&(o=h),u>a&&(a=u),h>l&&(l=h);d=0!==(d=Math.max(a-n,l-o))?1/d:0}return s(f,m,i,n,o,d),m}function t(e,t,r,s,i){var n,o;if(i===A(e,t,r,s)>0)for(n=t;n<r;n+=s)o=I(n,e[n],e[n+1],o);else for(n=r-s;n>=t;n-=s)o=I(n,e[n],e[n+1],o);if(o&&x(o,o.next)){var a=o.next;E(o),o=a}return o}function r(e,t){if(!e)return e;t||(t=e);var r,s=e;do{if(r=!1,s.steiner||!x(s,s.next)&&0!==y(s.prev,s,s.next))s=s.next;else{var i=s.prev;if(E(s),(s=t=i)===s.next)break;r=!0}}while(r||s!==t);return t}function s(e,t,c,l,u,h,d){if(e){!d&&h&&_(e,l,u,h);for(var p,f,m=e;e.prev!==e.next;)if(p=e.prev,f=e.next,h?n(e,l,u,h):i(e))t.push(p.i/c),t.push(e.i/c),t.push(f.i/c),E(e),e=f.next,m=f.next;else if((e=f)===m){d?1===d?s(e=o(r(e),t,c),t,c,l,u,h,2):2===d&&a(e,t,c,l,u,h):s(r(e),t,c,l,u,h,1);break}}}function i(e){var t=e.prev,r=e,s=e.next;if(y(t,r,s)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(m(t.x,t.y,r.x,r.y,s.x,s.y,i.x,i.y)&&y(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function n(e,t,r,s){var i=e.prev,n=e,o=e.next;if(y(i,n,o)>=0)return!1;for(var a=i.x<n.x?i.x<o.x?i.x:o.x:n.x<o.x?n.x:o.x,c=i.y<n.y?i.y<o.y?i.y:o.y:n.y<o.y?n.y:o.y,l=i.x>n.x?i.x>o.x?i.x:o.x:n.x>o.x?n.x:o.x,u=i.y>n.y?i.y>o.y?i.y:o.y:n.y>o.y?n.y:o.y,h=p(a,c,t,r,s),d=p(l,u,t,r,s),_=e.prevZ,f=e.nextZ;_&&_.z>=h&&f&&f.z<=d;){if(_!==e.prev&&_!==e.next&&m(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&y(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,f!==e.prev&&f!==e.next&&m(i.x,i.y,n.x,n.y,o.x,o.y,f.x,f.y)&&y(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;_&&_.z>=h;){if(_!==e.prev&&_!==e.next&&m(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&y(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&m(i.x,i.y,n.x,n.y,o.x,o.y,f.x,f.y)&&y(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function o(e,t,s){var i=e;do{var n=i.prev,o=i.next.next;!x(n,o)&&b(n,i,i.next,o)&&S(n,o)&&S(o,n)&&(t.push(n.i/s),t.push(i.i/s),t.push(o.i/s),E(i),E(i.next),i=e=o),i=i.next}while(i!==e);return r(i)}function a(e,t,i,n,o,a){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&g(c,l)){var u=v(c,l);return c=r(c,c.next),u=r(u,u.next),s(c,t,i,n,o,a),void s(u,t,i,n,o,a)}l=l.next}c=c.next}while(c!==e)}function c(e,s,i,n){var o,a,c,u=[];for(o=0,a=s.length;o<a;o++)(c=t(e,s[o]*n,o<a-1?s[o+1]*n:e.length,n,!1))===c.next&&(c.steiner=!0),u.push(f(c));for(u.sort(l),o=0;o<u.length;o++)i=r(i=h(u[o],i),i.next);return i}function l(e,t){return e.x-t.x}function u(e){if(e.next.prev===e)return e;let t=e;for(;;){const r=t.next;if(r.prev===t||r===t||r===e)break;t=r}return t}function h(e,t){var s=function(e,t){var r,s=t,i=e.x,n=e.y,o=-1/0;do{if(n<=s.y&&n>=s.next.y&&s.next.y!==s.y){var a=s.x+(n-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(a<=i&&a>o){if(o=a,a===i){if(n===s.y)return s;if(n===s.next.y)return s.next}r=s.x<s.next.x?s:s.next}}s=s.next}while(s!==t);if(!r)return null;if(i===o)return r;var c,l=r,u=r.x,h=r.y,_=1/0;s=r;do{i>=s.x&&s.x>=u&&i!==s.x&&m(n<h?i:o,n,u,h,n<h?o:i,n,s.x,s.y)&&(c=Math.abs(n-s.y)/(i-s.x),S(s,e)&&(c<_||c===_&&(s.x>r.x||s.x===r.x&&d(r,s)))&&(r=s,_=c)),s=s.next}while(s!==l);return r}(e,t);if(!s)return t;var i=v(s,e),n=r(s,s.next);let o=u(i);return r(o,o.next),n=u(n),u(t===s?n:t)}function d(e,t){return y(e.prev,e,t.prev)<0&&y(t.next,e,e.next)<0}function _(e,t,r,s){var i=e;do{null===i.z&&(i.z=p(i.x,i.y,t,r,s)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,s,i,n,o,a,c,l=1;do{for(r=e,e=null,n=null,o=0;r;){for(o++,s=r,a=0,t=0;t<l&&(a++,s=s.nextZ);t++);for(c=l;a>0||c>0&&s;)0!==a&&(0===c||!s||r.z<=s.z)?(i=r,r=r.nextZ,a--):(i=s,s=s.nextZ,c--),n?n.nextZ=i:e=i,i.prevZ=n,n=i;r=s}n.nextZ=null,l*=2}while(o>1)}(i)}function p(e,t,r,s,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function f(e){var t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function m(e,t,r,s,i,n,o,a){return(i-o)*(t-a)-(e-o)*(n-a)>=0&&(e-o)*(s-a)-(r-o)*(t-a)>=0&&(r-o)*(n-a)-(i-o)*(s-a)>=0}function g(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&b(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(S(e,t)&&S(t,e)&&function(e,t){var r=e,s=!1,i=(e.x+t.x)/2,n=(e.y+t.y)/2;do{r.y>n!=r.next.y>n&&r.next.y!==r.y&&i<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next}while(r!==e);return s}(e,t)&&(y(e.prev,e,t.prev)||y(e,t.prev,t))||x(e,t)&&y(e.prev,e,e.next)>0&&y(t.prev,t,t.next)>0)}function y(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,r,s){var i=w(y(e,t,r)),n=w(y(e,t,s)),o=w(y(r,s,e)),a=w(y(r,s,t));return i!==n&&o!==a||!(0!==i||!T(e,r,t))||!(0!==n||!T(e,s,t))||!(0!==o||!T(r,e,s))||!(0!==a||!T(r,t,s))}function T(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function w(e){return e>0?1:e<0?-1:0}function S(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function v(e,t){var r=new R(e.i,e.x,e.y),s=new R(t.i,t.x,t.y),i=e.next,n=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,s.next=r,r.prev=s,n.next=s,s.prev=n,s}function I(e,t,r,s){var i=new R(e,t,r);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function E(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function R(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function A(e,t,r,s){for(var i=0,n=t,o=r-s;n<r;n+=s)i+=(e[o]-e[n])*(e[n+1]+e[o+1]),o=n;return i}return e.deviation=function(e,t,r,s){var i=t&&t.length,n=i?t[0]*r:e.length,o=Math.abs(A(e,0,n,r));if(i)for(var a=0,c=t.length;a<c;a++){var l=t[a]*r,u=a<c-1?t[a+1]*r:e.length;o-=Math.abs(A(e,l,u,r))}var h=0;for(a=0;a<s.length;a+=3){var d=s[a]*r,_=s[a+1]*r,p=s[a+2]*r;h+=Math.abs((e[d]-e[p])*(e[_+1]-e[d+1])-(e[d]-e[_])*(e[p+1]-e[d+1]))}return 0===o&&0===h?0:Math.abs((h-o)/o)},e.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},s=0,i=0;i<e.length;i++){for(var n=0;n<e[i].length;n++)for(var o=0;o<t;o++)r.vertices.push(e[i][n][o]);i>0&&(s+=e[i-1].length,r.holes.push(s))}return r},e},void 0!==(n=i())&&(s.exports=n);const c=(0,o.g)(a.exports)},54792:(e,t,r)=>{r.d(t,{c:()=>n});var s=r(67432),i=r(9592);class n{constructor(e=(e=>e.values().next().value)){this._peeker=e,this._observable=new i.n,this._items=new Set}get length(){return(0,s.am)(this._observable),this._items.size}clear(){0!==this.length&&(this._items.clear(),this._observable.notify())}last(){if(0===this.length)return;let e;for(e of this._items);return e}peek(){if(0!==this.length)return this._peeker(this._items)}push(e){this.contains(e)||(this._items.add(e),this._observable.notify())}contains(e){return(0,s.am)(this._observable),this._items.has(e)}pop(){if(0===this.length)return;const e=this.peek();return this._items.delete(e),this._observable.notify(),e}popLast(){if(0===this.length)return;const e=this.last();return this._items.delete(e),this._observable.notify(),e}remove(e){this.contains(e)&&(this._items.delete(e),this._observable.notify())}filter(e){const t=this.length;return this._items.forEach((t=>{e(t)||this._items.delete(t)})),t!==this._items.size&&this._observable.notify(),this}*[Symbol.iterator](){(0,s.am)(this._observable),yield*this._items}}},23964:(e,t,r)=>{r.d(t,{c:()=>n});var s=r(67432),i=r(9592);class n{constructor(e){this._observable=new i.n,this._map=new Map(e)}get size(){return(0,s.am)(this._observable),this._map.size}clear(){this._map.size>0&&(this._map.clear(),this._observable.notify())}delete(e){const t=this._map.delete(e);return t&&this._observable.notify(),t}entries(){return(0,s.am)(this._observable),this._map.entries()}forEach(e,t){(0,s.am)(this._observable),this._map.forEach(((r,s)=>e.call(t,r,s,this)),t)}get(e){return(0,s.am)(this._observable),this._map.get(e)}has(e){return(0,s.am)(this._observable),this._map.has(e)}keys(){return(0,s.am)(this._observable),this._map.keys()}set(e,t){return this._map.set(e,t),this._observable.notify(),this}values(){return(0,s.am)(this._observable),this._map.values()}[Symbol.iterator](){return(0,s.am)(this._observable),this._map[Symbol.iterator]()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}}},85256:(e,t,r)=>{function s(){return[0,0]}function i(e,t){return[e,t]}function n(){return i(1,1)}function o(){return i(1,0)}function a(){return i(0,1)}r.d(t,{Qw:()=>c,Su:()=>s,WK:()=>i});const c=n(),l=o(),u=a();Object.freeze(Object.defineProperty({__proto__:null,ONES:c,UNIT_X:l,UNIT_Y:u,ZEROS:[0,0],clone:function(e){return[e[0],e[1]]},create:s,createView:function(e,t){return new Float64Array(e,t,2)},fromArray:function(e,t=[0,0]){const r=Math.min(2,e.length);for(let s=0;s<r;++s)t[s]=e[s];return t},fromValues:i,ones:n,unitX:o,unitY:a,zeros:function(){return[0,0]}},Symbol.toStringTag,{value:"Module"}))},60936:(e,t,r)=>{r.d(t,{A:()=>u});var s=r(41948),i=r(43780),n=r(38912),o=r(57896),a=r(66168),c=r(1580),l=r(12552);let u=class extends i.c{constructor(){super(...arguments),this.updating=!1,this._handleId=0,this._scheduleHandleId=0,this._pendingPromises=new Set}destroy(){this.removeAll()}add(e,t,r={}){return this._installWatch(e,t,r,o.aE)}addWhen(e,t,r={}){return this._installWatch(e,t,r,o._I)}addOnCollectionChange(e,t,{initial:r=!1,final:s=!1}={}){const i=++this._handleId;return this.addHandles([(0,o.on)(e,"after-changes",this._createSyncUpdatingCallback(),o.du),(0,o.on)(e,"change",t,{onListenerAdd:r?e=>t({added:e.toArray(),removed:[]}):void 0,onListenerRemove:s?e=>t({added:[],removed:e.toArray()}):void 0})],i),(0,n.uU)((()=>this.removeHandles(i)))}addPromise(e){if(null==e)return e;const t=++this._handleId;this.addHandles((0,n.uU)((()=>{this._pendingPromises.delete(e)&&(0!==this._pendingPromises.size||this.hasHandles(h)||this._set("updating",!1))})),t),this._pendingPromises.add(e),this._set("updating",!0);const r=()=>this.removeHandles(t);return e.then(r,r),e}removeAll(){this._pendingPromises.clear(),this.removeAllHandles(),this._set("updating",!1)}_installWatch(e,t,r={},s){const i=++this._handleId;r.sync||this._installSyncUpdatingWatch(e,i);const o=s(e,t,r);return this.addHandles(o,i),(0,n.uU)((()=>this.removeHandles(i)))}_installSyncUpdatingWatch(e,t){const r=this._createSyncUpdatingCallback(),s=(0,o.aE)(e,r,{sync:!0,equals:()=>!1});return this.addHandles(s,t),s}_createSyncUpdatingCallback(){return()=>{this.removeHandles(h),++this._scheduleHandleId;const e=this._scheduleHandleId;this._get("updating")||this._set("updating",!0),this.addHandles((0,a.Ow)((()=>{e===this._scheduleHandleId&&(this._set("updating",this._pendingPromises.size>0),this.removeHandles(h))})),h)}}};(0,s._)([(0,c.qq)({readOnly:!0})],u.prototype,"updating",void 0),u=(0,s._)([(0,l.c)("esri.core.support.UpdatingHandles")],u);const h=-42},46448:(e,t,r)=>{r.d(t,{c:()=>l});var s=r(38912),i=r(10860),n=r(54792),o=r(13056),a=r(25512),c=r(38432);class l{constructor(){this._inUseClients=new Array,this._clients=new Array,this._clientPromises=new Array,this._ongoingJobsQueue=new n.c}destroy(){this.close()}get closed(){return!this._clients?.length}open(e,t){return new Promise(((r,s)=>{let n=!0;const o=e=>{(0,i.wp)(t.signal),n&&(n=!1,e())};this._clients.length=e.length,this._clientPromises.length=e.length,this._inUseClients.length=e.length;for(let n=0;n<e.length;++n){const a=e[n];(0,i.eW)(a)?this._clientPromises[n]=a.then((e=>(this._clients[n]=new c.default(e,t,this._ongoingJobsQueue),o(r),this._clients[n])),(()=>(o(s),null))):(this._clients[n]=new c.default(a,t,this._ongoingJobsQueue),this._clientPromises[n]=Promise.resolve(this._clients[n]),o(r))}}))}broadcast(e,t,r){const s=new Array(this._clientPromises.length);for(let i=0;i<this._clientPromises.length;++i){const n=this._clientPromises[i];s[i]=n.then((s=>s?.invoke(e,t,r)))}return s}close(){let e;for(;e=this._ongoingJobsQueue.pop();)e.resolver.reject((0,i.Uh)(`Worker closing, aborting job calling '${e.methodName}'`));for(const e of this._clientPromises)e.then((e=>e?.close()));this._clients.length=0,this._clientPromises.length=0,this._inUseClients.length=0,(0,o.S)(this)}invoke(e,t,r){return this.apply(e,[t],r)}apply(e,t,r){const s=(0,i.qG)();this._ongoingJobsQueue.push({methodName:e,data:t,invokeOptions:r,resolver:s});for(let e=0;e<this._clientPromises.length;e++){const t=this._clients[e];t?t.jobAdded():this._clientPromises[e].then((e=>e?.jobAdded()))}return s.promise}createInvokeProxy(e){return(0,a.Y)(this,e)}on(e,t){return Promise.all(this._clientPromises).then((()=>(0,s.Ip)(this._clients.map((r=>r.on(e,t))))))}openPorts(){return new Promise((e=>{const t=new Array(this._clientPromises.length);let r=t.length;for(let s=0;s<this._clientPromises.length;++s)this._clientPromises[s].then((i=>{i&&(t[s]=i.openPort()),0==--r&&e(t)}))}))}get test(){return{numClients:this._clients.length}}}},13056:(e,t,r)=>{r.d(t,{S:()=>n,s:()=>i});const s=new FinalizationRegistry((e=>{e.close()}));function i(e,t){s.register(e,t,t)}function n(e){s.unregister(e)}},59612:(e,t,r)=>{r.d(t,{EN:()=>S,S8:()=>T,i2:()=>m,wt:()=>f}),r(9456);var s=r(53648),i=r(95247),n=r(7488),o=r(56156),a=r(67932),c=r(97088),l=r(85152),u=r(7684);const h=new Float64Array(2),d=new Float64Array(2),_="0123456789bcdefghjkmnpqrstuvwxyz",p=64;function f(e,t,r,s){const a=[e.xmin,e.ymin,e.xmax,e.ymax],h=n.c.fromExtent(i.c.fromBounds(a,s)),d=(0,u.yU)(h,s,o.c.WGS84,{densificationStep:t*p}),_=(0,c.Uh)(new l.c,d,!1,!1),f=_.coords.filter(((e,t)=>!(t%2))),g=_.coords.filter(((e,t)=>t%2)),y=Math.min(...f),x=Math.min(...g),b=Math.max(...f),T=Math.max(...g),w=m(y,x,r,o.c.WGS84),S=m(b,T,r,o.c.WGS84);if(!w||!S)throw new Error("InternalError: Unable to project tile bounds");return{bounds:a,geohashBounds:{xLL:w[0],yLL:w[1],xTR:S[0],yTR:S[1]},level:r}}function m(e,t,r,i){if(i.isWebMercator){const i=(0,s.UB)(e/a.ug.radius),n=i-360*Math.floor((i+180)/360),o=[0,0];return w(o,0,(0,s.UB)(Math.PI/2-2*Math.atan(Math.exp(-t/a.ug.radius))),n,r),o}const n=(0,u.yU)({x:e,y:t},i,o.c.WGS84);if(!n)return null;const c=[0,0];return w(c,0,n.y,n.x,r),c}function g(e){return _[e]}function y(e){return(e[0]+e[1])/2}function x(e,t,r){return e[0]=t,e[1]=r,e}function b(e,t){const r=t>y(e);return function(e,t){const r=y(e),s=t,i=!t;e[0]=i*e[0]+s*r,e[1]=i*r+s*e[1]}(e,r),r}function T(e,t){let r=-90,s=90,i=-180,n=180;for(let o=0;o<t;o++){const t=Math.ceil((o+1)/2),a=Math.floor((o+1)/2),c=1-o%2,l=30-(3*t+2*a),u=30-(2*t+3*a),h=3*c+2*(1-c),d=2*c+3*(1-c),_=3*c+7*(1-c)<<u,p=(7*c+3*(1-c)<<l&e.geohashX)>>l,f=(_&e.geohashY)>>u;for(let e=h-1;e>=0;e--){const t=(i+n)/2,r=p&1<<e?1:0;i=(1-r)*i+r*t,n=(1-r)*t+r*n}for(let e=d-1;e>=0;e--){const t=(r+s)/2,i=f&1<<e?1:0;r=(1-i)*r+i*t,s=(1-i)*t+i*s}}return[i,r,n,s]}function w(e,t,r,s,i){i%2&&(i+=1);let n=0,o=0,a=-90,c=90,l=-180,u=180;for(let e=0;e<i/2;e++){for(let t=0;t<5;t++){const r=(l+u)/2,i=s>r?1:0;n|=i<<29-(t+5*e),l=(1-i)*l+i*r,u=(1-i)*r+i*u}for(let t=0;t<5;t++){const s=(a+c)/2,i=r>s?1:0;o|=i<<29-(t+5*e),a=(1-i)*a+i*s,c=(1-i)*s+i*c}}e[2*t]=n,e[2*t+1]=o}function S(e,t,r){let s="";const i=x(h,-90,90),n=x(d,-180,180);for(let o=0;o<r;o++){let r=0;o%2?(r|=b(i,e)<<4,r|=b(n,t)<<3,r|=b(i,e)<<2,r|=b(n,t)<<1,r|=b(i,e)<<0):(r|=b(n,t)<<4,r|=b(i,e)<<3,r|=b(n,t)<<2,r|=b(i,e)<<1,r|=b(n,t)<<0),s+=g(r)}return s}},30936:(e,t,r)=>{r.d(t,{C:()=>c,y:()=>l});var s=r(24832),i=r(9456);const n=128e3;let o=null,a=null;async function c(){return o||(o=async function(){const e=(0,i.c)("esri-csp-restrictions")?await r.e(840).then(r.bind(r,30840)).then((e=>e.l)):await r.e(4175).then(r.bind(r,36556)).then((e=>e.l));a=await e.default({locateFile:e=>(0,s.O)(`esri/core/libs/libtess/${e}`)})}()),o}function l(e,t){const r=Math.max(e.length,n);return a.triangulate(e,t,r)}},57006:(e,t,r)=>{r.r(t),r.d(t,{createConnection:()=>R});var s=r(41948),i=(r(60708),r(2600)),n=r(20744),o=r(66360),a=r(10860),c=r(28176),l=(r(9456),r(72052),r(12552)),u=r(1580),h=r(37924),d=r(77860);let _=class extends d.c.EventedAccessor{destroy(){this.emit("destroy")}get connectionError(){return this.errorString?new n.c("stream-connection",this.errorString):null}onFeature(e){this.emit("data-received",e)}onMessage(e){this.emit("message-received",e)}};(0,s._)([(0,u.qq)({readOnly:!0})],_.prototype,"connectionError",null),_=(0,s._)([(0,l.c)("esri.layers.support.StreamConnection")],_);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 p{constructor(e){super({}),this._outstandingMessages=[],this.errorString=null;const{geometryType:t,spatialReference:r,sourceSpatialReference:s}=e;this._config=e,this._featureZScaler=(0,h.O)(t,s,r),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(e){null!=this._websocket?this._websocket.send(JSON.stringify(e)):this._outstandingMessages.push(e)}sendMessageToClient(e){this._onMessage(e)}updateCustomParameters(e){this._config.customParameters=e,null!=this._websocket&&this._websocket.close()}async _tryCreateWebSocket(e=this._config.source.path,t=1e3,r=0){try{if(this.destroyed)return;const t=(0,c.UP)(e,this._config.customParameters??{});this._websocket=await this._createWebSocket(t),this.notifyChange("connectionStatus")}catch(s){const i=t/1e3;return this._config.maxReconnectionAttempts&&r>=this._config.maxReconnectionAttempts?(o.c.getLogger(this).error(new n.c("websocket-connection","Exceeded maxReconnectionAttempts attempts. No further attempts will be made")),void this.destroy()):(o.c.getLogger(this).error(new n.c("websocket-connection",`Failed to connect. Attempting to reconnect in ${i}s`,s)),await(0,a.iV)(t),this._tryCreateWebSocket(e,Math.min(1.5*t,1e3*this._config.maxReconnectionInterval),r+1))}}_setWebSocketJSONParseHandler(e){e.onmessage=e=>{try{const t=JSON.parse(e.data);this._onMessage(t)}catch(e){return void o.c.getLogger(this).error(new n.c("websocket-connection","Failed to parse message, invalid JSON",{error:e}))}}}_createWebSocket(e){return new Promise(((t,r)=>{const s=new WebSocket(e);s.onopen=()=>{if(s.onopen=null,this.destroyed)return s.onclose=null,void s.close();s.onclose=e=>this._onClose(e),s.onerror=e=>this._onError(e),this._setWebSocketJSONParseHandler(s),t(s)},s.onclose=e=>{s.onopen=s.onclose=null,r(e)}}))}async _handshake(e=1e4){const t=this._websocket;if(null==t)return;const r=(0,a.qG)(),s=t.onmessage,{filter:i,outFields:c,spatialReference:l}=this._config;return r.timeout(e),t.onmessage=e=>{let a=null;try{a=JSON.parse(e.data)}catch(e){}a&&"object"==typeof a||(o.c.getLogger(this).error(new n.c("websocket-connection","Protocol violation. Handshake failed - malformed message",e.data)),r.reject(),this.destroy()),a.spatialReference?.wkid!==l?.wkid&&(o.c.getLogger(this).error(new n.c("websocket-connection",`Protocol violation. Handshake failed - expected wkid of ${l.wkid}`,e.data)),r.reject(),this.destroy()),"json"!==a.format&&(o.c.getLogger(this).error(new n.c("websocket-connection","Protocol violation. Handshake failed - format is not set",e.data)),r.reject(),this.destroy()),i&&a.filter!==i&&o.c.getLogger(this).error(new n.c("websocket-connection","Tried to set filter, but server doesn't support it")),c&&a.outFields!==c&&o.c.getLogger(this).error(new n.c("websocket-connection","Tried to set outFields, but server doesn't support it")),t.onmessage=s;for(const e of this._outstandingMessages)t.send(JSON.stringify(e));this._outstandingMessages=[],r.resolve()},t.send(JSON.stringify({filter:i,outFields:c,format:"json",spatialReference:{wkid:l.wkid}})),r.promise}_onMessage(e){if(this.onMessage(e),"type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)null!=this._featureZScaler&&this._featureZScaler(t.geometry),this.onFeature(t)}}_onError(e){const t="Encountered an error over WebSocket connection";this._set("errorString",t),o.c.getLogger(this).error("websocket-connection",t)}_onClose(e){this._websocket=null,this.notifyChange("connectionStatus"),1e3!==e.code&&o.c.getLogger(this).error("websocket-connection",`WebSocket closed unexpectedly with error code ${e.code}`),this.destroyed||this._open()}};(0,s._)([(0,u.qq)()],g.prototype,"connectionStatus",null),(0,s._)([(0,u.qq)()],g.prototype,"errorString",void 0),g=(0,s._)([(0,l.c)("esri.layers.graphics.sources.connections.WebSocketConnection")],g);var y=r(32848),x=r(95776),b=r(6704),T=r(56156);const w={maxQueryDepth:5,maxRecordCountFactor:3};let S=class extends g{constructor(e){super({...w,...e}),this._buddyServicesQuery=null,this._relatedFeatures=null}async _open(){const e=await this._fetchServiceDefinition(this._config.source);e.timeInfo.trackIdField||o.c.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 t=this._fetchWebSocketUrl(e.streamUrls,this._config.spatialReference);this._buddyServicesQuery||(this._buddyServicesQuery=this._queryBuddyServices()),await this._buddyServicesQuery,await this._tryCreateWebSocket(t);const{filter:r,outFields:s}=this._config;this.destroyed||this._setFilter(r,s)}_onMessage(e){if("attributes"in e){let t;try{t=this._enrich(e),null!=this._featureZScaler&&this._featureZScaler(t.geometry)}catch(e){return void o.c.getLogger(this).error(new n.c("geoevent-connection","Failed to parse message",e))}this.onFeature(t)}else this.onMessage(e)}async _fetchServiceDefinition(e){const t={f:"json",...this._config.customParameters},r=(0,i.c)(e.path,{query:t,responseType:"json"}),s=(await r).data;return this._serviceDefinition=s,s}_fetchWebSocketUrl(e,t){const r=e[0],{urls:s,token:i}=r,n=this._inferWebSocketBaseUrl(s);return(0,c.UP)(`${n}/subscribe`,{outSR:""+t.wkid,token:i})}_inferWebSocketBaseUrl(e){if(1===e.length)return e[0];for(const t of e)if(t.includes("wss"))return t;return o.c.getLogger(this).error(new n.c("geoevent-connection","Unable to infer WebSocket url",e)),null}async _setFilter(e,t){const r=this._websocket;if(null==r||null==e&&null==t)return;const s=JSON.stringify({filter:this._serializeFilter(e,t)});let i=!1;const c=(0,a.qG)();return r.onmessage=e=>{const t=JSON.parse(e.data);t.filter&&(t.error&&(o.c.getLogger(this).error(new n.c("geoevent-connection","Failed to set service filter",t.error)),this._set("errorString",`Could not set service filter - ${t.error}`),c.reject(t.error)),this._setWebSocketJSONParseHandler(r),i=!0,c.resolve())},r.send(s),setTimeout((()=>{i||(this.destroyed||this._websocket!==r||o.c.getLogger(this).error(new n.c("geoevent-connection","Server timed out when setting filter")),c.reject())}),1e4),c.promise}_serializeFilter(e,t){const r={};if(null==e&&null==t)return r;if(e?.geometry)try{const t=(0,b.h4)(e.geometry);if("extent"!==t.type)throw new n.c(`Expected extent but found type ${t.type}`);r.geometry=JSON.stringify(t.shiftCentralMeridian())}catch(e){o.c.getLogger(this).error(new n.c("geoevent-connection","Encountered an error when setting connection geometryDefinition",e))}return e?.where&&"1 = 1"!==e.where&&"1=1"!==e.where&&(r.where=e.where),null!=t&&(r.outFields=t.join(",")),r}_enrich(e){if(!this._relatedFeatures)return e;const t=this._serviceDefinition.relatedFeatures.joinField,r=e.attributes[t],s=this._relatedFeatures.get(r);if(!s)return o.c.getLogger(this).warn("geoevent-connection","Feature join failed. Is the join field configured correctly?",e),e;const{attributes:i,geometry:a}=s;for(const t in i)e.attributes[t]=i[t];return a&&(e.geometry=a),e.geometry||e.centroid||o.c.getLogger(this).error(new n.c("geoevent-connection","Found malformed feature - no geometry found",e)),e}async _queryBuddyServices(){try{const{relatedFeatures:e,keepLatestArchive:t}=this._serviceDefinition,r=this._queryRelatedFeatures(e),s=this._queryArchive(t);await r;const i=await s;if(!i)return;for(const e of i.features)this.onFeature(this._enrich(e))}catch(e){o.c.getLogger(this).error(new n.c("geoevent-connection","Encountered an error when querying buddy services",{error:e}))}}async _queryRelatedFeatures(e){if(!e)return;const t=await this._queryBuddy(e.featuresUrl);this._addRelatedFeatures(t)}async _queryArchive(e){if(e)return this._queryBuddy(e.featuresUrl)}async _queryBuddy(e){const t=new((await Promise.all([r.e(5612),r.e(5156),r.e(2692),r.e(7988),r.e(1744),r.e(236),r.e(8976),r.e(9512),r.e(2664),r.e(6556),r.e(672),r.e(1004)]).then(r.bind(r,672))).default)({url:e}),{capabilities:s}=await t.load(),i=s.query.supportsMaxRecordCountFactor,n=s.query.supportsPagination,o=s.query.supportsCentroid,a=this._config.maxRecordCountFactor,c=t.capabilities.query.maxRecordCount,l=i?c*a:c,u=new x.c;if(u.outFields=this._config.outFields??["*"],u.where=this._config.filter?.where??"1=1",u.returnGeometry=!0,u.returnExceededLimitFeatures=!0,u.outSpatialReference=T.c.fromJSON(this._config.spatialReference),o&&(u.returnCentroid=!0),i&&(u.maxRecordCountFactor=a),n)return u.num=l,t.destroy(),this._queryPages(e,u);const h=await(0,y.EL)(e,u,this._config.sourceSpatialReference);return t.destroy(),h.data}async _queryPages(e,t,r=[],s=0){t.start=null!=t.num?s*t.num:null;const{data:i}=await(0,y.EL)(e,t,this._config.sourceSpatialReference);return i.exceededTransferLimit&&s<(this._config.maxQueryDepth??0)?(i.features.forEach((e=>r.push(e))),this._queryPages(e,t,r,s+1)):(r.forEach((e=>i.features.push(e))),i)}_addRelatedFeatures(e){const t=new Map,r=e.features,s=this._serviceDefinition.relatedFeatures.joinField;for(const e of r){const r=e.attributes[s];t.set(r,e)}this._relatedFeatures=t}};S=(0,s._)([(0,l.c)("esri.layers.graphics.sources.connections.GeoEventConnection")],S);const v=S;let I=class extends p{constructor(e){super({}),this.connectionStatus="connected",this.errorString=null;const{geometryType:t,spatialReference:r,sourceSpatialReference:s}=e;this._featureZScaler=(0,h.O)(t,s,r)}normalizeCtorArgs(){return{}}updateCustomParameters(e){}sendMessageToSocket(e){}sendMessageToClient(e){if("type"in e)switch(e.type){case"features":case"featureResult":for(const t of e.features)null!=this._featureZScaler&&this._featureZScaler(t.geometry),this.onFeature(t)}this.onMessage(e)}};function E(e,t){if(null==e&&null==t)return null;const r={};return null!=t&&(r.geometry=t),null!=e&&(r.where=e),r}function R(e,t,r,s,i,n,o,a,c){const l={source:e,sourceSpatialReference:t,spatialReference:r,geometryType:s,filter:E(i,n),maxReconnectionAttempts:o,maxReconnectionInterval:a,customParameters:c};return e?e.path.startsWith("wss://")||e.path.startsWith("ws://")?new g(l):new v(l):new I(l)}(0,s._)([(0,u.qq)()],I.prototype,"connectionStatus",void 0),(0,s._)([(0,u.qq)()],I.prototype,"errorString",void 0),I=(0,s._)([(0,l.c)("esri.layers.support.ClientSideConnection")],I)},22108:(e,t,r)=>{r.d(t,{c:()=>u});var s,i=r(41948),n=r(40504),o=r(1580),a=r(53368),c=(r(72052),r(9456),r(12552));let l=s=class extends n.am{constructor(e){super(e),this.cols=null,this.level=0,this.levelValue=null,this.origin=null,this.resolution=0,this.rows=null,this.scale=0}clone(){return new s({cols:this.cols,level:this.level,levelValue:this.levelValue,resolution:this.resolution,rows:this.rows,scale:this.scale})}};(0,i._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],l.prototype,"cols",void 0),(0,i._)([(0,o.qq)({type:a.Ab,json:{write:!0}})],l.prototype,"level",void 0),(0,i._)([(0,o.qq)({type:String,json:{write:!0}})],l.prototype,"levelValue",void 0),(0,i._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],l.prototype,"origin",void 0),(0,i._)([(0,o.qq)({type:Number,json:{write:!0}})],l.prototype,"resolution",void 0),(0,i._)([(0,o.qq)({json:{write:!0,origins:{"web-document":{read:!1,write:!1},"portal-item":{read:!1,write:!1}}}})],l.prototype,"rows",void 0),(0,i._)([(0,o.qq)({type:Number,json:{write:!0}})],l.prototype,"scale",void 0),l=s=(0,i._)([(0,c.c)("esri.layers.support.LOD")],l);const u=l},87576:(e,t,r)=>{r.d(t,{c:()=>v});var s,i=r(41948),n=r(14628),o=r(40504),a=r(24296),c=r(1580),l=r(53368),u=(r(72052),r(9456),r(33600)),h=r(12552),d=r(18996),_=r(67776),p=r(56156),f=r(83372),m=r(60544),g=r(29120),y=r(22108),x=r(11712);const b=new n.O({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 T=s=class extends o.am{static create(e={}){const{resolutionFactor:t=1,scales:r,size:i=256,spatialReference:n=p.c.WebMercator,numLODs:o=24}=e;if(!(0,m.U3)(n)){const e=[];if(r)for(let t=0;t<r.length;t++){const s=r[t];e.push(new y.c({level:t,scale:s,resolution:s}))}else{let t=5e-4;for(let r=o-1;r>=0;r--)e.unshift(new y.c({level:r,scale:t,resolution:t})),t*=2}return new s({dpi:96,lods:e,origin:new _.c(0,0,n),size:[i,i],spatialReference:n})}const c=(0,m.Nq)(n),l=e.origin?new _.c({x:e.origin.x,y:e.origin.y,spatialReference:n}):new _.c(c?{x:c.origin[0],y:c.origin[1],spatialReference:n}:{x:0,y:0,spatialReference:n}),u=1/(39.37*(0,a.k8)(n)*96),h=[];if(r)for(let e=0;e<r.length;e++){const t=r[e],s=t*u;h.push(new y.c({level:e,scale:t,resolution:s}))}else{let e=(0,m.Eb)(n)?512/i*591657527.5917094:256/i*591657527.591555;const r=Math.ceil(o/t);h.push(new y.c({level:0,scale:e,resolution:e*u}));for(let s=1;s<r;s++){const r=e/2**t,i=r*u;h.push(new y.c({level:s,scale:r,resolution:i})),e=r}}return new s({dpi:96,lods:h,origin:l,size:[i,i],spatialReference:n})}constructor(e){super(e),this.dpi=96,this.format=null,this.origin=null,this.size=null,this.spatialReference=null}get isWrappable(){const{spatialReference:e,origin:t}=this;if(e&&t){const r=(0,m.Nq)(e);return e.isWrappable&&!!r&&Math.abs(r.origin[0]-t.x)<=r.dx}return!1}readOrigin(e,t){return _.c.fromJSON({spatialReference:t.spatialReference,...e})}set lods(e){let t=0,r=0;const s=[],i=this._levelToLOD={};e&&(t=-1/0,r=1/0,e.forEach((e=>{s.push(e.scale),t=e.scale>t?e.scale:t,r=e.scale<r?e.scale:r,i[e.level]=e}))),this._set("scales",s),this._set("lods",e),this._initializeUpsampleLevels()}readSize(e,t){return[t.cols,t.rows]}writeSize(e,t){t.cols=e[0],t.rows=e[1]}zoomToScale(e){const t=this.scales;if(e<=0)return t[0];if(e>=t.length-1)return t[t.length-1];const r=Math.floor(e),s=r+1;return t[r]/(t[r]/t[s])**(e-r)}scaleToZoom(e){const t=this.scales,r=t.length-1;let s=0;for(;s<r;s++){const r=t[s],i=t[s+1];if(r<=e)return s;if(i===e)return s+1;if(r>e&&i<e)return s+Math.log(r/e)/Math.log(r/i)}return s}snapScale(e,t=.95){const r=this.scaleToZoom(e);return r%Math.floor(r)>=t?this.zoomToScale(Math.ceil(r)):this.zoomToScale(Math.floor(r))}tileAt(e,t,r,s){const i=this.lodAt(e);if(!i)return null;let n,o;if("number"==typeof t)n=t,o=r;else if((0,m.yK)(t.spatialReference,this.spatialReference))n=t.x,o=t.y,s=r;else{const e=(0,g.yU)(t,this.spatialReference);if(null==e)return null;n=e.x,o=e.y,s=r}const a=i.resolution*this.size[0],c=i.resolution*this.size[1];return s||(s=new x.g(null,0,0,0,(0,f.Su)())),s.level=e,s.row=Math.floor((this.origin.y-o)/c+.001),s.col=Math.floor((n-this.origin.x)/a+.001),this.updateTileInfo(s),s}updateTileInfo(e,t=s.ExtrapolateOptions.NONE){let r=this.lodAt(e.level);if(!r&&t===s.ExtrapolateOptions.POWER_OF_TWO){const t=this.lods[this.lods.length-1];t.level<e.level&&(r=t)}if(!r)return;const i=e.level-r.level,n=r.resolution*this.size[0]/2**i,o=r.resolution*this.size[1]/2**i;e.id=`${e.level}/${e.row}/${e.col}`,e.extent||(e.extent=(0,f.Su)()),e.extent[0]=this.origin.x+e.col*n,e.extent[1]=this.origin.y-(e.row+1)*o,e.extent[2]=e.extent[0]+n,e.extent[3]=e.extent[1]+o}upsampleTile(e){const t=this._upsampleLevels[e.level];return!(!t||-1===t.parentLevel||(e.level=t.parentLevel,e.row=Math.floor(e.row/t.factor+.001),e.col=Math.floor(e.col/t.factor+.001),this.updateTileInfo(e),0))}getTileBounds(e,t){const r=this.lodAt(t.level);if(null==r)return null;const{resolution:s}=r,i=s*this.size[0],n=s*this.size[1];return e[0]=this.origin.x+t.col*i,e[1]=this.origin.y-(t.row+1)*n,e[2]=e[0]+i,e[3]=e[1]+n,e}lodAt(e){return this._levelToLOD?.[e]??null}clone(){return s.fromJSON(this.write({}))}getOrCreateCompatible(e,t){if(256===this.size[0]&&256===this.size[1])return 256===e?this:null;const r=[],i=this.lods.length;for(let e=0;e<i;e++){const s=this.lods[e],i=s.resolution*t;r.push(new y.c({level:s.level,scale:s.scale,resolution:i}))}return new s({size:[e,e],dpi:this.dpi,format:this.format,compressionQuality:this.compressionQuality,origin:this.origin,spatialReference:this.spatialReference,lods:r})}_initializeUpsampleLevels(){const e=this.lods;this._upsampleLevels=[];let t=null;for(let r=0;r<e.length;r++){const s=e[r];this._upsampleLevels[s.level]={parentLevel:t?t.level:-1,factor:t?t.resolution/s.resolution:0},t=s}}};var w,S;(0,i._)([(0,c.qq)({type:Number,json:{write:!0}})],T.prototype,"compressionQuality",void 0),(0,i._)([(0,c.qq)({type:Number,json:{write:!0}})],T.prototype,"dpi",void 0),(0,i._)([(0,c.qq)({type:String,json:{read:b.read,write:b.write,origins:{"web-scene":{read:!1,write:!1}}}})],T.prototype,"format",void 0),(0,i._)([(0,c.qq)({readOnly:!0})],T.prototype,"isWrappable",null),(0,i._)([(0,c.qq)({type:_.c,json:{write:!0}})],T.prototype,"origin",void 0),(0,i._)([(0,u.E)("origin")],T.prototype,"readOrigin",null),(0,i._)([(0,c.qq)({type:[y.c],value:null,json:{write:!0}})],T.prototype,"lods",null),(0,i._)([(0,c.qq)({readOnly:!0})],T.prototype,"scales",void 0),(0,i._)([(0,c.qq)({cast:e=>Array.isArray(e)?e:"number"==typeof e?[e,e]:[256,256]})],T.prototype,"size",void 0),(0,i._)([(0,u.E)("size",["rows","cols"])],T.prototype,"readSize",null),(0,i._)([(0,d.G)("size",{cols:{type:l.Ab},rows:{type:l.Ab}})],T.prototype,"writeSize",null),(0,i._)([(0,c.qq)({type:p.c,json:{write:!0}})],T.prototype,"spatialReference",void 0),T=s=(0,i._)([(0,h.c)("esri.layers.support.TileInfo")],T),w=T||(T={}),(S=w.ExtrapolateOptions||(w.ExtrapolateOptions={}))[S.NONE=0]="NONE",S[S.POWER_OF_TWO=1]="POWER_OF_TWO";const v=T},11712:(e,t,r)=>{r.d(t,{g:()=>s});class s{constructor(e,t,r,s,i=void 0){this.id=e,this.level=t,this.row=r,this.col=s,this.extent=i}}},21012:(e,t,r)=>{r.d(t,{M:()=>i});var s=r(37924);function i(e,t,r){if(!r?.features||!r.hasZ)return;const i=(0,s.O)(r.geometryType,t,e.outSpatialReference);if(null!=i)for(const e of r.features)i(e.geometry)}},93552:(e,t,r)=>{r.d(t,{A:()=>p});var s=r(89232),i=r(67720);function n(e,t){return e.x===t.x&&e.y===t.y}function o(e){if(!e)return;const t=e.length;if(t<=1)return;let r=0;for(let s=1;s<t;s++)n(e[s],e[r])||++r===s||(e[r]=e[s]);e.length=r+1}function a(e,t){return e.x=t.y,e.y=-t.x,e}function c(e,t){return e.x=-t.y,e.y=t.x,e}function l(e,t){return e.x=t.x,e.y=t.y,e}function u(e,t){return e.x=-t.x,e.y=-t.y,e}function h(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function d(e,t){return e.x*t.x+e.y*t.y}function _(e,t,r,s){return e.x=t.x*r+t.y*s,e.y=t.x*s-t.y*r,e}class p{constructor(e,t,r){this._writeVertex=e,this._writeTriangle=t,this._canUseThinTessellation=r,this._prevNormal={x:void 0,y:void 0},this._nextNormal={x:void 0,y:void 0},this._textureNormalLeft={x:0,y:1},this._textureNormalRight={x:0,y:-1},this._textureNormal={x:void 0,y:void 0},this._joinNormal={x:void 0,y:void 0},this._inner={x:void 0,y:void 0},this._outer={x:void 0,y:void 0},this._roundStart={x:void 0,y:void 0},this._roundEnd={x:void 0,y:void 0},this._startBreak={x:void 0,y:void 0},this._endBreak={x:void 0,y:void 0},this._innerPrev={x:void 0,y:void 0},this._innerNext={x:void 0,y:void 0},this._bevelStart={x:void 0,y:void 0},this._bevelEnd={x:void 0,y:void 0},this._bevelMiddle={x:void 0,y:void 0}}tessellate(e,t,r=this._canUseThinTessellation){o(e),r&&t.halfWidth<i.wt&&!t.offset?this._tessellateThin(e,t):this._tessellate(e,t)}_tessellateThin(e,t){if(e.length<2)return;const r=t.wrapDistance||65535;let s=t.initialDistance||0,i=!1,n=e[0].x,o=e[0].y;const a=e.length;for(let t=1;t<a;++t){i&&(i=!1,s=0);let a=e[t].x,c=e[t].y,l=a-n,u=c-o,h=Math.sqrt(l*l+u*u);if(l/=h,u/=h,s+h>r){i=!0;const e=(r-s)/h;h=r-s,a=(1-e)*n+e*a,c=(1-e)*o+e*c,--t}const d=this._writeVertex(n,o,0,0,l,u,u,-l,0,-1,s),_=this._writeVertex(n,o,0,0,l,u,-u,l,0,1,s);s+=h;const p=this._writeVertex(a,c,0,0,l,u,u,-l,0,-1,s),f=this._writeVertex(a,c,0,0,l,u,-u,l,0,1,s);this._writeTriangle(d,_,p),this._writeTriangle(_,p,f),n=a,o=c}}_tessellate(e,t){const r=e[0],i=e[e.length-1],o=n(r,i),p=o?3:2;if(e.length<p)return;const f=t.pixelCoordRatio,m=null!=t.capType?t.capType:s.wD.BUTT,g=null!=t.joinType?t.joinType:s.qY.MITER,y=null!=t.miterLimit?Math.min(t.miterLimit,4):2,x=null!=t.roundLimit?Math.min(t.roundLimit,1.05):1.05,b=null!=t.halfWidth?t.halfWidth:2,T=!!t.textured;let w,S,v,I=null;const E=this._prevNormal,R=this._nextNormal;let A=-1,M=-1;const C=this._joinNormal;let F,N;const P=this._textureNormalLeft,O=this._textureNormalRight,k=this._textureNormal;let D=-1,U=-1;const B=t.wrapDistance||65535;let L=t.initialDistance||0;const G=this._writeVertex,z=this._writeTriangle,V=(e,t,r,s,i,n)=>{const o=G(S,v,F,N,r,s,e,t,i,n,L);return D>=0&&U>=0&&o>=0&&z(D,U,o),D=U,U=o,o};o&&(w=e[e.length-2],R.x=i.x-w.x,R.y=i.y-w.y,M=h(R),R.x/=M,R.y/=M);let q=!1;for(let t=0;t<e.length;++t){if(q&&(q=!1,L=0),w&&(E.x=-R.x,E.y=-R.y,A=M,L+A>B&&(q=!0)),q){const r=(B-L)/A;A=B-L,w={x:(1-r)*w.x+r*e[t].x,y:(1-r)*w.y+r*e[t].y},--t}else w=e[t];S=w.x,v=w.y;const r=t<=0&&!q,i=t===e.length-1;if(r||(L+=A),I=i?o?e[1]:null:e[t+1],I?(R.x=I.x-S,R.y=I.y-v,M=h(R),R.x/=M,R.y/=M):(R.x=void 0,R.y=void 0),!o){if(r){c(C,R),F=C.x,N=C.y,m===s.wD.SQUARE&&(V(-R.y-R.x,R.x-R.y,R.x,R.y,0,-1),V(R.y-R.x,-R.x-R.y,R.x,R.y,0,1)),m===s.wD.ROUND&&(V(-R.y-R.x,R.x-R.y,R.x,R.y,-1,-1),V(R.y-R.x,-R.x-R.y,R.x,R.y,-1,1)),m!==s.wD.ROUND&&m!==s.wD.BUTT||(V(-R.y,R.x,R.x,R.y,0,-1),V(R.y,-R.x,R.x,R.y,0,1));continue}if(i){a(C,E),F=C.x,N=C.y,m!==s.wD.ROUND&&m!==s.wD.BUTT||(V(E.y,-E.x,-E.x,-E.y,0,-1),V(-E.y,E.x,-E.x,-E.y,0,1)),m===s.wD.SQUARE&&(V(E.y-E.x,-E.x-E.y,-E.x,-E.y,0,-1),V(-E.y-E.x,E.x-E.y,-E.x,-E.y,0,1)),m===s.wD.ROUND&&(V(E.y-E.x,-E.x-E.y,-E.x,-E.y,1,-1),V(-E.y-E.x,E.x-E.y,-E.x,-E.y,1,1));continue}}let n,p,G=(W=R,-((H=E).x*W.y-H.y*W.x));if(Math.abs(G)<.01)d(E,R)>0?(C.x=E.x,C.y=E.y,G=1,n=Number.MAX_VALUE,p=!0):(c(C,R),G=1,n=1,p=!1);else{C.x=(E.x+R.x)/G,C.y=(E.y+R.y)/G,n=h(C);const e=(n-1)*b*f;p=n>4||e>A&&e>M}F=C.x,N=C.y;let z=g;switch(g){case s.qY.BEVEL:n<1.05&&(z=s.qY.MITER);break;case s.qY.ROUND:n<x&&(z=s.qY.MITER);break;case s.qY.MITER:n>y&&(z=s.qY.BEVEL)}switch(z){case s.qY.MITER:if(V(C.x,C.y,-E.x,-E.y,0,-1),V(-C.x,-C.y,-E.x,-E.y,0,1),i)break;if(T){const e=q?0:L;D=this._writeVertex(S,v,F,N,R.x,R.y,C.x,C.y,0,-1,e),U=this._writeVertex(S,v,F,N,R.x,R.y,-C.x,-C.y,0,1,e)}break;case s.qY.BEVEL:{const e=G<0;let t,r,s,n;if(e){const e=D;D=U,U=e,t=P,r=O}else t=O,r=P;if(p)s=e?c(this._innerPrev,E):a(this._innerPrev,E),n=e?a(this._innerNext,R):c(this._innerNext,R);else{const t=e?u(this._inner,C):l(this._inner,C);s=t,n=t}const o=e?a(this._bevelStart,E):c(this._bevelStart,E);V(s.x,s.y,-E.x,-E.y,t.x,t.y);const h=V(o.x,o.y,-E.x,-E.y,r.x,r.y);if(i)break;const d=e?c(this._bevelEnd,R):a(this._bevelEnd,R);if(p){const e=this._writeVertex(S,v,F,N,-E.x,-E.y,0,0,0,0,L);D=this._writeVertex(S,v,F,N,R.x,R.y,n.x,n.y,t.x,t.y,L),U=this._writeVertex(S,v,F,N,R.x,R.y,d.x,d.y,r.x,r.y,L),this._writeTriangle(h,e,U)}else{if(T){const e=this._bevelMiddle;e.x=(o.x+d.x)/2,e.y=(o.y+d.y)/2,_(k,e,-E.x,-E.y),V(e.x,e.y,-E.x,-E.y,k.x,k.y),_(k,e,R.x,R.y),D=this._writeVertex(S,v,F,N,R.x,R.y,e.x,e.y,k.x,k.y,L),U=this._writeVertex(S,v,F,N,R.x,R.y,n.x,n.y,t.x,t.y,L)}else{const e=D;D=U,U=e}V(d.x,d.y,R.x,R.y,r.x,r.y)}if(e){const e=D;D=U,U=e}break}case s.qY.ROUND:{const e=G<0;let t,r;if(e){const e=D;D=U,U=e,t=P,r=O}else t=O,r=P;const s=e?u(this._inner,C):l(this._inner,C);let o,h;p?(o=e?c(this._innerPrev,E):a(this._innerPrev,E),h=e?a(this._innerNext,R):c(this._innerNext,R)):(o=s,h=s);const f=e?a(this._roundStart,E):c(this._roundStart,E),m=e?c(this._roundEnd,R):a(this._roundEnd,R),g=V(o.x,o.y,-E.x,-E.y,t.x,t.y),y=V(f.x,f.y,-E.x,-E.y,r.x,r.y);if(i)break;const x=this._writeVertex(S,v,F,N,-E.x,-E.y,0,0,0,0,L);p||this._writeTriangle(D,U,x);const b=u(this._outer,s),w=this._writeVertex(S,v,F,N,R.x,R.y,m.x,m.y,r.x,r.y,L);let I,A;const M=n>2;if(M){let t;n!==Number.MAX_VALUE?(b.x/=n,b.y/=n,t=d(E,b),t=(n*(t*t-1)+1)/t):t=-1,I=e?a(this._startBreak,E):c(this._startBreak,E),I.x+=E.x*t,I.y+=E.y*t,A=e?c(this._endBreak,R):a(this._endBreak,R),A.x+=R.x*t,A.y+=R.y*t}_(k,b,-E.x,-E.y);const B=this._writeVertex(S,v,F,N,-E.x,-E.y,b.x,b.y,k.x,k.y,L);_(k,b,R.x,R.y);const z=T?this._writeVertex(S,v,F,N,R.x,R.y,b.x,b.y,k.x,k.y,L):B,q=x,H=T?this._writeVertex(S,v,F,N,R.x,R.y,0,0,0,0,L):x;let W=-1,Y=-1;if(M&&(_(k,I,-E.x,-E.y),W=this._writeVertex(S,v,F,N,-E.x,-E.y,I.x,I.y,k.x,k.y,L),_(k,A,R.x,R.y),Y=this._writeVertex(S,v,F,N,R.x,R.y,A.x,A.y,k.x,k.y,L)),T?M?(this._writeTriangle(q,y,W),this._writeTriangle(q,W,B),this._writeTriangle(H,z,Y),this._writeTriangle(H,Y,w)):(this._writeTriangle(q,y,B),this._writeTriangle(H,z,w)):M?(this._writeTriangle(x,y,W),this._writeTriangle(x,W,Y),this._writeTriangle(x,Y,w)):(this._writeTriangle(x,y,B),this._writeTriangle(x,z,w)),p?(D=this._writeVertex(S,v,F,N,R.x,R.y,h.x,h.y,t.x,t.y,L),U=w):(D=T?this._writeVertex(S,v,F,N,R.x,R.y,h.x,h.y,t.x,t.y,L):g,this._writeTriangle(D,H,w),U=w),e){const e=D;D=U,U=e}break}}}var H,W}}},3828:(e,t,r)=>{r.r(t),r.d(t,{default:()=>Gu});var s=r(20744),i=r(38912),n=r(9456),o=r(52324),a=r(10860),c=r(72052),l=r(57896),u=r(50144),h=r(87576),d=r(60544),_=r(53680);function p(e,t){return[e,t]}function f(e,t,r){return e[0]=t,e[1]=r,e}const m=new _.c("0/0/0/0");class g{static create(e,t,r=null){const s=(0,d.Nq)(e.spatialReference),i=t.origin||p(e.origin.x,e.origin.y),n=p(e.size[0]*t.resolution,e.size[1]*t.resolution),o=p(-1/0,-1/0),a=p(1/0,1/0),c=p(1/0,1/0);null!=r&&(f(o,Math.max(0,Math.floor((r.xmin-i[0])/n[0])),Math.max(0,Math.floor((i[1]-r.ymax)/n[1]))),f(a,Math.max(0,Math.floor((r.xmax-i[0])/n[0])),Math.max(0,Math.floor((i[1]-r.ymin)/n[1]))),f(c,a[0]-o[0]+1,a[1]-o[1]+1));const{cols:l,rows:u}=t;let h,_,m,y;return!r&&l&&u&&(f(o,l[0],u[0]),f(a,l[1],u[1]),f(c,l[1]-l[0]+1,u[1]-u[0]+1)),e.isWrappable?(h=p(Math.ceil(Math.round((s.valid[1]-s.valid[0])/t.resolution)/e.size[0]),c[1]),_=p(Math.floor((s.origin[0]-i[0])/n[0]),o[1]),m=p(h[0]+_[0]-1,a[1]),y=!0):(_=o,m=a,h=c,y=!1),new g(t.level,t.resolution,t.scale,i,o,a,c,n,_,m,h,y)}constructor(e,t,r,s,i,n,o,a,c,l,u,h){this.level=e,this.resolution=t,this.scale=r,this.origin=s,this.first=i,this.last=n,this.size=o,this.norm=a,this.worldStart=c,this.worldEnd=l,this.worldSize=u,this.wrap=h}normalizeCol(e){if(!this.wrap)return e;const t=this.worldSize[0];return e<0?t-1-Math.abs((e+1)%t):e%t}denormalizeCol(e,t){return this.wrap?this.worldSize[0]*t+e:e}getWorldForColumn(e){return this.wrap?Math.floor(e/this.worldSize[0]):0}getFirstColumnForWorld(e){return e*this.worldSize[0]+this.first[0]}getLastColumnForWorld(e){return e*this.worldSize[0]+this.first[0]+this.size[0]-1}getColumnForX(e){return(e-this.origin[0])/this.norm[0]}getXForColumn(e){return this.origin[0]+e*this.norm[0]}getRowForY(e){return(this.origin[1]-e)/this.norm[1]}getYForRow(e){return this.origin[1]-e*this.norm[1]}getTileBounds(e,t,r=!1){m.set(t);const s=r?m.col:this.denormalizeCol(m.col,m.world),i=m.row;return function(e,t,r,s,i){e[0]=t,e[1]=r,e[2]=s,e[3]=i}(e,this.getXForColumn(s),this.getYForRow(i+1),this.getXForColumn(s+1),this.getYForRow(i)),e}getTileCoords(e,t,r=!1){m.set(t);const s=r?m.col:this.denormalizeCol(m.col,m.world);return Array.isArray(e)?f(e,this.getXForColumn(s),this.getYForRow(m.row)):(e.x=this.getXForColumn(s),e.y=this.getYForRow(m.row)),e}}var y=r(69752);class x{constructor(){this.spans=[]}acquire(e){this.lodInfo=e}release(){this.lodInfo=null,this.spans.length=0}*keys(){const e=this.lodInfo;for(const{row:t,colFrom:r,colTo:s}of this.spans)for(let i=r;i<=s;i++){const r=e.getWorldForColumn(i);yield new _.c(e.level,t,e.normalizeCol(i),r)}}forEach(e,t){const{spans:r,lodInfo:s}=this,{level:i}=s;if(0!==r.length)for(const{row:n,colFrom:o,colTo:a}of r)for(let r=o;r<=a;r++)e.call(t,i,n,s.normalizeCol(r),s.getWorldForColumn(r))}}x.pool=new y.c(x);class b{constructor(e,t,r){this.row=e,this.colFrom=t,this.colTo=r}}const T=new _.c("0/0/0/0");class w{static create(e,t){e[1]>t[1]&&([e,t]=[t,e]);const[r,s]=e,[i,n]=t,o=i-r,a=n-s,c=0!==a?o/a:0,l=(Math.ceil(s)-s)*c,u=(Math.floor(s)-s)*c;return new w(r,Math.floor(s),Math.ceil(n),c,o<0?l:u,o<0?u:l,o<0?i:r,o<0?r:i)}constructor(e,t,r,s,i,n,o,a){this.x=e,this.ymin=t,this.ymax=r,this.invM=s,this.leftAdjust=i,this.rightAdjust=n,this.leftBound=o,this.rightBound=a}incrRow(){this.x+=this.invM}getLeftCol(){return Math.max(this.x+this.leftAdjust,this.leftBound)}getRightCol(){return Math.min(this.x+this.rightAdjust,this.rightBound)}}const S=[[0,0],[0,0],[0,0],[0,0]];class v{constructor(e,t=null,r=e.lods[0].level,s=e.lods[e.lods.length-1].level){this.tileInfo=e,this.fullExtent=t,this.scales=[],this._infoByScale={},this._infoByLevel={};const i=e.lods.filter((e=>e.level>=r&&e.level<=s));this.minScale=i[0].scale,this.maxScale=i[i.length-1].scale;const n=this._lodInfos=i.map((r=>g.create(e,r,t)));i.forEach(((e,t)=>{this._infoByLevel[e.level]=n[t],this._infoByScale[e.scale]=n[t],this.scales[t]=e.scale}),this),this._wrap=e.isWrappable}get spatialReference(){return this.tileInfo.spatialReference}getLODInfoAt(e){return this._infoByLevel["number"==typeof e?e:e.level]}getTileBounds(e,t,r=!1){T.set(t);const s=this._infoByLevel[T.level];return s?s.getTileBounds(e,T,r):e}getTileCoords(e,t,r=!1){T.set(t);const s=this._infoByLevel[T.level];return s?s.getTileCoords(e,T,r):e}getTileCoverage(e,t=192,r=!0,s="closest"){if(!r&&(e.scale>this.minScale||e.scale<this.maxScale))return null;const i="closest"===s?this.getClosestInfoForScale(e.scale):this.getSmallestInfoForScale(e.scale),n=x.pool.acquire(i),o=this._wrap;let a,c,l,u=1/0,h=-1/0;const d=n.spans;S[0][0]=S[0][1]=S[1][1]=S[3][0]=-t,S[1][0]=S[2][0]=e.size[0]+t,S[2][1]=S[3][1]=e.size[1]+t;for(const t of S)e.toMap(t,t),t[0]=i.getColumnForX(t[0]),t[1]=i.getRowForY(t[1]);const _=[];let p=3;for(let e=0;e<4;e++){if(S[e][1]===S[p][1]){p=e;continue}const t=w.create(S[e],S[p]);u=Math.min(t.ymin,u),h=Math.max(t.ymax,h),void 0===_[t.ymin]&&(_[t.ymin]=[]),_[t.ymin].push(t),p=e}if(null==u||null==h||h-u>100)return null;let f=[];for(a=u;a<h;){null!=_[a]&&(f=f.concat(_[a])),c=1/0,l=-1/0;for(let e=f.length-1;e>=0;e--){const t=f[e];c=Math.min(c,t.getLeftCol()),l=Math.max(l,t.getRightCol())}if(c=Math.floor(c),l=Math.floor(l),a>=i.first[1]&&a<=i.last[1])if(o)if(i.size[0]<i.worldSize[0]){const e=Math.floor(l/i.worldSize[0]);for(let t=Math.floor(c/i.worldSize[0]);t<=e;t++)d.push(new b(a,Math.max(i.getFirstColumnForWorld(t),c),Math.min(i.getLastColumnForWorld(t),l)))}else d.push(new b(a,c,l));else c>i.last[0]||l<i.first[0]||(c=Math.max(c,i.first[0]),l=Math.min(l,i.last[0]),d.push(new b(a,c,l)));a+=1;for(let e=f.length-1;e>=0;e--){const t=f[e];t.ymax>=a?t.incrRow():f.splice(e,1)}}return n}getTileParentId(e){T.set(e);const t=this._infoByLevel[T.level],r=this._lodInfos.indexOf(t)-1;return r<0?null:(this._getTileIdAtLOD(T,this._lodInfos[r],T),T.id)}getTileResolution(e){const t=this._infoByLevel["object"==typeof e?e.level:e];return t?t.resolution:-1}getTileScale(e){const t=this._infoByLevel[e.level];return t?t.scale:-1}intersects(e,t){T.set(t);const r=this._infoByLevel[T.level],s=e.lodInfo;if(s.resolution>r.resolution){this._getTileIdAtLOD(T,s,T);const t=s.denormalizeCol(T.col,T.world);for(const r of e.spans)if(r.row===T.row&&r.colFrom<=t&&r.colTo>=t)return!0}if(s.resolution<r.resolution){const[t,i,n,o]=e.spans.reduce(((e,t)=>(e[0]=Math.min(e[0],t.row),e[1]=Math.max(e[1],t.row),e[2]=Math.min(e[2],t.colFrom),e[3]=Math.max(e[3],t.colTo),e)),[1/0,-1/0,1/0,-1/0]),a=r.denormalizeCol(T.col,T.world),c=s.getColumnForX(r.getXForColumn(a)),l=s.getRowForY(r.getYForRow(T.row)),u=s.getColumnForX(r.getXForColumn(a+1))-1,h=s.getRowForY(r.getYForRow(T.row+1))-1;return!(c>o||u<n||l>i||h<t)}const i=s.denormalizeCol(T.col,T.world);return e.spans.some((e=>e.row===T.row&&e.colFrom<=i&&e.colTo>=i))}normalizeBounds(e,t,r){if(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],this._wrap){const t=(0,d.Nq)(this.tileInfo.spatialReference),s=-r*(t.valid[1]-t.valid[0]);e[0]+=s,e[2]+=s}return e}getSmallestInfoForScale(e){const t=this.scales;if(this._infoByScale[e])return this._infoByScale[e];if(e>t[0])return this._infoByScale[t[0]];for(let r=1;r<t.length-1;r++)if(e>t[r]+1e-6)return this._infoByScale[t[r-1]];return this._infoByScale[t[t.length-1]]}getClosestInfoForScale(e){const t=this.scales;return this._infoByScale[e]||(e=t.reduce(((t,r)=>Math.abs(r-e)<Math.abs(t-e)?r:t),t[0])),this._infoByScale[e]}scaleToLevel(e){const t=this.scales;if(this._infoByScale[e])return this._infoByScale[e].level;for(let r=t.length-1;r>=0;r--)if(e<t[r])return r===t.length-1?this._infoByScale[t[t.length-1]].level:this._infoByScale[t[r]].level+(t[r]-e)/(t[r]-t[r+1]);return this._infoByScale[t[0]].level}scaleToZoom(e){return this.tileInfo.scaleToZoom(e)}_getTileIdAtLOD(e,t,r){const s=this._infoByLevel[r.level];return e.set(r),t.resolution<s.resolution?null:(t.resolution===s.resolution||(e.level=t.level,e.col=Math.floor(r.col*s.resolution/t.resolution+.01),e.row=Math.floor(r.row*s.resolution/t.resolution+.01)),e)}}var I=r(41948),E=r(43780),R=r(70680),A=r(1580),M=r(66360),C=r(12552),F=r(37648),N=r(27064);const P=new Set,O=[],k=new Map,D=[0,0];let U=class extends E.c{constructor(e){super(e),this._keyToItem=new Map,this.concurrency=6,this.strategy="scale-first",this.tileInfoView=null}initialize(){const{concurrency:e,process:t,strategy:r}=this;this._queue=new N.K({concurrency:e,process:(e,r)=>{const s=this._keyToItem.get(e);return t(s,{signal:r})},peeker:"scale-first"===r?e=>this._peekByScaleFirst(e):e=>this._peekByCenterFirst(e)})}destroy(){this.clear(),this._queue=(0,R.mG)(this._queue)}get length(){return this._queue?this._queue.length:0}get onGoingCount(){return this._keyToItem.size}abort(e){const t="string"==typeof e?e:e.id;this._queue.abort(t)}clear(){this._queue.clear(),this._keyToItem.clear()}has(e){return"string"==typeof e?this._keyToItem.has(e):this._keyToItem.has(e.id)}isOngoing(e){const t="string"==typeof e?e:e.id;return this.has(t)&&this._queue.isOngoing(t)}pause(){this._queue.pause()}push(e){const t=e.key.id;if(this._queue.has(t))return this._queue.get(t);const r=this._queue.push(t),s=()=>{this._keyToItem.delete(t)};return this._keyToItem.set(t,e),r.then(s,s),r}reset(){this._queue.reset()}resume(){this._queue.resume()}_peekByScaleFirst(e){if(!this.state)return e.values().next().value;const t=this.tileInfoView;let r=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;e.forEach((e=>{const t=this._keyToItem.get(e),i=this.tileInfoView.getTileScale(t.key);k.has(i)||(k.set(i,[]),r=Math.max(i,r),s=Math.min(i,s)),k.get(i).push(t.key),P.add(i)}));let i=this.state.scale;k.has(i)||(function(e,t){e.length=0,t.forEach((t=>e.push(t)))}(O,P),O.sort(((e,t)=>e-t)),i=O.reduce(((e,t)=>Math.abs(t-i)<Math.abs(e-i)?t:e),O[0])),i=Math.min(i,r),i=Math.max(i,s);const n=k.get(i),o=t.getClosestInfoForScale(i),a=o.getColumnForX(this.state.center[0]),c=o.getRowForY(this.state.center[1]);return n.sort(((e,t)=>{const r=o.denormalizeCol(e.col,e.world),s=o.denormalizeCol(t.col,t.world);return Math.sqrt((a-r)*(a-r)+(c-e.row)*(c-e.row))-Math.sqrt((a-s)*(a-s)+(c-t.row)*(c-t.row))})),P.clear(),k.clear(),n[0].id}_peekByCenterFirst(e){if(!this.state)return e.values().next().value;const t=this.tileInfoView,r=this.state.center;let s,i=Number.POSITIVE_INFINITY;return e.forEach((e=>{const n=this._keyToItem.get(e);t.getTileCoords(D,n.key);const o=(0,F.qy)(D,r);o<i&&(i=o,s=n.key)})),s.id}};(0,I._)([(0,A.qq)({constructOnly:!0})],U.prototype,"concurrency",void 0),(0,I._)([(0,A.qq)({constructOnly:!0})],U.prototype,"process",void 0),(0,I._)([(0,A.qq)()],U.prototype,"state",void 0),(0,I._)([(0,A.qq)({constructOnly:!0})],U.prototype,"strategy",void 0),(0,I._)([(0,A.qq)({constructOnly:!0})],U.prototype,"tileInfoView",void 0),U=(0,I._)([(0,C.c)("esri.views.2d.tiling.TileQueue")],U);var B=r(83372);new _.c(0,0,0,0),new Map;var L=r(67720);class G{constructor(e){this._client=e,this.layerView=this._client.createInvokeProxy(),this.container=this._client.createInvokeProxy("container"),this.eventLog=this._client.createInvokeProxy("eventLog")}}var z=r(96523),V=r(56156),q=r(16424);class H{constructor(e,t,r,s,i,n,o){this.instanceId=e,this.textureKey=t,this.indexStart=r,this.indexCount=s,this.vertexStart=i,this.vertexCount=n,this.overlaps=o}updateBaseOffsets(e){this.vertexStart+=e.vertexFrom,this.indexStart+=e.indexFrom}clone(){return new H(this.instanceId,this.textureKey,this.indexStart,this.indexCount,this.vertexStart,this.vertexCount,this.overlaps)}static write(e,t,r,s,i,n,o,a){e.push(t),e.push(r),e.push(s),e.push(i),e.push(n),e.push(o),e.push(a)}serialize(e){return e.push(this.instanceId),e.push(this.textureKey),e.push(this.indexStart),e.push(this.indexCount),e.push(this.vertexStart),e.push(this.vertexCount),e.push(this.overlaps),e}static deserialize(e){const t=e.readInt32(),r=e.readInt32(),s=e.readInt32(),i=e.readInt32(),n=e.readInt32(),o=e.readInt32(),a=e.readInt32();return new H(t,r,s,i,n,o,a)}}function W(e,t){if(null!==t){e.push(t.length);for(const r of t)r.serialize(e);return e}e.push(0)}function Y(e,t,r){const s=e.readInt32(),i=new Array(s);for(let s=0;s<i.length;s++)i[s]=t.deserialize(e,r);return i}H.byteSizeHint=7*Uint32Array.BYTES_PER_ELEMENT;class X{constructor(e,t){this.id=e,this.sortKey=t,this.records=[]}serialize(e){return e.push(this.id),e.writeF32(this.sortKey),W(e,this.records),e}static deserialize(e){const t=e.readInt32(),r=e.readF32(),s=new X(t,r);return s.records=Y(e,H)??[],s}}X.byteSizeHint=2*Uint32Array.BYTES_PER_ELEMENT+H.byteSizeHint;class j{get length(){return this._pos}constructor(e,t){this._pos=0;const r=t?this._roundToNearest(t,e.BYTES_PER_ELEMENT):40;this._array=new ArrayBuffer(r),this._buffer=new e(this._array),this._ctor=e,this._i16View=new Int16Array(this._array)}_roundToNearest(e,t){const r=Math.round(e);return 1===t?r:r+(t-r%t)}_ensureSize(e){if(this._pos+e>=this._buffer.length){const t=this._roundToNearest(1.25*(this._array.byteLength+e*this._buffer.BYTES_PER_ELEMENT),this._buffer.BYTES_PER_ELEMENT),r=new ArrayBuffer(t),s=new this._ctor(r);s.set(this._buffer,0),this._array=r,this._buffer=s,this._i16View=new Int16Array(this._array)}}ensureSize(e){this._ensureSize(e)}writeF32(e){this._ensureSize(1);const t=this._pos;return new Float32Array(this._array,4*this._pos,1)[0]=e,this._pos++,t}push(e){this._ensureSize(1);const t=this._pos;return this._buffer[this._pos++]=e,t}writeFixed(e){this._buffer[this._pos++]=e}setValue(e,t){this._buffer[e]=t}i1616Add(e,t,r){this._i16View[2*e]+=t,this._i16View[2*e+1]+=r}getValue(e){return this._buffer[e]}getValueF32(e){return new Float32Array(this._array,4*e,1)[0]}incr(e){if(this._buffer.length<e)throw new Error("Increment index overflows the target buffer");this._buffer[e]++}decr(e){this._buffer[e]--}writeRegion(e){this._ensureSize(e.length);const t=this._pos;return this._buffer.set(e,this._pos),this._pos+=e.length,t}writeManyFrom(e,t,r){this._ensureSize(r-t);for(let s=t;s!==r;s++)this.writeFixed(e._buffer[s])}buffer(){const e=this._array.slice(0,4*this._pos);return this.destroy(),e}toArray(){return[...this._buffer]}seek(e){this._pos=e}destroy(){this._array=null,this._buffer=null}}class ${constructor(e,t,r,s=0){const i=6*s*Uint32Array.BYTES_PER_ELEMENT,n=4*s*r,o=r/4,a=t.attributes.find((e=>"pos"===e.name||"position"===e.name));if(!a)throw new Error("InternalError: Unable to find position attribute");this.layout={...t,position:a},this._indices=new j(Uint32Array,i),this._vertices=new j(Uint32Array,n),this._metrics=new j(Uint32Array,0),this._metricCountOffset=this._metrics.push(0),this._strideInt=o,this._instanceId=e}serialize(e){const t=this._indices.buffer(),r=this._vertices.buffer(),s=this._metrics.length?this._metrics.buffer():null;return e.push(t,r),{instanceId:this._instanceId,layout:this.layout,indices:t,vertices:r,metrics:s}}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(e){this._vertices.ensureSize(e)}indexEnsureSize(e){this._indices.ensureSize(e)}writeIndex(e){this._indices.push(e)}writeVertex(e){this._vertices.push(e)}writeVertexRegion(e){this._vertices.writeRegion(e)}writeVertexF32(e){this._vertices.writeF32(e)}writeMetric(e){this._metrics.incr(this._metricCountOffset),e.serialize(this._metrics)}}class K{constructor(e,t=0){this._id=e,this._sizeHint=t,this._entityRecordCountOffset=0,this._entityCountOffset=0,this._entityIdIndex=0,this._entitySortKeyIndex=0,this._instanceIdToVertexData=new Map,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 j(Uint32Array,this._sizeHint*X.byteSizeHint),this._entityCountOffset=this._entities.push(0)}get id(){return this._id}serialize(){const e=new Array,t=[],r=this._entities.buffer();for(const r of this._instanceIdToVertexData.values())t.push(r.serialize(e));return{message:{data:t,entities:r},transferList:e}}vertexCount(){return this._current.writer?.vertexCount??0}indexCount(){return this._current.writer?.indexCount??0}vertexEnsureSize(e){this._current.writer.vertexEnsureSize(e)}indexEnsureSize(e){this._current.writer.indexEnsureSize(e)}vertexWrite(e){this._current.writer.writeVertex(e)}vertexWriteRegion(e){this._current.writer.writeVertexRegion(e)}vertexWriteF32(e){this._current.writer.writeVertexF32(e)}recordBounds(e,t,r,s){}indexWrite(e){this._current.writer.writeIndex(e)}metricStart(e){this._current.metric=e}metricEnd(){const e=this._current.writer;this._current.metric.bounds.length&&e.writeMetric(this._current.metric)}metricBoxWrite(e){this._current.metric.bounds.push(e)}entityStart(e,t=e){this._entityIdIndex=this._entities.push(e),this._entitySortKeyIndex=this._entities.writeF32(t),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(e,t,r=0){this._current.writer=this._getVertexWriter(e,t),this._current.indexStart=this._current.writer.indexCount,this._current.vertexStart=this._current.writer.vertexCount,this._current.instanceId=e,this._current.layoutHash=t.hash,this._current.textureKey=r}recordEnd(e=0){const t=this._current.vertexStart,r=this._current.writer.vertexCount-t;if(!r)return!1;const s=this._current.indexStart,i=this._current.writer.indexCount-s;return this._entities.incr(this._entityRecordCountOffset),H.write(this._entities,this._current.instanceId,this._current.textureKey,s,i,t,r,e),!0}copyLastFrom(e,t,r){const s=e._entities.getValue(e._entityIdIndex);if(s!==this._entities.getValue(this._entityIdIndex)){const t=e._entities.getValueF32(e._entitySortKeyIndex);this.entityStart(s,t)}this.recordStart(e._current.instanceId,e._current.writer.layout,e._current.textureKey);const i=this._current.writer.layout.stride/Uint32Array.BYTES_PER_ELEMENT,n=this._current.vertexStart,o=e._current.vertexStart-n,a=this._current.writer.indexWriter,c=this._current.writer.vertexWriter,l=e._current.writer.indexWriter,u=e._current.writer.vertexWriter;for(let t=e._current.indexStart;t!==l.length;t++){const e=l.getValue(t);a.push(e-o)}for(let t=e._current.vertexStart*i;t!==u.length;t++){const e=u.getValue(t);c.push(e)}const h=this._current.writer.layout.position,d=h.packPrecisionFactor??1,_=h.offset/Uint32Array.BYTES_PER_ELEMENT,p=t*d,f=r*d;for(let e=n*i;e<=c.length;e+=i)c.i1616Add(e+_,p,f);this.recordEnd()}_getVertexWriter(e,t){const{stride:r}=t,s=this._instanceIdToVertexData;return s.has(e)||s.set(e,new $(e,t,r,this._sizeHint)),s.get(e)}}function Q(e){switch(e){case 1:case 8:case 32:return-1;case 2:case 64:return 0;case 4:case 16:case 128:return 1}}function Z(e){switch(e){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(e,t,r=0){this.tileKey=e,this._bufferingEnabled=t,this._sizeHint=r,this._meshes={self:new K(this.id,this._sizeHint),neighbors:new Array},this._currentRecordOverlaps=0,this._currentEntityOverlaps=0}get id(){return this.tileKey}vertexCount(){return this._meshes.self.vertexCount()}indexCount(){return this._meshes.self.indexCount()}indexEnsureSize(e){this._meshes.self.indexEnsureSize(e)}entityStart(e,t=e){this._currentEntityOverlaps=0,this._meshes.self.entityStart(e,t)}entityRecordCount(){return this._meshes.self.entityRecordCount()}entityEnd(){if(this._meshes.self.entityEnd(),this._bufferingEnabled)for(let e=0;e<8;e++){const t=1<<e;this._currentEntityOverlaps&t&&this._meshes.neighbors[e].entityEnd()}}recordStart(e,t,r){this._currentRecordOverlaps=0,this._meshes.self.recordStart(e,t,r)}recordEnd(e=0){const t=this._meshes.self.recordEnd(this._currentRecordOverlaps);return t&&0!==this._currentRecordOverlaps?(this._copyIntoNeighbors(),this._currentEntityOverlaps|=this._currentRecordOverlaps,!0):t}recordBounds(e,t,r,s){this._bufferingEnabled&&this._addOverlap(e,t,r,s)}recordCount(){return this._meshes.self.recordCount()}metricStart(e){this._meshes.self.metricStart(e)}metricBoxWrite(e){this._meshes.self.metricBoxWrite(e)}metricEnd(){this._meshes.self.metricEnd()}vertexWrite(e){this._meshes.self.vertexWrite(e)}vertexWriteF32(e){this._meshes.self.vertexWriteF32(e)}vertexWriteRegion(e){this._meshes.self.vertexWriteRegion(e)}indexWrite(e){this._meshes.self.indexWrite(e)}serialize(e){const t={message:[],transferList:[]},r=this._meshes.self.serialize();return t.message.push({tileId:this.tileKey,...r.message}),t.transferList.push(...r.transferList),this._meshes.neighbors.forEach(((r,s)=>{const i=r.serialize(),n=1<<s,o=Q(n),a=Z(n),c=function(e,t,r,s){const i=e.clone(),n=1<<i.level,o=i.col+t,a=i.row+r;return s&&o<0?(i.col=o+n,i.world-=1):o>=n?(i.col=o-n,i.world+=1):i.col=o,i.row=a,i}(new _.c(this.tileKey),o,a,e);t.message.push({tileId:c.id,...i.message}),t.transferList.push(...i.transferList)})),t}_addOverlap(e,t,r,s){const i=Math.min(L.gT/2,r),n=Math.min(L.gT/2,s),o=255^((e<0+i?148:e>=L.gT-i?41:189)|(t<0+n?224:t>=L.gT-n?7:231));this._currentRecordOverlaps|=o}_copyIntoNeighbors(){for(let e=0;e<8;e++){const t=1<<e;if(this._currentRecordOverlaps&t){if(!this._meshes.neighbors[e]){const r=Math.floor(this._sizeHint/16);this._meshes.neighbors[e]=new K(t,r)}const r=this._meshes.neighbors[e],s=-Q(t)*L.gT,i=-Z(t)*L.gT;r.copyLastFrom(this._meshes.self,s,i)}}}}class ee{}var te=r(92400),re=r(62088),se=r(88264);const ie=53290320,ne=10;function oe(e,t,r,s,i,n,o){if(e.primitiveName===t)for(const t in e)if(t===r){let r=s?.readWithDefault(i,n,e[t]&&o);return"text"===e.type&&(r=r.toString()),void(e[t]=r)}if("type"in e&&null!=e.type)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.symbolLayers)for(const a of e.symbolLayers)oe(a,t,r,s,i,n,o);break;case"CIMHatchFill":e.lineSymbol&&oe(e.lineSymbol,t,r,s,i,n,o);break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if("CIMVectorMarker"===e.type&&e.markerGraphics)for(const a of e.markerGraphics)oe(a,t,r,s,i,n,o),oe(a.symbol,t,r,s,i,n,o)}}class ae{destroy(){}}class ce extends ae{constructor(e){super(),this._value=e}resize(e){}read(e,t){return this._value}readWithDefault(e,t,r){return this._value}referencesScale(){return!1}referencesGeometry(){return!1}}async function le(e,t,r=!1){const{defaultValue:s,valueExpressionInfo:i,value:n}=t;if(i){const{expression:n}=i,o=await e.createComputedField({expression:n},r);return o?{...t,computed:o,defaultValue:s}:null}return{...t,computed:new ce(n),defaultValue:s}}async function ue(e,t){const{defaultValue:r,valueExpressionInfo:s}=t,{expression:i}=s,n=await e.createComputedField({expression:i});return n?{...t,computed:n,defaultValue:r}:null}const he=e=>"boolean"!=typeof e&&"number"!=typeof e&&"valueExpressionInfo"in e,de=e=>e.some((e=>{for(const t in e){const r=e[t];if(he(r))return!0}return!1}));class _e{static async create(e,t,r){const s={},i=new Map,n=new Map,o=new Map,a=new Map,c=new Map;for(const l in r.params){const u=r.params[l];if(null!=u&&"object"==typeof u)if(Array.isArray(u)){if("object"==typeof u[0])throw new Error(`InternalError: Cannot handle ${l}. Nested array params are not supported`);s[l]=u}else if("valueExpressionInfo"in u){if(u.value){s[l]=u.value;continue}const t=await ue(e,u);if(!t){s[l]=u.defaultValue;continue}i.set(l,t),s[l]=null}else switch(u.type){case"cim-effect-infos":if(u.effectInfos.some((e=>e.overrides.length))){n.set(l,{effects:await Promise.all(u.effectInfos.map((async t=>{const r=t.overrides.map((t=>le(e,t)));return{effect:t.effect,compiledOverrides:(await Promise.all(r)).filter(te.G6)}})))});break}s[l]=u.effectInfos.map((e=>e.effect));break;case"cim-marker-placement-info":u.overrides.length&&o.set(l,{placementInfo:u,compiledOverrides:(await Promise.all(u.overrides.map((t=>le(e,t))))).filter(te.G6)}),s[l]=u.placement;break;case"text-rasterization-param":{if(u.overrides.length){const t=u.overrides.map((t=>le(e,t,u.useLegacyLabelEvaluationRules)));a.set(l,{compiledOverrides:(await Promise.all(t)).filter(te.G6),rasterizationParam:u,objectIdToResourceId:new Map});continue}const r={type:"cim-rasterization-info",resource:u.resource};s[l]=await t.fetchResourceImmediate(r)??null;break}case"sprite-rasterization-param":{if(u.overrides.length){const t=u.overrides.map((t=>le(e,t)));a.set(l,{compiledOverrides:(await Promise.all(t)).filter(te.G6),rasterizationParam:u,objectIdToResourceId:new Map});continue}if("animated"===u.resource.type){a.set(l,{compiledOverrides:[],rasterizationParam:u,objectIdToResourceId:new Map});continue}const r={type:"cim-rasterization-info",resource:u.resource};s[l]=await t.fetchResourceImmediate(r)??null;break}case"cim-marker-transform-param":{const{params:t}=u;if(de(t)){const r={compiledMarkerInfos:[]};await Promise.all(t.map((async t=>{const s={props:{}};for(const r in t)if(he(t[r])){const i=await ue(e,t[r]);s.compiledExpressionMap||(s.compiledExpressionMap=new Map);const n=s.compiledExpressionMap;i&&n.set(r,i)}else s.props[r]=t[r];r.compiledMarkerInfos.push(s)}))),c.set(l,r)}else s[l]={type:"cim-marker-transform-info",infos:t};break}default:s[l]=u}else s[l]=u}return new _e(r,s,i,n,o,a,c)}constructor(e,t,r,s,i,n,o){this.inputMeshParams=e,this._resolvedMeshParams=t,this._dynamicProperties=r,this._dynamicEffectProperties=s,this._dynamicPlacementProperties=i,this._dynamicAsyncProperties=n,this._dynamicTransformProperties=o,this.evaluator=e=>e}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(e,t,r){for(const n of this._dynamicAsyncProperties.values()){const o=(0,re.ct)(n.rasterizationParam.resource);"animated"===n.rasterizationParam.resource.type&&n.rasterizationParam.resource.randomizeStartTime&&(o.startGroup=(i=t.getObjectId()||0,Math.floor(function(e,t){let r;if("string"==typeof e)r=(0,se.sV)(e+`-seed(${t})`);else{let s=12;r=e^t;do{r=107*(r>>8^r)+s|0}while(0!=--s)}return(1+r/(1<<31))/2}(i,ie)*ne)));for(const{primitiveName:e,propertyName:i,computed:a,defaultValue:c,valueExpressionInfo:l}of n.compiledOverrides)try{oe(o,e,i,a,t,r,c)}catch(t){M.c.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.mesh.MeshWriterInputEvaluator").errorOnce(new s.c("invalid-arcade-expression",`Encountered an error when evaluating the arcade expression '${l?.expression}' (primitive: '${e}', property: '${i}')`,t))}const a=e.enqueueRequest({type:"cim-rasterization-info",resource:o});n.objectIdToResourceId.set(t.getObjectId(),a)}var i}evaluateMeshParams(e,t,r){for(const[e,s]of this._dynamicProperties.entries())this._resolvedMeshParams[e]=s.computed.readWithDefault(t,r,s.defaultValue);for(const[e,s]of this._dynamicPlacementProperties.entries())for(const{computed:i,defaultValue:n,propertyName:o}of s.compiledOverrides){const a=i.readWithDefault(t,r,n);s.placementInfo.placement[o]=a,this._resolvedMeshParams[e]=s.placementInfo.placement}for(const[e,s]of this._dynamicEffectProperties.entries())for(const i of s.effects){for(const{computed:e,defaultValue:s,propertyName:n}of i.compiledOverrides){const o=e.readWithDefault(t,r,s);i.effect[n]=o}this._resolvedMeshParams[e]=s.effects.map((e=>e.effect))}for(const[e,s]of this._dynamicTransformProperties.entries()){const i={type:"cim-marker-transform-info",infos:[]};for(const e of s.compiledMarkerInfos){const s={...e.props};if(e.compiledExpressionMap)for(const[i,n]of e.compiledExpressionMap){const e=n.computed.readWithDefault(t,r,n.defaultValue);s[i]="number"==typeof e||"boolean"==typeof e?e:n.defaultValue}i.infos.push(s)}this._resolvedMeshParams[e]=i}for(const[r,s]of this._dynamicAsyncProperties.entries()){const i=s.objectIdToResourceId.get(t.getObjectId());if(null==i)continue;const n=e.getResource(i);this._resolvedMeshParams[r]=n}return this._evaluatedMeshParams=this.evaluator(this._resolvedMeshParams),this.evaluatedMeshParams}}var pe=r(30936),fe=(r(17012),r(93320)),me=r(85152);function ge(e,t,r,s,i,n,o){ze=0;const a=(s-r)*n,c=i&&i.length,l=c?(i[0]-r)*n:a;let u,h,d,_,p,f=ye(t,r,0,0,l,n,!0);if(f&&f.next!==f.prev){if(c&&(f=function(e,t,r,s,i,n){const o=new Array;for(let i=0,a=s.length;i<a;i++){const c=ye(e,t,0,s[i]*n,i<a-1?s[i+1]*n:r*n,n,!1);c===c.next&&(c.steiner=!0),o.push(Ie(c))}o.sort(Oe);for(const e of o)i=Ee(e,i);return i}(t,r,s,i,f,n)),a>80*n){u=d=t[0+r*n],h=_=t[1+r*n];for(let e=n;e<l;e+=n){const s=t[e+r*n],i=t[e+1+r*n];u=Math.min(u,s),h=Math.min(h,i),d=Math.max(d,s),_=Math.max(_,i)}p=Math.max(d-u,_-h),p=0!==p?1/p:0}be(f,e,n,u,h,p,o,0)}}function ye(e,t,r,s,i,n,o){let a;if(o===function(e,t,r,s,i,n){let o=0;for(let r=s,a=i-n;r<i;r+=n)o+=(e[a+t*n]-e[r+t*n])*(e[r+1+t*n]+e[a+1+t*n]),a=r;return o}(e,t,0,s,i,n)>0)for(let r=s;r<i;r+=n)a=Se(r+t*n,e[r+t*n],e[r+1+t*n],a);else for(let r=i-n;r>=s;r-=n)a=Se(r+t*n,e[r+t*n],e[r+1+t*n],a);return a&&Pe(a,a.next)&&(ve(a),a=a.next),a}function xe(e,t=e){if(!e)return e;let r,s=e;do{if(r=!1,s.steiner||!Pe(s,s.next)&&0!==Ae(s.prev,s,s.next))s=s.next;else{if(ve(s),s=t=s.prev,s===s.next)break;r=!0}}while(r||s!==t);return t}function be(e,t,r,s,i,n,o,a){if(!e)return;!a&&n&&(e=Re(e,s,i,n));let c=e;for(;e.prev!==e.next;){const l=e.prev,u=e.next;if(n?we(e,s,i,n):Te(e))t.push(l.index/r+o),t.push(e.index/r+o),t.push(u.index/r+o),ve(e),e=u.next,c=u.next;else if((e=u)===c){a?1===a?be(e=ke(e,t,r,o),t,r,s,i,n,o,2):2===a&&De(e,t,r,s,i,n,o):be(xe(e),t,r,s,i,n,o,1);break}}}function Te(e){const t=e.prev,r=e,s=e.next;if(Ae(t,r,s)>=0)return!1;let i=e.next.next;const n=i;let o=0;for(;i!==e.prev&&(0===o||i!==n);){if(o++,Ce(t.x,t.y,r.x,r.y,s.x,s.y,i.x,i.y)&&Ae(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function we(e,t,r,s){const i=e.prev,n=e,o=e.next;if(Ae(i,n,o)>=0)return!1;const a=i.x<n.x?i.x<o.x?i.x:o.x:n.x<o.x?n.x:o.x,c=i.y<n.y?i.y<o.y?i.y:o.y:n.y<o.y?n.y:o.y,l=i.x>n.x?i.x>o.x?i.x:o.x:n.x>o.x?n.x:o.x,u=i.y>n.y?i.y>o.y?i.y:o.y:n.y>o.y?n.y:o.y,h=Ne(a,c,t,r,s),d=Ne(l,u,t,r,s);let _=e.prevZ,p=e.nextZ;for(;_&&_.z>=h&&p&&p.z<=d;){if(_!==e.prev&&_!==e.next&&Ce(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Ae(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,p!==e.prev&&p!==e.next&&Ce(i.x,i.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Ae(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;_&&_.z>=h;){if(_!==e.prev&&_!==e.next&&Ce(i.x,i.y,n.x,n.y,o.x,o.y,_.x,_.y)&&Ae(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&Ce(i.x,i.y,n.x,n.y,o.x,o.y,p.x,p.y)&&Ae(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Se(e,t,r,s){const i=Le.create(e,t,r);return s?(i.next=s.next,i.prev=s,s.next.prev=i,s.next=i):(i.prev=i,i.next=i),i}function ve(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Ie(e){let t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function Ee(e,t){const r=function(e,t){let r=t;const s=e.x,i=e.y;let n,o=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){const e=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=s&&e>o){if(o=e,e===s){if(i===r.y)return r;if(i===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(s===o)return n.prev;const a=n,c=n.x,l=n.y;let u,h=1/0;for(r=n.next;r!==a;)s>=r.x&&r.x>=c&&s!==r.x&&Ce(i<l?s:o,i,c,l,i<l?o:s,i,r.x,r.y)&&(u=Math.abs(i-r.y)/(s-r.x),(u<h||u===h&&r.x>n.x)&&Fe(r,e)&&(n=r,h=u)),r=r.next;return n}(e,t);if(!r)return t;const s=Be(r,e);return xe(s,s.next),xe(r,r.next)}function Re(e,t,r,s){let i;for(;i!==e;i=i.next){if(i=i||e,null===i.z&&(i.z=Ne(i.x,i.y,t,r,s)),i.prev.next!==i||i.next.prev!==i)return i.prev.next=i,i.next.prev=i,Re(e,t,r,s);i.prevZ=i.prev,i.nextZ=i.next}return e.prevZ.nextZ=null,e.prevZ=null,function(e){let t,r=1;for(;;){let s,i=e;e=null,t=null;let n=0;for(;i;){n++,s=i;let o=0;for(;o<r&&s;o++)s=s.nextZ;let a=r;for(;o>0||a>0&&s;){let r;0===o?(r=s,s=s.nextZ,a--):0!==a&&s?i.z<=s.z?(r=i,i=i.nextZ,o--):(r=s,s=s.nextZ,a--):(r=i,i=i.nextZ,o--),t?t.nextZ=r:e=r,r.prevZ=t,t=r}i=s}if(t.nextZ=null,r*=2,n<2)return e}}(e)}function Ae(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Me(e,t,r,s){return!!(Pe(e,t)&&Pe(r,s)||Pe(e,s)&&Pe(r,t))||Ae(e,t,r)>0!=Ae(e,t,s)>0&&Ae(r,s,e)>0!=Ae(r,s,t)>0}function Ce(e,t,r,s,i,n,o,a){return(i-o)*(t-a)-(e-o)*(n-a)>=0&&(e-o)*(s-a)-(r-o)*(t-a)>=0&&(r-o)*(n-a)-(i-o)*(s-a)>=0}function Fe(e,t){return Ae(e.prev,e,e.next)<0?Ae(e,t,e.next)>=0&&Ae(e,e.prev,t)>=0:Ae(e,t,e.prev)<0||Ae(e,e.next,t)<0}function Ne(e,t,r,s,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-s)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Pe(e,t){return e.x===t.x&&e.y===t.y}function Oe(e,t){return e.x-t.x}function ke(e,t,r,s){let i=e;do{const n=i.prev,o=i.next.next;!Pe(n,o)&&Me(n,i,i.next,o)&&Fe(n,o)&&Fe(o,n)&&(t.push(n.index/r+s),t.push(i.index/r+s),t.push(o.index/r+s),ve(i),ve(i.next),i=e=o),i=i.next}while(i!==e);return i}function De(e,t,r,s,i,n,o){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.index!==e.index&&Ue(a,e)){let c=Be(a,e);return a=xe(a,a.next),c=xe(c,c.next),be(a,t,r,s,i,n,o,0),void be(c,t,r,s,i,n,o,0)}e=e.next}a=a.next}while(a!==e)}function Ue(e,t){return e.next.index!==t.index&&e.prev.index!==t.index&&!function(e,t){let r=e;do{if(r.index!==e.index&&r.next.index!==e.index&&r.index!==t.index&&r.next.index!==t.index&&Me(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&Fe(e,t)&&Fe(t,e)&&function(e,t){let r=e,s=!1;const i=(e.x+t.x)/2,n=(e.y+t.y)/2;do{r.y>n!=r.next.y>n&&r.next.y!==r.y&&i<(r.next.x-r.x)*(n-r.y)/(r.next.y-r.y)+r.x&&(s=!s),r=r.next}while(r!==e);return s}(e,t)}function Be(e,t){const r=Le.create(e.index,e.x,e.y),s=Le.create(t.index,t.x,t.y),i=e.next,n=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,s.next=r,r.prev=s,n.next=s,s.prev=n,s}class Le{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(e,t,r){const s=ze<Ge.length?Ge[ze++]:new Le;return s.index=e,s.x=t,s.y=r,s.prev=null,s.next=null,s.z=null,s.prevZ=null,s.nextZ=null,s.steiner=!1,s}}const Ge=[];let ze=0;for(let e=0;e<8096;e++)Ge.push(new Le);const Ve=new fe.CU(0,0,0,1,0),qe=new fe.CU(0,0,0,1,0);function He(e,t,r){let s=0;for(let i=1;i<r;i++){const r=e[2*(t+i-1)],n=e[2*(t+i-1)+1];s+=(e[2*(t+i)]-r)*(e[2*(t+i)+1]+n)}return s}function We(e,t,r,s,i){let n=0;for(let o=r;o<s;o+=3){const r=2*(e[o]-i),s=2*(e[o+1]-i),a=2*(e[o+2]-i);n+=Math.abs((t[r]-t[a])*(t[s+1]-t[r+1])-(t[r]-t[s])*(t[a+1]-t[r+1]))}return n}Ve.setExtent(L.gT),qe.setExtent(L.gT);var Ye=r(7857),Xe=r(68564),je=r(1720),$e=r(55872),Ke=r(14510);class Qe{static executeEffects(e,t,r,s){const i=(0,Ke.mm)(e);let n=new je.y(t);for(const t of e){const e=(0,$e.g)(t);e&&(n=e.execute(n,t,1.3333333333333333,r,s,i))}return n}static applyEffects(e,t,r){if(!e)return t;const s=(0,Ke.mm)(e);let i,n=new je.y(Ye.k.fromJSONCIM(t));for(const t of e){const e=(0,$e.g)(t);e&&(n=e.execute(n,t,1,null,r,s))}const o=[];let a=null;for(;i=n.next();)o.push(...(0,Xe.k)(i)),a=i.geometryType;return 0===o.length||null===a?null:"esriGeometryPolygon"===a?{rings:o}:{paths:o}}}let Ze=null;function Je(){return Ze}const et=new Float32Array(1);new Uint32Array(et.buffer);var tt=r(77800);function rt(e){switch(e){case tt.Ck.BYTE:case tt.Ck.UNSIGNED_BYTE:return 1;case tt.Ck.SHORT:case tt.Ck.UNSIGNED_SHORT:return 2;case tt.Ck.FLOAT:case tt.Ck.INT:case tt.Ck.UNSIGNED_INT:return 4}}class st{static fromVertexSpec({attributes:e},t){let r,s,i;const n=[];for(const o in e){const a=e[o];!1!==t?.[o]&&("position"===a.pack?r={...a,name:o,offset:0}:"id"===a.pack?s={...a,name:o,offset:4}:"bitset"===o?i={...a,name:o,offset:7}:n.push({...a,name:o}))}const o=function(e){const t=[],r=[],s=[];for(const i of e){const e=rt(i.type)*i.count;switch(e%2||e%4||4){case 4:t.push(i);continue;case 2:r.push(i);continue;case 1:s.push(i);continue;default:throw new Error("Found unexpected dataType byte count")}}return t.push(...r),t.push(...s),t}(n),a=[];let c=8,l=1;for(const e of o)a.push({...e,offset:c}),c+=rt(e.type)*e.count,e.packAlternating&&(l=Math.max(e.packAlternating.count,l));const u=Uint32Array.BYTES_PER_ELEMENT,h=c%u;return new st(r,s,i,a,c+(h?u-h:0),l)}constructor(e,t,r,s,i,n){this.position=e,this.id=t,this.bitset=r,this.standardAttributes=s,this.stride=i,this.packVertexCount=n,s.push(r),this._attributes=[e,t,r,...s]}get attributeLayout(){if(!this._attributeLayout){const e=function(e){const t=e.map((({name:e,count:t,type:r})=>`${e}.${t}.${r}`)).join(",");return(0,se.sV)(t)}(this._attributes),t=this._attributes.map((e=>({name:e.name,count:e.count,offset:e.offset,type:e.type,packPrecisionFactor:e.packPrecisionFactor,normalized:e.normalized??!1})));this._attributeLayout={attributes:t,hash:e,stride:this.stride}}return this._attributeLayout}}class it{static fromVertexSpec(e,t){const r=st.fromVertexSpec(e,t);return new it(r)}constructor(e){this._spec=e,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(e,t,r,s,i,n){for(let e=0;e<this._spec.packVertexCount;e++){const o=e*this._spec.stride;this._packPosition(r,s,o),this._packId(t,o);const a=this._spec.bitset;if(n){if(a.packTessellation){const e=a.packTessellation(n,i);this._pack(e,a,o)}for(const e of this._spec.standardAttributes)if(null!=e.packTessellation){const t=e.packTessellation(n,i);this._pack(t,e,o)}else if(e.packAlternating?.packTessellation){const t=e.packAlternating.packTessellation(n,i);for(let r=0;r<this._spec.packVertexCount;r++){const s=t[r];this._pack(s,e,r*this._spec.stride)}}}}e.vertexWriteRegion(this._packedU32View)}pack(e,t){for(const r of this._spec.standardAttributes)if(r.pack&&"string"!=typeof r.pack){const s=r.pack(e,t);for(let e=0;e<this._spec.packVertexCount;e++)this._pack(s,r,e*this._spec.stride)}else if(r.packAlternating?.pack){const s=r.packAlternating.pack(e,t);for(let e=0;e<this._spec.packVertexCount;e++){const t=s[e];this._pack(t,r,e*this._spec.stride)}}}_packPosition(e,t,r){const{offset:s}=this._spec.position,i=this._spec.position.packPrecisionFactor??1,n=65535&e*i|t*i<<16;this._dataView.setUint32(r+s,n,!0)}_packId(e,t){const r=e*(this._spec.id.packPrecisionFactor??1),s=4278190080&this._dataView.getUint32(t+this._spec.id.offset,!0);this._dataView.setUint32(t+this._spec.id.offset,r|s,!0)}_pack(e,t,r){!function(e,t,r,s){const i=r.packPrecisionFactor??1;switch(r.type){case tt.Ck.BYTE:if(1===r.count)e.setInt8(s+r.offset,t*i);else for(let n=0;n<r.count;n++){const o=n*Int8Array.BYTES_PER_ELEMENT;e.setInt8(s+r.offset+o,t[n]*i)}break;case tt.Ck.UNSIGNED_BYTE:if(1===r.count)e.setUint8(s+r.offset,t*i);else for(let n=0;n<r.count;n++){const o=n*Uint8Array.BYTES_PER_ELEMENT;e.setUint8(s+r.offset+o,t[n]*i)}break;case tt.Ck.SHORT:if(1===r.count)e.setInt16(s+r.offset,t*i,!0);else for(let n=0;n<r.count;n++){const o=n*Int16Array.BYTES_PER_ELEMENT;e.setInt16(s+r.offset+o,t[n]*i,!0)}break;case tt.Ck.UNSIGNED_SHORT:if(1===r.count)e.setUint16(s+r.offset,t*i,!0);else for(let n=0;n<r.count;n++){const o=n*Uint16Array.BYTES_PER_ELEMENT;e.setUint16(s+r.offset+o,t[n]*i,!0)}break;case tt.Ck.INT:if(1===r.count)e.setInt32(s+r.offset,t*i,!0);else for(let n=0;n<r.count;n++){const o=n*Int32Array.BYTES_PER_ELEMENT;e.setInt32(s+r.offset+o,t[n]*i,!0)}break;case tt.Ck.UNSIGNED_INT:if(1===r.count)e.setUint32(s+r.offset,t*i,!0);else for(let n=0;n<r.count;n++){const o=n*Uint32Array.BYTES_PER_ELEMENT;e.setUint32(s+r.offset+o,t[n]*i,!0)}break;case tt.Ck.FLOAT:if(1===r.count)e.setFloat32(s+r.offset,t*i,!0);else for(let n=0;n<r.count;n++){const o=n*Float32Array.BYTES_PER_ELEMENT;e.setFloat32(s+r.offset+o,t[n]*i,!0)}}}(this._dataView,e,t,r)}}class nt{constructor(e,t,r,s){this._instanceId=e,this._evaluator=t,this._viewParams=r,this._optionalAttributes=s,this._evaluator.evaluator=e=>this.vertexSpec.createComputedParams(e)}get _vertexPack(){if(!this._cachedVertexPack){const e=it.fromVertexSpec(this.vertexSpec,this._optionalAttributes);this._evaluator.hasDynamicProperties||e.pack(this._evaluator.evaluatedMeshParams,this._viewParams),this._cachedVertexPack=e}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(e){this._references=e}getBoundsInfo(){return null}getTileInfo(){return this._viewParams.tileInfo}async loadDependencies(){(function(e){if(!e)return!1;for(const t of e)switch(t.effect.type){case"CIMGeometricEffectBuffer":case"CIMGeometricEffectOffset":case"CIMGeometricEffectDonut":return!0}return!1})(this._evaluator.inputMeshParams.params.effects?.effectInfos)&&await async function(){Ze=await Promise.all([r.e(984),r.e(324)]).then(r.bind(r,82704))}()}enqueueRequest(e,t,r){this._evaluator.hasDynamicProperties&&this._evaluator.enqueueRequest(e,t,r)}write(e,t,r,s,i){this.ensurePacked(t,r,s);const n=this.evaluatedMeshParams.effects;if(!n||0===n.length)return void this._write(e,r,void 0,i);const o=r.readGeometryForDisplay()?.clone();if(!o)return;const a=Ye.k.fromOptimizedCIM(o,r.geometryType),c=Je();a.invertY();const l=e.id||"",u=Qe.executeEffects(n,a,l,c);let h;for(;h=u.next();)h.invertY(),this._write(e,r,h,i)}ensurePacked(e,t,r){if(!this._evaluator.hasDynamicProperties)return;const s=this._evaluator.evaluateMeshParams(e,t,r);this._vertexPack.pack(s,this._viewParams)}_writeVertex(e,t,r,s,i){const n=this.evaluatedMeshParams;this._vertexPack.writeVertex(e,t,r,s,n,i)}}const ot=(0,n.c)("featurelayer-fast-triangulation-enabled");class at extends nt{async loadDependencies(){await Promise.all([super.loadDependencies(),(0,pe.C)()])}_write(e,t,r){const s=r?.asOptimized()??t.readGeometryForDisplay(),i=this._clip(s);i&&(e.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(e,t,i),e.recordEnd())}_clip(e){return e?function(e,t){if(null==e)return null;if(!function(e,t,r){let s=0;for(let t=0;t<e.lengths.length;t++){const i=e.lengths[t];for(let t=0;t<i;t++){const i=e.coords[2*(t+s)],n=e.coords[2*(t+s)+1];if(i<-128||i>r||n<-128||n>r)return!0}s+=i}return!1}(e,0,L.gT+128))return e;Ve.setPixelMargin(t),Ve.reset(fe.ao.Polygon);let r=0;for(let t=0;t<e.lengths.length;t++){const s=e.lengths[t];let i=e.coords[2*(0+r)],n=e.coords[2*(0+r)+1];Ve.moveTo(i,n);for(let t=1;t<s;t++)i=e.coords[2*(t+r)],n=e.coords[2*(t+r)+1],Ve.lineTo(i,n);Ve.close(),r+=s}const s=Ve.result(!1);if(!s)return null;const i=[],n=[];for(const e of s){let t=0;for(const r of e)n.push(r.x),n.push(r.y),t++;i.push(t)}return new me.c(i,n)}(e,this.hasEffects?256:8):null}_writeGeometry(e,t,r){const s=r.maxLength>100,i=[],n=this.createTesselationParams(t);if(!s&&ot&&function(e,t){const{coords:r,lengths:s,hasIndeterminateRingOrder:i}=t,n=e;if(i)return!1;let o=0;for(let e=0;e<s.length;){let t=e,i=s[e],a=He(r,o,i);const c=[];for(;++t<s.length;){const e=s[t],n=He(r,o+i,e);if(!(n>0))break;a+=n,c.push(o+i),i+=e}const l=n.length;ge(n,r,o,o+i,c,2,0);const u=We(n,r,l,n.length,0),h=Math.abs(a);if(Math.abs((u-h)/Math.max(1e-7,h))>1e-5)return n.length=0,!1;e=t,o+=i}return!0}(i,r))return void(i.length&&this._writeVertices(e,t,r.coords,n,i));const o=function(e){const{coords:t,lengths:r}=e,{buffer:s}=(0,pe.y)(t,r);return s}(r);this._writeVertices(e,t,o,n)}_writeVertices(e,t,r,s,i){const n=t.getDisplayId(),o=e.vertexCount(),a=this.hasEffects;let c=0;if(i)for(const t of i){const i=r[2*t],o=r[2*t+1];a&&e.recordBounds(i,o,0,0),this._writeVertex(e,n,i,o,s),c++}else for(let t=0;t<r.length;t+=2){const i=Math.round(r[t]),o=Math.round(r[t+1]);a&&e.recordBounds(i,o,0,0),this._writeVertex(e,n,i,o,s),c++}e.indexEnsureSize(c);for(let t=0;t<c;t++)e.indexWrite(t+o)}}const ct={createComputedParams:e=>e,attributes:{id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1},pos:{type:tt.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},inverseArea:{type:tt.Ck.FLOAT,count:1,packTessellation:({inverseArea:e})=>e}}};var lt=r(51760),ut=r(44728),ht=r(89232);function dt(e,t){return[!!e?.minScale&&t.scaleToZoom(e.minScale)||0,!!e?.maxScale&&t.scaleToZoom(e.maxScale)||100]}function _t(e){return 1<<e}function pt(e){let t=0;for(const[r,s]of e)s&&(t|=1<<r);return t}function ft(e){let t;if(!e)return[0,0,0,0];if("string"==typeof e){const r=ut.c.fromString(e);if(!r)return M.c.getLogger("esri.views.2d.engine.webgl.shaderGraph.techniques.meshWriterUtils").errorOnce(new s.c("mapview:mesh-processing","Unable to parse string into color",{color:e})),[0,0,0,0];t=r.toArray()}else t=e;const[r,i,n,o]=t;return[r*(o/255),i*(o/255),n*(o/255),o]}function mt(e,t){return Math.round(Math.min(Math.sqrt(e*t),255))}function gt(e,t){return Math.round(e*t)/t}function yt(e,t){return Math.ceil(e*t)/t}const xt={createComputedParams:e=>e,attributes:{id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1},pos:{type:tt.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},zoomRange:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:L.M6,pack:({scaleInfo:e},{tileInfo:t})=>dt(e,t)},color:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:e})=>ft(e)}}};class bt extends at{constructor(){super(...arguments),this.vertexSpec=xt}createTesselationParams(e){return null}}const Tt={createComputedParams:e=>e,attributes:{...xt.attributes,tlbr:{count:4,type:tt.Ck.UNSIGNED_SHORT,pack:({sprite:e})=>{const{rect:t,width:r,height:s}=e,i=t.x+L.mc,n=t.y+L.mc;return[i,n,i+r,n+s]}},inverseRasterizationScale:{count:1,type:tt.Ck.BYTE,packPrecisionFactor:16,pack:({sprite:e})=>1/e.rasterizationScale}}};class wt extends bt{constructor(){super(...arguments),this.vertexSpec=Tt}_write(e,t,r){const s=r?.asOptimized()??t.readGeometryForDisplay(),i=this._clip(s);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;e.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(e,t,i),e.recordEnd()}}var St,vt;(vt=St||(St={}))[vt.Geographic=0]="Geographic",vt[vt.Arithmatic=1]="Arithmatic";const It=1.1,Et=1,Rt=1e-5,At=.05,Mt=1e-30,Ct=2;function Ft(e){const{sprite:t,aspectRatio:r,scaleProportionally:s}=e,i=(0,u.im)(e.height),n=i>0?i:t.height;let o=i*r;return o<=0?o=t.width:s&&(o*=t.width/t.height),{width:o,height:n}}function Nt(e){const{applyRandomOffset:t,sampleAlphaOnly:r}=e,{width:s,height:i}=Ft(e);return pt([[Ct,t],[4,r],[6,s<L.c5],[5,i<L.c5]])}function Pt(e){const{width:t}=Ft(e);return Math.round(t<L.c5?t*L.Q0:t)}function Ot(e){const{height:t}=Ft(e);return Math.round(t<L.c5?t*L.Q0:t)}const kt={createComputedParams:e=>e,attributes:{...Tt.attributes,bitset:{count:1,type:tt.Ck.UNSIGNED_BYTE,pack:Nt},width:{count:1,type:tt.Ck.UNSIGNED_SHORT,pack:Pt},height:{count:1,type:tt.Ck.UNSIGNED_SHORT,pack:Ot},offset:{count:2,type:tt.Ck.SHORT,pack:({offsetX:e,offsetY:t})=>[(0,u.im)(e),-(0,u.im)(t)]},scale:{count:2,type:tt.Ck.UNSIGNED_BYTE,packPrecisionFactor:16,pack:({scaleX:e,scaleY:t})=>[e,t]},angle:{count:1,type:tt.Ck.UNSIGNED_BYTE,pack:({angle:e})=>(0,lt.Qf)(e)}}};var Dt=r(93552);class Ut{constructor(){this.extrusionOffsetX=0,this.extrusionOffsetY=0,this.normalX=0,this.normalY=0,this.directionX=0,this.directionY=0,this.distance=0}}const Bt={createComputedParams:e=>e,attributes:{id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},pos:{type:tt.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1},zoomRange:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:L.M6,pack:({scaleInfo:e},{tileInfo:t})=>dt(e,t)},color:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:e})=>ft(e)},offset:{type:tt.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({extrusionOffsetX:e,extrusionOffsetY:t})=>[gt(e,16),gt(t,16)]},normal:{type:tt.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({normalX:e,normalY:t})=>[gt(e,16),gt(t,16)]},halfWidth:{type:tt.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:16,pack:({width:e})=>yt((0,u.im)(.5*e),16)},referenceHalfWidth:{type:tt.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:16,pack:({referenceWidth:e})=>yt((0,u.im)(.5*e),16)}}};class Lt{constructor(){this.id=0,this.bitset=0,this.indexCount=0,this.vertexCount=0,this.vertexFrom=0,this.vertexBounds=0}}class Gt extends nt{constructor(e,t,r,s){super(e,t,r,s),this.vertexSpec=Bt,this._currentWrite=new Lt,this._tessellationOptions={halfWidth:0,pixelCoordRatio:1,offset:0,wrapDistance:65535,textured:!1},this._tessParams=new Ut,this._initializeTessellator()}writeLineVertices(e,t,r){const s=this._getLines(t);null!=s&&this._writeVertices(e,r,s)}_initializeTessellator(){this._lineTessellator=new Dt.A(this._writeTesselatedVertex.bind(this),this._writeTriangle.bind(this),!0)}_write(e,t,r){const s=r??Ye.k.fromFeatureSetReaderCIM(t);s&&this._writeGeometry(e,t,s)}_writeGeometry(e,t,r,s){e.recordStart(this.instanceId,this.attributeLayout,s),this.writeLineVertices(e,r,t),e.recordEnd()}_getLines(e){return function(e,t){qe.setPixelMargin(t);const r=qe,s=-t,i=L.gT+t;let n=[],o=!1;if(!e.nextPath())return null;let a=!0;for(;a;){e.seekPathStart();const t=[];if(!e.pathSize)return null;r.reset(fe.ao.LineString),e.nextPoint();let c=e.x,l=e.y;if(o)r.moveTo(c,l);else{if(c<s||c>i||l<s||l>i){o=!0;continue}t.push({x:c,y:l})}let u=!1;for(;e.nextPoint();)if(c=e.x,l=e.y,o)r.lineTo(c,l);else{if(c<s||c>i||l<s||l>i){u=!0;break}t.push({x:c,y:l})}if(u)o=!0;else{if(o){const e=r.resultWithStarts();if(e)for(const t of e)n.push(t)}else n.push({line:t,start:0});a=e.nextPath(),o=!1}}return n=n.filter((e=>e.line.length>1)),0===n.length?null:n}(e,this.hasEffects?256:16)}_writeVertices(e,t,r){const{_currentWrite:s,_tessellationOptions:i,evaluatedMeshParams:n}=this,{width:o,capType:a,joinType:c,miterLimit:l,hasSizeVV:h}=n,d=(0,u.im)(.5*o);i.halfWidth=d,i.capType=function(e){switch(e){case"butt":case ht.q.Butt:return ht.wD.BUTT;case"round":case ht.q.Round:return ht.wD.ROUND;case"square":case ht.q.Square:return ht.wD.SQUARE}}(a),i.joinType=function(e){switch(e){case"bevel":case ht.Sg.Bevel:return ht.qY.BEVEL;case"miter":case ht.Sg.Miter:return ht.qY.MITER;case"round":case ht.Sg.Round:return ht.qY.ROUND}}(c),i.miterLimit=l;const _=!h;s.out=e,s.id=t.getDisplayId(),s.vertexCount=0,s.indexCount=0,s.vertexFrom=e.vertexCount(),s.vertexBounds=_&&d<L.wt?0:1;for(const{line:e,start:t}of r)i.initialDistance=t%65535,this._lineTessellator.tessellate(e,i,_)}_writeTesselatedVertex(e,t,r,s,i,n,o,a,c,l,u){const{out:h,id:d,vertexBounds:_}=this._currentWrite;return this.hasEffects&&h.recordBounds(e,t,_,_),this._tessParams.extrusionOffsetX=o,this._tessParams.extrusionOffsetY=a,this._tessParams.normalX=c,this._tessParams.normalY=l,this._tessParams.directionX=i,this._tessParams.directionY=n,this._tessParams.distance=u,this._writeVertex(h,d,e,t,this._tessParams),this._currentWrite.vertexFrom+this._currentWrite.vertexCount++}_writeTriangle(e,t,r){const{out:s}=this._currentWrite;s.indexEnsureSize(3),s.indexWrite(e),s.indexWrite(t),s.indexWrite(r),this._currentWrite.indexCount+=3}}const zt={createComputedParams:e=>e,attributes:{...Bt.attributes,bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:e=>0},color:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:e})=>ft(e)}}},Vt={createComputedParams:e=>e,attributes:{...Bt.attributes,bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:e=>pt([[0,!0]])},color:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:e})=>ft(e)}}};class qt extends Gt{constructor(){super(...arguments),this.vertexSpec=Vt}}class Ht extends bt{constructor(e,t,r,s){super(e,t,r,s),this.vertexSpec=zt,this._lineMeshWriter=this._createOutlineWriter(e,t,r,s)}_createOutlineWriter(e,t,r,s){return new qt(e,t,r,s)}_write(e,t,r){const s=r?.asOptimized()??t.readGeometryForDisplay(),i=this._clip(s);i&&(e.recordStart(this.instanceId,this.attributeLayout),this._writeGeometry(e,t,i),this._lineMeshWriter.writeLineVertices(e,Ye.k.fromOptimizedCIM(i,"esriGeometryPolyline"),t),e.recordEnd())}ensurePacked(e,t,r){super.ensurePacked(e,t,r),this._lineMeshWriter.ensurePacked(e,t,r)}enqueueRequest(e,t,r){super.enqueueRequest(e,t,r),this._lineMeshWriter.enqueueRequest(e,t,r)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}}var Wt=r(75040),Yt=r(90736);const Xt=()=>M.c.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class jt{constructor(){this._includedModules=new Map}include(e,t){if(this._includedModules.has(e)){const r=this._includedModules.get(e);if(r!==t){Xt().error("Trying to include shader module multiple times with different sets of options.");const t=new Set;for(const s of Object.keys(r))r[s]!==e[s]&&t.add(s);for(const s of Object.keys(e))r[s]!==e[s]&&t.add(s);t.forEach((t=>console.error(` ${t}: current ${r[t]} new ${e[t]}`)))}}else this._includedModules.set(e,t),e(this.builder,t)}}class $t extends jt{constructor(){super(...arguments),this.vertex=new Zt,this.fragment=new Zt,this.attributes=new Jt,this.varyings=new er,this.extensions=new tr,this.constants=new rr}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!0){const r=this.extensions.generateSource(e),s=this.attributes.generateSource(e),i=this.varyings.generateSource(e),n="vertex"===e?this.vertex:this.fragment,o=n.uniforms.generateSource(),a=n.code.generateSource(),c="vertex"===e?sr:function(e=!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${e?"out vec4 fragColor;":""}\n`}(t),l=this.constants.generateSource().concat(n.constants.generateSource());return`${t?"#version 300 es":""}\n${r.join("\n")}\n${c}\n${l.join("\n")}\n${o.join("\n")}\n${s.join("\n")}\n${i.join("\n")}\n${a.join("\n")}`}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const r=e.bind[Wt.u.Pass];r&&t.set(e.name,r)})),this.fragment.uniforms.entries.forEach((e=>{const r=e.bind[Wt.u.Pass];r&&t.set(e.name,r)}));const r=Array.from(t.values()),s=r.length;return(t,i)=>{for(let n=0;n<s;++n)r[n](e,t,i)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const r=e.bind[Wt.u.Draw];r&&t.set(e.name,r)})),this.fragment.uniforms.entries.forEach((e=>{const r=e.bind[Wt.u.Draw];r&&t.set(e.name,r)}));const r=Array.from(t.values()),s=r.length;return(t,i,n)=>{for(let o=0;o<s;++o)r[o](e,t,i,n)}}}class Kt{constructor(){this._entries=new Map}add(...e){for(const t of e)this._add(t)}get(e){return this._entries.get(e)}_add(e){if(null!=e){if(this._entries.has(e.name)&&!this._entries.get(e.name).equals(e))throw new s.c(`Duplicate uniform name ${e.name} for different uniform type`);this._entries.set(e.name,e)}else Xt().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class Qt{constructor(){this._entries=new Array}add(e){this._entries.push(e)}generateSource(){return this._entries}}class Zt extends jt{constructor(){super(...arguments),this.uniforms=new Kt,this.code=new Qt,this.constants=new rr}get builder(){return this}}class Jt{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class er{constructor(){this._entries=new Map}add(e,t){this._entries.has(e)&&(0,Yt.Uc)(this._entries.get(e)===t),this._entries.set(e,t)}generateSource(e){const t=new Array;return this._entries.forEach(((r,s)=>t.push("vertex"===e?`out ${r} ${s};`:`in ${r} ${s};`))),t}}class tr{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?tr.ALLOWLIST_VERTEX:tr.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}}tr.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"],tr.ALLOWLIST_VERTEX=[];class rr{constructor(){this._entries=new Set}add(e,t,r){let s="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":s=rr._numberToFloatStr(r);break;case"int":s=rr._numberToIntStr(r);break;case"bool":s=r.toString();break;case"vec2":s=`vec2(${rr._numberToFloatStr(r[0])}, ${rr._numberToFloatStr(r[1])})`;break;case"vec3":s=`vec3(${rr._numberToFloatStr(r[0])}, ${rr._numberToFloatStr(r[1])}, ${rr._numberToFloatStr(r[2])})`;break;case"vec4":s=`vec4(${rr._numberToFloatStr(r[0])}, ${rr._numberToFloatStr(r[1])}, ${rr._numberToFloatStr(r[2])}, ${rr._numberToFloatStr(r[3])})`;break;case"ivec2":s=`ivec2(${rr._numberToIntStr(r[0])}, ${rr._numberToIntStr(r[1])})`;break;case"ivec3":s=`ivec3(${rr._numberToIntStr(r[0])}, ${rr._numberToIntStr(r[1])}, ${rr._numberToIntStr(r[2])})`;break;case"ivec4":s=`ivec4(${rr._numberToIntStr(r[0])}, ${rr._numberToIntStr(r[1])}, ${rr._numberToIntStr(r[2])}, ${rr._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":s=`${t}(${Array.prototype.map.call(r,(e=>rr._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${s};`),this}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const sr="precision highp float;\nprecision highp sampler2D;";function ir(e,t){const r=[];for(r.push(t);r.length;){const t=r.pop();if("object"==typeof t&&!e.has(t.uid)){e.add(t.uid);for(const e of t.children)r.push(e)}}}class nr{constructor(){this.uid=nr.NodeCount++,this._debugName=null,this._isMutable=!1,this.isImplicit=!1}get isMutable(){return this._isMutable}setMutable(){return this._isMutable=!0,this}setDebugName(e){return e=e.split(" ").map(((e,t)=>t>0?e.charAt(0).toUpperCase()+e.slice(1):e)).join(""),this._debugName=e,this.isImplicit&&this.children[0]instanceof nr&&this.children[0].setDebugName(e),this}get debugInfo(){return{name:this._debugName??""}}cloneInto(e){e._debugName=this._debugName,e._isMutable=this._isMutable,e.isImplicit=this.isImplicit,e.uid=this.uid}}function or(e){return"object"==typeof e?e.clone():e}nr.NodeCount=0;class ar extends nr{constructor(){super(...arguments),this.shaderType="primitive-node"}}class cr extends nr{constructor(e){super(),this.child=e,this.shaderType="scope-node"}get children(){return[this.child]}clone(){const e=new cr(or(this.child));return this.cloneInto(e),e}}class lr extends nr{constructor(e,t,r){super(),this.property=e,this.target=t,this.returnType=r,this.shaderType="property-access-node"}get children(){const e=[this.target];return"string"!=typeof this.property&&e.push(this.property),e}clone(){const e=new lr(this.property,or(this.target),this.returnType);return this.cloneInto(e),e}}class ur extends nr{constructor(e,t,r){super(),this.condition=e,this.ifTrue=t,this.ifFalse=r,this.shaderType="condition-node"}get children(){return[this.condition,this.ifTrue,this.ifFalse]}clone(){const e=or(this.ifTrue),t=this.ifFalse?or(this.ifFalse):null,r=new ur(this.condition,e,t);return this.cloneInto(r),r}}class hr extends nr{constructor(e,t,r,s){super(),this.captureList=e,this.returnType=t,this.generator=s,this.shaderType="block-node",r&&(this.subgraph=new cr(r))}get children(){return Object.keys(this.captureList).map((e=>this.captureList[e])).concat(this.subgraph??[])}clone(){const e={};for(const t in this.captureList)e[t]=or(this.captureList[t]);const t=new hr(e,this.returnType,this.subgraph?or(this.subgraph.child):this.subgraph,this.generator);return this.cloneInto(t),t}}class dr extends nr{constructor(e,t,r,s,i,n=!1){super(),this.token=e,this._children=t,this.isInfix=r,this.isPropertyAccess=s,this.returnType=i,this.isTernary=n,this.shaderType="function-node"}get children(){return this._children}clone(){const e=new dr(this.token,this._children.map(or),this.isInfix,this.isPropertyAccess,this.returnType,this.isTernary);return this.cloneInto(e),e}}var _r,pr,fr,mr,gr,yr,xr,br,Tr,wr,Sr,vr,Ir,Er;function Rr(e){return new Proxy(e,{get(t,r){if("constructor"===r)return new Proxy(t.constructor,{construct:(e,t,r)=>Rr(new e(...t))});if(r in t)return t[r];if("string"==typeof r){const t=function(e){const t=[["float","vec2","vec3","vec4"],["int","ivec2","ivec3","ivec4"],["uint","uvec2","uvec3","uvec4"],["bool","bvec2","bvec3","bvec4"]];for(const r of t)if(r.includes(e))return r.map((e=>Zr[e]));throw new Error("Unable to find type family")}(e.type);return is(e,r,t[r.length-1])}}})}function Ar(e){return new Proxy(e,{construct:(e,t,r)=>Rr(new e(...t))})}class Mr extends Error{}let Cr=_r=class extends ar{constructor(e,t){super(),this.elementType=e,this.size=t,this.children=[],this.type="array"}clone(){const e=new _r(this.elementType,this.size);return super.cloneInto(e),e}get(e){if("number"==typeof e){const t=new Wr(e);return t.isImplicit=!0,is(this,t,this.elementType.constructor)}return is(this,e,this.elementType.constructor)}last(){return this.get(this.size-1)}first(){return this.get(0)}findIndex(e,t,r){return function(e,t,r=0,s=e.size){const i=new Wr(r).setMutable().setDebugName("FindIndexIterator"),n=t(e.get(i)).setDebugName("FindIndexPredicate"),o=us({iter:i},Wr,n,(({out:e,iter:t,subgraph:r})=>`\n${e} = -1;\n\nfor (; ${t} < ${s}; ${t}++) {\n\n${r.body}\n\n if (${r.varName}) {\n ${e} = ${t};\n break;\n }\n\n}\n`)).setDebugName("FindIndexBlock");return o}(this,e,t,r)}glslFindIndex(e,t,r){return function(e,t,r=0,s=e.size){const i=us({array:e},Wr,null,(({out:e,array:i})=>`\n${e} = -1;\nfor (int i = ${r}; i < ${s}; i++) {\n bool condition;\n ${t({array:i,i:"i",out:"condition"})}\n if (condition) {\n ${e} = i;\n break;\n }\n}\n`)).setDebugName("GlslFindIndexBlock");return i}(this,e,t,r)}static ofType(e,t){const r={construct:(r,s)=>new _r(new e,t)};return new Proxy(_r,r)}};Cr.type="array",Cr=_r=(0,I._)([function(e){return new Proxy(e,{construct:(e,t,r)=>function(e){return new Proxy(e,{get(t,r){if(r in t)return t[r];if("string"==typeof r){const t=parseInt(r,10);if(!isNaN(t))return is(e,`[${t}]`,e.elementType.constructor)}}})}(new e(...t))})}],Cr);class Fr extends ar{constructor(){super(...arguments),this.type="sampler2D",this.children=[]}clone(){const e=new Fr;return e.children=this.children.map(or),super.cloneInto(e),e}}Fr.type="sampler2D";class Nr extends ar{constructor(e){super(),this.type="float",this.children=[e]}clone(){const e=new Nr(or(this.children[0]));return super.cloneInto(e),e}multiply(e){return _s(this,"number"==typeof e?qr(e,Nr):e)}divide(e){return ps(this,"number"==typeof e?qr(e,Nr):e)}add(e){return fs(this,"number"==typeof e?qr(e,Nr):e)}subtract(e){return ms(this,"number"==typeof e?qr(e,Nr):e)}}Nr.type="float";let Pr=pr=class extends ar{constructor(e,t){super(),this.type="vec2",this.children=[e,t].filter((e=>null!=e))}clone(){const e=new pr(or(this.children[0]),or(this.children[1]));return super.cloneInto(e),e}get 0(){return is(this,"[0]",Nr)}get 1(){return is(this,"[1]",Nr)}get 2(){throw new Mr}get 3(){throw new Mr}multiply(e){return _s(this,"number"==typeof e?qr(e,Nr):e)}divide(e){return ps(this,"number"==typeof e?qr(e,Nr):e)}add(e){return fs(this,"number"==typeof e?qr(e,Nr):e)}subtract(e){return ms(this,"number"==typeof e?qr(e,Nr):e)}};Pr.type="vec2",Pr=pr=(0,I._)([Ar],Pr);let Or=fr=class extends ar{constructor(e,t,r){super(),this.type="vec3",this.children=[e,t,r].filter((e=>null!=e))}get 0(){return is(this,"[0]",Nr)}get 1(){return is(this,"[1]",Nr)}get 2(){return is(this,"[2]",Nr)}get 3(){throw new Mr}clone(){const e=new fr(or(this.children[0]),or(this.children[1]),or(this.children[2]));return super.cloneInto(e),e}multiply(e){return _s(this,"number"==typeof e?qr(e,Nr):e)}divide(e){return ps(this,"number"==typeof e?qr(e,Nr):e)}add(e){return fs(this,"number"==typeof e?qr(e,Nr):e)}subtract(e){return ms(this,"number"==typeof e?qr(e,Nr):e)}};Or.type="vec3",Or=fr=(0,I._)([Ar],Or);let kr=mr=class extends ar{constructor(e,t,r,s){super(),this.type="vec4",this.children=[e,t,r,s].filter((e=>null!=e))}clone(){const e=new mr(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]));return super.cloneInto(e),e}get 0(){return is(this,"[0]",Nr)}get 1(){return is(this,"[1]",Nr)}get 2(){return is(this,"[2]",Nr)}get 3(){return is(this,"[3]",Nr)}multiply(e){return _s(this,"number"==typeof e?qr(e,Nr):e)}divide(e){return ps(this,"number"==typeof e?qr(e,Nr):e)}add(e){return fs(this,"number"==typeof e?qr(e,Nr):e)}subtract(e){return ms(this,"number"==typeof e?qr(e,Nr):e)}};kr.type="vec4",kr=mr=(0,I._)([Ar],kr);let Dr=gr=class extends ar{constructor(e){super(),this.type="uint",this.children=[e]}clone(){const e=new gr(or(this.children[0]));return super.cloneInto(e),e}};Dr.type="uint",Dr=gr=(0,I._)([Ar],Dr);let Ur=yr=class extends ar{constructor(e,t){super(),this.type="uvec2",this.children=[e,t].filter((e=>null!=e))}clone(){const e=new yr(or(this.children[0]),or(this.children[1]));return super.cloneInto(e),e}};Ur.type="uvec2",Ur=yr=(0,I._)([Ar],Ur);let Br=xr=class extends ar{constructor(e,t,r){super(),this.type="uvec3",this.children=[e,t,r].filter((e=>null!=e))}clone(){const e=new xr(or(this.children[0]),or(this.children[1]),or(this.children[2]));return super.cloneInto(e),e}};Br.type="uvec3",Br=xr=(0,I._)([Ar],Br);let Lr=br=class extends ar{constructor(e,t,r,s){super(),this.type="uvec4",this.children=[e,t,r,s].filter((e=>null!=e))}clone(){const e=new br(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]));return super.cloneInto(e),e}};Lr.type="uvec4",Lr=br=(0,I._)([Ar],Lr);class Gr extends ar{constructor(e){super(),this.type="bool",this.children=[e]}and(e){return ws(this,e)}or(e){return Ts(this,e)}clone(){const e=new Gr(or(this.children[0]));return super.cloneInto(e),e}}Gr.type="bool";let zr=Tr=class extends ar{constructor(e,t){super(),this.type="bvec2",this.children=[e,t].filter((e=>null!=e))}all(){return Ss(this)}any(){return vs(this)}clone(){const e=new Tr(or(this.children[0]),or(this.children[1]));return super.cloneInto(e),e}};zr.type="bvec2",zr=Tr=(0,I._)([Ar],zr);let Vr=wr=class extends ar{constructor(e,t,r){super(),this.type="bvec3",this.children=[e,t,r].filter((e=>null!=e))}all(){return Ss(this)}any(){return vs(this)}clone(){const e=new wr(or(this.children[0]),or(this.children[1]),or(this.children[2]));return super.cloneInto(e),e}};function qr(e,t){return"number"==typeof e?new t(e):e}Vr.type="bvec3",Vr=wr=(0,I._)([Ar],Vr);let Hr=Sr=class extends ar{constructor(e,t,r,s){super(),this.type="bvec4",this.children=[e,t,r,s].filter((e=>null!=e))}all(){return Ss(this)}any(){return vs(this)}clone(){const e=new Sr(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]));return super.cloneInto(e),e}};Hr.type="bvec4",Hr=Sr=(0,I._)([Ar],Hr);class Wr extends ar{constructor(e){super(),this.type="int",this.children=[e]}multiply(e){return _s(this,qr(e,Wr))}add(e){return fs(this,qr(e,Wr))}subtract(e){return ms(this,qr(e,Wr))}divide(e){return ps(this,qr(e,Wr))}clone(){const e=new Wr(or(this.children[0]));return super.cloneInto(e),e}}Wr.type="int";let Yr=vr=class extends ar{constructor(e,t){super(),this.type="ivec2",this.children=[e,t].filter((e=>null!=e))}clone(){const e=new vr(or(this.children[0]),or(this.children[1]));return super.cloneInto(e),e}};Yr.type="ivec2",Yr=vr=(0,I._)([Ar],Yr);let Xr=Ir=class extends ar{constructor(e,t,r){super(),this.type="ivec3",this.children=[e,t,r].filter((e=>null!=e))}clone(){const e=new Ir(or(this.children[0]),or(this.children[1]),or(this.children[2]));return super.cloneInto(e),e}};Xr.type="ivec3",Xr=Ir=(0,I._)([Ar],Xr);let jr=Er=class extends ar{constructor(e,t,r,s){super(),this.type="ivec4",this.children=[e,t,r,s].filter((e=>null!=e))}clone(){const e=new Er(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]));return super.cloneInto(e),e}};jr.type="ivec4",jr=Er=(0,I._)([Ar],jr);class $r extends ar{constructor(e,t,r,s){super(),this.type="mat2",this.children=[e,t,r,s]}clone(){const e=new $r(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]));return super.cloneInto(e),e}}$r.type="mat2";class Kr extends ar{static identity(){return new Kr(1,0,0,0,1,0,0,0,1)}static fromRotation(e){const t=ks(e),r=Es(e);return new Kr(r,t,0,ls(t),r,0,0,0,1)}constructor(e,t,r,s,i,n,o,a,c){super(),this.type="mat3",this.children=[e,t,r,s,i,n,o,a,c]}add(e){return fs(this,e)}multiply(e){return _s(this,e)}clone(){const e=new Kr(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]),or(this.children[4]),or(this.children[5]),or(this.children[6]),or(this.children[7]),or(this.children[8]));return super.cloneInto(e),e}}Kr.type="mat3";class Qr extends ar{static identity(){return new Qr(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(e,t,r,s,i,n,o,a,c,l,u,h,d,_,p,f){super(),this.type="mat4",this.children=[e,t,r,s,i,n,o,a,c,l,u,h,d,_,p,f]}static fromColumns(e,t,r,s){return new Qr(e.x,e.y,e.z,e.w,t.x,t.y,t.z,t.w,r.x,r.y,r.z,r.w,s.x,s.y,s.z,s.w)}multiply(e){return _s(this,e)}clone(){const e=new Qr(or(this.children[0]),or(this.children[1]),or(this.children[2]),or(this.children[3]),or(this.children[4]),or(this.children[5]),or(this.children[6]),or(this.children[7]),or(this.children[8]),or(this.children[9]),or(this.children[10]),or(this.children[11]),or(this.children[12]),or(this.children[13]),or(this.children[14]),or(this.children[15]));return super.cloneInto(e),e}}Qr.type="mat4";const Zr={float:Nr,vec2:Pr,vec3:Or,vec4:kr,int:Wr,ivec2:Yr,ivec3:Xr,ivec4:jr,uint:Dr,uvec2:Ur,uvec3:Br,uvec4:Lr,bool:Gr,bvec2:zr,bvec3:Vr,bvec4:Hr},Jr=(...e)=>new Wr(...e),es=(...e)=>new Nr(...e),ts=(...e)=>new Pr(...e),rs=(...e)=>new kr(...e),ss=(...e)=>new Kr(...e);function is(e,t,r){const s=new r(new lr(t,e,r));return s.isImplicit=!0,s}function ns(e,t,r,s=null){if(s){const i=new s,n=new s(new dr(e,[t,r],!0,!1,i));return n.isImplicit=!0,n}if("float"===t.type||"int"===t.type){const s=new r.constructor(new dr(e,[t,r],!0,!1,r.constructor));return s.isImplicit=!0,s}if(("mat2"===t.type||"mat3"===t.type||"mat4"===t.type)&&"float"!==r.type){const s=new r.constructor(new dr(e,[t,r],!0,!1,r.constructor));return s.isImplicit=!0,s}const i=new t.constructor(new dr(e,[t,r],!0,!1,t.constructor));return i.isImplicit=!0,i}function os(e,t,r=t.constructor){const s=new r(new dr(e,[t],!1,!1,r));return s.isImplicit=!0,s}function as(e,t,r,s=t.constructor){const i=new s(new dr(e,[t,r],!1,!1,s));return i.isImplicit=!0,i}function cs(e,t,r,s,i=t.constructor){const n=new i(new dr(e,[t,r,s],!1,!1,i));return n.isImplicit=!0,n}function ls(e){return _s(e,es(-1))}function us(e,t,r,s){return new t(new hr(e,t,r,s))}function hs(e,t,r){const s="function"==typeof t?t():t,i="function"==typeof r?r():r,n=new s.constructor(new ur(e,s,i));return n.isImplicit=!0,n}function ds(...e){const t=e.map((([e,t])=>"function"==typeof t?[e,t()]:[e,t])),r=t[0][1].constructor,s=t.findIndex((e=>!0===e[0]));if(-1===s)throw new Error("A cond must have a fallthrough case with `true`/; ");const i=t.slice(0,s),n=t[s][1],o=new r(i.reduceRight(((e,t)=>hs(t[0],t[1],e)),n));return o.isImplicit=!0,o}function _s(e,t){return ns("*",e,t)}function ps(e,t){return ns("/",e,t)}function fs(e,t){return ns("+",e,t)}function ms(e,t){return ns("-",e,t)}function gs(e,t){return ns("==",e,t,Gr)}function ys(e,t){return ns("<=",e,t,Gr)}function xs(e,t){return ns(">",e,t,Gr)}function bs(e,t){return ns(">=",e,t,Gr)}function Ts(...e){return e.length<=1?e[0]:e.slice(1).reduce(((e,t)=>function(e,t){return ns("||",e,t,Gr)}(e,t)),e[0])}function ws(...e){return e.length<=1?e[0]:e.slice(1).reduce(((e,t)=>function(e,t){return ns("&&",e,t,Gr)}(e,t)),e[0])}function Ss(e){return os("all",e,Gr)}function vs(e){return os("any",e,Gr)}function Is(e,t,r){return cs("clamp",e,t,r,e.constructor)}function Es(e){return os("cos",e)}function Rs(e,t){return as("dot",e,t,Nr)}function As(e){return os("fract",e)}function Ms(e){return os("length",e,Nr)}function Cs(e,t){return as("max",e,t)}function Fs(e,t){return as("min",e,t)}function Ns(e,t,r){return cs("mix",e,t,r)}function Ps(e,t){return as("mod",e,t)}function Os(e){return"bool"===e.type?os("!",e):os("not",e)}function ks(e){return os("sin",e)}function Ds(e,t){return as("step",e,t,t.constructor)}function Us(e,t){return as("texture2D",e,t,kr)}function Bs(e,t,r){const s=t.split("\n");for(const t of s)if(t.trim().length){{let t="";null!=r&&(t+=`/*id:${r??"000"}*/ `),e.body+=t.padEnd(14)}e.body+=" ".repeat(e.indent)+t+"\n"}}class Ls{write(e){for(const t of e.rootOutputNodes())e.shouldPruneOutputNode(t)||(t.variableName=this._write(e,t.node));return e}_createVarName(e,t){let r="";return"boolean"!=typeof t&&"number"!=typeof t&&t.debugInfo.name&&(r=`${t.debugInfo.name}_`),`${r}v${e.varCount++}`}_write(e,t,r=!1){if("number"==typeof t)return t.toString();if("boolean"==typeof t)return t.toString();let s=e.getEmit(t);if(s)return s;switch(t.shaderType){case"scope-node":s=this._writeScopeNode(e,t);break;case"primitive-node":s=this._writePrimitveNode(e,t,r);break;case"function-node":s=this._writeFunctionNode(e,t);break;case"property-access-node":s=this._writePropertyAccessNode(e,t);break;case"text-node":s=t.text;break;case"block-node":s=this._writeBlockNode(e,t);break;case"condition-node":s=this._writeConditionNode(e,t)}return e.setEmit(t,s),s}_writeScopeNode(e,t){const r=new t.child.constructor;r.setDebugName(t.debugInfo.name);const s=this._write(e,r,!0);return Bs(e,`{ /*ScopeStart: ${t.uid} ${t.debugInfo.name}*/`),e.indent+=2,Bs(e,`${s} = ${this._write(e,t.child)};`),e.indent-=2,Bs(e,`} /*ScopeEnd: ${t.uid} ${t.debugInfo.name}*/`),s}_writeConditionNode(e,t){const r=new t.ifTrue.constructor,s=this._write(e,r,!0);Bs(e,`if (${this._write(e,t.condition)}) {`),e.indent+=2;const i=e.createSubgraphContext(),n=this._write(i,t.ifTrue);if(e.body+=i.body,n&&Bs(e,`${s} = ${n};`),e.indent-=2,Bs(e,"}"),t.ifFalse){Bs(e,"else {"),e.indent+=2;const r=e.createSubgraphContext(),i=this._write(r,t.ifFalse);e.body+=r.body,i&&Bs(e,`${s} = ${i};`),e.indent-=2,Bs(e,"}")}return s}_writeBlockNode(e,t){const{captureList:r,generator:s,returnType:i}=t,n={};for(const t in r){if(!r[t])continue;const s=this._write(e,r[t]);n[t]=s}const o=new i,a=this._write(e,o,!0);if(n.out=a,t.subgraph){const r=e.createSubgraphContext(),s=this._write(r,t.subgraph.child),i=r.body;n.subgraph={varName:s,body:i}}const c=s(n);return Bs(e,"{\n"),e.indent+=2,Bs(e,c),e.indent-=2,Bs(e,"}\n"),a}_writePropertyAccessNode(e,t){const r=this._write(e,t.target);return"string"==typeof t.property&&t.property.includes("[")?`${r}${t.property}`:"string"!=typeof t.property?`${r}[${this._write(e,t.property)}]`:`${r}.${t.property}`}_writeFunctionNode(e,t){const r=t.returnType.type;if(t.isInfix){const[s,i]=t.children.map((t=>this._write(e,t))),n=this._createVarName(e,t);return Bs(e,`${r.padEnd(5)} ${n} = ${s} ${t.token} ${i};`,t.uid),n}const s=t.children.map((t=>this._write(e,t))).join(", "),i=this._createVarName(e,t);return Bs(e,`${r.padEnd(5)} ${i} = ${t.token}(${s});`,t.uid),i}_writePrimitveNode(e,t,r=!1){const s=e.getInput(t);if(s)return s.isUsed=!0,s.variableName;const i=1===t.children.length&&t.children[0]?.type===t.type;if(t.isImplicit||i)return this._write(e,t.children[0]);const n=this._createVarName(e,t);if(r)return Bs(e,`${t.type.padEnd(5)} ${n};`,t.uid),n;const o=!t.debugInfo.name&&!t.isMutable;if(o&&"float"===t.type&&"number"==typeof t.children[0])return Number.isInteger(t.children[0])?t.children[0].toFixed(1):t.children[0].toString();if(o&&"int"===t.type&&"number"==typeof t.children[0]&&Number.isInteger(t.children[0]))return t.children[0].toString();const a=t.children.map((t=>this._write(e,t))).join(", ");return"array"===t.type?(Bs(e,`${t.type.padEnd(5)} ${n} = [${a}];`,t.uid),n):o?`${t.type}(${a})`:(Bs(e,`${t.type.padEnd(5)} ${n} = ${t.type}(${a});`,t.uid),n)}}class Gs{constructor(e,t,r){this.variableName=e,this.variableInputType=t,this.node=r,this.type="shader-input",this.isUsed=!1}clone(){return new Gs(this.variableName,this.variableInputType,or(this.node))}}class zs{constructor(e,t,r){this.outVariableName=e,this.outVariableType=t,this.node=r,this.type="shader-output"}clone(){const e=new zs(this.outVariableName,this.outVariableType,or(this.node));return e.variableName=this.variableName,e}}class Vs{static createVertex(e,t,r,s,i,n){const o=[];for(const t in e){const s=e[t],i=r.get(t);i?o.push(new Gs(i,"builtin",s)):o.push(new Gs("a_"+t,"attribute",s))}for(const e of s){const t=e.uniformHydrated;o.push(new Gs(e.uniformName,"uniform",t))}const a=[];for(const e in t){const r=t[e];"glPosition"===e?a.push(new zs("gl_Position","builtin",r)):"glPointSize"===e?a.push(new zs("gl_PointSize","builtin",r)):a.push(new zs("v_"+e,"varying",r))}return new Vs(o,a,i,n)}static createFragment(e,t,r,s,i,n){const o=[],a=Array.from(i.rootOutputNodes());for(const t in e){const s=e[t],i=r.get(t);if(i){o.push(new Gs(i,"builtin",s));continue}const n=a.find((e=>e.node===s));n&&o.push(new Gs(n.outVariableName,n.outVariableType,s))}for(const e of s){const t=e.uniformHydrated;o.push(new Gs(e.uniformName,"uniform",t))}const c=[];for(const e in t){const s=t[e],i=r.get(e);if("discard"===e)c.push(new zs(null,"discard",s));else{if(!i)throw new Error(`Member ${e} in shader fragment output shoule be tagged as builtin`);c.push(new zs(i,"builtin",s))}}return new Vs(o,c,n)}constructor(e,t,r,s){this.type="shader-graph-context",this.indent=0,this.body="",this.varCount=0,this._inputShaderTypesByNodeUid=new Map,this._nodeEmitMap=new Map;for(const t of e)this._inputShaderTypesByNodeUid.set(t.node.uid,t);this._outputShaderTypes=t,this._transformFeedbackBindings=r,this._transformFeedbackNames=new Set(r.map((e=>"v_"+e.propertyKey))),this._usedInFragmentShader=s}shouldPruneOutputNode(e){return!!this._usedInFragmentShader&&"builtin"!==e.outVariableType&&!this._transformFeedbackNames.has(e.outVariableName)&&!this._usedInFragmentShader.has(e.node.uid)}setEmit(e,t){this._nodeEmitMap.set(e.uid,t)}getEmit(e){return this._nodeEmitMap.get(e.uid)}inputs(){return this._inputShaderTypesByNodeUid.values()}getInput(e){return this._inputShaderTypesByNodeUid.get(e.uid)}*rootOutputNodes(){for(const e of this._outputShaderTypes)yield e}*nodes(){const e=[];for(const t of this._outputShaderTypes.values())e.push(t.node);for(;e.length;){const t=e.pop();"number"!=typeof t&&"boolean"!=typeof t&&e.push(...t.children.filter(Boolean)),yield t}}*nodesOfTypeOrFunction(){for(const e of this.nodes())"number"!=typeof e&&"boolean"!=typeof e&&(yield e)}createSubgraphContext(){const e=this.clone();return e.body="",e.indent=this.indent+2,e._nodeEmitMap=new Map(this._nodeEmitMap),e}clone(){const e=new Vs([],this._outputShaderTypes,this._transformFeedbackBindings,this._usedInFragmentShader);return e._inputShaderTypesByNodeUid=this._inputShaderTypesByNodeUid,e.indent=this.indent,e.body=this.body,e.varCount=this.varCount,e._nodeEmitMap=this._nodeEmitMap,e}insertVertexShader(e){e.vertex.code.add(""),this._insertInputs(e,"vertex"),e.vertex.code.add(""),e.vertex.code.add("// OUTPUTS: "),e.vertex.code.add("// --------------------------------------------------------- ");for(const t of this.rootOutputNodes()){const r="builtin"===t.outVariableType;this.shouldPruneOutputNode(t)||(r?e.vertex.code.add(`// ${t.outVariableType.padEnd(7)} ${t.node.type.padEnd(9)} ${t.outVariableName};`):e.vertex.code.add(`${t.outVariableType.padEnd(10)} ${t.node.type.padEnd(9)} ${t.outVariableName};`))}e.vertex.code.add(""),e.vertex.code.add("void main() {"),e.vertex.code.add(" "+this.body.split("\n").join("\n "));for(const t of this.rootOutputNodes())this.shouldPruneOutputNode(t)||e.vertex.code.add(` ${t.outVariableName} = ${t.variableName};`);e.vertex.code.add("}")}insertFragmentShader(e){this._insertInputs(e,"fragment"),e.fragment.code.add(""),e.fragment.code.add("void main() {"),e.fragment.code.add(" "+this.body.split("\n").join("\n "));for(const t of this.rootOutputNodes())"discard"===t.outVariableType?(e.fragment.code.add(" // TODO: Should ensure codegen for discard appears first in fragment shader"),e.fragment.code.add(` if (${t.variableName}) {`),e.fragment.code.add(" discard;"),e.fragment.code.add(" }"),e.fragment.code.add(" ")):e.fragment.code.add(` ${t.outVariableName} = ${t.variableName};`);e.fragment.code.add("}")}_insertInputs(e,t){e[t].code.add("// INPUTS: "),e[t].code.add("// --------------------------------------------------------- ");for(const r of this.inputs())r.isUsed&&"builtin"!==r.variableInputType&&("array"===r.node.type?e[t].code.add(`${r.variableInputType.padEnd(10)} ${r.node.elementType.type.padEnd(9)} ${r.variableName}[${r.node.size}];`):e[t].code.add(`${r.variableInputType.padEnd(10)} ${r.node.type.padEnd(9)} ${r.variableName};`))}}var qs=r(58820),Hs=r(94460),Ws=r(72008);const Ys=()=>M.c.getLogger("esri.views.webgl.BufferObject");class Xs{static createIndex(e,t,r){return new Xs(e,tt.K.ELEMENT_ARRAY_BUFFER,t,r)}static createVertex(e,t,r){return new Xs(e,tt.K.ARRAY_BUFFER,t,r)}static createUniform(e,t,r){return new Xs(e,tt.K.UNIFORM_BUFFER,t,r)}static createPixelPack(e,t=tt._m.STREAM_READ,r){const s=new Xs(e,tt.K.PIXEL_PACK_BUFFER,t);return r&&s.setSize(r),s}static createPixelUnpack(e,t=tt._m.STREAM_DRAW,r){return new Xs(e,tt.K.PIXEL_UNPACK_BUFFER,t,r)}static createTransformFeedback(e,t=tt._m.STATIC_DRAW,r){const s=new Xs(e,tt.K.TRANSFORM_FEEDBACK_BUFFER,t);return s.setSize(r),s}constructor(e,t,r,s){this._context=e,this.bufferType=t,this.usage=r,this._glName=null,this._size=-1,this._indexType=void 0,e.instanceCounter.increment(tt.y4.BufferObject,this),this._glName=this._context.gl.createBuffer(),(0,Hs.m_)(this._context.gl),s&&this.setData(s)}get glName(){return this._glName}get size(){return this._size}get indexType(){return this._indexType}get usedMemory(){return this.bufferType===tt.K.ELEMENT_ARRAY_BUFFER?this._indexType===tt.Ck.UNSIGNED_INT?4*this._size:2*this._size:this._size}get _isVAOAware(){return this.bufferType===tt.K.ELEMENT_ARRAY_BUFFER||this.bufferType===tt.K.ARRAY_BUFFER}dispose(){this._context?.gl?(this._glName&&(this._context.gl.deleteBuffer(this._glName),this._glName=null),this._context.instanceCounter.decrement(tt.y4.BufferObject,this),this._context=null):this._glName&&Ys().warn("Leaked WebGL buffer object")}setSize(e,t=null){if(e<=0&&Ys().error("Buffer size needs to be positive!"),this.bufferType===tt.K.ELEMENT_ARRAY_BUFFER&&null!=t)switch(this._indexType=t,t){case tt.Ck.UNSIGNED_SHORT:e*=2;break;case tt.Ck.UNSIGNED_INT:e*=4}this._setBufferData(e)}setData(e){if(!e)return;let t=e.byteLength;this.bufferType===tt.K.ELEMENT_ARRAY_BUFFER&&((0,Ws.Qx)(e)&&(t/=2,this._indexType=tt.Ck.UNSIGNED_SHORT),(0,Ws.Nt)(e)&&(t/=4,this._indexType=tt.Ck.UNSIGNED_INT)),this._setBufferData(t,e)}_setBufferData(e,t=null){this._size=e;const r=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const s=this._context.gl;null!=t?s.bufferData(this.bufferType,t,this.usage):s.bufferData(this.bufferType,e,this.usage),(0,Hs.m_)(s),this._isVAOAware&&this._context.bindVAO(r)}setSubData(e,t,r,s){if(!e)return;(t<0||t*e.BYTES_PER_ELEMENT>=this.usedMemory)&&Ys().error("offset is out of range!"),r>=s&&Ys().error("end must be bigger than start!"),(t+(s-r))*e.BYTES_PER_ELEMENT>this.usedMemory&&Ys().error("An attempt to write beyond the end of the buffer!");const i=this._context.getBoundVAO();this._isVAOAware&&this._context.bindVAO(null),this._context.bindBuffer(this);const{gl:n}=this._context;n.bufferSubData(this.bufferType,t*e.BYTES_PER_ELEMENT,e,r,s-r),(0,Hs.m_)(n),this._isVAOAware&&this._context.bindVAO(i)}getSubData(e,t=0,r,s){if(r<0||s<0)return void Ys().error("Problem getting subdata: offset and length were less than zero!");const i=function(e){return(0,te.GQ)(e)}(e)?e.BYTES_PER_ELEMENT:1;if(i*((r??0)+(s??0))>e.byteLength)return void Ys().error("Problem getting subdata: offset and length exceeded destination size!");t+i*(s??0)>this.usedMemory&&Ys().warn("Potential problem getting subdata: requested data exceeds buffer size!");const n=this._context.gl;this.bufferType===tt.K.TRANSFORM_FEEDBACK_BUFFER?(this._context.bindBuffer(this,tt.K.TRANSFORM_FEEDBACK_BUFFER),n.getBufferSubData(tt.K.TRANSFORM_FEEDBACK_BUFFER,t,e,r,s),this._context.unbindBuffer(tt.K.TRANSFORM_FEEDBACK_BUFFER)):(this._context.bindBuffer(this,tt.K.COPY_READ_BUFFER),n.getBufferSubData(tt.K.COPY_READ_BUFFER,t,e,r,s),this._context.unbindBuffer(tt.K.COPY_READ_BUFFER))}async getSubDataAsync(e,t=0,r,s){await this._context.clientWaitAsync(),this.getSubData(e,t,r,s)}}var js=r(39104),$s=r(97684);class Ks{constructor(e,t){this._context=e,this._descriptor=t,this.type=js.A.RenderBuffer,this._context.instanceCounter.increment(tt.y4.Renderbuffer,this);const r=this._context.gl;this.glName=r.createRenderbuffer(),this._context.bindRenderbuffer(this);const{width:s,height:i,internalFormat:n,multisampled:o}=t;o?r.renderbufferStorageMultisample(r.RENDERBUFFER,this.samples,n,s,i):r.renderbufferStorage(r.RENDERBUFFER,n,s,i)}get descriptor(){return this._descriptor}get samples(){const e=this._descriptor.samples,t=this._context.parameters.maxSamples;return e?Math.min(e,t):t}get usedMemory(){return function(e){return e.width<=0||e.height<=0||null==e.internalFormat?0:e.width*e.height*(0,$s.O4)(e.internalFormat)}(this._descriptor)}resize(e,t){const r=this._descriptor;if(r.width===e&&r.height===t)return;r.width=e,r.height=t;const s=this._context.gl;this._context.bindRenderbuffer(this),r.multisampled?s.renderbufferStorageMultisample(s.RENDERBUFFER,this.samples,r.internalFormat,r.width,r.height):s.renderbufferStorage(s.RENDERBUFFER,r.internalFormat,r.width,r.height)}dispose(){this._context&&(this._context.gl.deleteRenderbuffer(this.glName),this._context.instanceCounter.decrement(tt.y4.Renderbuffer,this),this._context=null)}}var Qs=r(22184);class Zs{constructor(e,t,r=null){this._context=e,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,e.instanceCounter.increment(tt.y4.FramebufferObject,this);const s=Js(t)?t:new Qs.w(this._context,t);if(this._colorAttachments.set(tt.Qx.COLOR_ATTACHMENT0,s),this._validateTextureDescriptor(s.descriptor),this._validateColorAttachmentPoint(tt.Qx.COLOR_ATTACHMENT0),null!=r)if(function(e){return Js(e)||null!=e&&"pixelFormat"in e}(r))this._context.capabilities.depthTexture||console.error("Setting the depth/stencil texture as an attachment requires WEBGL_depth_texture or WebGL2"),this._depthStencilTexture=Js(r)?r:new Qs.w(this._context,r),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const e=function(e){return null!=e&&"type"in e&&e.type===js.A.RenderBuffer}(r)?r:new Ks(this._context,r);this._depthStencilBuffer=e,this._validateRenderBufferDescriptor(e.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const e=this._context.getBoundFramebufferObject();this._colorAttachments.forEach(((e,t)=>this.detachColorTexture(t)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName&&(this._context.gl.deleteFramebuffer(this._glName),this._glName=null),this._context.bindFramebuffer(e),this._context.instanceCounter.decrement(tt.y4.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(tt.Qx.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const e=this._colorAttachments.get(tt.Qx.COLOR_ATTACHMENT0);return e?.descriptor?.width??0}get height(){const e=this._colorAttachments.get(tt.Qx.COLOR_ATTACHMENT0);return e?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((e,[t,r])=>e+r.usedMemory),this.depthStencil?.usedMemory??0)}getColorTexture(e){const t=this._colorAttachments.get(e);return t&&Js(t)?t:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(e,t=tt.Qx.COLOR_ATTACHMENT0){if(!e)return;this._validateColorAttachmentPoint(t);const r=e.descriptor;this._validateTextureDescriptor(r),this.detachColorTexture(t)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(e.glName,t)),this._colorAttachments.set(t,e)}detachColorTexture(e=tt.Qx.COLOR_ATTACHMENT0){const t=this._colorAttachments.get(e);if(t){if(this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,e),this._context.bindFramebuffer(t)}return this._colorAttachments.delete(e),t}}setColorTextureTarget(e,t=tt.Qx.COLOR_ATTACHMENT0){const r=this._colorAttachments.get(t);r&&this._framebufferTexture2D(r.glName,t,e)}attachDepthStencil(e){if(e)switch(e.type){case js.A.Texture:return this._attachDepthStencilTexture(e);case js.A.RenderBuffer:return this._attachDepthStencilBuffer(e)}}_attachDepthStencilTexture(e){if(null==e)return;const t=e.descriptor;t.pixelFormat!==tt.Id.DEPTH_STENCIL&&t.pixelFormat!==tt.Id.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),t.dataType!==tt.OK.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._context.capabilities.depthTexture||console.error("Extension WEBGL_depth_texture isn't supported therefore it is no possible to set the depth/stencil texture!"),this._validateTextureDescriptor(t),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(e.glName,tt.GE)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=e}detachDepthStencilTexture(){const e=this._depthStencilTexture;return e&&this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,tt.GE)),this._depthStencilTexture=null,e}_attachDepthStencilBuffer(e){if(null==e)return;const t=e.descriptor;if(this._validateRenderBufferDescriptor(t),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const r=this._context.gl,s=this._getGLAttachmentPoint(t);r.framebufferRenderbuffer(tt.kl.FRAMEBUFFER,s,r.RENDERBUFFER,e.glName)}this._depthStencilBuffer=e}detachDepthStencilBuffer(){const e=this._depthStencilBuffer;if(e&&this._initialized){this._context.bindFramebuffer(this);const t=this._context.gl,r=this._getGLAttachmentPoint(e.descriptor);t.framebufferRenderbuffer(tt.kl.FRAMEBUFFER,r,t.RENDERBUFFER,null)}return this._depthStencilBuffer=null,e}copyToTexture(e,t,r,s,i,n,o){(e<0||t<0||i<0||n<0)&&console.error("Offsets cannot be negative!"),(r<=0||s<=0)&&console.error("Copy width and height must be greater than zero!");const a=o.descriptor;o.descriptor.target!==tt.c5.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==a?.width||null==a?.height||e+r>this.width||t+s>this.height||i+r>a.width||n+s>a.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,l=c.bindTexture(o,Qs.w.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(Qs.w.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(tt.c5.TEXTURE_2D,0,i,n,e,t,r,s),c.bindTexture(l,Qs.w.TEXTURE_UNIT_FOR_UPDATES)}readPixels(e,t,r,s,i,n,o){(r<=0||s<=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(e,t,r,s,i,n,o)}async readPixelsAsync(e,t,r,s,i,n,o){const{gl:a}=this._context,c=Xs.createPixelPack(this._context,tt._m.STREAM_READ,o.byteLength);this._context.bindBuffer(c),this._context.bindFramebuffer(this),a.readPixels(e,t,r,s,i,n,0),this._context.unbindBuffer(tt.K.PIXEL_PACK_BUFFER),await c.getSubDataAsync(o),c.dispose()}resize(e,t){if(this.width===e&&this.height===t)return;const r={width:e,height:t};ei(r,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((e=>e.resize(r.width,r.height))),this._depthStencilTexture?.resize(r.width,r.height),this._initialized&&(ei(r,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(r.width,r.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(e=tt.kl.FRAMEBUFFER){const t=this._context.gl;if(this._initialized)return void t.bindFramebuffer(e,this.glName);this._glName&&t.deleteFramebuffer(this._glName);const r=t.createFramebuffer();if(t.bindFramebuffer(e,r),this._colorAttachments.forEach(((t,r)=>this._framebufferTexture2D(t.glName,r,ti(t),e))),this._depthStencilBuffer){const r=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(e,r,t.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,t.DEPTH_STENCIL_ATTACHMENT,ti(this._depthStencilTexture),e);(0,Hs.gv)()&&t.checkFramebufferStatus(e)!==t.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!"),this._glName=r,this._initialized=!0}_framebufferTexture2D(e,t=tt.Qx.COLOR_ATTACHMENT0,r=tt.c5.TEXTURE_2D,s=tt.kl.FRAMEBUFFER,i=0){this._context.gl.framebufferTexture2D(s,t,r,e,i)}_disposeDepthStencilAttachments(){const e=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const t=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(tt.kl.FRAMEBUFFER,t,e.RENDERBUFFER,null)}this._depthStencilBuffer=(0,R.yI)(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,e.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=(0,R.yI)(this._depthStencilTexture))}_validateTextureDescriptor(e){e.target!==tt.c5.TEXTURE_2D&&e.target!==tt.c5.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),ei(e,this._context.parameters.maxTextureSize),this._validateBufferDimensions(e)}_validateRenderBufferDescriptor(e){ei(e,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(e)}_validateBufferDimensions(e){e.width<=0&&(e.width=this.width),e.height<=0&&(e.height=this.height),this.width>0&&this.height>0&&(this.width===e.width&&this.height===e.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(e){switch(e.internalFormat){case tt.Qb.DEPTH_COMPONENT16:case tt.Qb.DEPTH_COMPONENT24:case tt.Qb.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case tt.Qb.DEPTH24_STENCIL8:case tt.Qb.DEPTH32F_STENCIL8:case tt.Qb.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case tt.Qb.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===Zs._MAX_COLOR_ATTACHMENTS){const{gl:e}=this._context;Zs._MAX_COLOR_ATTACHMENTS=e.getParameter(e.MAX_COLOR_ATTACHMENTS)}const t=e-tt.Qx.COLOR_ATTACHMENT0;t+1>Zs._MAX_COLOR_ATTACHMENTS&&M.c.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${t+1}. Implementation supports up to ${Zs._MAX_COLOR_ATTACHMENTS} color attachments`)}}function Js(e){return null!=e&&"type"in e&&e.type===js.A.Texture}function ei(e,t){const r=Math.max(e.width,e.height);if(r>t){M.c.getLogger("esri.views.webgl.FramebufferObject").warn(`Resizing FBO attachment size ${e.width}x${e.height} to device limit ${t}`);const s=t/r;return e.width=Math.round(e.width*s),e.height=Math.round(e.height*s),!1}return!0}function ti(e){return e.descriptor.target===tt.c5.TEXTURE_CUBE_MAP?tt.c5.TEXTURE_CUBE_MAP_POSITIVE_X:tt.c5.TEXTURE_2D}Zs._MAX_COLOR_ATTACHMENTS=-1;const ri=["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"],si=!1;var ii,ni=r(8528),oi={exports:{}};void 0!==(ii=["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"])&&(oi.exports=ii);const ai=(0,ni.g)(oi.exports);var ci,li={exports:{}};void 0!==(ci=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"])&&(li.exports=ci);const ui=(0,ni.g)(li.exports);var hi,di,_i={exports:{}};hi=_i,void 0!==(di=["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"])&&(hi.exports=di);const pi=(0,ni.g)(_i.exports);var fi=999,mi=9999,gi=0,yi=1,xi=2,bi=3,Ti=4,wi=5,Si=6,vi=7,Ii=8,Ei=9,Ri=10,Ai=11,Mi=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Ci(e){return function(e){var t=function(){var e,t,r,s=0,i=0,n=fi,o=[],a=[],c=1,l=0,u=0,h=!1,d=!1,_="";return function(e){return a=[],null!==e?f(e.replace?e.replace(/\r\n/g,"\n"):e):(o.length&&p(o.join("")),n=Ri,p("(eof)"),a)};function p(e){e.length&&a.push({type:Mi[n],data:e,position:u,line:c,column:l})}function f(t){var o;for(s=0,r=(_+=t).length;e=_[s],s<r;){switch(o=s,n){case gi:s=x();break;case yi:case xi:s=y();break;case bi:s=b();break;case Ti:s=S();break;case Ai:s=w();break;case wi:s=v();break;case mi:s=I();break;case Ei:s=g();break;case fi:s=m()}o!==s&&("\n"===_[o]?(l=0,++c):++l)}return i+=s,_=_.slice(s),a}function m(){return o=o.length?[]:o,"/"===t&&"*"===e?(u=i+s-1,n=gi,t=e,s+1):"/"===t&&"/"===e?(u=i+s-1,n=yi,t=e,s+1):"#"===e?(n=xi,u=i+s,s):/\s/.test(e)?(n=Ei,u=i+s,s):(h=/\d/.test(e),d=/[^\w_]/.test(e),u=i+s,n=h?Ti:d?bi:mi,s)}function g(){return/[^\s]/g.test(e)?(p(o.join("")),n=fi,s):(o.push(e),t=e,s+1)}function y(){return"\r"!==e&&"\n"!==e||"\\"===t?(o.push(e),t=e,s+1):(p(o.join("")),n=fi,s)}function x(){return"/"===e&&"*"===t?(o.push(e),p(o.join("")),n=fi,s+1):(o.push(e),t=e,s+1)}function b(){if("."===t&&/\d/.test(e))return n=wi,s;if("/"===t&&"*"===e)return n=gi,s;if("/"===t&&"/"===e)return n=yi,s;if("."===e&&o.length){for(;T(o););return n=wi,s}if(";"===e||")"===e||"("===e){if(o.length)for(;T(o););return p(e),n=fi,s+1}var r=2===o.length&&"="!==e;if(/[\w_\d\s]/.test(e)||r){for(;T(o););return n=fi,s}return o.push(e),t=e,s+1}function T(e){for(var t,r,s=0;;){if(t=ui.indexOf(e.slice(0,e.length+s).join("")),r=ui[t],-1===t){if(s--+e.length>0)continue;r=e.slice(0,1).join("")}return p(r),u+=r.length,(o=o.slice(r.length)).length}}function w(){return/[^a-fA-F0-9]/.test(e)?(p(o.join("")),n=fi,s):(o.push(e),t=e,s+1)}function S(){return"."===e||/[eE]/.test(e)?(o.push(e),n=wi,t=e,s+1):"x"===e&&1===o.length&&"0"===o[0]?(n=Ai,o.push(e),t=e,s+1):/[^\d]/.test(e)?(p(o.join("")),n=fi,s):(o.push(e),t=e,s+1)}function v(){return"f"===e&&(o.push(e),t=e,s+=1),/[eE]/.test(e)||"-"===e&&/[eE]/.test(t)?(o.push(e),t=e,s+1):/[^\d]/.test(e)?(p(o.join("")),n=fi,s):(o.push(e),t=e,s+1)}function I(){if(/[^\d\w_]/.test(e)){var r=o.join("");return n=ai.indexOf(r)>-1?Ii:pi.indexOf(r)>-1?vi:Si,p(o.join("")),n=fi,s}return o.push(e),t=e,s+1}}(),r=[];return(r=r.concat(t(e))).concat(t(null))}(e)}const Fi=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function Ni(e,t){for(let r=t-1;r>=0;r--){const t=e[r];if("whitespace"!==t.type&&"block-comment"!==t.type){if("keyword"!==t.type)break;if("attribute"===t.data||"in"===t.data)return!0}}return!1}function Pi(e,t,r,s){s=s||r;for(const i of e)if("ident"===i.type&&i.data===r)return s in t?t[s]++:t[s]=0,Pi(e,t,s+"_"+t[s],s);return r}function Oi(e,t,r="afterVersion"){function s(e,t){for(let r=t;r<e.length;r++){const t=e[r];if("operator"===t.type&&";"===t.data)return r}return null}const i={data:"\n",type:"whitespace"},n=t=>t<e.length&&/[^\r\n]$/.test(e[t].data);let o=function(e){let t=-1,i=0,n=-1;for(let o=0;o<e.length;o++){const a=e[o];if("preprocessor"===a.type&&(/\#(if|ifdef|ifndef)\s+.+/.test(a.data)?++i:/\#endif\s*.*/.test(a.data)&&--i),"afterVersion"!==r&&"afterPrecision"!==r||"preprocessor"===a.type&&a.data.startsWith("#version")&&(n=Math.max(n,o)),"afterPrecision"===r&&"keyword"===a.type&&"precision"===a.data){const t=s(e,o);if(null===t)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,t)}t<n&&0===i&&(t=o)}return t+1}(e);n(o-1)&&e.splice(o++,0,i);for(const r of t)e.splice(o++,0,r);n(o-1)&&n(o)&&e.splice(o,0,i)}function ki(e,t,r,s="lowp"){Oi(e,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:s},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"ident",data:t},{type:"operator",data:";"}],"afterPrecision")}function Di(e,t,r,s,i="lowp"){Oi(e,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:s.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:i},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"ident",data:t},{type:"operator",data:";"}],"afterPrecision")}function Ui(e,t){let r,s,i=-1;for(let n=t;n<e.length;n++){const t=e[n];if("operator"===t.type&&("["===t.data&&(r=n),"]"===t.data)){s=n;break}"integer"===t.type&&(i=parseInt(t.data,10))}return r&&s&&e.splice(r,s-r+1),i}function Bi(e,t){if(e.startsWith("#version 300"))return e;const r=function(e){return si?Li.get(e):null}(e);if(null!=r)return r;const s=Ci(e);if("300 es"===function(e,t="100",r="300 es"){const s=/^\s*\#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const i of e)if("preprocessor"===i.type){const e=s.exec(i.data);if(e){const s=e[1].replaceAll(/\s\s+/g," ");if(s===r)return s;if(s===t)return i.data="#version "+r,t;throw new Error("unknown glsl version: "+s)}}return e.splice(0,0,{type:"preprocessor",data:"#version "+r},{type:"whitespace",data:"\n"}),null}(s,"100","300 es"))return e;let i=null,n=null;const o={},a={};for(let e=0;e<s.length;++e){const r=s[e];switch(r.type){case"keyword":t===tt.Gs.VERTEX_SHADER&&"attribute"===r.data?r.data="in":"varying"===r.data&&(r.data=t===tt.Gs.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(r.data.trim())&&(r.data=r.data.replaceAll(/(2D|Cube|EXT)/g,"")),t===tt.Gs.FRAGMENT_SHADER&&"gl_FragColor"===r.data&&(i||(i=Pi(s,o,"fragColor"),ki(s,i,"vec4")),r.data=i),t===tt.Gs.FRAGMENT_SHADER&&"gl_FragData"===r.data){const t=Ui(s,e+1),i=Pi(s,o,"fragData");Di(s,i,"vec4",t,"mediump"),r.data=i}else t===tt.Gs.FRAGMENT_SHADER&&"gl_FragDepthEXT"===r.data&&(n||(n=Pi(s,o,"gl_FragDepth")),r.data=n);break;case"ident":if(ri.includes(r.data)){if(t===tt.Gs.VERTEX_SHADER&&Ni(s,e))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");r.data in a||(a[r.data]=Pi(s,o,r.data)),r.data=a[r.data]}}}for(let e=s.length-1;e>=0;--e){const t=s[e];if("preprocessor"===t.type){const r=t.data.match(/\#extension\s+(.*)\:/);if(r&&r[1]&&Fi.has(r[1].trim())){const t=s[e+1];s.splice(e,t&&"whitespace"===t.type?2:1)}const i=t.data.match(/\#ifdef\s+(.*)/);i&&i[1]&&Fi.has(i[1].trim())&&(t.data="#if 1");const n=t.data.match(/\#ifndef\s+(.*)/);n&&n[1]&&Fi.has(n[1].trim())&&(t.data="#if 0")}}return function(e,t){return si&&Li.set(e,t),t}(e,function(e){return e.map((e=>"eof"!==e.type?e.data:"")).join("")}(s))}const Li=new Map;class Gi{constructor(e,t,r,s,i=new Map,n=[]){this._context=e,this._locations=s,this._uniformBlockBindings=i,this._transformFeedbackVaryings=n,this._refCount=1,this._compiled=!1,this._linesOfCode=0,this._nameToUniformLocation=new Map,this._nameToUniform1=new Map,this._nameToUniform1v=new Map,this._nameToUniform2=new Map,this._nameToUniform3=new Map,this._nameToUniform4=new Map,this._nameToUniformMatrix3=new Map,this._nameToUniformMatrix4=new Map,e||console.error("RenderingContext isn't initialized!"),0===t.length&&console.error("Shaders source should not be empty!"),t=Bi(t,tt.Gs.VERTEX_SHADER),r=Bi(r,tt.Gs.FRAGMENT_SHADER),this._vShader=zi(this._context,tt.Gs.VERTEX_SHADER,t),this._fShader=zi(this._context,tt.Gs.FRAGMENT_SHADER,r),qi.enabled&&(this._linesOfCode=t.match(/\n/g).length+r.match(/\n/g).length+2,this._context.instanceCounter.increment(tt.y4.LinesOfCode,this._vShader,this._linesOfCode)),this._vShader&&this._fShader||console.error("Error loading shaders!"),this._context.instanceCounter.increment(tt.y4.Shader,this),(0,Hs.E5)()&&(this.vertexShader=t,this.fragmentShader=r),this.usedMemory=t.length+r.length;const o=this._context.gl,a=o.createProgram();o.attachShader(a,this._vShader),o.attachShader(a,this._fShader),this._locations.forEach(((e,t)=>o.bindAttribLocation(a,e,t))),this._transformFeedbackVaryings?.length&&o.transformFeedbackVaryings(a,this._transformFeedbackVaryings,o.SEPARATE_ATTRIBS),o.linkProgram(a),(0,Hs.E5)()&&!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[e,t]of this._uniformBlockBindings){const r=o.getUniformBlockIndex(a,e);r<4294967295&&o.uniformBlockBinding(a,r,t)}this._glName=a,this._context.instanceCounter.increment(tt.y4.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 e=this._context.gl.getExtension("KHR_parallel_shader_compile");return null==e||null==this.glName?(this._compiled=!0,!0):(this._compiled=!!this._context.gl.getProgramParameter(this.glName,e.COMPLETION_STATUS_KHR),this._compiled)}dispose(){if(--this._refCount>0)return;const e=this._context.gl,t=this._context.instanceCounter;this._nameToUniformLocation.forEach((e=>e&&t.decrement(tt.y4.Uniform,e))),this._nameToUniformLocation.clear(),this._vShader&&(this._linesOfCode>0&&(t.decrement(tt.y4.LinesOfCode,this._vShader,this._linesOfCode),this._linesOfCode=0),e.deleteShader(this._vShader),this._vShader=null,t.decrement(tt.y4.Shader,this)),this._fShader&&(e.deleteShader(this._fShader),this._fShader=null),this._glName&&(e.deleteProgram(this._glName),this._glName=null,t.decrement(tt.y4.Program,this))}ref(){++this._refCount}_getUniformLocation(e){const t=this._nameToUniformLocation.get(e);if(void 0!==t)return t;if(this.glName){const t=this._context.gl.getUniformLocation(this.glName,e);return this._nameToUniformLocation.set(e,t),t&&this._context.instanceCounter.increment(tt.y4.Uniform,t),t}return null}hasUniform(e){return null!=this._getUniformLocation(e)}setUniform1i(e,t){const r=this._nameToUniform1.get(e);void 0!==r&&t===r||(this._context.gl.uniform1i(this._getUniformLocation(e),t),this._nameToUniform1.set(e,t))}setUniform1iv(e,t){Vi(this._nameToUniform1v,e,t)&&this._context.gl.uniform1iv(this._getUniformLocation(e),t)}setUniform2iv(e,t){Vi(this._nameToUniform2,e,t)&&this._context.gl.uniform2iv(this._getUniformLocation(e),t)}setUniform3iv(e,t){Vi(this._nameToUniform3,e,t)&&this._context.gl.uniform3iv(this._getUniformLocation(e),t)}setUniform4iv(e,t){Vi(this._nameToUniform4,e,t)&&this._context.gl.uniform4iv(this._getUniformLocation(e),t)}setUniform1f(e,t){const r=this._nameToUniform1.get(e);void 0!==r&&t===r||(this._context.gl.uniform1f(this._getUniformLocation(e),t),this._nameToUniform1.set(e,t))}setUniform1fv(e,t){Vi(this._nameToUniform1v,e,t)&&this._context.gl.uniform1fv(this._getUniformLocation(e),t)}setUniform2f(e,t,r){const s=this._nameToUniform2.get(e);void 0===s?(this._context.gl.uniform2f(this._getUniformLocation(e),t,r),this._nameToUniform2.set(e,[t,r])):t===s[0]&&r===s[1]||(this._context.gl.uniform2f(this._getUniformLocation(e),t,r),s[0]=t,s[1]=r)}setUniform2fv(e,t){Vi(this._nameToUniform2,e,t)&&this._context.gl.uniform2fv(this._getUniformLocation(e),t)}setUniform3f(e,t,r,s){const i=this._nameToUniform3.get(e);void 0===i?(this._context.gl.uniform3f(this._getUniformLocation(e),t,r,s),this._nameToUniform3.set(e,[t,r,s])):t===i[0]&&r===i[1]&&s===i[2]||(this._context.gl.uniform3f(this._getUniformLocation(e),t,r,s),i[0]=t,i[1]=r,i[2]=s)}setUniform3fv(e,t){const r=this._getUniformLocation(e);null!=r&&Vi(this._nameToUniform3,e,t)&&this._context.gl.uniform3fv(r,t)}setUniform4f(e,t,r,s,i){const n=this._nameToUniform4.get(e);void 0===n?(this._context.gl.uniform4f(this._getUniformLocation(e),t,r,s,i),this._nameToUniform4.set(e,[t,r,s,i])):void 0!==n&&t===n[0]&&r===n[1]&&s===n[2]&&i===n[3]||(this._context.gl.uniform4f(this._getUniformLocation(e),t,r,s,i),n[0]=t,n[1]=r,n[2]=s,n[3]=i)}setUniform4fv(e,t){const r=this._getUniformLocation(e);null!=r&&Vi(this._nameToUniform4,e,t)&&this._context.gl.uniform4fv(r,t)}setUniformMatrix3fv(e,t,r=!1){const s=this._getUniformLocation(e);null!=s&&Vi(this._nameToUniformMatrix3,e,t)&&this._context.gl.uniformMatrix3fv(s,r,t)}setUniformMatrix4fv(e,t,r=!1){const s=this._getUniformLocation(e);null!=s&&Vi(this._nameToUniformMatrix4,e,t)&&this._context.gl.uniformMatrix4fv(s,r,t)}stop(){}}function zi(e,t,r){const s=e.gl,i=s.createShader(t);return s.shaderSource(i,r),s.compileShader(i),(0,Hs.E5)()&&!s.getShaderParameter(i,s.COMPILE_STATUS)&&(console.error("Compile error in ".concat(t===tt.Gs.VERTEX_SHADER?"vertex":"fragment"," shader")),console.error(s.getShaderInfoLog(i)),console.error(function(e){let t=2;return e.replaceAll("\n",(()=>"\n"+function(e){return e>=1e3?e.toString():(" "+e).slice(-3)}(t++)+":"))}(r))),i}function Vi(e,t,r){const s=e.get(t);if(!s)return e.set(t,Array.from(r)),!0;const i=r.length;if(s.length!==i)return e.set(t,Array.from(r)),!0;for(let e=0;e<i;++e){const t=r[e];if(s[e]!==t){for(s[e]=t;e<i;++e)s[e]=r[e];return!0}}return!1}const qi={enabled:!1};r(2944);var Hi=r(51576);function Wi(e,t,r){const s=new Hi.O(t.width,t.height);return s.dataType=t.dataType,t.depth&&(s.depth=t.depth),t.flipped&&(s.flipped=t.flipped),t.hasMipmap&&(s.hasMipmap=t.hasMipmap),s.internalFormat=t.internalFormat,t.isImmutable&&(s.isImmutable=t.isImmutable),t.isOpaque&&(s.isOpaque=t.isOpaque),t.maxAnisotropy&&(s.maxAnisotropy=t.maxAnisotropy),s.pixelFormat=t.pixelFormat,t.preMultiplyAlpha&&(s.preMultiplyAlpha=t.preMultiplyAlpha),t.samplingMode&&(s.samplingMode=t.samplingMode),t.target&&(s.target=t.target),s.uniform=t.uniform,t.unpackAlignment&&(s.unpackAlignment=t.unpackAlignment),t.wrapMode&&(s.wrapMode=t.wrapMode),new Qs.w(e,s,r)}function Yi(e,t,r){const i=t.length;if(i!==r){const n=new s.c("Invalid Uniform",`Invalid length, expected ${r} but got ${i}`,{uniformName:e,values:t});M.c.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram").errorOnce(n)}}new Map;class Xi{constructor(e,t,r,s,i,n){this._program=null,this._vao=null,this._temporaryTextures=[],this.vertexShader=e,this.fragmentShader=t,this._locations=r,this._locationInfo=s,this._uniformBindings=i,this._transformFeedbackBindings=n}destroy(){this._program&&this._program.dispose(),this.cleanupTemporaryTextures()}get locations(){return this._locations}get locationInfo(){return this._locationInfo}setUniforms(e){this._uniforms=e}cleanupTemporaryTextures(){for(const e of this._temporaryTextures)e.dispose();this._temporaryTextures=[]}bind(e){const t=this._uniforms;if(!this._program){const t=new Map;for(const[e,r]of this._locations)t.set(e,r);const r=[];for(const e of this._transformFeedbackBindings??[]){const{index:t,propertyKey:s}=e;r[t]=`v_${s}`}this._program=new Gi(e,this.vertexShader,this.fragmentShader,t,new Map,r)}const r=this._program;e.useProgram(r);for(const s of this._uniformBindings){const{shaderModulePath:i,uniformName:n,uniformType:o,uniformArrayLength:a}=s,c=(0,qs.YT)(i,t);if(null==c){if("sampler2D"===o)continue;throw new Error(`Failed to find uniform value for ${i}`)}switch("array"===o?s.uniformArrayElementType:o){case"sampler2D":{const{unit:t,texture:s}=c;if(r.setUniform1i(n,t),"type"in s)e.bindTexture(s,t);else{const r=Wi(e,s.descriptor,s.data);e.bindTexture(r,t)}break}case"int":if(!a){r.setUniform1i(n,c);break}Yi(s.uniformName,c,a),r.setUniform1iv(n,c);break;case"float":if(!a){r.setUniform1f(n,c);break}Yi(s.uniformName,c,a),r.setUniform1fv(n,c);break;case"vec2":if(!a){r.setUniform2f(n,c[0],c[1]);break}Yi(s.uniformName,c,a),r.setUniform2fv(n,c.flat());break;case"vec3":if(!a){r.setUniform3f(n,c[0],c[1],c[2]);break}Yi(s.uniformName,c,a),r.setUniform3fv(n,c.flat());break;case"vec4":if(!a){r.setUniform4f(n,c[0],c[1],c[2],c[3]);break}Yi(s.uniformName,c,a),r.setUniform4fv(n,c.flat());break;case"mat3":r.setUniformMatrix3fv(n,c.flat());break;case"mat4":r.setUniformMatrix4fv(n,c.flat());break;default:throw new Error(`Unable to set uniform for type ${o}`)}}}}function ji(e){return new e}function $i(e,t,r){const s=e.constructor[t]??[];e.constructor.hasOwnProperty(t)||Object.defineProperty(e.constructor,t,{value:s.slice()}),e.constructor[t].push(r)}function Ki(e,t){return(r,s)=>{$i(r,"locations",{typeCtor:t,propertyKey:s,parameterIndex:null,index:e})}}const Qi=e=>(t,r,s)=>{$i(t,"inputs",{inputCtor:e,propertyKey:r,parameterIndex:s})},Zi=e=>(t,r)=>{$i(t,"uniforms",{typeCtor:e,propertyKey:r})},Ji=e=>(t,r)=>{$i(t,"options",{typeCtor:e,propertyKey:r})},en=(e,t)=>{$i(e,"defines",{propertyKey:t})},tn=(e,t)=>(r,s)=>{r.constructor.builtins.push({builtin:e,propertyKey:s,typeCtor:t})};class rn{}rn.builtins=[],(0,I._)([tn("gl_VertexID",Wr)],rn.prototype,"glVertexID",void 0);class sn{}class nn{}nn.builtins=[],(0,I._)([tn("gl_FragCoord",kr)],nn.prototype,"glFragCoord",void 0),(0,I._)([tn("gl_PointCoord",Pr)],nn.prototype,"glPointCoord",void 0);class on{}(0,I._)([(e,t)=>{$i(e,"builtins",{builtin:"gl_FragColor",propertyKey:t})}],on.prototype,"glFragColor",void 0);class an{constructor(){this.type="uniform-group"}get _uniforms(){return this.constructor.uniforms??[]}}class cn{constructor(){this.logShader=!1,this.computeAttributes={}}get vertexInput(){const e=(0,te.mk)(this._shaderModuleClass.inputs,(e=>"vertex"===e.propertyKey&&0===e.parameterIndex));if(!e)throw new Error("Unable to find vertex input parameter");return e}get computeInput(){return(0,te.mk)(this._shaderModuleClass.inputs,(e=>"vertex"===e.propertyKey&&1===e.parameterIndex))}get fragmentInput(){const e=(0,te.mk)(this._shaderModuleClass.inputs,(e=>"fragment"===e.propertyKey));if(!e)throw new Error("Unable to find fragment input parameter");return e}get transformFeedbackBindings(){return this.fragmentInput.inputCtor.transformFeedbackBindings??[]}get locations(){return[...this.vertexInput.inputCtor.locations,...this.computeInput?.inputCtor.locations??[]]}get locationsMap(){const e=new Map,t=new Set;for(const r of this.locations)t.has(r.index)?M.c.getLogger("esri.views.2d.engine.webgl.shaderGraph.GraphShaderModule").warnOnce("mapview-rendering",`Unable to assigned attribute ${r.propertyKey} to ${r.index}. Index already in use`,{locationsMap:e}):(e.set(r.propertyKey,r.index),t.add(r.index));return e}get locationInfo(){if(!this._locationInfo){const e=this.locationsMap,t=Array.from(e.entries()).map((([e,t])=>`${e}.${t}`)).join("."),r=(0,se.sV)(t);this._locationInfo={hash:r,locations:e}}return this._locationInfo}get renamedLocationsMap(){const e=new Map;for(const t of this.locations)e.set("a_"+t.propertyKey,t.index);return e}get optionPropertyKeys(){if(!this._optionPropertyKeys){const e=new Set;for(const t of this._options)e.add(t.propertyKey);this._optionPropertyKeys=e}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(e,t,r,s){try{const{vertex:i,fragment:n,uniformBindings:o}=this._generateShaders(e,t,r,s);return new Xi(i,n,this.renamedLocationsMap,this.locationInfo,o,this.transformFeedbackBindings)}catch(e){return console.error("Failed to create program",{error:e}),new Xi("","",this.renamedLocationsMap,this.locationInfo,[],this.transformFeedbackBindings)}}getDebugUniformClassInfo(e){const t=this._options.find((t=>t.propertyKey===e));if(t)return{type:"option",className:t.typeCtor};const r=this._uniforms.find((t=>t.propertyKey===e));if(!r)throw new Error(`Unable to find uniform class type for property: ${e}`);return{type:"required",className:r.typeCtor}}getShaderKey(e,t,r,s){const i=Object.keys(r).map((e=>`${e}.${r[e]}`)).join("."),n=Object.keys(s).map((e=>`${e}.${s[e]}`)).join("."),o=Object.keys(t).filter((e=>this.optionPropertyKeys.has(e)&&t[e])).join(".");return`${this.constructor.name}.${e.hash}.${i}.${n}.${o}`}_generateShaders(e,t,r,s){const i=[];this._setDefines(r),this._setOptionalUniforms(i,t),this._setRequiredUniforms(i);const n=this._hydrateVertexInput(s),o=this._injectPackPrecisionFactor(n,e),a=this._hydrateComputeInput(),c=a&&this._injectPackPrecisionFactor(a,e),l=this.vertex(o,c),u=this._hydrateFragmentInput(l),h=this.fragment(u),d=new Set;for(const e in h)ir(d,h[e]);const _=this._getVertexInputBuiltins(),p=Vs.createVertex({...n,...a},l,_,i,this.transformFeedbackBindings,d);(new Ls).write(p);const f=this._getFragmentInputBuiltins(h);f.set("glPointCoord","gl_PointCoord");const m=Vs.createFragment(u,h,f,i,p,this.transformFeedbackBindings);(new Ls).write(m);const g=this._createShaderBuilder(p,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:i}}_setDefines(e){for(const t in e)this[t]=e[t]}_setOptionalUniforms(e,t){for(const r of this._options)t[r.propertyKey]?this[r.propertyKey]=this._hydrateUniformGroup(e,r):this[r.propertyKey]=null}_setRequiredUniforms(e){for(const t of this._uniforms)this[t.propertyKey]=this._hydrateUniformGroup(e,t)}_hydrateUniformGroup(e,t){const r=new(0,t.typeCtor);for(const s of r._uniforms??[]){const i=ji(s.typeCtor),n=`u_${t.propertyKey}_${s.propertyKey}`,o=i.type,a=[t.propertyKey,s.propertyKey].join(".");if("type"in s.typeCtor&&"array"===s.typeCtor.type){const t=i;e.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformArrayLength:t.size,uniformArrayElementType:t.elementType.type,uniformHydrated:i})}else e.push({shaderModulePath:a,uniformName:n,uniformType:o,uniformHydrated:i});r[s.propertyKey]=i}return r}_hydrateVertexInput(e){const t=this.vertexInput.inputCtor,r=t.locations.reduce(((t,r)=>!1===e[r.propertyKey]?t:{...t,[r.propertyKey]:ji(r.typeCtor)}),{});for(const{propertyKey:e,typeCtor:s}of t.builtins){const t=ji(s);r[e]=t}return r}_hydrateComputeInput(){return null==this.computeInput?null:this.computeInput.inputCtor.locations.reduce(((e,t)=>({...e,[t.propertyKey]:ji(t.typeCtor)})),{})}_injectPackPrecisionFactor(e,t){const r={};for(const s in e){const i=e[s],n=t.attributes.find((e=>e.name===s));if(n?.packPrecisionFactor){if("float"!==i.type&&"vec2"!==i.type&&"vec3"!==i.type&&"vec4"!==i.type)throw new Error(`InternalError: packPrecisionFactor requires GenType, but found ${i.type}`);r[s]=i.divide(new Nr(n.packPrecisionFactor))}else r[s]=i}return r}_hydrateFragmentInput(e){const t={};for(const r in e)t[r]=e[r];for(const{propertyKey:e,typeCtor:r}of nn.builtins){const s=ji(r);t[e]=s}return t}_getVertexInputBuiltins(){const e=this.vertexInput.inputCtor,t=new Map;for(const{builtin:r,propertyKey:s}of e.builtins)t.set(s,r);return t}_getFragmentInputBuiltins(e){const t=e.constructor,r=new Map;for(const e of t.builtins??[])r.set(e.propertyKey,e.builtin);return r}_createShaderBuilder(e,t){const r=new $t;return this._insertDebugInfo(r),e.insertVertexShader(r),t.insertFragmentShader(r),r}_insertDebugInfo(e){e.vertex.code.add("// DEFINES: "),e.vertex.code.add("// --------------------------------------------------------- ");for(const t of this._defines)this[t.propertyKey]?e.vertex.code.add(`// ${t.propertyKey}: true`):e.vertex.code.add(`// ${t.propertyKey}: false`);e.vertex.code.add(""),e.vertex.code.add("// OPTIONS: "),e.vertex.code.add("// --------------------------------------------------------- ");for(const t of this._options)this[t.propertyKey]?e.vertex.code.add(`// ${t.propertyKey}: true`):e.vertex.code.add(`// ${t.propertyKey}: false`)}}var ln=r(56100);function un(e){const t=es(12.9898),r=es(78.233),s=es(43758.5453);return As(ks(Ps(Rs(e,ts(t,r)),es(3.14))).multiply(s))}function hn(e){return gs(e,es(Mt))}function dn(e,t){const r=es(2**t);return Ps(function(e){return os("floor",e)}(e.divide(r)),es(2))}function _n(e,t){return dn(e,t+ln.IX.length)}class pn extends an{getVisualVariableData(e){if(!this._vvData){const t=this.getAttributeDataCoords(e);this._vvData=Us(this.visualVariableData,t).setDebugName("storage2")}return this._vvData}getAttributeDataCoords(e){if(!this._uv){const t=function(e){const t=dn(e.z,7),r=es(1).subtract(t),s=e.xyz.subtract(((...e)=>new Or(...e))(0,0,es(128)));return r.multiply(e).add(t.multiply(s))}(e),r=this.size,s=Jr(t.x),i=Jr(t.y).multiply(Jr(256)),n=Jr(t.z).multiply(Jr(256)).multiply(Jr(256)),o=es(s.add(i).add(n)),a=Ps(o,r),c=o.subtract(a).divide(r);this._uv=new Pr(a,c).add(.5).divide(r)}return this._uv}getFilterData(e){const t=this.getAttributeDataCoords(e);return Us(this.filterFlags,t).setDebugName("storage0")}getAnimationData(e){const t=this.getAttributeDataCoords(e);return Us(this.animation,t).setDebugName("storage1")}getVVData(e){return this.getVisualVariableData(e)}getDataDrivenData0(e){const t=this.getAttributeDataCoords(e);return Us(this.dataDriven0,t).setDebugName("storage30")}getDataDrivenData1(e){const t=this.getAttributeDataCoords(e);return Us(this.dataDriven1,t).setDebugName("storage31")}getDataDrivenData2(e){const t=this.getAttributeDataCoords(e);return Us(this.dataDriven2,t).setDebugName("storage32")}getGPGPUData(e){const t=this.getAttributeDataCoords(e);return Us(this.gpgpu,t).setDebugName("storage4")}getFilterFlags(e){return(0,n.c)("webgl-ignores-sampler-precision")?function(e){return os("ceil",e)}(this.getFilterData(e).x.multiply(es(255))):this.getFilterData(e).x.multiply(es(255))}getAnimationValue(e){return this.getAnimationData(e).x}getSizeValue(e){return this.getVisualVariableData(e).x}getColorValue(e){return this.getVisualVariableData(e).y}getOpacityValue(e){return this.getVisualVariableData(e).z}getRotationValue(e){return this.getVisualVariableData(e).w}}(0,I._)([Zi(Fr)],pn.prototype,"filterFlags",void 0),(0,I._)([Zi(Fr)],pn.prototype,"animation",void 0),(0,I._)([Zi(Fr)],pn.prototype,"gpgpu",void 0),(0,I._)([Zi(Fr)],pn.prototype,"visualVariableData",void 0),(0,I._)([Zi(Fr)],pn.prototype,"dataDriven0",void 0),(0,I._)([Zi(Fr)],pn.prototype,"dataDriven1",void 0),(0,I._)([Zi(Fr)],pn.prototype,"dataDriven2",void 0),(0,I._)([Zi(Nr)],pn.prototype,"size",void 0);class fn extends an{}(0,I._)([Zi(Nr)],fn.prototype,"activeReasons",void 0),(0,I._)([Zi(Nr)],fn.prototype,"highlightAll",void 0);class mn extends an{}(0,I._)([Zi(Pr)],mn.prototype,"position",void 0),(0,I._)([Zi(Nr)],mn.prototype,"distance",void 0),(0,I._)([Zi(Nr)],mn.prototype,"smallSymbolDistance",void 0),(0,I._)([Zi(Nr)],mn.prototype,"smallSymbolSizeThreshold",void 0);class gn extends an{}(0,I._)([Zi(Kr)],gn.prototype,"displayViewScreenMat3",void 0),(0,I._)([Zi(Kr)],gn.prototype,"displayViewMat3",void 0),(0,I._)([Zi(Kr)],gn.prototype,"displayMat3",void 0),(0,I._)([Zi(Kr)],gn.prototype,"viewMat3",void 0),(0,I._)([Zi(Kr)],gn.prototype,"tileMat3",void 0),(0,I._)([Zi(Nr)],gn.prototype,"displayZoomFactor",void 0),(0,I._)([Zi(Nr)],gn.prototype,"requiredZoomFactor",void 0),(0,I._)([Zi(Pr)],gn.prototype,"tileOffset",void 0),(0,I._)([Zi(Nr)],gn.prototype,"currentScale",void 0),(0,I._)([Zi(Nr)],gn.prototype,"currentZoom",void 0),(0,I._)([Zi(Nr)],gn.prototype,"metersPerSRUnit",void 0),(0,I._)([Zi(Nr)],gn.prototype,"rotation",void 0),(0,I._)([Zi(Nr)],gn.prototype,"pixelRatio",void 0);class yn extends rn{}(0,I._)([Ki(0,Or)],yn.prototype,"id",void 0),(0,I._)([Ki(1,Nr)],yn.prototype,"bitset",void 0),(0,I._)([Ki(2,Pr)],yn.prototype,"pos",void 0);class xn extends sn{}(0,I._)([Ki(14,Pr)],xn.prototype,"nextPos1",void 0),(0,I._)([Ki(15,Pr)],xn.prototype,"nextPos2",void 0);class bn extends nn{}class Tn extends cn{clip(e,t){let r=new Nr(0);const s=this.storage.getFilterFlags(e);if(r=r.add(es(2).multiply(es(1).subtract(_n(s,0)))),this.inside?r=r.add(es(2).multiply(es(1).subtract(_n(s,1)))):this.outside?r=r.add(es(2).multiply(_n(s,1))):this.highlight&&(r=r.add(es(2).multiply(es(1).subtract(this._checkHighlight(s))))),null!=t){const e=new Nr(1).subtract(Ds(t.x,this.view.currentZoom)),s=Ds(t.y,this.view.currentZoom);r=r.add(new Nr(2).multiply(e.add(s)))}return r}getFragmentOutput(e,t,r=new Nr(1/255)){const s=new on;return s.glFragColor=this._maybeWriteHittest(t)??this._maybeHighlight(e,r)??e,s}_maybeHighlight(e,t){return this.highlight?new kr(e.rgb,Ds(t,e.a)):null}_checkHighlight(e){let t=this._checkHighlightBit(e,0);for(let r=1;r<ln.IX.length;r++)t=t.add(this._checkHighlightBit(e,r));return Ds(new Nr(.1),t.add(this.highlight.highlightAll))}_checkHighlightBit(e,t){return function(e,t){return dn(e,t)}(e,t).multiply(dn(this.highlight.activeReasons,t))}maybeRunHittest(e,t,r){if(null==this.hittestRequest)return null;let s=hs(xs(this.hittest(e,t,r),this.hittestRequest.distance),new Nr(2),new Nr(0));const i=function(e){return e.multiply(2).subtract(1)}(this.storage.getAttributeDataCoords(e.id));s=s.add(this.clip(e.id,e.zoomRange));const n=new kr(new Nr(1/255),0,0,0);return{glPointSize:new Nr(1),glPosition:new kr(i,s,1),color:n}}_maybeWriteHittest(e){return null!=this.hittestRequest?e.color:null}}function wn(e,t,r){const s=r.subtract(t),i=Is(function(e,t){return Rs(e,function(e){return os("normalize",e)}(t))}(e.subtract(t),s).divide(Ms(s)),new Nr(0),new Nr(1));return function(e,t){return as("distance",e,t,Nr)}(e,t.add(i.multiply(r.subtract(t))))}function Sn(e,t,r,s){return gs(function(e){const t=function(e){return os("abs",e)}(e);return Ds(t.x.add(t.y).add(t.z),new Nr(1.05))}(function(e,t,r,s){const i=new Kr(r.x.multiply(s.y).subtract(s.x.multiply(r.y)),s.x.multiply(t.y).subtract(t.x.multiply(s.y)),t.x.multiply(r.y).subtract(r.x.multiply(t.y)),r.y.subtract(s.y),s.y.subtract(t.y),t.y.subtract(r.y),s.x.subtract(r.x),t.x.subtract(s.x),r.x.subtract(t.x)),n=t.x.multiply(r.y.subtract(s.y)),o=r.x.multiply(s.y.subtract(t.y)),a=s.x.multiply(t.y.subtract(r.y)),c=n.add(o).add(a);return new Nr(1).divide(c).multiply(i.multiply(new Or(1,e)))}(e,t,r,s)),new Nr(1))}function vn(e){return e.distance.add(1)}function In(e,t,r){const{viewMat3:s,tileMat3:i}=e.view,n=s.multiply(i),o=n.multiply(new Or(t.pos,1)),a=n.multiply(new Or(r.nextPos1,1)),c=n.multiply(new Or(r.nextPos2,1));return function(e,t,r,s){const i=function(e,t){return e.x.multiply(t.y).subtract(t.x.multiply(e.y))}(r.subtract(t),s.subtract(t)),n=ws(function(e,t){return ns("<",e,t,Gr)}(i,new Nr(At)),xs(i,new Nr(-At)));return ds([ws(Os(n),Sn(e.xy,t,r,s)),new Nr(-1)],[!0,()=>{const i=wn(e,t,r),n=wn(e,r,s),o=wn(e,s,t);return Fs(Fs(i,n),o)}])}(e.hittestRequest.position,o.xy,a.xy,c.xy)}(0,I._)([en],Tn.prototype,"inside",void 0),(0,I._)([en],Tn.prototype,"outside",void 0),(0,I._)([Ji(fn)],Tn.prototype,"highlight",void 0),(0,I._)([Zi(pn)],Tn.prototype,"storage",void 0),(0,I._)([Zi(gn)],Tn.prototype,"view",void 0),(0,I._)([Ji(mn)],Tn.prototype,"hittestRequest",void 0);class En extends an{getColor(e,t,r){return ds([Ts(hn(e),r),t],[ys(e,this.values.first()),this.colors.first()],[bs(e,this.values.last()),this.colors.last()],[!0,()=>{const t=this.values.findIndex((t=>xs(t,e))),r=this.values.get(t),s=t.subtract(1),i=this.values.get(s),n=e.subtract(i).divide(r.subtract(i));return Ns(this.colors.get(s),this.colors.get(t),n)}])}}(0,I._)([Zi(Cr.ofType(kr,8))],En.prototype,"colors",void 0),(0,I._)([Zi(Cr.ofType(Nr,8))],En.prototype,"values",void 0);class Rn extends an{getOpacity(e){return ds([hn(e),new Nr(1)],[ys(e,this.opacityValues.first()),this.opacities.first()],[bs(e,this.opacityValues.last()),this.opacities.last()],[!0,()=>{const t=this.opacityValues.findIndex((t=>xs(t,e))),r=this.opacityValues.get(t),s=t.subtract(1),i=this.opacityValues.get(s),n=e.subtract(i).divide(r.subtract(i));return Ns(this.opacities.get(s),this.opacities.get(t),n)}])}}function An(e){return null!=e.visualVariableSizeMinMaxValue||null!=e.visualVariableSizeScaleStops||null!=e.visualVariableSizeStops||null!=e.visualVariableSizeUnitValue}function Mn(e,t,r,s=new Gr(!1)){if(null==e.visualVariableColor)return r;const i=e.storage.getColorValue(t);return e.visualVariableColor.getColor(i,r,s)}function Cn(e,t){if(null==e.visualVariableOpacity)return new Nr(1);const r=e.storage.getOpacityValue(t);return e.visualVariableOpacity.getOpacity(r)}(0,I._)([Zi(Cr.ofType(Nr,8))],Rn.prototype,"opacities",void 0),(0,I._)([Zi(Cr.ofType(Nr,8))],Rn.prototype,"opacityValues",void 0);class Fn extends yn{}(0,I._)([Ki(3,kr)],Fn.prototype,"color",void 0),(0,I._)([Ki(4,Pr)],Fn.prototype,"zoomRange",void 0);class Nn extends Tn{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(e,t){const r=Cn(this,e.id),s=Mn(this,e.id,e.color).multiply(r),i=this.view.displayViewScreenMat3.multiply(new Or(e.pos.xy,1)),n=this.clip(e.id,e.zoomRange);return{glPosition:new kr(i.xy,n,1),color:s,...this.maybeRunHittest(e,t,null)}}fragment(e){return this.getFragmentOutput(e.color,e,new Nr(0))}hittest(e,t){return In(this,e,t)}}(0,I._)([Ji(En)],Nn.prototype,"visualVariableColor",void 0),(0,I._)([Ji(Rn)],Nn.prototype,"visualVariableOpacity",void 0),(0,I._)([(0,I.a)(0,Qi(Fn)),(0,I.a)(1,Qi(xn))],Nn.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(bn))],Nn.prototype,"fragment",null);class Pn extends an{getPatternOffsetAtTileOrigin(e,t=new Nr(0),r=new Nr(1)){const s=new Pr(16777216).divide(e);let i=e.multiply(As(this.maxIntsToLocalOrigin.multiply(s))).add(this.tileOffsetFromLocalOrigin).subtract(new Nr(.5).multiply(e));return i=new Pr(i.x.multiply(r).subtract(i.y.multiply(t)),i.x.multiply(t).add(i.y.multiply(r))),Ps(i,e)}}(0,I._)([Zi(Pr)],Pn.prototype,"tileOffsetFromLocalOrigin",void 0),(0,I._)([Zi(Pr)],Pn.prototype,"maxIntsToLocalOrigin",void 0);class On extends an{}(0,I._)([Zi(Pr)],On.prototype,"size",void 0),(0,I._)([Zi(Fr)],On.prototype,"texture",void 0);class kn extends Fn{}function Dn(e,t){const r=Ns(new Pr(1),new Pr(1/L.Q0),new Pr(dn(t.bitset,6),dn(t.bitset,5))),s=e.view.requiredZoomFactor,i=new Pr(t.width,t.height).multiply(r),n=i.multiply(t.scale).multiply(s),o=t.angle.multiply(.024543692606171875),a=ks(o),c=Es(o),l=function(e,t,r,s,i){const n=gs(dn(i,Ct),es(1)),o=function(e){return Rs(e,rs(255/256,255/65536,255/16777216,255/4294967296))}(new kr(e,0));return hs(n,ss(s.divide(t.x),r.divide(t.y),0,ls(r.divide(t.x)),s.divide(t.y),0,un(ts(o,0)),un(ts(0,o)),1),ss(s.divide(t.x),r.divide(t.y),0,ls(r.divide(t.x)),s.divide(t.y),0,0,0,1))}(t.id,n,a,c,t.bitset),u=e.localTileOffset.getPatternOffsetAtTileOrigin(i,a,c),h=s.multiply(t.scale).multiply(t.offset.subtract(u)).divide(n),d=new Or(t.pos,1),_=l.multiply(d).xy.subtract(h),p=t.tlbr.divide(e.mosaicInfo.size.xyxy);let f=dn(t.bitset,4);return null!=e.visualVariableColor&&(f=hs(hn(e.storage.getColorValue(t.id)),new Nr(0),f)),{tileTextureCoord:_,tlbr:p,sampleAlphaOnly:f}}function Un(e,t){const r=Ps(t.tileTextureCoord,new Nr(1)),s=Ns(t.tlbr.xy,t.tlbr.zw,r);let i=Us(e.mosaicInfo.texture,s);return i=hs(xs(t.sampleAlphaOnly,new Nr(.5)),i.aaaa,i),t.color.multiply(i)}(0,I._)([Ki(5,kr)],kn.prototype,"tlbr",void 0),(0,I._)([Ki(6,Nr)],kn.prototype,"width",void 0),(0,I._)([Ki(7,Nr)],kn.prototype,"height",void 0),(0,I._)([Ki(8,Pr)],kn.prototype,"offset",void 0),(0,I._)([Ki(9,Pr)],kn.prototype,"scale",void 0),(0,I._)([Ki(10,Nr)],kn.prototype,"angle",void 0);class Bn extends Nn{vertex(e,t){return{...super.vertex(e,t),...Dn(this,e)}}fragment(e){const t=Un(this,e);return this.getFragmentOutput(t,e,new Nr(0))}}(0,I._)([Zi(On)],Bn.prototype,"mosaicInfo",void 0),(0,I._)([Zi(Pn)],Bn.prototype,"localTileOffset",void 0),(0,I._)([(0,I.a)(0,Qi(kn)),(0,I.a)(1,Qi(xn))],Bn.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(class extends bn{}))],Bn.prototype,"fragment",null);class Ln extends an{getSize(e,t){const r=this.minMaxValueAndSize.xy,s=this.minMaxValueAndSize.zw;return hs(hn(e),t,(()=>{const t=Is(e.subtract(r.x).divide(r.y.subtract(r.x)),new Nr(0),new Nr(1));return s.x.add(t.multiply(s.y.subtract(s.x)))}))}}(0,I._)([Zi(kr)],Ln.prototype,"minMaxValueAndSize",void 0);class Gn extends an{getSizeForViewScale(e){return ds([ys(e,this.values.first()),this.sizes.first()],[bs(e,this.values.last()),this.sizes.last()],[!0,()=>{const t=this.values.findIndex((t=>xs(t,e))),r=this.values.get(t),s=t.subtract(1),i=this.values.get(s),n=e.subtract(i).divide(r.subtract(i));return Ns(this.sizes.get(s),this.sizes.get(t),n)}])}}(0,I._)([Zi(Cr.ofType(Nr,8))],Gn.prototype,"sizes",void 0),(0,I._)([Zi(Cr.ofType(Nr,8))],Gn.prototype,"values",void 0);class zn extends an{getSize(e,t){const r=ds([hn(e),t],[ys(e,this.values.first()),this.sizes.first()],[bs(e,this.values.last()),this.sizes.last()],[!0,()=>{const t=this.values.findIndex((t=>xs(t,e))),r=this.values.get(t),s=t.subtract(1),i=this.values.get(s),n=e.subtract(i).divide(r.subtract(i));return Ns(this.sizes.get(s),this.sizes.get(t),n)}]);return hs(hn(r),t,r)}}(0,I._)([Zi(Cr.ofType(Nr,8))],zn.prototype,"sizes",void 0),(0,I._)([Zi(Cr.ofType(Nr,8))],zn.prototype,"values",void 0);class Vn extends an{getSize(e,t){return hs(hn(e),t,e.multiply(this.unitValueToPixelsRatio))}}(0,I._)([Zi(Nr)],Vn.prototype,"unitValueToPixelsRatio",void 0);class qn extends yn{}(0,I._)([Ki(3,kr)],qn.prototype,"color",void 0),(0,I._)([Ki(4,Pr)],qn.prototype,"offset",void 0),(0,I._)([Ki(5,Pr)],qn.prototype,"normal",void 0),(0,I._)([Ki(6,Nr)],qn.prototype,"halfWidth",void 0),(0,I._)([Ki(7,Nr)],qn.prototype,"referenceHalfWidth",void 0),(0,I._)([Ki(8,Pr)],qn.prototype,"zoomRange",void 0);class Hn extends bn{}class Wn extends an{}function Yn(e){return Cs(new Nr(It).multiply(Ds(e,new Nr(Et))),new Nr(1))}function Xn(e,t){const{id:r,offset:s,pos:i,normal:n,zoomRange:o}=t,{displayViewScreenMat3:a,displayViewMat3:c}=e.view,l=Mn(e,r,t.color),u=Cn(e,r),h=function(e,t){const{id:r,halfWidth:s,referenceHalfWidth:i}=t;if(An(e)){const t=function(e,t,r){if(An(e)){const s=e.storage.getSizeValue(t);return e.visualVariableSizeMinMaxValue?.getSize(s,r)??e.visualVariableSizeScaleStops?.getSizeForViewScale(e.view.currentScale)??e.visualVariableSizeStops?.getSize(s,r)??e.visualVariableSizeUnitValue?.getSize(s,r)}return r}(e,r,new Nr(2).multiply(i));return new Nr(.5).multiply(s.divide(Cs(i,new Nr(Rt)))).multiply(t)}return s}(e,t),d=new Nr(.5).multiply(e.antialiasingControls.antialiasing),_=Cs(h.add(d),new Nr(.45)).add(new Nr(.1).multiply(d)),p=Yn(_).multiply(_).multiply(s),f=c.multiply(new Or(p,new Nr(0))),m=a.multiply(new Or(i,new Nr(1))).add(f),g=new Nr(2).multiply(Ds(h,new Nr(0))).add(e.clip(r,o)),y=new kr(m.xy,g,1);return{color:l,opacity:u,halfWidth:_,normal:n,scaledOffset:p,scaledHalfWidth:h,glPosition:new kr(y.xy,g,1)}}function jn(e,t){const{opacity:r,color:s}=e,i=function(e,t){const{halfWidth:r,normal:s}=e,i=Yn(r),n=Ms(s).multiply(r);return Is(i.multiply(r.subtract(n)).divide(t.add(i).subtract(new Nr(1))),new Nr(0),new Nr(1))}(e,t);return r.multiply(s).multiply(i)}(0,I._)([Zi(Nr)],Wn.prototype,"antialiasing",void 0),(0,I._)([Zi(Nr)],Wn.prototype,"blur",void 0);class $n extends Tn{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}vertex(e,t){const r=Xn(this,e);return{...r,...this.maybeRunHittest(e,t,r.halfWidth)}}fragment(e){const t=jn(e,this.antialiasingControls.blur);return this.getFragmentOutput(t,e)}hittest(e,t,r){const{viewMat3:s,tileMat3:i}=this.view,n=s.multiply(i),o=n.multiply(new Or(e.pos,1)),a=n.multiply(new Or(t.nextPos1,1)),c=n.multiply(new Or(t.nextPos2,1)),{distance:l,smallSymbolDistance:u,smallSymbolSizeThreshold:h}=this.hittestRequest,d=Ds(r,h.multiply(.5)).multiply(l.subtract(u)),_=this.hittestRequest.position;return Fs(wn(_,o.xy,a.xy),wn(_,o.xy,c.xy)).subtract(r).add(d)}}(0,I._)([Zi(Wn)],$n.prototype,"antialiasingControls",void 0),(0,I._)([Ji(En)],$n.prototype,"visualVariableColor",void 0),(0,I._)([Ji(Rn)],$n.prototype,"visualVariableOpacity",void 0),(0,I._)([Ji(Ln)],$n.prototype,"visualVariableSizeMinMaxValue",void 0),(0,I._)([Ji(Gn)],$n.prototype,"visualVariableSizeScaleStops",void 0),(0,I._)([Ji(zn)],$n.prototype,"visualVariableSizeStops",void 0),(0,I._)([Ji(Vn)],$n.prototype,"visualVariableSizeUnitValue",void 0),(0,I._)([(0,I.a)(0,Qi(qn)),(0,I.a)(1,Qi(xn))],$n.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(Hn))],$n.prototype,"fragment",null);class Kn extends yn{}(0,I._)([Ki(3,Pr)],Kn.prototype,"offset",void 0),(0,I._)([Ki(4,kr)],Kn.prototype,"color",void 0),(0,I._)([Ki(5,Pr)],Kn.prototype,"normal",void 0),(0,I._)([Ki(6,Nr)],Kn.prototype,"halfWidth",void 0),(0,I._)([Ki(7,Nr)],Kn.prototype,"referenceHalfWidth",void 0),(0,I._)([Ki(8,Pr)],Kn.prototype,"zoomRange",void 0);class Qn extends Hn{}function Zn(e,t,r){const{id:s,bitset:i}=t,n=dn(i,0),o=xs(n,new Nr(.5)),a=Xn(e,t),c=hs(o,a.halfWidth,new Nr(0)),l=Cn(e,s),u=Mn(e,s,t.color),h=hs(o,t.color,u.multiply(l)),d=e.view.displayViewScreenMat3.multiply(new Or(t.pos.xy,1)),_=e.clip(t.id),p=new kr(d.xy,_,1),f=hs(o,a.glPosition,p),m=r&&e.maybeRunHittest(t,r,o);return{isOutline:n,color:h,opacity:new Nr(1),halfWidth:c,normal:a.normal,glPosition:f,...m}}class Jn extends Tn{constructor(){super(...arguments),this.computeAttributes={pos:["nextPos1","nextPos2"]}}}(0,I._)([Zi(Wn)],Jn.prototype,"antialiasingControls",void 0),(0,I._)([Ji(En)],Jn.prototype,"visualVariableColor",void 0),(0,I._)([Ji(Rn)],Jn.prototype,"visualVariableOpacity",void 0),(0,I._)([Ji(Ln)],Jn.prototype,"visualVariableSizeMinMaxValue",void 0),(0,I._)([Ji(Gn)],Jn.prototype,"visualVariableSizeScaleStops",void 0),(0,I._)([Ji(zn)],Jn.prototype,"visualVariableSizeStops",void 0),(0,I._)([Ji(Vn)],Jn.prototype,"visualVariableSizeUnitValue",void 0);class eo extends Jn{vertex(e,t){return Zn(this,e,t)}fragment(e){const{color:t,isOutline:r}=e,s=xs(r,new Nr(.5)),i=hs(s,jn(e,this.antialiasingControls.blur),t),n=hs(s,new Nr(1/255),new Nr(0));return this.getFragmentOutput(i,e,n)}hittest(e,t,r){return hs(r,vn(this.hittestRequest),In(this,e,t))}}(0,I._)([(0,I.a)(0,Qi(Kn)),(0,I.a)(1,Qi(xn))],eo.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(Qn))],eo.prototype,"fragment",null);class to extends Fn{}function ro(e,t){const r=t.tlbr.xy,s=t.tlbr.zw,i=s.x.subtract(r.x),n=r.y.subtract(s.y),o=new Pr(i,n).multiply(t.inverseRasterizationScale),a=o.multiply(e.view.requiredZoomFactor),c=function(e){const t=new Nr(1),r=new Nr(0);return new Kr(t.divide(e.x),r.divide(e.y),0,ls(r.divide(e.x)),t.divide(e.y),0,0,0,1)}(a),l=e.localTileOffset.getPatternOffsetAtTileOrigin(o).divide(a),u=new Or(t.pos,1);return{tileTextureCoord:c.multiply(u).xy.subtract(l),tlbr:t.tlbr.divide(e.mosaicInfo.size.xyxy)}}function so(e,t){const r=Ps(e.tileTextureCoord,new Nr(1)),s=Ns(e.tlbr.xy,e.tlbr.zw,r),i=Us(t.texture,s);return e.color.multiply(i)}(0,I._)([Ki(5,kr)],to.prototype,"tlbr",void 0),(0,I._)([Ki(6,Nr)],to.prototype,"inverseRasterizationScale",void 0);class io extends Nn{vertex(e,t){return{...super.vertex(e,t),...ro(this,e)}}fragment(e){const t=so(e,this.mosaicInfo);return this.getFragmentOutput(t,e,new Nr(0))}}(0,I._)([Zi(On)],io.prototype,"mosaicInfo",void 0),(0,I._)([Zi(Pn)],io.prototype,"localTileOffset",void 0),(0,I._)([(0,I.a)(0,Qi(to)),(0,I.a)(1,Qi(xn))],io.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(class extends bn{}))],io.prototype,"fragment",null);class no extends Kn{}(0,I._)([Ki(9,kr)],no.prototype,"tlbr",void 0),(0,I._)([Ki(10,Nr)],no.prototype,"inverseRasterizationScale",void 0);class oo extends Qn{}class ao extends eo{vertex(e,t){return{...Zn(this,e,t),...ro(this,e)}}fragment(e){const{isOutline:t}=e,r=xs(t,new Nr(.5)),s=hs(r,jn(e,this.antialiasingControls.blur),so(e,this.mosaicInfo)),i=hs(r,new Nr(1/255),new Nr(0));return this.getFragmentOutput(s,e,i)}}(0,I._)([Zi(On)],ao.prototype,"mosaicInfo",void 0),(0,I._)([Zi(Pn)],ao.prototype,"localTileOffset",void 0),(0,I._)([(0,I.a)(0,Qi(no)),(0,I.a)(1,Qi(xn))],ao.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(oo))],ao.prototype,"fragment",null);const co=16,lo=.0625;class uo extends yn{}(0,I._)([Ki(3,kr)],uo.prototype,"color",void 0),(0,I._)([Ki(4,kr)],uo.prototype,"tlbr",void 0),(0,I._)([Ki(5,Nr)],uo.prototype,"angle",void 0),(0,I._)([Ki(6,Nr)],uo.prototype,"aux1",void 0),(0,I._)([Ki(7,Nr)],uo.prototype,"aux2",void 0),(0,I._)([Ki(8,Pr)],uo.prototype,"aux3",void 0),(0,I._)([Ki(9,Pr)],uo.prototype,"aux4",void 0),(0,I._)([Ki(10,Pr)],uo.prototype,"zoomRange",void 0);class ho extends Jn{vertex(e,t){const{aux1:r,aux2:s,aux3:i,aux4:n}=e,o={...e,width:r,height:s,offset:i,scale:n.multiply(lo)},a=Zn(this,{...e,halfWidth:r.multiply(lo),referenceHalfWidth:s.multiply(lo),offset:i.multiply(lo),normal:n.subtract(128).multiply(lo)}),c=Dn(this,o),l=xs(a.isOutline,new Nr(.5));return{...a,...c,...this.maybeRunHittest(e,t,l)}}fragment(e){const{isOutline:t}=e,r=xs(t,new Nr(.5)),s=hs(r,jn(e,this.antialiasingControls.blur),Un(this,e)),i=hs(r,new Nr(1/255),new Nr(0));return this.getFragmentOutput(s,e,i)}hittest(e,t,r){return hs(r,vn(this.hittestRequest),In(this,e,t))}}(0,I._)([Zi(On)],ho.prototype,"mosaicInfo",void 0),(0,I._)([Zi(Pn)],ho.prototype,"localTileOffset",void 0),(0,I._)([(0,I.a)(0,Qi(uo)),(0,I.a)(1,Qi(xn))],ho.prototype,"vertex",null),(0,I._)([(0,I.a)(0,Qi(class extends oo{}))],ho.prototype,"fragment",null);const _o=kt.attributes,po=Vt.attributes,fo={createComputedParams:e=>e,attributes:{id:_o.id,pos:_o.pos,zoomRange:_o.zoomRange,tlbr:_o.tlbr,angle:_o.angle,color:_o.color,bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:e=>Nt(e)},aux1:{count:1,type:tt.Ck.UNSIGNED_SHORT,pack:e=>Pt(e)},aux2:{count:1,type:tt.Ck.UNSIGNED_SHORT,pack:e=>Ot(e)},aux3:{count:2,type:tt.Ck.SHORT,pack:({offsetX:e,offsetY:t})=>[(0,u.im)(e),(0,u.im)(t)]},aux4:{count:2,type:tt.Ck.UNSIGNED_BYTE,pack:({scaleX:e,scaleY:t})=>[e*co,t*co]}}},mo={createComputedParams:e=>e,attributes:{id:_o.id,pos:_o.pos,zoomRange:_o.zoomRange,tlbr:_o.tlbr,angle:_o.angle,color:po.color,bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:e=>pt([[0,!0]])},aux1:{count:1,type:tt.Ck.UNSIGNED_SHORT,pack:e=>(0,u.im)(.5*e.width)*co},aux2:{count:1,type:tt.Ck.UNSIGNED_SHORT,pack:e=>(0,u.im)(.5*e.referenceWidth)*co},aux3:{count:2,type:tt.Ck.SHORT,packTessellation:({extrusionOffsetX:e,extrusionOffsetY:t})=>[e*co,t*co]},aux4:{count:2,type:tt.Ck.UNSIGNED_BYTE,packTessellation:({normalX:e,normalY:t})=>[e*co+128,t*co+128]}}};class go extends qt{constructor(){super(...arguments),this.vertexSpec=mo}}const yo={createComputedParams:e=>e,attributes:{...Tt.attributes,...zt.attributes}},xo={createComputedParams:e=>e,attributes:{...Tt.attributes,...Vt.attributes}};class bo extends qt{constructor(){super(...arguments),this.vertexSpec=xo}}const To={createComputedParams:e=>e,attributes:{pos:{type:tt.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1},offset:{type:tt.Ck.BYTE,count:2,packAlternating:{count:4,pack:()=>[[-1,-1],[1,-1],[-1,1],[1,1]]}}}};var wo=r(86916),So=r(64696),vo=r(44444),Io=r(57880);const Eo=8388607,Ro=e=>e&Eo;var Ao=r(47656);class Mo{constructor(e,t,r,s,i,n,o,a,c=[]){this.entityTexel=e,this.anchorX=t,this.anchorY=r,this.directionX=s,this.directionY=i,this.maxScale=n,this.minScale=o,this.referenceBounds=a,this.bounds=c}serialize(e){e.push(this.entityTexel),e.writeF32(this.anchorX),e.writeF32(this.anchorY),e.writeF32(this.directionX),e.writeF32(this.directionY),e.writeF32(this.maxScale),e.writeF32(this.minScale),null===this.referenceBounds?(e.writeF32(0),e.writeF32(0),e.writeF32(0)):(e.writeF32(this.referenceBounds.size),e.writeF32(this.referenceBounds.offsetX),e.writeF32(this.referenceBounds.offsetY)),W(e,this.bounds)}static deserialize(e){const t=e.readInt32(),r=e.readF32(),s=e.readF32(),i=e.readF32(),n=e.readF32(),o=e.readF32(),a=e.readF32(),c=e.readF32(),l=e.readF32(),u=e.readF32(),h=Y(e,Ao.c)??[];return new Mo(t,r,s,i,n,o,a,{size:c,offsetX:l,offsetY:u},h)}}const Co=1024;function Fo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function No(e,t){return Math.sqrt(e*e+t*t)}function Po(e){const t=No(e[0],e[1]);e[0]/=t,e[1]/=t}function Oo(e,t){return No(e[0]-t[0],e[1]-t[1])}function ko(e){return e.length-1}function Do(e,t,r=1){const[s,i]=function(e,t){return e[t+1]}(e,t);return Math.sqrt(s*s+i*i)*r}class Uo{constructor(e,t,r,s,i){this._segments=e,this._index=t,this._distance=r,this._xStart=s,this._yStart=i,this._done=!1}static create(e){return new Uo(e,0,0,e[0][0],e[0][1])}clone(){return new Uo(this._segments,this._index,this._distance,this.xStart,this.yStart)}equals(e){return this._index===e._index||e._index===this._index-1&&(0===this._distance||1===e._distance)||e._index===this._index+1&&(1===this._distance||0===e._distance)}leq(e){return this._index<e._index||this._index===e._index&&this._distance<=e._distance}geq(e){return this._index>e._index||this._index===e._index&&this._distance>=e._distance}get _segment(){return this._segments[this._index+1]}get angle(){const e=this.dy,t=(0*e+-1*-this.dx)/(1*this.length);let r=Math.acos(t);return e>0&&(r=2*Math.PI-r),r}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:e,dy:t}=this;return Math.sqrt(e*e+t*t)}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<ko(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(e,t){const r=this.backwardLength;if(e<=r)return this._distance=(r-e)/this.length,this;let s=this.backwardLength;for(;this.prev();){if(s+this.length>e)return this._seekBackwards(e-s);s+=this.length}return this._distance=0,t?this:null}seek(e,t=!1){if(e<0)return this._seekBackwards(Math.abs(e),t);if(e<=this.remainingLength)return this._distance=(this.backwardLength+e)/this.length,this;let r=this.remainingLength;for(;this.next();){if(r+this.length>e)return this.seek(e-r,t);r+=this.length}return this._distance=1,t?this:null}}function Bo(e,t,r,s=!0){const i=function(e){let t=0;for(let r=0;r<ko(e);r++)t+=Do(e,r);return t}(e),n=Uo.create(e),o=i/2;if(!s)return n.seek(o),void(Math.abs(n.x)<Co&&Math.abs(n.y)<Co&&r(n.clone(),0,o+0*t,i));const a=Math.max((i-t)/2,0),c=Math.floor(a/t),l=o-c*t;n.seek(l);for(let e=-c;e<=c;e++)Math.abs(n.x)<Co&&Math.abs(n.y)<Co&&r(n.clone(),e,o+e*t,i),n.seek(t)}function Lo(e,t){const r=1e-6;if(t<=0)return;const s=e.length;if(s<3)return;const i=[];let n=0;i.push(0);for(let t=1;t<s;t++)n+=Oo(e[t],e[t-1]),i.push(n);t=Math.min(t,.2*n);const o=[];o.push(e[0][0]),o.push(e[0][1]);const a=e[s-1][0],c=e[s-1][1],l=Fo([0,0],e[0],e[1]);Po(l),e[0][0]+=t*l[0],e[0][1]+=t*l[1],Fo(l,e[s-1],e[s-2]),Po(l),e[s-1][0]+=t*l[0],e[s-1][1]+=t*l[1];for(let e=1;e<s;e++)i[e]+=t;i[s-1]+=t;const u=.5*t;for(let n=1;n<s-1;n++){let a=0,c=0,l=0;for(let s=n-1;s>=0&&!(i[s+1]<i[n]-u);s--){const o=u+i[s+1]-i[n],h=i[s+1]-i[s],d=i[n]-i[s]<u?1:o/h;if(Math.abs(d)<r)break;const _=d*d,p=d*o-.5*_*h,f=d*h/t,m=e[s+1],g=e[s][0]-m[0],y=e[s][1]-m[1];a+=f/p*(m[0]*d*o+.5*_*(o*g-h*m[0])-_*d*h*g/3),c+=f/p*(m[1]*d*o+.5*_*(o*y-h*m[1])-_*d*h*y/3),l+=f}for(let o=n+1;o<s&&!(i[o-1]>i[n]+u);o++){const s=u-i[o-1]+i[n],h=i[o]-i[o-1],d=i[o]-i[n]<u?1:s/h;if(Math.abs(d)<r)break;const _=d*d,p=d*s-.5*_*h,f=d*h/t,m=e[o-1],g=e[o][0]-m[0],y=e[o][1]-m[1];a+=f/p*(m[0]*d*s+.5*_*(s*g-h*m[0])-_*d*h*g/3),c+=f/p*(m[1]*d*s+.5*_*(s*y-h*m[1])-_*d*h*y/3),l+=f}o.push(a/l),o.push(c/l)}o.push(a),o.push(c);for(let t=0,r=0;t<s;t++)e[t][0]=o[r++],e[t][1]=o[r++]}var Go=r(53648);class zo{static getPlacement(e,t,r,s,i,n){const o=(0,$e.m)(r);return o?(-1===t&&e.invertY(),o.execute(e,r,s,i,n)):null}}var Vo=r(97576),qo=r(14624);class Ho{constructor(e){const{offsetX:t,offsetY:r,postAngle:s,fontSize:i,scaleFactor:n,transforms:o}=e;if(this.offsetX=t,this.offsetY=r,this.postAngle=s,this.fontSize=Math.min(i,96),this.transforms=o,o&&o.infos.length>1){const e=(0,qo.ol)(i,s,!1,t,r,o);this.fontSize=Math.min(e.size,96),this.postAngle=e.rotation,this.offsetX=e.offsetX,this.offsetY=e.offsetY}n&&(this.fontSize*=n,this.offsetX*=n,this.offsetY*=n)}}const Wo=[4,4],Yo=[16,4],Xo={topLeft:Yo,topRight:Yo,bottomLeft:Yo,bottomRight:Yo},jo=[4,2],$o=[4,6],Ko={topLeft:jo,topRight:jo,bottomLeft:$o,bottomRight:$o},Qo={topLeft:jo,topRight:$o,bottomLeft:jo,bottomRight:$o},Zo={topLeft:$o,topRight:$o,bottomLeft:Wo,bottomRight:Wo},Jo={topLeft:Wo,topRight:Wo,bottomLeft:$o,bottomRight:$o},ea={topLeft:$o,topRight:Wo,bottomLeft:$o,bottomRight:Wo},ta={topLeft:Wo,topRight:$o,bottomLeft:Wo,bottomRight:$o},ra={createComputedParams:e=>e,attributes:{pos:{type:tt.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:e,mapAligned:t})=>pt([[0,e],[3,!!t]])},zoomRange:{type:tt.Ck.UNSIGNED_SHORT,count:2,packPrecisionFactor:L.M6,packTessellation:({minZoom:e,maxZoom:t})=>[e||0,t||28]},offset:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:e})=>{const{bottomLeft:t,bottomRight:r,topLeft:s,topRight:i}=e;return[s,i,t,r]}}},textureUV:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,packTessellation:({texcoords:e})=>{const{bottomLeft:t,bottomRight:r,topLeft:s,topRight:i}=e;return[s,i,t,r]}}},color:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:e})=>e},fontSize:{type:tt.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,packTessellation:({fontSize:e})=>(0,u.im)(e)},referenceSize:{type:tt.Ck.UNSIGNED_BYTE,count:1,packPrecisionFactor:4,packTessellation:({fontSize:e},{referenceSize:t})=>(0,u.im)(t??e)},haloColor:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:e})=>ft(e)},haloFontSize:{type:tt.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:4,pack:({haloFontSize:e})=>(0,u.im)(e)},clipAngle:{type:tt.Ck.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:e})=>ia(e||0)},referenceSymbol:{type:tt.Ck.BYTE,count:4,packPrecisionFactor:1,packTessellation:(e,t)=>{if(!e.referenceBounds)return[0,0,0,0];const r=(0,Io.Ab)(t.horizontalAlignment),s=(0,Io.O4)(t.verticalAlignment),{offsetX:i,offsetY:n,size:o}=e.referenceBounds;return[(0,u.im)(i),-(0,u.im)(n),(0,u.im)(o),r+1<<2|s+1]}}}};class sa extends nt{constructor(){super(...arguments),this.vertexSpec=ra,this._textMeshParamsPropsInitialized=!1}ensurePacked(e,t,r){super.ensurePacked(e,t,r),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new Ho(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(e,t,r){const s=this._getShaping();if(!s)return;const i=t.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(e,t,s,r);if(r&&r.nextPath())return r.nextPoint(),this._writeGlyphs(e,i,r.x,r.y,s,0);if("esriGeometryPolygon"===t.geometryType){const r=t.readCentroidForDisplay();if(!r)return;const[n,o]=r.coords;return this._writeGlyphs(e,i,n,o,s,0)}if("esriGeometryMultipoint"===t.geometryType){const r=t.readGeometryForDisplay();return void r?.forEachVertex(((t,r)=>this._writeGlyphs(e,i,t,r,s,0)))}const n=t.readXForDisplay(),o=t.readYForDisplay();return this._writeGlyphs(e,i,n,o,s,0)}_writePlacedTextMarkers(e,t,r,s){const i=s??Ye.k.fromFeatureSetReaderCIM(t);if(!i)return;const n=zo.getPlacement(i,-1,this.evaluatedMeshParams.placement,(0,u.im)(1),e.id,Je());if(!n)return;const o=t.getDisplayId();let a=n.next();for(;null!=a;){const t=a.tx,s=-a.ty,i=-a.getAngle();this._writeGlyphs(e,o,t,s,r,i),a=n.next()}}_getShaping(){const e=this._textMeshTransformProps,t=this.evaluatedMeshParams;if(!t.glyphs?.glyphs.length)return null;const r=Math.round((0,u.im)(e.fontSize)),s=(0,u.im)(e.offsetX),i=(0,u.im)(e.offsetY),n=(0,Go.qk)((0,u.im)(t.lineWidth),32,512),o=L.Cq*(0,Go.qk)(t.lineHeightRatio,.25,4);return(0,Vo.C0)(t.glyphs,{scale:r/L.iK,angle:e.postAngle,xOffset:s,yOffset:i,horizontalAlignment:t.horizontalAlignment,verticalAlignment:t.verticalAlignment,maxLineWidth:n,lineHeight:o,decoration:t.decoration,borderLineSizePx:(0,u.im)(t.boxBorderLineSize),hasBackground:!!t.boxBackgroundColor,useCIMAngleBehavior:t.useCIMAngleBehavior})}_writeGlyphs(e,t,r,s,i,n,o){const a=this.evaluatedMeshParams,c=this._textMeshTransformProps,l=c.fontSize,h=(0,u.im)(c.offsetX),d=(0,u.im)(c.offsetY);0!==n&&i.setRotation(n);const _=i.bounds,p=r+_.x+h,f=s+_.y-d,m=2*(a.minPixelBuffer?a.minPixelBuffer/l:1),g=Math.max(_.width,_.height)*m;i.textBox&&(e.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),e.recordBounds(p,f,g,g),this._writeTextBox(e,t,r,s,i.textBox,o),e.recordEnd());for(const n of i.glyphs){e.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),e.recordBounds(p,f,g,g);const{texcoords:i,offsets:c}=n;this._writeQuad(e,t,r,s,{texcoords:i,offsets:c,fontSize:l,color:ft(a.color),isBackground:!1,referenceBounds:o}),e.recordEnd()}0!==n&&i.setRotation(-n)}_writeTextBox(e,t,r,s,i,n,o){const a=this.evaluatedMeshParams,{fontSize:c}=this._textMeshTransformProps,{boxBackgroundColor:l,boxBorderLineColor:u}=a,h={isBackground:!0,fontSize:c,referenceBounds:n,...o};l&&(this._writeQuad(e,t,r,s,{texcoords:Xo,offsets:i.main,color:ft(l),...h}),u||(this._writeQuad(e,t,r,s,{texcoords:Zo,offsets:i.top,color:ft(l),...h}),this._writeQuad(e,t,r,s,{texcoords:Jo,offsets:i.bot,color:ft(l),...h}),this._writeQuad(e,t,r,s,{texcoords:ea,offsets:i.left,color:ft(l),...h}),this._writeQuad(e,t,r,s,{texcoords:ta,offsets:i.right,color:ft(l),...h}))),u&&(this._writeQuad(e,t,r,s,{texcoords:Ko,offsets:i.top,color:ft(u),...h}),this._writeQuad(e,t,r,s,{texcoords:Ko,offsets:i.bot,color:ft(u),...h}),this._writeQuad(e,t,r,s,{texcoords:Qo,offsets:i.left,color:ft(u),...h}),this._writeQuad(e,t,r,s,{texcoords:Qo,offsets:i.right,color:ft(u),...h}))}_writeQuad(e,t,r,s,i){const n=e.vertexCount();this._writeVertex(e,t,r,s,i),e.indexWrite(n+0),e.indexWrite(n+1),e.indexWrite(n+2),e.indexWrite(n+1),e.indexWrite(n+3),e.indexWrite(n+2)}}const ia=e=>Math.round(e*(254/360)),na=(0,wo.sB)((e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t})),oa={createComputedParams:e=>e,attributes:{...Bt.attributes,bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:({shouldSampleAlphaOnly:e,shouldScaleDash:t,isSDF:r})=>pt([[4,e],[2,t],[3,r]])},tlbr:{type:tt.Ck.UNSIGNED_SHORT,count:4,pack:({sprite:e})=>{const{rect:t,width:r,height:s}=e,i=t.x+L.mc,n=t.y+L.mc;return[i,n,i+r,n+s]}},accumulatedDistance:{type:tt.Ck.UNSIGNED_SHORT,count:1,packTessellation:({distance:e})=>e},segmentDirection:{type:tt.Ck.BYTE,count:2,packPrecisionFactor:16,packTessellation:({directionX:e,directionY:t})=>[e,t]}}};class aa{static from(e){return"width"in e?this.fromSimpleMeshParams(e):this.fromComplexMeshParams(e)}static fromSimpleMeshParams(e){const t=new aa(e.sprite,e.color,e.outlineColor,e.minPixelBuffer,e.placement,e.scaleInfo,e.effects),{type:r,width:s,height:i,angle:n,outlineSize:o,referenceSize:a,sprite:c,overrideOutlineColor:l}=e;return t.rawWidth=(0,u.im)(s),t.rawHeight=(0,u.im)(i),t.angle=n,t.outlineSize=(0,u.im)(o),t.referenceSize=(0,u.im)(a),t.overrideOutlineColor=l,t.offsetX=(0,u.im)(e.offsetX),t.offsetY=(0,u.im)(e.offsetY),"simple"!==r||c.sdf||(t.rawWidth=c.width,t.rawHeight=c.height),t.sizeRatio=c.sdf?2:1,t._computeSize(e,!1),t}static fromComplexMeshParams(e){const t=new aa(e.sprite,e.color,e.outlineColor,e.minPixelBuffer,e.placement,e.scaleInfo,e.effects);let{alignment:r,transforms:s,size:i,scaleX:n,anchorX:o,anchorY:a,angle:c,colorLocked:l,frameHeight:h,widthRatio:d,offsetX:_,offsetY:p,outlineSize:f,referenceSize:m,scaleFactor:g,sizeRatio:y,isAbsoluteAnchorPoint:x,rotateClockwise:b,scaleSymbolsProportionally:T,sprite:w}=e;if(s&&s.infos.length>0){const e=(0,qo.ol)(i,c,b,_,p,s);i=e.size,c=e.rotation,_=e.offsetX,p=e.offsetY,b=!1}g&&(i*=g,_*=g,p*=g);const S=n*(w.width/w.height);t.alignment=r,t.rawHeight=(0,u.im)(i),t.rawWidth=t.rawHeight*S,t.referenceSize=(0,u.im)(m),t.sizeRatio=y,t.angle=c,t.rotateClockwise=b,t.anchorX=o,t.anchorY=a,t.offsetX=(0,u.im)(_),t.offsetY=(0,u.im)(p),x&&i&&(w.sdf?t.anchorX=o/(i*d):t.anchorX=o/(i*S),t.anchorY=a/i);const v=T&&h?i/h:1;return t.outlineSize=0===f||isNaN(f)?0:(0,u.im)(f)*v,t.scaleSymbolsProportionally=T,t.colorLocked=l,t._computeSize(e,!0),t}constructor(e,t,r,s,i,n,o){this.sprite=e,this.color=t,this.outlineColor=r,this.minPixelBuffer=s,this.placement=i,this.scaleInfo=n,this.effects=o,this.rawWidth=0,this.rawHeight=0,this.angle=0,this.outlineSize=0,this.referenceSize=0,this.sizeRatio=1,this.alignment=ht.yu.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(e,t){const{sprite:r,hasSizeVV:s}=e,i=!!r.sdf,{rawWidth:n,rawHeight:o,sizeRatio:a,outlineSize:c}=this,l=n*a,u=o*a;if(i&&!s){const e=t&&n>o?l:n,r=o,s=c+2;this.computedWidth=Math.min(e+s,l),this.computedHeight=Math.min(r+s,u)}else this.computedWidth=l,this.computedHeight=u;const h=i?L.y/Math.max(l,u):1,d=.5*(l-this.computedWidth)*h,_=.5*(u-this.computedHeight)*h,p=r.rect.x+L.mc+d,f=r.rect.y+L.mc+_,m=p+r.width-2*d,g=f+r.height-2*_;this.texXmin=Math.floor(p),this.texYmin=Math.floor(f),this.texXmax=Math.ceil(m),this.texYmax=Math.ceil(g),this.computedWidth*=(this.texXmax-this.texXmin)/(m-p),this.computedHeight*=(this.texYmax-this.texYmin)/(g-f),this.anchorX*=l/this.computedWidth,this.anchorY*=u/this.computedHeight}}const ca=0,la=1,ua=2,ha=3,da=4,_a=3.14159265359/180,pa=128/Math.PI;const fa={createComputedParams:e=>aa.from(e),attributes:{pos:{type:tt.Ck.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:({sprite:e,alignment:t,scaleSymbolsProportionally:r,overrideOutlineColor:s,colorLocked:i})=>{let n=0;return e.sdf&&(n|=_t(ca)),t===ht.yu.MAP&&(n|=_t(la)),r&&(n|=_t(ua)),s&&(n|=_t(ha)),i&&(n|=_t(da)),n}},zoomRange:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:L.M6,pack:({scaleInfo:e},{tileInfo:t})=>dt(e,t)},offset:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({angle:e,computedWidth:t,computedHeight:r,anchorX:s,anchorY:i,offsetX:n,offsetY:o,rotateClockwise:a})=>{const c=function(e,t,r,s,i=!1){const n=(0,vo.Su)(),o=i?1:-1;return e?(0,So.IT)(n,o*_a*e):(0,So.ZX)(n),(t||r)&&(0,So.GS)(n,n,[t,-r]),s&&(0,So.c9)(n,n,o*_a*-s),n}(0,n,o,-e,a),l=-(.5+s)*t,u=-(.5-i)*r,h=[l,u],d=[l+t,u],_=[l,u+r],p=[l+t,u+r];return(0,F.m4)(h,h,c),(0,F.m4)(d,d,c),(0,F.m4)(_,_,c),(0,F.m4)(p,p,c),[h,d,_,p]}}},textureUV:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:({texXmax:e,texXmin:t,texYmax:r,texYmin:s})=>[[t,s],[e,s],[t,r],[e,r]]}},color:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({color:e})=>ft(e)},outlineColor:{type:tt.Ck.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:e})=>ft(e)},sizing:{type:tt.Ck.UNSIGNED_BYTE,count:4,pack:({rawWidth:e,rawHeight:t,outlineSize:r,referenceSize:s})=>[mt(Math.max(e,t),128),mt(r,128),mt(s,128),0]},placementAngle:{type:tt.Ck.UNSIGNED_BYTE,count:1,packTessellation:({placementAngle:e})=>function(e){return function(e,t){return e%=256,Math.abs(e>=0?e:e+256)}(e*pa)}(e)},sizeRatio:{type:tt.Ck.UNSIGNED_SHORT,count:1,packPrecisionFactor:64,pack:({sizeRatio:e})=>e}}},ma={createComputedParams:e=>e,attributes:{pos:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:10,pack:"position"},id:{type:tt.Ck.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:e=>0},offset:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:16,packAlternating:{count:4,pack:({size:e})=>{const t=(0,u.im)(e),r=-t/2,s=-t/2;return[[r,s],[r+t,s],[r,s+t],[r+t,s+t]]}}},texCoords:{type:tt.Ck.SHORT,count:2,packPrecisionFactor:4,packAlternating:{count:4,pack:()=>[[0,1],[1,1],[0,0],[1,0]]}},size:{type:tt.Ck.UNSIGNED_BYTE,count:2,pack:({size:e})=>[e,e]},referenceSize:{type:tt.Ck.UNSIGNED_BYTE,count:1,pack:({size:e})=>(0,u.im)(e)},zoomRange:{type:tt.Ck.UNSIGNED_BYTE,count:2,pack:({scaleInfo:e},{tileInfo:t})=>dt(e,t)}}},ga=function(e){const t={};for(const r in e){const s={name:r,constructor:e[r]};t[r]=s}return t}({FillMeshWriter:bt,DotDensityMeshWriter:class extends at{constructor(){super(...arguments),this.vertexSpec=ct}createTesselationParams(e){return{inverseArea:1/e.readGeometryArea()}}},ComplexFillMeshWriter:class extends wt{constructor(){super(...arguments),this.vertexSpec=kt}},PatternFillMeshWriter:wt,OutlineFillMeshWriter:Ht,PatternOutlineFillMeshWriter:class extends Ht{constructor(){super(...arguments),this.vertexSpec=yo}_createOutlineWriter(e,t,r,s){return new bo(e,t,r,s)}_write(e,t,r){const s=r?.asOptimized()??t.readGeometryForDisplay(),i=this._clip(s);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;e.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(e,t,i),this._lineMeshWriter.writeLineVertices(e,Ye.k.fromOptimizedCIM(i,"esriGeometryPolyline"),t),e.recordEnd()}ensurePacked(e,t,r){super.ensurePacked(e,t,r),this._lineMeshWriter.ensurePacked(e,t,r)}enqueueRequest(e,t,r){super.enqueueRequest(e,t,r),this._lineMeshWriter.enqueueRequest(e,t,r)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}},ComplexOutlineFillMeshWriter:class extends Ht{constructor(){super(...arguments),this.vertexSpec=fo}_createOutlineWriter(e,t,r,s){return new go(e,t,r,s)}_write(e,t,r){const s=r?.asOptimized()??t.readGeometryForDisplay(),i=this._clip(s);if(!i)return;const n=this.evaluatedMeshParams.sprite?.textureBinding;e.recordStart(this.instanceId,this.attributeLayout,n),this._writeGeometry(e,t,i),this._lineMeshWriter.writeLineVertices(e,Ye.k.fromOptimizedCIM(i,"esriGeometryPolyline"),t),e.recordEnd()}ensurePacked(e,t,r){super.ensurePacked(e,t,r),this._lineMeshWriter.ensurePacked(e,t,r)}enqueueRequest(e,t,r){super.enqueueRequest(e,t,r),this._lineMeshWriter.enqueueRequest(e,t,r)}async loadDependencies(){await Promise.all([super.loadDependencies(),this._lineMeshWriter.loadDependencies()])}},MarkerMeshWriter:class extends nt{constructor(){super(...arguments),this.vertexSpec=fa}getBoundsInfo(){return this.evaluatedMeshParams.boundsInfo}_write(e,t,r){const s=this.evaluatedMeshParams.sprite?.textureBinding,i=t.getDisplayId();e.recordStart(this.instanceId,this.attributeLayout,s);const n=this.evaluatedMeshParams.minPixelBuffer,o=Math.max(this.evaluatedMeshParams.computedWidth,n),a=Math.max(this.evaluatedMeshParams.computedHeight,n),c=this.evaluatedMeshParams.offsetX,l=-this.evaluatedMeshParams.offsetY;if(null!=this.evaluatedMeshParams.placement)this._writePlacedMarkers(e,t,r,o,a);else if(r&&r.nextPath()){r.nextPoint();const t=r.x,s=r.y;e.recordBounds(t+c,s+l,o,a),this._writeQuad(e,i,t,s)}else if("esriGeometryPolygon"===t.geometryType){const r=t.readCentroidForDisplay();if(!r)return;const[s,n]=r.coords;e.recordBounds(s+c,n+l,o,a),this._writeQuad(e,i,s,n)}else if("esriGeometryPoint"===t.geometryType){const r=t.readXForDisplay(),s=t.readYForDisplay();e.recordBounds(r+c,s+l,o,a),this._writeQuad(e,i,r,s)}else{const r=t.readGeometryForDisplay();r?.forEachVertex(((t,r)=>{e.recordBounds(t+c,r+l,o,a),Math.abs(t)>Co||Math.abs(r)>Co||this._writeQuad(e,i,t,r)}))}e.recordEnd()}_writePlacedMarkers(e,t,r,s,i){const n=r??Ye.k.fromFeatureSetReaderCIM(t)?.clone();if(!n)return;const o=zo.getPlacement(n,-1,this.evaluatedMeshParams.placement,(0,u.im)(1),e.id,Je());if(!o)return;const a=t.getDisplayId();let c=o.next();const l=this.evaluatedMeshParams.offsetX,h=-this.evaluatedMeshParams.offsetY;for(;null!=c;){const t=c.tx,r=-c.ty;if(Math.abs(t)>Co||Math.abs(r)>Co){c=o.next();continue}const n=-c.getAngle();e.recordBounds(t+l,r+h,s,i),this._writeQuad(e,a,t,r,n),c=o.next()}}_writeQuad(e,t,r,s,i){const n=e.vertexCount(),o=null==i?null:{placementAngle:i};this._writeVertex(e,t,r,s,o),e.indexWrite(n+0),e.indexWrite(n+1),e.indexWrite(n+2),e.indexWrite(n+1),e.indexWrite(n+3),e.indexWrite(n+2)}},PieChartMeshWriter:class extends nt{constructor(){super(...arguments),this.vertexSpec=ma}_write(e,t){const r=t.getDisplayId(),s=this.evaluatedMeshParams.minPixelBuffer,i=Math.max((0,u.im)(this.evaluatedMeshParams.size),s);let n,o;if("esriGeometryPoint"===t.geometryType)n=t.readXForDisplay(),o=t.readYForDisplay();else{const e=t.readCentroidForDisplay();if(!e)return;n=e?.coords[0],o=e?.coords[1]}e.recordStart(this.instanceId,this.attributeLayout),e.recordBounds(n,o,i,i);const a=e.vertexCount();this._writeVertex(e,r,n,o),e.indexWrite(a+0),e.indexWrite(a+1),e.indexWrite(a+2),e.indexWrite(a+1),e.indexWrite(a+3),e.indexWrite(a+2),e.recordEnd()}},TextMeshWriter:sa,LineMeshWriter:Gt,TexturedLineMeshWriter:class extends Gt{constructor(e,t,r,s){super(e,t,r,s),this.vertexSpec=oa,this._tessellationOptions.textured=!0}_write(e,t,r){const s=r??Ye.k.fromFeatureSetReaderCIM(t);if(!s)return;const{sprite:i}=this.evaluatedMeshParams;this._writeGeometry(e,t,s,i?.textureBinding)}},HeatmapMeshWriter:class extends nt{constructor(){super(...arguments),this.vertexSpec=To}_write(e,t){e.recordStart(this.instanceId,this.attributeLayout);const r=t.getDisplayId();if("esriGeometryPoint"===t.geometryType){const s=t.readXForDisplay(),i=t.readYForDisplay();this._writeQuad(e,r,s,i)}else if("esriGeometryMultipoint"===t.geometryType){const s=t.readGeometryForDisplay();s?.forEachVertex(((t,s)=>{t>=0&&t<=512&&s>=0&&s<=512&&this._writeQuad(e,r,t,s)}))}e.recordEnd()}_writeQuad(e,t,r,s){const i=e.vertexCount();this._writeVertex(e,t,r,s),e.indexWrite(i+0),e.indexWrite(i+1),e.indexWrite(i+2),e.indexWrite(i+1),e.indexWrite(i+3),e.indexWrite(i+2)}},LabelMeshWriter:class extends sa{constructor(){super(...arguments),this._zoomLevel=0}_write(e,t,r,s){if(this._zoomLevel=s||0,null!=r)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const r=t.readXForDisplay(),s=t.readYForDisplay();return this._writePoint(e,r,s,t)}case"esriGeometryEnvelope":case"esriGeometryPolygon":case"esriGeometryMultipoint":{const r=t.readCentroidForDisplay();if(!r)return;const[s,i]=r.coords;return this._writePoint(e,s,i,t)}case"esriGeometryPolyline":{const r=t.readLegacyGeometryForDisplay();this._writeLines(e,t,r)}}}_writePoint(e,t,r,s){const i=this._getShaping();if(!i)return;let n=this._getPointReferenceBounds();n||(n={offsetX:0,offsetY:0,size:0});const o=i.boundsT,a=(0,Io.YT)(this.evaluatedMeshParams.horizontalAlignment),c=(0,Io.OS)(this.evaluatedMeshParams.verticalAlignment),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,u=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=Ro(s.getDisplayId());e.metricStart(new Mo(h,t,r,a,c,l,u,n)),e.metricBoxWrite(o),this._writeGlyphs(e,s.getDisplayId(),t,r,i,0,n),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t,r){const{repeatLabel:s,scaleInfo:i}=this.evaluatedMeshParams,n=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping();if(!o)return;this._current={out:e,id:t.getDisplayId(),shaping:o,zoomRange:dt(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0}};const a=function(e,t){const r=t;for(let t=0;t<e.length;t++){let s=e[t];Lo(s,r);const i=[];i.push(s[0]);for(let e=1;e<s.length;e++){const[t,r]=s[e-1],[n,o]=s[e],a=n-t,c=o-r;i.push([a,c])}e[t]=i,s=i}return e}(r.paths,o.bounds.width),c=this._placeSubdivGlyphs.bind(this),l=(o.bounds.width+n)/2;for(const e of a)Bo(e,l,c,!!s)}_placeSubdivGlyphs(e,t,r,s){const{allowOverrun:i,labelPosition:n,repeatLabelDistance:o}=this.evaluatedMeshParams,a=this._current.zoomRange[0],c=na(t),l=this._current.shaping.bounds.width/2,u=Math.sqrt(o||128)/2,h=Math.min(r,s-r),d=this._current.shaping.isMultiline?28:Math.log2(h/(u+l/2)),_=0===t?d:Math.min(c,d),p=Math.max(a,this._zoomLevel+1-_),f=this._zoomLevel-p,m=this._current.shaping.bounds.width/2*2**f;this._current.shaping.isMultiline?0===t&&this._placeStraight(e,p):i&&f<0?this._placeStraightAlong(e,a):"parallel"===n?this._placeStraightAlong(e,p):"curved"===n&&this._placeCurved(e,p,m)}_placeStraight(e,t){const{out:r,id:s,shaping:i,zoomRange:n,referenceBounds:o}=this._current,{x:a,y:c}=e,l=e.angle*(180/Math.PI)%360,u=(e.angle*(180/Math.PI)+180)%360;if(i.textBox){const a=Math.max(t,n[0],0),c=Math.min(28,n[1]),h=(0,So.IT)((0,vo.Su)(),-e.angle),[d,_]=i.shapeBackground(h),p={minZoom:a,maxZoom:c,clipAngle:l,mapAligned:!0,isLineLabel:!0};r.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),this._writeTextBox(r,s,e.x,e.y,_,o,p),r.recordEnd(),p.clipAngle=u,r.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),this._writeTextBox(r,s,e.x,e.y,_,o,p),r.recordEnd()}for(const h of i.glyphs)h.minZoom=t,h.maxZoom=n[1],h.angle=e.angle,this._writeLineGlyph(r,s,a,c,i.bounds,h,l,o,!0),h.angle=e.angle+Math.PI,this._writeLineGlyph(r,s,a,c,i.bounds,h,u,o,!0)}_placeCurved(e,t,r){const{out:s,id:i}=this._current,n=e.clone(),o=e.angle*(180/Math.PI)%360,a=(e.angle*(180/Math.PI)+180)%360,c=Ro(i),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,u=this.evaluatedMeshParams.scaleInfo?.minScale??0;s.metricStart(new Mo(c,e.x,e.y,0,0,l,u,null)),this._placeFirst(n,t,1,o),this._placeBack(e,n,t,r,1,o),this._placeForward(e,n,t,r,1,o),this._placeFirst(n,t,0,a),this._placeBack(e,n,t,r,0,a),this._placeForward(e,n,t,r,0,a),s.metricEnd()}_placeStraightAlong(e,t){const{out:r,id:s,shaping:i,zoomRange:n,referenceBounds:o}=this._current,{boxBorderLineColor:a,boxBackgroundColor:c}=this.evaluatedMeshParams,l=e.clone(),u=e.angle*(180/Math.PI)%360,h=(e.angle*(180/Math.PI)+180)%360;if(i.glyphs.length>0&&(a||c)){const a=Math.max(t,n[0],0),c=Math.min(28,n[1]),l=(0,So.IT)((0,vo.Su)(),-e.angle),[d,_]=i.shapeBackground(l),p={minZoom:a,maxZoom:c,clipAngle:u,mapAligned:!0,isLineLabel:!0};r.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),this._writeTextBox(r,s,e.x,e.y,_,o,p),r.recordEnd(),p.clipAngle=h,r.recordStart(this.instanceId,this.attributeLayout,i.glyphs[0].textureBinding),this._writeTextBox(r,s,e.x,e.y,_,o,p),r.recordEnd()}const d=Ro(s),_=this.evaluatedMeshParams.scaleInfo?.maxScale??0,p=this.evaluatedMeshParams.scaleInfo?.minScale??0;r.metricStart(new Mo(d,e.x,e.y,0,0,_,p,null)),this._placeFirst(l,t,1,u,!0),this._placeFirst(l,t,0,h,!0),r.metricEnd()}_placeBack(e,t,r,s,i,n){const o=e.clone();let a=e.backwardLength+0;for(;o.prev()&&!(a>=s);)this._placeOnSegment(o,t,a,r,-1,i,n),a+=o.length+0}_placeForward(e,t,r,s,i,n){const o=e.clone();let a=e.remainingLength+0;for(;o.next()&&!(a>=s);)this._placeOnSegment(o,t,a,r,1,i,n),a+=o.length+0}_placeFirst(e,t,r,s,i=!1){const n=e,{out:o,id:a,shaping:c,zoomRange:l,referenceBounds:u}=this._current,h=c.glyphs;for(const d of h){const h=d.x>c.bounds.x?r:1-r,_=h*e.remainingLength+(1-h)*e.backwardLength,p=Math.abs(d.x+d.width/2-c.bounds.x),f=Math.max(0,this._zoomLevel+Math.log2(p/(_+0))),m=Math.max(t,i?0:f);d.maxZoom=Math.min(l[1],28),d.angle=e.angle+(1-r)*Math.PI,d.minZoom=Math.max(l[0],m),o.metricBoxWrite(d.bounds),this._writeLineGlyph(o,a,n.x,n.y,c.bounds,d,s,u,!0)}}_placeOnSegment(e,t,r,s,i,n,o){const{out:a,id:c,shaping:l,referenceBounds:u}=this._current,h=l.glyphs,d=e.dx/e.length,_=e.dy/e.length,p={x:e.x+r*-i*d,y:e.y+r*-i*_};for(const t of h){const h=t.x>l.bounds.x?n:1-n;if(!(h&&1===i||!h&&-1===i))continue;const d=Math.abs(t.x+t.width/2-l.bounds.x),_=Math.max(0,this._zoomLevel+Math.log2(d/r)-.1),f=Math.max(s,this._zoomLevel+Math.log2(d/(r+e.length+0)));0!==_&&(t.angle=e.angle+(1-n)*Math.PI,t.minZoom=f,t.maxZoom=_,this._writeLineGlyph(a,c,p.x,p.y,l.bounds,t,o,u,!0))}}_writeLineGlyph(e,t,r,s,i,n,o,a,c){const l=r+i.x,u=s+i.y,h=2*(this.evaluatedMeshParams.minPixelBuffer?this.evaluatedMeshParams.minPixelBuffer/this._textMeshTransformProps.fontSize:1),d=Math.max(i.width,i.height)*h;e.recordStart(this.instanceId,this.attributeLayout,n.textureBinding),e.recordBounds(l,u,d,d);const{texcoords:_,offsets:p}=n,f=this._textMeshTransformProps.fontSize;this._writeQuad(e,t,r,s,{texcoords:_,offsets:p,fontSize:f,color:ft(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:c,isLineLabel:!0}),e.recordEnd()}}});async function ya(e,t,r,s){return Promise.all(r.map((r=>async function(e,t,r,s,i,n,o){const a=ga[r],c=await _e.create(e,t,i),l=new a.constructor(s,c,n,o);return await l.loadDependencies(),l}(e,t,r.meshWriterName,r.id,r.options,s,r.optionalAttributes))))}class xa{constructor(){this._defaultResult=null,this._backgroundFillResult=null}static async from(e,t,r,s){const i=new xa;return i.setDefault(await ya(e,t,r.meshes,s)),i}size(){return 1}getDefault(){return this._defaultResult}setDefault(e){this._defaultResult=e}getBackgroundFill(){return this._backgroundFillResult}setBackgroundFill(e){this._backgroundFillResult=e}match(e,t){const r=this.doMatch(e,t)||this.getDefault();if(r&&r.length>0){const e=this.getBackgroundFill();if(e)return[...e,...r]}return r}getSortKey(e,t){return 0}doMatch(e,t){return null}async fetchResources(e,t){}}class ba extends xa{static async fromDictionaryRenderer(e,t,r){return new ba(e,t,r)}constructor(e,t,r){super(),this._storage=e,this._schema=t,this._viewParams=r,this._hashToGroup=new Map}get fieldMap(){return this._schema.fieldMap}async fetchResources(e,t){const r=t.getCursor(),s=[];for(;r.next();)s.push(this._updateMeshWriterGroup(e,r));await Promise.all(s)}match(e,t){const r=e.getAttributeHash();return this._hashToGroup.get(r)}async _updateMeshWriterGroup(e,t){const r=t.readLegacyFeatureForDisplay(),s=t.getAttributeHash();if(this._hashToGroup.has(s))return;this._hashToGroup.set(s,null);const i=await e.fetchDictionaryResourceImmediate({type:"dictionary-request",feature:r});if(!i)return;const n=await ya(this._storage,e,i.meshes,this._viewParams);this._hashToGroup.set(s,n)}}class Ta extends xa{constructor(e,t){super(),this._intervals=[],this._isMaxInclusive=t,this._field=e}static async fromIntervalSchema(e,t,r,s){const i=await e.createComputedField(r),n=new Ta(i,r.isMaxInclusive);await Promise.all(r.intervals.map((async r=>{const i=await ya(e,t,r.meshes,s);n.add(r,i)})));const o=await ya(e,t,r.defaultSymbol,s);n.setDefault(o);const a=await ya(e,t,r.backgroundFill,s);return n.setBackgroundFill(a),n}add(e,t){this._intervals.push({interval:e,result:t}),this._intervals.sort(((e,t)=>e.interval.min-t.interval.min))}size(){return super.size()+this._intervals.length}doMatch(e,t){const r=this._field?.read(e,t);if(null==r||isNaN(r)||r===1/0||r===-1/0)return null;for(let e=0;e<this._intervals.length;e++){const{interval:t,result:s}=this._intervals[e],i=r>=t.min,n=this._isMaxInclusive?r<=t.max:r<t.max;if(i&&n)return s}return null}}class wa extends xa{static async fromLabelSchema(e,t,r,s){const i=r.classes.map((async r=>{const i=await ya(e,t,r.meshes,s);return{minScale:r.minScale,maxScale:r.maxScale,meshes:i,expression:null,where:await e.createWhereClause(r.where)}})),n=await Promise.all(i);return new wa(n)}constructor(e){super(),this._labels=e}match(e,t){if(!this._labels.length)return null;const r=this._getLabels(t.$view.scale),s=[];for(const t of r)t.where&&!t.where(e)||s.push(...t.meshes);return s}_getLabels(e){return this._labels.filter((t=>this._validForTileScale(t,e)))}_validForTileScale(e,t){const r=t-t/4,s=t+t/2;return(!e.minScale||e.minScale>=r)&&(!e.maxScale||e.maxScale<=s)}}class Sa extends xa{constructor(e,t){super(),this._defaultSymbolSortKey=0,this._nullResult=null,this._resultsMap=new Map,this._fields=[],this._fields=e,this._separator=t||""}static async fromMatcherSchema(e,t,r,s){const i=r.expression?[e.createComputedField({expression:r.expression})]:[r.field?e.createComputedField({field:r.field}):null,r.field2?e.createComputedField({field:r.field2}):null,r.field3?e.createComputedField({field:r.field3}):null],n=(await Promise.all(i)).filter((e=>!!e)),o=new Sa(n,r.fieldDelimiter),a=await ya(e,t,r.defaultSymbol,s);o.setDefault(a);const c=await ya(e,t,r.backgroundFill,s);return o.setBackgroundFill(c),await Promise.all(r.map.map((async(r,i)=>{const n=await ya(e,t,r.symbol,s);"<Null>"===r.value?o.setNullResult(n):o.add(r.value,n,i+1)}))),o}setNullResult(e){this._nullResult=e}getSortKey(e,t){const r=this._getValueFromFields(e,t);if(null==r||""===r||"<Null>"===r)return 0;const s=this._resultsMap.get(r.toString());return s?s.sortKey:this._defaultSymbolSortKey}add(e,t,r){this._resultsMap.set(e.toString(),{meshWriters:t,sortKey:r}),this._defaultSymbolSortKey=Math.max(this._defaultSymbolSortKey,r+1)}size(){return super.size()+this._resultsMap.size}doMatch(e,t){const r=this._getValueFromFields(e,t);if(null!==this._nullResult&&(null==r||""===r||"<Null>"===r))return this._nullResult;if(null==r)return null;const s=r.toString();return this._resultsMap.get(s)?.meshWriters}_getValueFromFields(e,t){const r=[];for(const s of this._fields){const i=s.read(e,t);null==i||""===i?r.push("<Null>"):r.push(i)}return r.join(this._separator)}}async function va(e,t,r,s){switch(r.type){case"simple":case"heatmap":case"dot-density":case"pie-chart":return xa.from(e,t,r,s);case"interval":return Ta.fromIntervalSchema(e,t,r,s);case"dictionary":return ba.fromDictionaryRenderer(e,r,s);case"label":return wa.fromLabelSchema(e,t,r,s);case"map":return Sa.fromMatcherSchema(e,t,r,s);case"subtype":return Ia.fromSubtypes(e,t,r,s);case"cluster":return Ea.fromClusterSchema(e,t,r,s);default:throw new Error("Impl")}}class Ia extends xa{constructor(e,t){super(),this._subMatchers=e,this._subtypeField=t}static async fromSubtypes(e,t,r,s){const i=new Map,n=[];for(const o in r.renderers){const a=parseInt(o,10),c=va(e,t,r.renderers[o],s).then((e=>i.set(a,e)));n.push(c)}return await Promise.all(n),new Ia(i,r.subtypeField)}match(e,t){const r=e.readAttribute(this._subtypeField),s=this._subMatchers.get(r);return s?s.match(e,t):null}}class Ea extends xa{static async fromClusterSchema(e,t,r,s){const[i,n]=await Promise.all([va(e,t,r.feature,s),va(e,t,r.cluster,s)]);return new Ea(i,n)}constructor(e,t){super(),this._featureMatcher=e,this._clusterMatcher=t}match(e,t){return 1===e.readAttribute("cluster_count")?this._featureMatcher.match(e,t):this._clusterMatcher.match(e,t)}}class Ra extends ee{static async create(e,t,r,s){const i=await va(e,t,r.symbology,s),n=r.labels?await va(e,t,r.labels,s):null;return new Ra(i,n)}constructor(e,t){super(),this._symbology=e,this._labels=t}destroy(){}async enqueueMatcherRequests(e,t){await Promise.all([this._symbology.fetchResources(e,t),this._labels?.fetchResources(e,t)])}enqueueWriterRequests(e,t,r){const s=this._symbology.match(t,r);if(s){for(const i of s)i.enqueueRequest(e,t,r);if(this._labels){const s=this._labels.match(t,r);if(!s)return;for(const i of s)i.enqueueRequest(e,t,r)}}}write(e,t,r,s,i){const n=this._symbology.match(r,s);if(n){for(const o of n)o.write(e,t,r,s,i);if(e.entityRecordCount()>=1&&this._labels){const o=this._labels.match(r,s);if(!o)return;for(const a of o)a.setReferences(n),a.write(e,t,r,s,i)}}}getSortKey(e,t){return this._symbology.getSortKey(e,t)}}class Aa{}class Ma extends Aa{constructor(e){super(),this._fetcher=e,this._controller=new AbortController,this._pendingIds=new Set,this._pendingRequests=[],this._resourceIdToResource=new Map}destory(){this._controller.abort()}get _abortOptions(){return{signal:this._controller.signal}}enqueueRequest(e){const t=function(e){return"url"in e&&"urlHash"in e?{...e,url:""}:e}(e.resource),r=(0,se.sV)(JSON.stringify(t));return this._pendingIds.has(r)||(this._pendingIds.add(r),this._pendingRequests.push({...e,resourceId:r})),r}async fetchEnqueuedResources(){const e=this._pendingRequests;this._pendingIds.clear(),this._pendingRequests=[];const t=await this._fetcher.fetch(e,this._abortOptions);for(let r=0;r<t.length;r++){const s=e[r].resourceId;this._resourceIdToResource.set(s,t[r])}}async fetchResourceImmediate(e){const t=await this._fetcher.fetch([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch resources");return t[0]}async fetchDictionaryResourceImmediate(e){const t=await this._fetcher.fetchDictionary([e],this._abortOptions);if(1!==t.length)throw new Error("FeaturePipelineResourceProxy: failed to fetch dictionary resources");return t[0]}getResource(e){return this._resourceIdToResource.get(e)}}var Ca=r(59612),Fa=r(97088),Na=r(34888);class Pa{static async create(e,t){if("count"===t.statisticType){const e=new ce(1);return new Pa(t.name,t.alias,t.type,t.statisticType,e)}const r=await e.createComputedField({expression:t.onStatisticExpression?.expression,field:t.onStatisticField});return new Pa(t.name,t.alias,t.type,t.statisticType,r)}constructor(e,t,r,s,i){this.name=e,this.alias=t,this.type=r,this.statisticType=s,this.computed=i}}var Oa=r(77860),ka=r(77048),Da=r(51752),Ua=r(47302);class Ba{constructor(e){this.subscription=e,this.handledChunks=new Set}destroy(){}}class La{constructor(e,t){this._source=e,this._attributeStore=t,this._sendStates=new Map}destroy(){}get enablePixelBuffering(){return!0}onSubscribe(e){const t=this.createState(e);this._sendStates.set(e.key.id,t),this.updateChunks()}onUnsubscribe(e){this._sendStates.get(e.key.id)?.destroy(),this._sendStates.delete(e.key.id)}invalidate(){const e=Array.from(this._sendStates.values());this._sendStates.clear();for(const t of e)t.destroy(),this.onSubscribe(t.subscription)}invalidateAttributeData(){}getFeatureObjectIdsForAggregate(e){throw new Error("InternalError: AggregateId lookup not supported")}getDisplayIds(e){return this.displayMap(e,(e=>e),(e=>e))}getDisplayAndObjectIds(e){return this.displayMap(e,(e=>e),((e,t,r)=>[e,r]))}}class Ga extends La{constructor(e,t,r,s){super(e,t),this.spatialReference=r,this.aggregateFields=s,this.events=new Oa.c,this.featureAdapter=Da.u}get aggregateQueryEngine(){return this._aggregateQueryEngine||(this._aggregateQueryEngine=new Ua.U({featureStore:this,fieldsIndex:this._metadata.fieldsIndex,geometryType:this._metadata.geometryType,objectIdField:this._metadata.objectIdField,spatialReference:this.spatialReference})),this._aggregateQueryEngine}removeChunks(e){}forEach(e){return this.forEachAggregateWorldSpace(e)}forEachInBounds(e,t){}forEachBounds(e,t){const r=(0,ka.Su)();for(const s of e){const e=(0,Fa.C_)(r,s.geometry,!1,!1);e&&t(e)}}}class za{constructor(e,t,r,s,i){this.subscription=e,this.reader=t,this.clear=r,this.end=s,this.debugInfo=i,this.type="append"}get id(){return this.subscription.tile.id}createMessage(e,t,r){return{type:"append",clear:this.clear,id:this.id,append:e,end:this.end,debugInfo:this.debugInfo,subscriptionVesrion:this.subscription.version,version:t,attributeEpoch:r}}}class Va{constructor(e,t,r,s,i){this.subscription=e,this.reader=t,this.remove=r,this.end=s,this.debugInfo=i,this.type="update"}get id(){return this.subscription.tile.id}createMessage(e,t,r){return{type:"update",id:this.id,modify:e,debugInfo:this.debugInfo,remove:this.remove,version:t,subscriptionVesrion:this.subscription.version,end:this.end,attributeEpoch:r}}}class qa extends ae{constructor(e){super(),this._field=e}resize(e){throw new Error("Method not implemented.")}read(e,t){return e.readAttribute(this._field)}readWithDefault(e,t){return e.readAttribute(this._field)}referencesScale(){return!1}referencesGeometry(){return!1}}var Ha=r(6384);function Wa(e){return null==e||e===1/0||e===-1/0||"number"==typeof e&&isNaN(e)}class Ya extends ae{static async create(e,t){const r=await(0,Ha.kr)(e,t.spatialReference,t.fields);return new Ya(r)}constructor(e){super(),this._compiled=e}resize(e){}read(e,t){return function(e,t,r){if(null==e)return null;const s=t.readArcadeFeature();t.contextTimeZone=r.$view?.timeZone;try{return e.evaluate({...r,$feature:s},e.services)}catch(e){return M.c.getLogger("esri.views.2d.support.arcadeOnDemand").warn("Feature arcade evaluation failed:",e),null}}(this._compiled,e,t)}readWithDefault(e,t,r){return function(e,t,r,s){if(null==e)return null!=s?s:null;const i=t.readArcadeFeature(),n=e.evaluate({...r,$feature:i},e.services);return Wa(n)?null!=s?s:null:n}(this._compiled,e,t,r)}referencesScale(){return this._compiled?.referencesScale()??!1}referencesGeometry(){return this._compiled?.referencesGeometry()??!1}}var Xa=r(47828),ja=r(54052),$a=r(41936),Ka=r(564),Qa=r(4144);class Za extends ae{static async create(e,t){const r=(0,Qa.y6)(e);return new Za((e=>r.replaceAll(/{[^}]*}/g,(t=>{const r=t.slice(1,-1),s=e.metadata.fieldsIndex.get(r);if(null==s)return t;const i=e.readAttribute(r);return null==i?"":function(e,t){if(null==e)return"";const r=t.domain;if(r)if("codedValue"===r.type||"coded-value"===r.type){const t=e;for(const e of r.codedValues)if(e.code===t)return e.name}else if("range"===r.type){const{max:s,min:i}=(0,$a.w1)(t),n=+e;if(null!=i&&null!=s&&i<=n&&n<=s)return r.name}let s=e;return(0,Ka.gp)(t)?s=(0,Xa._m)(s,(0,Xa.Cg)("short-date")):(0,Ka.iW)(t)&&(s=(0,ja.iy)(+s)),s||""}(i,s)}))))}constructor(e){super(),this._evaluator=e}resize(e){}read(e,t){return this._evaluator(e)}readWithDefault(e,t,r){const s=this._evaluator(e);return Wa(s)?r:s}referencesScale(){return!1}referencesGeometry(){return!1}}class Ja extends ae{constructor(e,t){super(),this._field=e,this._normalizationInfo=t}resize(e){throw new Error("Method not implemented.")}read(e,t){return this._readNormalized(e)}readWithDefault(e,t){return this._readNormalized(e)}referencesScale(){return!1}referencesGeometry(){return!1}_readNormalized(e){const t=e.readAttribute(this._field);if(null==t)return null;const{normalizationField:r,normalizationTotal:s,normalizationType:i}=this._normalizationInfo,n=e.readAttribute(r);switch(i??"esriNormalizeByField"){case"esriNormalizeByField":return n?n?t/n:void 0:null;case"esriNormalizeByLog":return Math.log(t)*Math.LOG10E;case"esriNormalizeByPercentOfTotal":return s?t/s*100:null}}}class ec{static fromBuffer(e,t){return new ec(e,t)}static create(e,t=4294967295){const r=new Uint32Array(Math.ceil(e/32));return new ec(r,t)}constructor(e,t){this._mask=0,this._buf=e,this._mask=t}_getIndex(e){return Math.floor(e/32)}has(e){const t=this._mask&e;return!!(this._buf[this._getIndex(t)]&1<<t%32)}hasRange(e,t){let r=e,s=t;for(;r%32&&r!==s;){if(this.has(r))return!0;r++}for(;s%32&&r!==s;){if(this.has(r))return!0;s--}if(r===s)return!1;for(let e=r/32;e!==s/32;e++)if(this._buf[e])return!0;return!1}set(e){const t=this._mask&e,r=this._getIndex(t),s=1<<t%32;this._buf[r]|=s}setRange(e,t){let r=e,s=t;for(;r%32&&r!==s;)this.set(r++);for(;s%32&&r!==s;)this.set(s--);if(r!==s)for(let e=r/32;e!==s/32;e++)this._buf[e]=4294967295}unset(e){const t=this._mask&e,r=this._getIndex(t),s=1<<t%32;this._buf[r]&=4294967295^s}resize(e){const t=this._buf,r=new Uint32Array(Math.ceil(e/32));r.set(t),this._buf=r}or(e){for(let t=0;t<this._buf.length;t++)this._buf[t]|=e._buf[t];return this}and(e){for(let t=0;t<this._buf.length;t++)this._buf[t]&=e._buf[t];return this}xor(e){for(let t=0;t<this._buf.length;t++)this._buf[t]^=e._buf[t];return this}ior(e){for(let t=0;t<this._buf.length;t++)this._buf[t]|=~e._buf[t];return this}iand(e){for(let t=0;t<this._buf.length;t++)this._buf[t]&=~e._buf[t];return this}ixor(e){for(let t=0;t<this._buf.length;t++)this._buf[t]^=~e._buf[t];return this}any(){for(let e=0;e<this._buf.length;e++)if(this._buf[e])return!0;return!1}copy(e){for(let t=0;t<this._buf.length;t++)this._buf[t]=e._buf[t];return this}clone(){return new ec(this._buf.slice(),this._mask)}clear(){for(let e=0;e<this._buf.length;e++)this._buf[e]=0;return this}forEachSet(e){for(let t=0;t<this._buf.length;t++){let r=this._buf[t],s=32*t;if(r)for(;r;)1&r&&e(s),r>>>=1,s++}}countSet(){let e=0;return this.forEachSet((t=>{e++})),e}}var tc=r(44247);const rc=()=>M.c.getLogger("esri.views.2d.layers.features.support.whereUtils"),sc={getAttribute:(e,t)=>e.readAttribute(t)};async function ic(e,t){try{const r=await(0,tc.u)(e,t);if(!r.isStandardized){const e=new s.c("mapview - bad input","Unable to apply filter's definition expression, as expression is not standardized.",r);rc().error(e)}return e=>{const t=e.readArcadeFeature();return r.testFeature(t,sc)}}catch(t){return rc().warn("mapview-bad-where-clause","Encountered an error when evaluating where clause",e),e=>!0}}const nc=()=>M.c.getLogger("esri.views.2d.layers.features.support.ComputedAttributeStorage"),oc=4294967295;function ac(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class cc{constructor(e){this._numerics=[],this._strings=[],this._allocatedSize=256,this._bitsets=[],this._instanceIds=[],this._bounds=[],this._dirtyBitset=this.getBitset(this.createBitset()),this.compilationOptions=e}createBitset(){const e=this._bitsets.length;return this._bitsets.push(ec.create(this._allocatedSize,Eo)),e+1}async createComputedField(e,t=!1){if(e.expression)try{if(!this.compilationOptions)throw new Error("InternalError: Compilation options not defined");return t?Za.create(e.expression,this.compilationOptions):await Ya.create(e.expression,this.compilationOptions)}catch(t){const r=new s.c("featurelayer","Failed to compile arcade expression",{error:t,expression:e.expression});return nc().error(r),null}if(e.normalizationType||e.normalizationField)return new Ja(e.field,e);if(e.field)return new qa(e.field);const r=new s.c("featurelayer","Unable to create computed field. No expression or field found",{info:e});return nc().error(r),null}async createWhereClause(e){return e?ic(e,this.compilationOptions.fields):null}getBitset(e){return this._bitsets[e-1]}getComputedNumeric(e,t){return this.getComputedNumericAtIndex(e&Eo,0)}setComputedNumeric(e,t,r){return this.setComputedNumericAtIndex(e&Eo,r,0)}getComputedString(e,t){return this.getComputedStringAtIndex(e&Eo,0)}setComputedString(e,t,r){return this.setComputedStringAtIndex(e&Eo,0,r)}getComputedNumericAtIndex(e,t){const r=e&Eo;return this._ensureNumeric(t,r),this._numerics[t][r]}setComputedNumericAtIndex(e,t,r){const s=e&Eo;this._ensureNumeric(t,s),this._numerics[t][s]=r}getPackedChunkId(e){const t=e&Eo;return this._ensureInstanceId(t),this._instanceIds[t]}setPackedChunkId(e,t){const r=e&Eo;this._ensureInstanceId(r),this._instanceIds[r]=t}getComputedStringAtIndex(e,t){const r=e&Eo;return this._ensureString(t,r),this._strings[t][r]}setComputedStringAtIndex(e,t,r){const s=e&Eo;this._ensureString(t,s),this._strings[t][s]=r}getXMin(e){return this._bounds[4*(e&Eo)]}getYMin(e){return this._bounds[4*(e&Eo)+1]}getXMax(e){return this._bounds[4*(e&Eo)+2]}getYMax(e){return this._bounds[4*(e&Eo)+3]}setBounds(e,t,r=!1){const s=e&Eo;if(!r&&!this._dirtyBitset.has(e))return this._bounds[4*s]!==oc;this._dirtyBitset.unset(e);const i=t.readGeometryWorldSpace();if(ac(this._bounds,4*s+4,0),!i||!i.coords.length)return this._bounds[4*s]=oc,this._bounds[4*s+1]=oc,this._bounds[4*s+2]=oc,this._bounds[4*s+3]=oc,!1;let n=1/0,o=1/0,a=-1/0,c=-1/0;return i.forEachVertex(((e,t)=>{n=Math.min(n,e),o=Math.min(o,t),a=Math.max(a,e),c=Math.max(c,t)})),this._bounds[4*s]=n,this._bounds[4*s+1]=o,this._bounds[4*s+2]=a,this._bounds[4*s+3]=c,!0}getBounds(e,t){const r=this.getXMin(t),s=this.getYMin(t),i=this.getXMax(t),n=this.getYMax(t);return(0,ka.qy)(e,r,s,i,n),r!==oc}_ensureNumeric(e,t){this._numerics[e]||(this._numerics[e]=[]),ac(this._numerics[e],t,0)}_ensureInstanceId(e){ac(this._instanceIds,e,0)}_ensureString(e,t){this._strings[e]||(this._strings[e]=[]),ac(this._strings[e],t,null)}}var lc=r(33008),uc=r(3900),hc=r(79596),dc=r(78104),_c=r(95776);class pc{getObjectId(e){return e.getObjectId()}getAttributes(e){return e.readAttributes()}getAttribute(e,t){return e.readAttribute(t)}getAttributeAsTimestamp(e,t){return e.readAttributeAsTimestamp(t)}cloneWithGeometry(e,t){return e}getGeometry(e){return e.readGeometryWorldSpace()}getCentroid(e,t){return e.readCentroidForDisplay()}}pc.Shared=new pc;class fc{constructor(e){this._geometryBounds=(0,B.Su)(),this._idToVisibility=new Map,this._serviceInfo=e}static async create(e){const t=new fc(e);return await t.update(e.filterJSON,e.spatialReference),t}get hash(){return this._hash}check(e){return this._applyFilter(e)}clear(){const e=this._resetAllHiddenIds();return this.update(),{show:e,hide:[]}}invalidate(){this._idToVisibility.forEach(((e,t)=>{this._idToVisibility.set(t,0)}))}setKnownIds(e){for(const t of e)this._idToVisibility.set(t,1)}setTrue(e){const t=[],r=[],s=new Set(e);return this._idToVisibility.forEach(((e,i)=>{const n=!!(1&this._idToVisibility.get(i)),o=s.has(i);!n&&o?t.push(i):n&&!o&&r.push(i),this._idToVisibility.set(i,o?3:0)})),{show:t,hide:r}}createQuery(){const{geometry:e,spatialRel:t,where:r,timeExtent:s,objectIds:i}=this;return _c.c.fromJSON({geometry:e,spatialRel:t,where:r,timeExtent:s,objectIds:i})}async update(e,t){this._hash=JSON.stringify(e);const r=await(0,uc._8)(e,null,t);await Promise.all([this._setGeometryFilter(r),this._setIdFilter(r),this._setAttributeFilter(r),this._setTimeFilter(r)])}async _setAttributeFilter(e){if(!e?.where)return this._clause=null,void(this.where=null);this._clause=await ic(e.where,this._serviceInfo.fieldsIndex),this.where=e.where}_setIdFilter(e){this._idsToShow=e?.objectIds&&new Set(e.objectIds),this._idsToHide=e?.hiddenIds&&new Set(e.hiddenIds),this.objectIds=e?.objectIds}async _setGeometryFilter(e){if(!e?.geometry)return this._spatialQueryOperator=null,this.geometry=null,void(this.spatialRel=null);const t=e.geometry,r=e.spatialRel||"esriSpatialRelIntersects",s=await(0,hc.q0)(r,t,this._serviceInfo.geometryType,this._serviceInfo.hasZ,this._serviceInfo.hasM);(0,lc.ac)(this._geometryBounds,t),this._spatialQueryOperator=s,this.geometry=t,this.spatialRel=r}_setTimeFilter(e){if(this.timeExtent=this._timeOperator=null,e?.timeExtent)if(this._serviceInfo.timeInfo)this.timeExtent=e.timeExtent,this._timeOperator=(0,dc.k)(this._serviceInfo.timeInfo,e.timeExtent,pc.Shared);else{const t=new s.c("feature-layer-view:time-filter-not-available","Unable to apply time filter, as layer doesn't have time metadata.",e.timeExtent);M.c.getLogger("esri.views.2d.layers.features.controllers.FeatureFilter").error(t)}}_applyFilter(e){return this._filterByGeometry(e)&&this._filterById(e)&&this._filterByTime(e)&&this._filterByExpression(e)}_filterByExpression(e){return!this.where||this._clause(e)}_filterById(e){return(!this._idsToHide?.size||!this._idsToHide.has(e.getObjectId()))&&(!this._idsToShow?.size||this._idsToShow.has(e.getObjectId()))}_filterByGeometry(e){if(!this.geometry)return!0;const t=e.readGeometryWorldSpace();return!!t&&this._spatialQueryOperator(t)}_filterByTime(e){return null==this._timeOperator||this._timeOperator(e)}_resetAllHiddenIds(){const e=[];return this._idToVisibility.forEach(((t,r)=>{1&t||(this._idToVisibility.set(r,1),e.push(r))})),e}}class mc{constructor(e){this._options=e,this._fieldsIndex="fieldsIndex"in e?q.c.fromJSON(e.fieldsIndex):new q.c(e.fields),e.spatialReference&&(this._spatialReference=V.c.fromJSON(e.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 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}}r(60708);var gc=r(10724),yc=r(85436),xc=r(62024),bc=r(67224),Tc=r(28484),wc=r(6704);const Sc=(0,n.c)("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],vc=Sc[0],Ic=Sc[1],Ec=Sc[2],Rc=Sc[3],Ac=(0,n.c)("featurelayer-simplify-payload-size-factors")??[1,2,4],Mc=Ac[0],Cc=Ac[1],Fc=Ac[2],Nc=(0,n.c)("featurelayer-simplify-mobile-factor")??2,Pc=(0,n.c)("esri-mobile"),Oc=4294967295;class kc{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._deleted=null,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}get isEmpty(){return null!=this._deleted&&this._deleted.countSet()===this.getSize()}getAreaSimplificationThreshold(e,t){let r=1;const s=Pc?Nc:1;t>4e6?r=Fc*s:t>1e6?r=Cc*s:t>5e5?r=Mc*s:t>1e5&&(r=s);let i=0;return e>4e3?i=Rc*r:e>2e3?i=Ec*r:e>100?i=Ic:e>15&&(i=vc),i}parseTimestampOffset(e){return e}getBounds(e){if(function(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(0)}(this._boundsBuffer,4*this.getIndex()+4),this.getBoundsXMin()===Oc)return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(!t)return this.setBoundsXMin(Oc),!1;let r=1/0,s=1/0,i=-1/0,n=-1/0;return t.forEachVertex(((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),n=Math.max(n,t)})),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(n),(0,ka.qy)(e,r,s,i,n),!0}const t=this.getBoundsXMin(),r=this.getBoundsYMin(),s=this.getBoundsXMax(),i=this.getBoundsYMax();return(0,ka.qy)(e,t,r,s,i),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const r of this._joined){r.setIndex(this.getIndex());const s=r._readAttribute(e,t);if(void 0!==s)return s}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}removeIds(e){if(null==this._objectIdToIndex){const e=new Map,t=this.getCursor();for(;t.next();){const r=t.getObjectId();(0,R.EN)(r),e.set(r,t.getIndex())}this._objectIdToIndex=e}const t=this._objectIdToIndex;for(const r of e.values())t.has(r)&&this._removeAtIndex(t.get(r))}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace(),s=new Na._M(e,t,r);return s.objectId=this.getObjectId(),s.displayId=this.getDisplayId(),s}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return(0,Fa.qw)(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryWorldSpace(){let e=this._readGeometry();if(e||(e=this._createGeometryFromServerCentroid()),!e)return null;const t=e.clone(),r=this.getInTransform();return null!=r&&(0,Fa.Ij)(t,t,this.hasZ,this.hasM,r),t}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();if(!t)return null;const r=t.clone(),s=this.getInTransform();return null!=s&&(0,Fa.Ij)(r,r,this.hasZ,this.hasM,s),r}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);return"esriGeometryPoint"!==this.geometryType&&t&&this.getInTransform()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some((t=>t.hasField(e)))}geometry(){const e=this.readGeometryWorldSpace(),t=(0,Fa.qw)(e,this.geometryType,this.hasZ,this.hasM),r=(0,wc.h4)(t);if(r){if(!this.metadata.spatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.spatialReference}return r}autocastArcadeDate(e,t){return t&&t instanceof Date?this.isUnknownDateTimeField(e)?gc.Ql.unknownDateJSToArcadeDate(t):gc.Ql.dateJSAndZoneToArcadeDate(t,this.contextTimeZone??Tc.OX):t}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===Tc.OI}field(e){let t=this.fields.get(e);if(t)switch(t.type){case"date-only":case"esriFieldTypeDateOnly":return yc.K.fromReader(this.readAttribute(e,!1));case"time-only":case"esriFieldTypeTimeOnly":return xc.C.fromReader(this.readAttribute(e,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return gc.Ql.fromReaderAsTimeStampOffset(this.readAttribute(e,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(e,this.readAttribute(e,!0));default:return this.readAttribute(e,!1)}for(const r of this._joined)if(r.setIndex(this.getIndex()),t=r.fields.get(e),t)switch(t.type){case"date-only":case"esriFieldTypeDateOnly":return yc.K.fromReader(r._readAttribute(e,!1));case"time-only":case"esriFieldTypeTimeOnly":return xc.C.fromReader(r._readAttribute(e,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return gc.Ql.fromReaderAsTimeStampOffset(r._readAttribute(e,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(e,r._readAttribute(e,!0));default:return this.readAttribute(e,!1)}throw new Error(`Field ${e} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map((e=>e.name))}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes??{}}};for(const e in r.attributes){const t=r.attributes[e];t instanceof Date&&(r.attributes[e]=t.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}_getExists(){return null==this._deleted||!this._deleted.has(this.getIndex())}_computeDisplayCentroid(e){const t=Ye.k.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=(0,bc.S)(t);return r?(r[1]*=-1,new me.c([],r)):null}copyInto(e){e._joined=this._joined,e._deleted=this._deleted,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return(0,Fa.qw)(e,this.geometryType,!1,!1)}_createGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createQuantizedExtrudedGeometry(t,r)}_createQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createQuantizedExtrudedLine(e,t):this._createQuantizedExtrudedQuad(e,t)}_createQuantizedExtrudedQuad(e,t){return new me.c([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createQuantizedExtrudedLine(e,t){return new me.c([2],[e-1,t+1,1,-1])}_removeAtIndex(e){null==this._deleted&&(this._deleted=ec.create(this.getSize())),this._deleted.set(e)}}class Dc extends kc{static fromFeatures(e,t){const{objectIdField:r,geometryType:s}=t,i=(0,Fa.od)([],e,s,!1,!1,r);for(let t=0;t<i.length;t++)i[t].displayId=e[t].displayId;return Dc.fromOptimizedFeatures(i,t)}static fromFeatureSet(e,t){const r=(0,Fa.ui)(e,t.objectIdField);return Dc.fromOptimizedFeatureSet(r,t)}static fromOptimizedFeatureSet(e,t){const r=Dc.fromOptimizedFeatures(e.features,t);return r._exceededTransferLimit=e.exceededTransferLimit,r._transform=e.transform,r._fieldsIndex=new q.c(e.fields),r}static fromOptimizedFeatures(e,t,r){const s=new Dc(e,t);return s._fieldsIndex=t.fieldsIndex,s._transform=r,s}static empty(e){return new Dc([],e)}constructor(e,t){super(t),this._exceededTransferLimit=!1,this._featureIndex=-1,this._fieldsIndex=null,this._geometryType=t.geometryType,this._features=e}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(e){const t=new Set(e);this._features=this._features.filter((e=>!(null!=e.objectId&&t.has(e.objectId))))}getSize(){return this._features.length}getCursor(){return this.copy()}getInTransform(){return this._transform}getAttributeHash(){let e="";for(const t in this._current.attributes)e+=this._current.attributes[t];return e}getIndex(){return this._featureIndex}setIndex(e){this._featureIndex=e}getObjectId(){return this._current?.objectId}getDisplayId(){return this._current.displayId}setDisplayId(e){this._current.displayId=e}copy(){const e=new Dc(this._features,this.metadata);return this.copyInto(e),e}next(){for(;++this._featureIndex<this._features.length&&!this._getExists(););return this._featureIndex<this._features.length}readGeometryArea(){return(0,Na.ED)(this._current)?(0,Fa.Oo)(this._current.geometry,2):0}_readX(){return(0,Na.ED)(this._current)?this._current.geometry.coords[0]:0}_readY(){return(0,Na.ED)(this._current)?this._current.geometry.coords[1]:0}_readGeometry(){return(0,Na.ED)(this._current)?this._current.geometry??null:null}_readServerCentroid(){return this._current.centroid}_readAttribute(e,t){if(!this._fieldsIndex){const t=this._current.attributes[e];if(void 0!==t)return t;const r=e.toLowerCase();for(const e in this._current.attributes)if(e.toLowerCase()===r)return this._current.attributes[e];return}const r=this._fieldsIndex.get(e);if(!r)return;let s=this._current.attributes[r.name];return null==s?s:("esriFieldTypeTimestampOffset"===this.fields.get(e)?.type&&(s=this.parseTimestampOffset(s)),t&&this.fields.isDateField(e)?new Date(s):s)}_readAttributes(){return this._current.attributes}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._transform=this._transform,e._fieldsIndex=this._fieldsIndex}}class Uc extends Ba{constructor(e,t){super(e),this.bins=new Map,this.done=!1,this._store=t}reset(){this.destroy(),this.bins.clear(),this.done=!1,this.handledChunks.clear()}destroy(){for(const e of this.bins.values()){const t=e.cachedFeature?.objectId;null!=t&&this._store.releaseDisplayIdForObjectId(t)}}*featuresWorldSpace(){for(const e of this.bins.values()){const t=e.cachedFeature;if(t){const e=t.clone();(0,Fa.Ij)(e.geometry,e.geometry,!1,!1,this.subscription.tile.transform),yield e}}}getGeohashBounds(e,t){const r=this.subscription.tile;return(0,Ca.wt)(r.extent,r.resolution,t,e)}}class Bc extends Ga{static async create(e,t,r,s){const i=new cc({spatialReference:t}),n=e.fixedBinLevel,o=await Promise.all(e.fields.map((async e=>Pa.create(i,e)))),a=e.featureFilter?await fc.create({geometryType:r.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:r.metadata.timeInfo,fieldsIndex:r.metadata.fieldsIndex,spatialReference:t,filterJSON:e.featureFilter}):null;return new Bc({fields:o,geohashLevel:n,spatialReference:t,featureFilter:a},r,s)}constructor(e,t,r){super(t,r,e.spatialReference,e.fields),this._indexOptions=e,this._metadata=new mc({geometryType:"esriGeometryPolygon",objectIdField:"aggregateId",fields:this._indexOptions.fields,globalIdField:null,spatialReference:t.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}createState(e){return new Uc(e,this._attributeStore)}async*applyOverride(e){for(const e of this._sendStates.values())e.reset()}displayMap(e,t,r){const s=new Map(e.map((e=>[t(e),e]))),i=[];for(const e of this._sendStates.values())for(const t of e.featuresWorldSpace()){const{objectId:e,displayId:n}=t,o=s.get(e);if(null!=o){const t=r(n,o,e);i.push(t),s.delete(e)}}return i}getDisplayFeatures(e){const t=new Set(e),r=new Set,s=[];for(const e of this._sendStates.values())for(const i of e.featuresWorldSpace())t.has(i.displayId)&&!r.has(i.objectId)&&(i.geometry&&s.push({...(0,Fa.G0)(i,this._metadata.geometryType,!1,!1),displayId:i.displayId}),r.add(i.objectId));return{features:[],aggregates:s}}getFeatureObjectIdsForAggregate(e){for(const t of this._sendStates.values())for(const r of t.bins.values())if(r.id===e)return Array.from(r.objectIds);return[]}async*updateChunks(){if(this._source.chunks().length)for(const e of this._sendStates.values())yield*this._update(e,this._source)}forEachAggregateWorldSpace(e){for(const t of this._sendStates.values())for(const r of t.featuresWorldSpace())e(r)}async*_update(e,t){const{handledChunks:r,subscription:s,bins:i}=e,{spatialReference:n,geohashLevel:o}=this._indexOptions,a=s.tile;if(e.done)return;for(const s of t.chunks()){if(r.has(s.chunkId))continue;r.add(s.chunkId);const t=s.queryInfo;if("tileId"in t){const e=new _.c(t.tileId);if(e.level!==a.level||e.world!==a.key.world)continue}const c=s.getGeohashIndex(this._indexOptions),l=e.getGeohashBounds(n,o);c.putBins(i,l)}const c=[],l=s.tile.transform;for(const e of i.values()){if(e.cachedFeature)e.cachedFeature.attributes=e.getAttributes();else{const t=e.getGeometry(this.spatialReference,l),r=new Na._M(t,e.getAttributes(),null);t||(r.centroid=e.getGeometryCentroid(this.spatialReference,l)),r.objectId=e.id,r.displayId=this._attributeStore.createDisplayIdForObjectId(e.id),e.cachedFeature=r}c.push(e.cachedFeature)}this.events.emit("changed"),e.done=!t.updateTracking.updating;const u=Dc.fromOptimizedFeatures(c,this._metadata,l),h=u.getCursor(),d=e.subscription.tile.arcadeEvaluationOptions;for(;h.next();)this._attributeStore.setAttributeData(h.getDisplayId(),h,d);const p=new Va(e.subscription,u,[],e.done,{});yield p}}const Lc=Math.PI/180;class Gc{static create(e){return new Gc(e.map((e=>function(e){switch(e.statisticType){case"min":return new Vc(e);case"max":return new qc(e);case"avg":return new Wc(e);case"avg_angle":return new Yc(e);case"sum":case"count":return new Hc(e);case"mode":return new Xc(e)}}(e))))}constructor(e){this._statistics=e}values(){return this._statistics.values()}insert(e,t){for(const r of this._statistics)r.insert(e,t)}merge(e){for(let t=0;t<this._statistics.length;t++){const r=this._statistics[t],s=e._statistics[t];if(r.field.name!==s.field.name)throw new Error("InternalError: Tried to merge incompatible statistics");r.merge(s)}}clone(){return new Gc(this._statistics.map((e=>e.clone())))}}class zc{constructor(e){this.field=e}insert(e,t){if(!this.field.computed)return;const r=this.field.computed.read(e,t);Wa(r)||this._insertValue(r)}}class Vc extends zc{constructor(){super(...arguments),this.type="min",this.value=Number.MAX_VALUE}_insertValue(e){this.value=Math.min(this.value,e)}merge(e){this.value=Math.min(this.value,e.value)}clone(){const e=new Vc(this.field);return e.value=this.value,e}}class qc extends zc{constructor(){super(...arguments),this.type="max",this.value=Number.MIN_VALUE}_insertValue(e){this.value=Math.max(this.value,e)}merge(e){this.value=Math.max(this.value,e.value)}clone(){const e=new qc(this.field);return e.value=this.value,e}}class Hc extends zc{constructor(){super(...arguments),this.type="sum",this.value=0}_insertValue(e){this.value+=e}merge(e){this.value+=e.value}clone(){const e=new Hc(this.field);return e.value=this.value,e}}class Wc extends zc{constructor(){super(...arguments),this.type="avg",this._total=0,this._count=0}get value(){return this._total/this._count}_insertValue(e){this._total+=e,this._count+=1}merge(e){this._total+=e._total,this._count+=e._count}clone(){const e=new Wc(this.field);return e._total=this._total,e._count=this._count,e}}class Yc extends zc{constructor(){super(...arguments),this.type="avg_angle",this._x=0,this._y=0,this._count=0}get value(){const e=this._x/this._count,t=this._y/this._count,r=180/Math.PI;return Math.atan2(t,e)*r}_insertValue(e){this._x=this._x+Math.cos(e*Lc),this._y=this._y+Math.sin(e*Lc),this._count+=1}merge(e){this._x+=e._x,this._y+=e._y,this._count+=e._count}clone(){const e=new Yc(this.field);return e._x=this._x,e._y=this._y,e._count=this._count,e}}class Xc extends zc{constructor(){super(...arguments),this._frequencies=new Map}get value(){let e,t=0;for(const[r,s]of this._frequencies.entries())s>t&&(t=s,e=r);return e}_insertValue(e){const t=this._frequencies.get(e);null!=t?this._frequencies.set(e,t+1):this._frequencies.set(e,1)}merge(e){for(const[t,r]of e._frequencies.entries()){const e=this._frequencies.get(t);null!=e?this._frequencies.set(t,e+r):this._frequencies.set(t,r)}}clone(){const e=new Xc(this.field);return e._frequencies=new Map(this._frequencies),e}}class jc{static createId(e,t){return`${e}.${t}`}static create(e,t,r,s){return new jc(e,t,Gc.create(r),s)}constructor(e,t,r,s){this.gridX=e,this.gridY=t,this._statistics=r,this._worldUnitsPerCell=s,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._objectIds=new Set}get id(){return jc.createId(this.gridX,this.gridY)}get count(){return this._count}get statistics(){return this._statistics}get objectIds(){return this._objectIds}get firstObjectId(){return this._objectIds.values().next().value}get centroidXWorld(){return this._xWorldTotal/this._count}get centroidYWorld(){return this._yWorldTotal/this._count}clone(){const e=new jc(this.gridX,this.gridY,this._statistics.clone(),this._worldUnitsPerCell);return e._count=this._count,e._xWorldTotal=this._xWorldTotal,e._yWorldTotal=this._yWorldTotal,e._firstFeatureAttributes=this._firstFeatureAttributes,e._objectIds=new Set(this._objectIds),e}insert(e,t,r,s){0===this._count?this._firstFeatureAttributes=e.readAttributes():this._firstFeatureAttributes=null,this._count+=1,this._xWorldTotal+=r,this._yWorldTotal+=s,this._statistics.insert(e,t),this._objectIds.add(e.getObjectId())}merge(e){if(0!==e._count){this._count+=e._count,this._firstFeatureAttributes=e._firstFeatureAttributes,this._xWorldTotal+=e._xWorldTotal,this._yWorldTotal+=e._yWorldTotal,this._statistics.merge(e._statistics);for(const t of e._objectIds.values())this._objectIds.add(t)}}getCentroid(e){const t=new me.c([],[this.centroidXWorld,this.centroidYWorld]);if(null!=e){const r=new me.c;return(0,Fa.iC)(r,t,!1,!1,"esriGeometryPoint",e)}return t}getGeometricCentroid(e){const t=this.gridX*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,r=this.gridY*this._worldUnitsPerCell+.5*this._worldUnitsPerCell,s=new me.c([],[t,r]);if(null!=e){const t=new me.c;return(0,Fa.iC)(t,s,!1,!1,"esriGeometryPoint",e)}return s}getAttributes(){const e={aggregateId:this.id};for(const t of this._statistics.values())e[t.field.name]=t.value;return null!=this._firstFeatureAttributes?{...e,...this._firstFeatureAttributes}:e}}var $c=r(24296);function Kc(e,t){return(0,$c.k8)(e)*$c.Co*96/t}class Qc{constructor(e){this._options=e,this._cells=new Map,this._pixelsPerMapUnit=Kc(e.spatialReference,e.scale)}insert(e,t){const r=e.getCursor(),s={$view:{scale:this._options.scale}};for(;r.next();)this._insertFeature(r,s,t)}putCellsInBounds(e,t){const[r,s,i,n]=t,o=Math.floor(r*this._pixelsPerMapUnit/this._options.cellSize),a=Math.floor(s*this._pixelsPerMapUnit/this._options.cellSize),c=Math.ceil(i*this._pixelsPerMapUnit/this._options.cellSize),l=Math.ceil(n*this._pixelsPerMapUnit/this._options.cellSize);for(let t=a;t<=l;t++)for(let r=o;r<=c;r++){const s=`${r}.${t}`,i=this._cells.get(s);if(!i)continue;const n=e.get(i.id);n?i&&!e.has(i.id)&&n.merge(i):e.set(i.id,i.clone())}}putCells(e){for(const t of this._cells.values()){const r=e.get(t.id);r?r.merge(t):e.set(t.id,t.clone())}}_insertFeature(e,t,r){const{featureFilter:s}=this._options;if(null!==s&&!s.check(e))return;let i=0,n=0;if("esriGeometryPoint"===e.geometryType)i=e.readXWorldSpace(),n=e.readYWorldSpace();else{if(r){const t=e.readCentroidForDisplay();if(null==t)return;const[r,s]=t.coords;if(r<0||r>L.gT||s<0||s>L.gT)return}const t=e.readCentroidWorldSpace();if(null==t)return;i=t.coords[0],n=t.coords[1]}const o=i*this._pixelsPerMapUnit,a=n*this._pixelsPerMapUnit,c=Math.floor(o/this._options.cellSize),l=Math.floor(a/this._options.cellSize);this._getCellOrCreate(c,l).insert(e,t,i,n)}_getCellOrCreate(e,t){const r=jc.createId(e,t);let s=this._cells.get(r);if(!s){const i=1*this._options.cellSize/this._pixelsPerMapUnit;s=jc.create(e,t,this._options.fields,i),this._cells.set(r,s)}return s}}class Zc{constructor(e,t){this.inner=e,this.displayId=t}}class Jc extends Ba{constructor(e){super(e),this.didSend=!1,this.done=!1}}class el{constructor(e,t,r,s,i){this._level=e,this._scale=t,this._indexOptions=r,this._clusterRadius=s,this._store=i,this._cells=new Map,this._handledChunks=new Set,this._statistics=new Map,this._clusters=new Map}destroy(){this._clearClusters()}_clearClusters(){for(const e of this._clusters.values())this._store.releaseDisplayIdForObjectId(e.inner.id);this._clusters.clear()}*aggregatesWorldSpace(){for(const e of this._clusters.values()){const t=e.inner.getCentroid(null),r=new Na._M(t,e.inner.getAttributes(),null);r.objectId=e.inner.id,r.displayId=e.displayId,yield r}}clusters(){return this._clusters.values()}updateChunks(e){let t=!1;for(const r of e){const e=r.queryInfo;"tileId"in e&&new _.c(e.tileId).level!==this._level||this._handledChunks.has(r.chunkId)||(this._handledChunks.add(r.chunkId),t=!0,r.getGridIndex({...this._indexOptions,scale:this._scale}).putCells(this._cells))}return t&&this._clusterCells(),t}async updateStatistics(e){let t=!1;for(const e of this._clusters.values())e.inner.count>1&&(t=this._updateAggregateStatistics(this._statistics,e.inner)||t);if(t){const t=Array.from(this._statistics.entries()).map((([e,t])=>({fieldName:e,minValue:t.minValue,maxValue:t.maxValue})));await e.container.updateStatistics(this._level,t)}}createAggregateFeatures(e,t){const r=e.subscription,s=[],i=r.tile.transform;for(const e of this._clusters.values()){const t=e.inner.getCentroid(i),n=new Na._M(t,e.inner.getAttributes(),null);n.objectId=e.inner.id,n.displayId=e.displayId;const o=n.geometry.coords,a=r.tile.lod,c=a.wrap?a.worldSize[0]:null;if(null!=c)if(1===c){const e=n.clone();e.geometry.coords[0]-=L.gT,s.push(e);const t=n.clone();t.geometry.coords[0]+=L.gT,s.push(t)}else o[0]>L.gT+L.gT/2?o[0]-=c*L.gT:o[0]<-L.gT/2&&(o[0]+=c*L.gT);const[l,u]=n.geometry.coords;l<L.gT+128&&l>=-128&&u<L.gT+128&&u>=-128&&s.push(n)}return Dc.fromOptimizedFeatures(s,t,r.tile.transform)}_clusterCells(){let e=Array.from(this._cells.values());e=e.sort(((e,t)=>t.count-e.count));const t=[];for(const e of this._clusters.values())t.push(e.inner.id);this._clusters.clear();const r=new Set;for(const t of e){if(r.has(t.id))continue;const e=this._store.createDisplayIdForObjectId(t.id),s=new Zc(t.clone(),e);r.add(t.id),this._clusters.set(t.id,s);const i=this._clusterRadius*(1/Kc(this._indexOptions.spatialReference,this._scale)),n=1+this._clusterRadius/this._indexOptions.cellSize,o=t.centroidXWorld,a=t.centroidYWorld;for(let e=t.gridY-n;e<=t.gridY+n;e++)for(let c=t.gridX-n;c<=t.gridX+n;c++){if(e===t.gridY&&c===t.gridX)continue;const n=this._cells.get(jc.createId(c,e));if(!n||r.has(n.id))continue;const l=Math.abs(n.centroidXWorld-o),u=Math.abs(n.centroidYWorld-a);l<i&&u<i&&(s.inner.merge(n),r.add(n.id))}}for(const e of t)this._store.releaseDisplayIdForObjectId(e)}_updateAggregateStatistics(e,t){let r=!1;for(const s of t.statistics.values()){if("esriFieldTypeString"===s.field.type)continue;const t=s.value,i=s.field,n=e.get(i.name);if(n){const{minValue:e,maxValue:s}=n,i=Math.min(n.minValue,t),o=Math.max(n.maxValue,t);e===i&&s===o||(n.minValue=i,n.maxValue=o,r=!0)}else e.set(i.name,{minValue:t,maxValue:t}),r=!0}return r}}class tl extends Ga{static async create(e,t,r,s,i){const n=new cc({spatialReference:r}),o={fields:await Promise.all(t.fields.map((async e=>Pa.create(n,e)))),spatialReference:r,featureFilter:t.featureFilter?await fc.create({geometryType:s.metadata.geometryType,hasM:!1,hasZ:!1,timeInfo:s.metadata.timeInfo,fieldsIndex:s.metadata.fieldsIndex,spatialReference:r,filterJSON:t.featureFilter}):null,cellSize:t.clusterRadius/4};return new tl(e,t.clusterRadius,o,s,i)}constructor(e,t,r,s,i){super(s,i,r.spatialReference,r.fields),this._connection=e,this._clusterRadius=t,this._indexOptions=r,this._cellsPerScale=new Map,this._metadata=new mc({geometryType:"esriGeometryPoint",objectIdField:"aggregateId",fields:[...this._indexOptions.fields,...this._source.metadata.fieldsIndex.fields,{name:"aggregateId",alias:"aggregateId",type:"esriFieldTypeOID"}],globalIdField:null,spatialReference:s.metadata.spatialReference,subtypeField:null,subtypes:null,timeInfo:null,timeReferenceUnknownClient:null,typeIdField:null,types:null})}get enablePixelBuffering(){return!1}onSubscribe(e){super.onSubscribe(e),this._requiredLevel=e.tile.level,this._requiredScale=e.tile.scale}createState(e){return new Jc(e)}async*applyOverride(e){for(const e of this._cellsPerScale.values())e.destroy();this._cellsPerScale.clear();for(const e of this._sendStates.values())e.done=!1}displayMap(e,t,r){const s=new Map(e.map((e=>[t(e),e]))),i=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const e of n.clusters()){const t=s.get(e.inner.id);if(null==t){if(1===e.inner.count){const t=s.get(e.inner.firstObjectId);if(null!=t){const n=r(e.displayId,t,e.inner.firstObjectId);i.push(n),s.delete(e.inner.firstObjectId)}}}else{const n=r(e.displayId,t,e.inner.id);i.push(n),s.delete(e.inner.id)}}return i}getDisplayFeatures(e){const t=new Set(e),r=new Set,s=[],i=[],n=this._getClusterState(this._requiredLevel,this._requiredScale);for(const e of n.aggregatesWorldSpace())if(t.has(e.displayId)&&!r.has(e.displayId)){const t=(0,Fa.G0)(e,this._metadata.geometryType,!1,!1);if(r.add(e.displayId),1===t.attributes.cluster_count){s.push({...t,displayId:e.displayId});continue}i.push({...t,displayId:e.displayId})}return{features:s,aggregates:i}}getFeatureObjectIdsForAggregate(e){const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const r of t.clusters())if(r.inner.id===e)return Array.from(r.inner.objectIds);return[]}async*updateChunks(){const e=this._source.chunks();if(!e.length)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale);if(t.updateChunks(e)||!this._source.updateTracking.updating)for(const e of this._sendStates.values())e.subscription.tile.level===this._requiredLevel&&(e.didSend=!1,e.done=!1);const r=Array.from(this._sendStates.values()).filter((e=>e.done)).map((e=>e.subscription.tile.key)),s=new Set(r);for(const e of this._sendStates.values()){if(this._source.updateTracking.updating){if(r.some((t=>t.containsChild(e.subscription.tile.key))))continue;if(e.subscription.tile.key.getChildKeys().every((e=>s.has(e))))continue}e.didSend||e.subscription.tile.level!==this._requiredLevel||(e.didSend=!0,yield*this._update(e,t,this._source))}await t.updateStatistics(this._connection)}forEachAggregateWorldSpace(e){if(null==this._requiredLevel||null==this._requiredScale)return;const t=this._getClusterState(this._requiredLevel,this._requiredScale);for(const r of t.aggregatesWorldSpace())e(r)}_getClusterState(e,t){if(null==e||null==t)throw new Error("InternalError: Level and scale must be defined");let r=this._cellsPerScale.get(t);return r||(r=new el(e,t,this._indexOptions,this._clusterRadius,this._attributeStore),this._cellsPerScale.set(t,r)),r}async*_update(e,t,r){if(e.done)return;const s=t.createAggregateFeatures(e,this._metadata);this.events.emit("changed"),e.done=!r.updateTracking.updating;const i=s.getCursor(),n=e.subscription.tile.arcadeEvaluationOptions;for(;i.next();)this._attributeStore.setAttributeData(i.getDisplayId(),i,n);const o=new za(e.subscription,s,!0,e.done,{});yield o}}var rl=r(85304);function sl(e,t){if(!(this instanceof sl))return new sl(e,t);this._maxEntries=Math.max(4,e||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),t&&("function"==typeof t?this.toBBox=t:this._initFormat(t)),this.clear()}function il(e,t,r){if(!r)return t.indexOf(e);for(var s=0;s<t.length;s++)if(r(e,t[s]))return s;return-1}function nl(e,t){ol(e,0,e.children.length,t,e)}function ol(e,t,r,s,i){i||(i=ml(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var n,o=t;o<r;o++)n=e.children[o],al(i,e.leaf?s(n):n);return i}function al(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function cl(e,t){return e.minX-t.minX}function ll(e,t){return e.minY-t.minY}function ul(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function hl(e){return e.maxX-e.minX+(e.maxY-e.minY)}function dl(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function _l(e,t){var r=Math.max(e.minX,t.minX),s=Math.max(e.minY,t.minY),i=Math.min(e.maxX,t.maxX),n=Math.min(e.maxY,t.maxY);return Math.max(0,i-r)*Math.max(0,n-s)}function pl(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function fl(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function ml(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function gl(e,t,r,s,i){for(var n,o=[t,r];o.length;)(r=o.pop())-(t=o.pop())<=s||(n=t+Math.ceil((r-t)/s/2)*s,(0,rl.q)(e,n,t,r,i),o.push(t,n,n,r))}sl.prototype={all:function(){return this._all(this.data,[])},search:function(e){var t=this.data,r=[],s=this.toBBox;if(!fl(e,t))return r;for(var i,n,o,a,c=[];t;){for(i=0,n=t.children.length;i<n;i++)o=t.children[i],fl(e,a=t.leaf?s(o):o)&&(t.leaf?r.push(o):pl(e,a)?this._all(o,r):c.push(o));t=c.pop()}return r},collides:function(e){var t=this.data,r=this.toBBox;if(!fl(e,t))return!1;for(var s,i,n,o,a=[];t;){for(s=0,i=t.children.length;s<i;s++)if(n=t.children[s],fl(e,o=t.leaf?r(n):n)){if(t.leaf||pl(e,o))return!0;a.push(n)}t=a.pop()}return!1},load:function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0,r=e.length;t<r;t++)this.insert(e[t]);return this}var s=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===s.height)this._splitRoot(this.data,s);else{if(this.data.height<s.height){var i=this.data;this.data=s,s=i}this._insert(s,this.data.height-s.height-1,!0)}else this.data=s;return this},insert:function(e){return null!=e&&this._insert(e,this.data.height-1),this},clear:function(){return this.data=ml([]),this},remove:function(e,t){if(null==e)return this;for(var r,s,i,n,o=this.data,a=this.toBBox(e),c=[],l=[];o||c.length;){if(o||(o=c.pop(),s=c[c.length-1],r=l.pop(),n=!0),o.leaf&&-1!==(i=il(e,o.children,t)))return o.children.splice(i,1),c.push(o),this._condense(c),this;n||o.leaf||!pl(o,a)?s?(r++,o=s.children[r],n=!1):o=null:(c.push(o),l.push(r),r=0,s=o,o=o.children[0])}return this},toBBox:function(e){return e},compareMinX:cl,compareMinY:ll,toJSON:function(){return this.data},fromJSON:function(e){return this.data=e,this},_all:function(e,t){for(var r=[];e;)e.leaf?t.push.apply(t,e.children):r.push.apply(r,e.children),e=r.pop();return t},_build:function(e,t,r,s){var i,n=r-t+1,o=this._maxEntries;if(n<=o)return nl(i=ml(e.slice(t,r+1)),this.toBBox),i;s||(s=Math.ceil(Math.log(n)/Math.log(o)),o=Math.ceil(n/Math.pow(o,s-1))),(i=ml([])).leaf=!1,i.height=s;var a,c,l,u,h=Math.ceil(n/o),d=h*Math.ceil(Math.sqrt(o));for(gl(e,t,r,d,this.compareMinX),a=t;a<=r;a+=d)for(gl(e,a,l=Math.min(a+d-1,r),h,this.compareMinY),c=a;c<=l;c+=h)u=Math.min(c+h-1,l),i.children.push(this._build(e,c,u,s-1));return nl(i,this.toBBox),i},_chooseSubtree:function(e,t,r,s){for(var i,n,o,a,c,l,u,h;s.push(t),!t.leaf&&s.length-1!==r;){for(u=h=1/0,i=0,n=t.children.length;i<n;i++)c=ul(o=t.children[i]),(l=dl(e,o)-c)<h?(h=l,u=c<u?c:u,a=o):l===h&&c<u&&(u=c,a=o);t=a||t.children[0]}return t},_insert:function(e,t,r){var s=this.toBBox,i=r?e:s(e),n=[],o=this._chooseSubtree(i,this.data,t,n);for(o.children.push(e),al(o,i);t>=0&&n[t].children.length>this._maxEntries;)this._split(n,t),t--;this._adjustParentBBoxes(i,n,t)},_split:function(e,t){var r=e[t],s=r.children.length,i=this._minEntries;this._chooseSplitAxis(r,i,s);var n=this._chooseSplitIndex(r,i,s),o=ml(r.children.splice(n,r.children.length-n));o.height=r.height,o.leaf=r.leaf,nl(r,this.toBBox),nl(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(r,o)},_splitRoot:function(e,t){this.data=ml([e,t]),this.data.height=e.height+1,this.data.leaf=!1,nl(this.data,this.toBBox)},_chooseSplitIndex:function(e,t,r){var s,i,n,o,a,c,l,u;for(c=l=1/0,s=t;s<=r-t;s++)o=_l(i=ol(e,0,s,this.toBBox),n=ol(e,s,r,this.toBBox)),a=ul(i)+ul(n),o<c?(c=o,u=s,l=a<l?a:l):o===c&&a<l&&(l=a,u=s);return u},_chooseSplitAxis:function(e,t,r){var s=e.leaf?this.compareMinX:cl,i=e.leaf?this.compareMinY:ll;this._allDistMargin(e,t,r,s)<this._allDistMargin(e,t,r,i)&&e.children.sort(s)},_allDistMargin:function(e,t,r,s){e.children.sort(s);var i,n,o=this.toBBox,a=ol(e,0,t,o),c=ol(e,r-t,r,o),l=hl(a)+hl(c);for(i=t;i<r-t;i++)n=e.children[i],al(a,e.leaf?o(n):n),l+=hl(a);for(i=r-t-1;i>=t;i--)n=e.children[i],al(c,e.leaf?o(n):n),l+=hl(c);return l},_adjustParentBBoxes:function(e,t,r){for(var s=r;s>=0;s--)al(t[s],e)},_condense:function(e){for(var t,r=e.length-1;r>=0;r--)0===e[r].children.length?r>0?(t=e[r-1].children).splice(t.indexOf(e[r]),1):this.clear():nl(e[r],this.toBBox)},_initFormat:function(e){var t=["return a"," - b",";"];this.compareMinX=new Function("a","b",t.join(e[0])),this.compareMinY=new Function("a","b",t.join(e[1])),this.toBBox=new Function("a","return {minX: a"+e[0]+", minY: a"+e[1]+", maxX: a"+e[2]+", maxY: a"+e[3]+"};")}};class yl{static fromReader(e){const t=[],r=e.copy(),s=(0,ka.Su)();for(;r.next();)r.getBounds(s)&&t.push(r.getIndex());const i=sl(9,(e=>(r.setIndex(e),{minX:r.getBoundsXMin(),minY:r.getBoundsYMin(),maxX:r.getBoundsXMax(),maxY:r.getBoundsYMax()})));return i.load(t),new yl(i)}constructor(e){this._index=e}search(e){const t={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this._index.search(t)}}var xl=r(7684);class bl{static create(e,t,r,s){const i=Gc.create(e),n=new Array(32);for(let e=0;e<n.length;e++)n[e]=null;return new bl(i,t,r,s,n)}constructor(e,t,r,s,i){this._statistics=e,this.xNode=t,this.yNode=r,this.depth=s,this.children=i,this._objectIds=new Set,this._count=0,this._xWorldTotal=0,this._yWorldTotal=0,this._xGeohashTotal=0,this._yGeohashTotal=0,this.next=null}get id(){return`${this.xNode}.${this.yNode}`}get objectIds(){return this._objectIds}clone(){const e=new bl(this._statistics.clone(),this.xNode,this.yNode,this.depth,this.children);return e._count=this._count,e._xWorldTotal=this._xWorldTotal,e._yWorldTotal=this._yWorldTotal,e._xGeohashTotal=this._xGeohashTotal,e._yGeohashTotal=this._yGeohashTotal,e.next=this.next,e.cachedFeature=this.cachedFeature,e._objectIds=new Set(this._objectIds),e}insert(e,t,r,s,i,n){this._count+=1,this._xWorldTotal+=t,this._yWorldTotal+=r,this._xGeohashTotal+=s,this._yGeohashTotal+=i,this._statistics.insert(e,n),this._objectIds.add(e.getObjectId())}merge(e){if(0!==e._count){this._count+=e._count,this._xWorldTotal+=e._xWorldTotal,this._yWorldTotal+=e._yWorldTotal,this._xGeohashTotal+=e._xWorldTotal,this._yGeohashTotal+=e._yWorldTotal,this._statistics.merge(e._statistics);for(const t of e._objectIds.values())this._objectIds.add(t)}}getGeometry(e,t){const r=this._getLngLatBounds(),[s,i,n,o]=r,a=(0,xl.yU)({rings:[[[s,i],[s,o],[n,o],[n,i],[s,i]]]},V.c.WGS84,e),c=(0,Fa.Uh)(new me.c,a,!1,!1);return null!=t?(0,Fa.iC)(new me.c,c,!1,!1,"esriGeometryPolygon",t,!1,!1):c}getGeometryCentroid(e,t){const r=this._getLngLatBounds(),[s,i,n,o]=r,a=(0,xl.yU)({x:(s+n)/2,y:(i+o)/2},V.c.WGS84,e),c=(0,Fa.M$)(new me.c,a);return null!=t?(0,Fa.iC)(new me.c,c,!1,!1,"esriGeometryPoint",t,!1,!1):c}getAttributes(){const e={aggregateId:this.id};for(const t of this._statistics.values())e[t.field.name]=t.value;return e.aggregateCount=this._count,e}_getLngLatBounds(){const e=this.depth,t=Math.ceil(e/2),r=Math.floor(e/2),s=30-(3*t+2*r),i=30-(2*t+3*r),n=this.xNode<<s,o=this.yNode<<i;return(0,Ca.S8)({geohashX:n,geohashY:o},this.depth)}}class Tl{constructor(e){this._fields=e,this._root=bl.create(this._fields,0,0,0)}destroy(){}insert(e,t,r,s,i,n,o){let a=this._root,c=0,l=0,u=0;for(;null!==a;){if(a.insert(e,t,r,s,i,o),c>=n)return;const h=Math.ceil((c+1)/2),d=Math.floor((c+1)/2),_=1-c%2,p=30-(3*h+2*d),f=30-(2*h+3*d),m=(s&7*_+3*(1-_)<<p)>>p,g=(i&3*_+7*(1-_)<<f)>>f,y=m+g*(8*_+4*(1-_));l=l<<3*_+2*(1-_)|m,u=u<<2*_+3*(1-_)|g,null==a.children[y]&&(a.children[y]=bl.create(this._fields,l,u,c+1)),c+=1,a=a.children[y]}}putBins(e,t){for(const r of this.getNodes(t)){const t=e.get(r.id);t?t.merge(r):e.set(r.id,r.clone())}}getNodes(e){const t=[],{geohashBounds:r,level:s}=e;let i=this._root;for(;null!==i;){const e=i.depth,n=i.xNode,o=i.yNode;if(e>=s){t.push(i),i=i.next;continue}const a=Math.ceil((e+1)/2),c=Math.floor((e+1)/2),l=1-e%2,u=30-(3*a+2*c),h=30-(2*a+3*c),d=~((1<<u)-1),_=~((1<<h)-1),p=(r.xLL&d)>>u,f=(r.yLL&_)>>h,m=(r.xTR&d)>>u,g=(r.yTR&_)>>h,y=n<<3*l+2*(1-l),x=o<<2*l+3*(1-l),b=y+8*l+4*(1-l),T=x+4*l+8*(1-l),w=Math.max(y,p),S=Math.max(x,f),v=Math.min(b,m),I=Math.min(T,g);let E=null,R=null;for(let e=S;e<=I;e++)for(let t=w;t<=v;t++){const r=t-y+(e-x)*(8*l+4*(1-l)),s=i.children[r];s&&(E||(E=s,E.next=i.next),R&&(R.next=s),R=s,s.next=i.next)}i=E||i.next}return t}}class wl{constructor(e){this._options=e,this._tree=new Tl(e.fields)}insert(e,t){const r=e.getCursor(),s={$view:{scale:0}};for(;r.next();)this._insertFeature(r,s,t)}putBins(e,t){this._tree.putBins(e,t)}_insertFeature(e,t,r){const{featureFilter:s,geohashLevel:i,spatialReference:n}=this._options;if(null!==s&&!s.check(e))return;let o=0,a=0;if("esriGeometryPoint"===e.geometryType)o=e.readXWorldSpace(),a=e.readYWorldSpace();else{if(r){const t=e.readCentroidForDisplay();if(null==t)return;const[r,s]=t.coords;if(r<0||r>L.gT||s<0||s>L.gT)return}const t=e.readCentroidWorldSpace();if(null==t)return;o=t.coords[0],a=t.coords[1]}const c=(0,Ca.i2)(o,a,i,n);c&&this._tree.insert(e,o,a,c[0],c[1],i,t)}}class Sl extends kc{static from(e,t){return new Sl(e.copy(),t)}constructor(e,t){super(e.metadata),this._currentIndex=-1,this._displayTranslationX=0,this._displayTranslationY=0,this._displayScaleX=1,this._displayScaleY=1,this._reader=e,this._indices=t,this._isPoint="esriGeometryPoint"===e.geometryType}setTransformForDisplay(e){const t=this._reader.getInTransform();if(null==t){const[t,r]=e.scale,[s,i]=e.translate;return this._displayTranslationX=-s/t,this._displayScaleX=1/t,this._displayTranslationY=i/r,this._displayScaleY=1/-r,void(this._displayTransform=e)}const[r,s]=t.scale,[i,n]=t.translate,[o,a]=e.scale,[c,l]=e.translate;if(this._displayScaleX=r/o,this._displayTranslationX=(i-c)/o,this._displayScaleY=s/a,this._displayTranslationY=(-n+l)/a,!this._isPoint&&t)throw new Error("InternalError: Relative transformations not supported for non-point features");this._displayTransform=e}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 e=new Sl(this._reader.copy(),this._indices);return e._currentIndex=this._currentIndex,e._displayTransform=this._displayTransform,e._displayTranslationX=this._displayTranslationX,e._displayTranslationY=this._displayTranslationY,e._displayScaleX=this._displayScaleX,e._displayScaleY=this._displayScaleY,e}_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 e=this._reader.readGeometryForDisplay();if(!this._displayTransform)return e;const t=new me.c;return(0,Fa.iC)(t,e,this.hasZ,this.hasM,this.geometryType,this._displayTransform),t.deltaDecode()}readCentroidForDisplay(){const e=this._reader.readCentroidForDisplay()?.clone();if(e){const[t,r]=e.coords;e.coords[0]=t*this._displayScaleX+this._displayTranslationX,e.coords[1]=r*this._displayScaleY+this._displayTranslationY}return e}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(e,t=!1){return this._reader.readAttribute(e,t)}readAttributes(){return this._reader.readAttributes()}joinAttributes(e){return this._reader.joinAttributes(e)}getBounds(e){return this._reader.getBounds(e)}getAttributeHash(){return this._reader.getAttributeHash()}getObjectId(){return this._reader.getObjectId()}getDisplayId(){return this._reader.getDisplayId()}setDisplayId(e){return this._reader.setDisplayId(e)}setIndex(e){return this._reader.setIndex(e)}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(){return this._reader.readLegacyFeatureForDisplay()}readLegacyGeometryForDisplay(){return this._reader.readLegacyGeometryForDisplay()}readGeometryArea(){return this._reader.readGeometryArea()}readGeometryWorldSpace(){return this._reader.readGeometryWorldSpace()}_readGeometry(){return this._reader._readGeometry()}_readAttribute(e,t){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(e){return this.readAttribute(e,!0)}hasField(e){return this._reader.hasField(e)}setField(e,t){return this._reader.setField(e,t)}keys(){return this._reader.keys()}castToText(e=!1){return this._reader.castToText(e)}}class vl{size(){return this.reader.getSize()}get fields(){return this.reader.fields}invalidate(){this._geohashIndex=null,this._geohashIndexHash=null,this._spatialIndex=null,this._gridIndex=null,this._gridIndexHash=null}queryFeaturesInBounds(e){const t=this._getSpatialIndex().search(e);return Sl.from(this.reader,t)}getGeohashIndex(e){const t=JSON.stringify(e);return t!==this._geohashIndexHash&&(this._geohashIndexHash=t,this._geohashIndex=new wl(e),this._geohashIndex.insert(this.reader,this.isTiled)),this._geohashIndex}getGridIndex(e){const t=JSON.stringify(e);return t!==this._gridIndexHash&&(this._gridIndexHash=t,this._gridIndex=new Qc(e),this._gridIndex.insert(this.reader,this.isTiled)),this._gridIndex}_getSpatialIndex(){return this._spatialIndex||(this._spatialIndex=yl.fromReader(this.reader)),this._spatialIndex}}class Il extends vl{constructor(){super(...arguments),this.chunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return Dc.fromOptimizedFeatures(this._features,this._layerSchema??{fields:[]})}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate(),this._layerSchema||(this._layerSchema=e.reader.fullSchema());const{reader:t,removed:r}=e,s=[],i=new Set,n=t.getCursor(),o=new Set(r);for(this.overridenIds.clear();n.next();){const e=n.readOptimizedFeatureWorldSpace(),t=e.objectId;s.push(e),i.add(t),this.overridenIds.add(t),this.removed.delete(t)}for(const e of this._features){const t=e.objectId;o.has(t)||i.has(t)||(s.push(e),this.overridenIds.add(t))}this._features=s;for(const e of i.values())this.removed.delete(e);for(const e of r)this.removed.add(e),this.overridenIds.add(e)}getTileReader(e){if(!this._features.length)return null;const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class El extends Ba{}class Rl extends La{constructor(e,t){super(e,t),this.handledChunks=new Set,this.handledChunksForIdCreation=new Set,this.handledChunksForAttributeData=new Set}destroy(){super.destroy();for(const e of this._source.chunks())this._cleanupChunkIds(e)}invalidateAttributeData(){this.handledChunksForAttributeData.clear()}onSubscribe(e){super.onSubscribe(e),this._evalOptions=e.tile.arcadeEvaluationOptions}createState(e){return new El(e)}get aggregateQueryEngine(){return null}displayMap(e,t,r){const s=new Map(e.map((e=>[t(e),e]))),i=[];for(const e of this._source.chunks()){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId(),n=t.getDisplayId(),o=s.get(e);if(null!=o){const t=r(n,o,e);i.push(t),s.delete(e)}}}return i}getDisplayFeatures(e){const t=new Set(e),r=new Set,s=[];for(const e of this._source.chunks()){const i=e.reader.getCursor();for(;i.next();){const e=i.getObjectId(),n=i.getDisplayId();t.has(n)&&!r.has(e)&&(s.push({...i.readLegacyFeatureWorldSpace(),displayId:n}),r.add(e))}}return{features:s,aggregates:[]}}async*applyOverride(e){const t=[],r=e.reader.getCursor();for(;r.next();){const e=r.getObjectId();t.push(e);const s=this._attributeStore.createDisplayIdForObjectId(e);r.setDisplayId(s),this._attributeStore.setAttributeData(s,r,this._evalOptions)}const s=this.getDisplayIds(t),i=this.getDisplayIds(e.removed),n=new Il;n.applyOverrides(e);for(const e of this._sendStates.values())yield new Va(e.subscription,null,s,!1,n.queryInfo);for(const e of this._sendStates.values()){const t=n.getTileReader(e.subscription.tile);yield new Va(e.subscription,t,i,!1,n.queryInfo)}for(const t of e.removed)this._attributeStore.releaseDisplayIdForObjectId(t)}async*updateChunks(){if(this._source.chunks().length){await this._updateAttributeData();for(const e of this._sendStates.values())yield*this._update(e)}}removeChunks(e){for(const t of e)this.handledChunks.delete(t.chunkId),this.handledChunksForAttributeData.delete(t.chunkId),this._cleanupChunkIds(t)}_cleanupChunkIds(e){if(this.handledChunksForIdCreation.has(e.chunkId)){const t=e.reader.getCursor();for(;t.next();){const e=t.getObjectId();this._attributeStore.releaseDisplayIdForObjectId(e)}this.handledChunksForIdCreation.delete(e.chunkId)}}async _updateAttributeData(){for(const e of this._source.chunks()){const{chunkId:t,reader:r}=e;if(!this.handledChunksForIdCreation.has(t)){this.handledChunksForIdCreation.add(t);const e=r.getCursor();for(;e.next();){const t=this._attributeStore.createDisplayIdForObjectId(e.getObjectId());e.setDisplayId(t)}}}for(const e of this._source.chunks())if(!this.handledChunksForAttributeData.has(e.chunkId)){this.handledChunksForAttributeData.add(e.chunkId);const t=e.reader.getCursor();for(;t.next();){const e=t.getDisplayId();this._attributeStore.setAttributeData(e,t,this._evalOptions)}}}*_update(e){const{subscription:t,handledChunks:r}=e;for(const s of this._source.chunks()){const{chunkId:i}=s;if(r.has(i))continue;r.add(i);const n=s.getTileReader(t.tile);n&&(yield new za(e.subscription,n,!1,s.end,s.queryInfo))}}}class Al{constructor(e){this.data=e,this._referenceCount=0}increment(){this._referenceCount+=1}decrement(){this._referenceCount-=1}empty(){return 0===this._referenceCount}}class Ml{constructor(){this._freeIdsGenerationA=[],this._freeIdsGenerationB=[],this._idCounter=1,this._freeIds=this._freeIdsGenerationA,this._objectIdToDisplayId=new Map}createIdForObjectId(e){let t=this._objectIdToDisplayId.get(e);return t?t.increment():(t=new Al((0|this._getFreeId())>>>0),t.increment(),this._objectIdToDisplayId.set(e,t)),t.data}releaseIdForObjectId(e){const t=this._objectIdToDisplayId.get(e);t&&(t.decrement(),t.empty()&&(this._objectIdToDisplayId.delete(e),this._freeIds.push(t.data)))}incrementGeneration(){this._freeIds=this._freeIds===this._freeIdsGenerationA?this._freeIdsGenerationB:this._freeIdsGenerationA}_getFreeId(){return this._freeIds.length?this._freeIds.pop():this._idCounter++}}const Cl=()=>M.c.getLogger("esri.views.layers.2d.features.support.AttributeStore"),Fl=(Cl(),()=>null),Nl=(0,n.c)("esri-shared-array-buffer");(0,n.c)("esri-atomics");class Pl{constructor(e,t,r){this.size=0,this.texelSize=4,this.dirtyStart=0,this.dirtyEnd=0;const{pixelType:s,layout:i,textureOnly:n}=t;this.textureOnly=n||!1,this.pixelType=s,this.layout=i,this._resetRange(),this.size=e,this.isLocal=r,n||(this.data=this._initData(s,e))}get buffer(){return this.data?.buffer}unsetComponentAllTexels(e,t){const r=this.data;for(let s=0;s<this.size*this.size;s++)r[s*this.texelSize+e]&=~t;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponentAllTexels(e,t){const r=this.data;for(let s=0;s<this.size*this.size;s++)r[s*this.texelSize+e]|=255&t;this.dirtyStart=0,this.dirtyEnd=this.size*this.size-1}setComponent(e,t,r){const s=this.data;for(const i of r)s[i*this.texelSize+e]|=t,this.dirtyStart=Math.min(this.dirtyStart,i),this.dirtyEnd=Math.max(this.dirtyEnd,i)}setComponentTexel(e,t,r){this.data[r*this.texelSize+e]|=t,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)}unsetComponentTexel(e,t,r){this.data[r*this.texelSize+e]&=~t,this.dirtyStart=Math.min(this.dirtyStart,r),this.dirtyEnd=Math.max(this.dirtyEnd,r)}getData(e,t){const r=Ro(e);return this.data[r*this.texelSize+t]}setData(e,t,r){const s=Ro(e),i=1<<t;0!=(this.layout&i)?null!=this.data&&(this.data[s*this.texelSize+t]=r,this.dirtyStart=Math.min(this.dirtyStart,s),this.dirtyEnd=Math.max(this.dirtyEnd,s)):Cl().error("mapview-attributes-store","Tried to set a value for a texel's readonly component")}expand(e){if(this.size=e,!this.textureOnly){const t=this._initData(this.pixelType,e),r=this.data;t.set(r),this.data=t}}toMessage(){const e=this.dirtyStart,t=this.dirtyEnd,r=this.texelSize;if(e>t)return null;this._resetRange();const s=!this.isLocal,i=this.pixelType,n=this.layout,o=this.data;return{start:e,end:t,data:s&&o.slice(e*r,(t+1)*r)||null,pixelType:i,layout:n}}_initData(e,t){const r=ArrayBuffer,i=function(e){switch(e){case tt.OK.UNSIGNED_BYTE:return Uint8Array;case tt.OK.UNSIGNED_SHORT_4_4_4_4:return Uint16Array;case tt.OK.FLOAT:return Float32Array;default:return void M.c.getLogger("esri.views.2d.engine.webgl.Utils").error(new s.c("webgl-utils",`Unable to handle type ${e}`))}}(e),n=new i(new r(t*t*4*i.BYTES_PER_ELEMENT));for(let e=0;e<n.length;e+=4)n[e+1]=255;return n}_resetRange(){this.dirtyStart=2147483647,this.dirtyEnd=0}}class Ol{constructor(e){this._client=e,this._filters=[],this._blocks=new Array,this._attributeComputeInfo=null,this._abortController=new AbortController,this._size=L.OO,this._idsToHighlight=new Map,this._referencesScale=!1,this._referencesGeometry=!1,this._initialized=!1,this.version=0,this._idGenerator=new Ml,this._epoch=1}destroy(){this._abortController.abort()}_initialize(){if(null!=this._blockDescriptors)return;const e=tt.OK.FLOAT;Fl(`Creating AttributeStore ${Nl?"with":"without"} shared memory`),this._blockDescriptors=[{pixelType:tt.OK.UNSIGNED_BYTE,layout:1},{pixelType:tt.OK.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:tt.OK.UNSIGNED_BYTE,layout:15,textureOnly:!0},{pixelType:e,layout:15},{pixelType:e,layout:15},{pixelType:e,layout:15},{pixelType:e,layout:15}],this._blocks=this._blockDescriptors.map((()=>null))}get referencesScale(){return this._referencesScale}get referencesGeometry(){return this._referencesGeometry}get _signal(){return this._abortController.signal}get hasHighlight(){return this._idsToHighlight.size>0}createDisplayIdForObjectId(e){return this._idGenerator.createIdForObjectId(e)}releaseDisplayIdForObjectId(e){return this._idGenerator.releaseIdForObjectId(e)}incrementDisplayIdGeneration(){this._idGenerator.incrementGeneration()}async update(e,t,r,s,i=0){const o=(0,z.qq)(this._schema,e);if(this.version=i,o&&((0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${i}] AttributeStore.update`,{changed:o}),this._schema=e,this._attributeComputeInfo=null,this._initialize(),null!=e))if(r&&(this._filters=await Promise.all(e.filters.map((e=>e?fc.create({geometryType:r.geometryType,hasM:!1,hasZ:!1,timeInfo:r.timeInfo,fieldsIndex:r.fieldsIndex,spatialReference:s??r.spatialReference,filterJSON:e}):null)))),"subtype"!==e.type)this._attributeComputeInfo={isSubtype:!1,map:new Map},await Promise.all(e.bindings.map((async e=>{const r=await this._bind(t,e);this._referencesGeometry=this._referencesGeometry||(r?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(r?.referencesScale()??!1)})));else{this._attributeComputeInfo={isSubtype:!0,subtypeField:e.subtypeField,map:new Map},this._referencesScale=!1,this._referencesGeometry=!1;for(const r in e.bindings){const s=e.bindings[r];await Promise.all(s.map((async e=>{const s=await this._bind(t,e,parseInt(r,10));this._referencesGeometry=this._referencesGeometry||(s?.referencesGeometry()??!1),this._referencesScale=this._referencesScale||(s?.referencesScale()??!1)})))}}}setHighlight(e){const t=this._getBlock(0);t.unsetComponentAllTexels(0,(1<<ln.IX.length)-1);for(const{displayId:r,highlightFlags:s}of e){if(null==r)continue;const e=Ro(r);t.setComponent(0,s,[e])}this._idsToHighlight.clear();for(const{objectId:t,highlightFlags:r}of e)this._idsToHighlight.set(t,r)}setData(e,t,r,s){const i=Ro(e);this._ensureSizeForTexel(i),this._getBlock(t).setData(e,r,s)}getData(e,t,r){return this._getBlock(t).getData(e,r)}getHighlightFlags(e){return this._idsToHighlight.get(e)||0}unsetAttributeData(e){const t=Ro(e);this._getBlock(0).setData(t,0,0)}setAttributeData(e,t,r){const s=Ro(e);this._ensureSizeForTexel(s),this._getBlock(0).setData(s,0,this.getFilterFlags(t));const i=this._attributeComputeInfo;let n=null;i&&(n=i.isSubtype?i.map.get(t.readAttribute(i.subtypeField)):i.map,n?.size&&n.forEach(((e,i)=>{const n=1*i%4,o=Math.floor(1*i/4),a=this._getBlock(o+L.Kc.VV);let c=e.field?.read(t,r);e.valueRepresentation&&(c=function(e,t){if(!e||!t)return e;switch(t){case"radius":case"distance":return 2*e;case"diameter":case"width":return e;case"area":return Math.sqrt(e)}return e}(c,e.valueRepresentation)),(null===c||isNaN(c)||c===1/0||c===-1/0)&&(c=Mt),a.setData(s,n,c)})))}get epoch(){return this._epoch}async sendUpdates(){const e=this._blocks.map((e=>null!=e?e.toMessage():null)),t=this._getInitArgs();(0,n.c)("esri-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.start"),await this._client.update({initArgs:t,blockData:e,version:this.version,sendUpdateEpoch:this._epoch},this._signal),this._epoch+=1,(0,n.c)("esri-2d-log-updating")&&console.log("AttributeStore: _doSendUpdate.end")}_ensureSizeForTexel(e){for(;e>=this._size*this._size;)if(this._expand())return}async _bind(e,t,r){const s=await e.createComputedField(t),{valueRepresentation:i}=t,n=this._attributeComputeInfo;if(n.isSubtype){const e=n.map.get(r)??new Map;e.set(t.binding,{field:s,valueRepresentation:i}),n.map.set(r,e)}else n.map.set(t.binding,{field:s,valueRepresentation:i});return s}_getInitArgs(){return this._initialized?null:(this._initialized=!0,this._getBlock(L.Kc.Animation),this._getBlock(L.Kc.GPGPU),{blockSize:this._size,blockDescriptors:this._blocks.map((e=>null!=e?{textureOnly:e.textureOnly,buffer:e.buffer,pixelType:e.pixelType}:null))})}_getBlock(e){const t=this._blocks[e];if(null!=t)return t;Fl(`Initializing AttributeBlock at index ${e}`);const r=new Pl(this._size,this._blockDescriptors[e],this._client.isLocal);return this._blocks[e]=r,this._initialized=!1,r}_expand(){if(this._size<this._schema.capabilities.maxTextureSize){const e=this._size<<=1;Fl("Expanding block size to",e,this._blocks);for(const t of this._blocks)t?.expand(e);return this._initialized=!1,this._size=e,0}return Cl().error(new s.c("mapview-limitations","Maximum number of onscreen features exceeded.")),-1}isVisible(e){return!!(this._getBlock(0).getData(e,0)&1<<ln.IX.length)}getFilterFlags(e){let t=0;for(let r=0;r<this._filters.length;r++){const s=!!(1<<r),i=this._filters[r];t|=(!s||null==i||i.check(e)?1:0)<<r}let r=0;if(this._idsToHighlight.size){const t=e.getObjectId();r=this.getHighlightFlags(t)}return t<<ln.IX.length|r}}class kl{constructor(e,t){this._connection=e,this._source=t,this._version=1,this._queue=new N.K({concurrency:1,process:e=>this._process(e)}),this._proxy=new Ma({fetch:(e,t)=>this._connection.layerView.fetch(e,t),fetchDictionary:(e,t)=>this._connection.layerView.fetchDictionary(e,t)}),this._attributeStore=new Ol({isLocal:!1,update:e=>(0,a.jO)(this._connection.container.updateAttributeView(e))})}destroy(){this._proxy.destory(),this._strategy?.destroy(),this._attributeStore.destroy()}get aggregateQueryEngine(){return this._strategy?.aggregateQueryEngine}getDisplayFeatures(e){return this._strategy?this._strategy.getDisplayFeatures(e):{features:[],aggregates:[]}}getFeatureObjectIdsForAggregate(e){return this._strategy?this._strategy.getFeatureObjectIdsForAggregate(e):[]}onSubscribe(e){this._strategy?.onSubscribe(e)}onUnsubscribe(e){this._strategy?.onUnsubscribe(e)}async update(e,t,r,s,i){const o=e.processor,a=(0,z.qq)(this._schema,o);if(!a&&!s)return;(0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${this._version}] SymbolProcessor.update`,{changes:a,schema:o}),this._schema=o;const c=V.c.fromJSON(e.source.mutable.dataFilter.outSpatialReference),l=new cc({fields:new q.c,spatialReference:c});return await this._attributeStore.update(o.storage,l,this._source.metadata,c,t),this._strategy?.invalidateAttributeData(),s||(0,z.Y5)(a,"mesh")?((0,z.Y5)(a,"mesh.strategy")&&await this._updateStrategy(o.mesh.strategy,c,i),this._updateSortKey(l,"sortKey"in o.mesh?o.mesh.sortKey:null),((0,z.Y5)(a,"mesh.factory")||"dictionary"===o.mesh.factory.symbology.type)&&(this._factory=await Ra.create(l,this._proxy,o.mesh.factory,r)),this._invalidate(),this._version=t,this._connection.container.updateRenderState(this._version)):void 0}async applyOverride(e){if(!this._strategy)return;const t=this._strategy.applyOverride(e);for await(const e of t)try{await this._process(e)}catch(e){}this._source.applyOverride(e)}async updateChunks(){return this._doUpdateChunks()}async removeChunks(e){this._strategy?.removeChunks(e),this._attributeStore.incrementDisplayIdGeneration()}updateHighlight({highlights:e}){if(!this._strategy)return void this._attributeStore.setHighlight(e.map((({objectId:e,highlightFlags:t})=>({objectId:e,highlightFlags:t,displayId:-1}))));const t=this._strategy.displayMap(e,(({objectId:e})=>e),((e,{highlightFlags:t},r)=>({objectId:r,displayId:e,highlightFlags:t})));this._attributeStore.setHighlight(t)}async _doUpdateChunks(){if(!this._strategy)return;const e=this._strategy.updateChunks(),t=[];for await(const r of e){const e=this._queue.push(r).catch((e=>(0,a.Az)(e)));t.push(e)}try{await Promise.all(t)}catch(e){}(0,n.c)("esri-2d-update-debug")&&console.log("SendUpdates"),await this._attributeStore.sendUpdates(),(0,n.c)("esri-2d-update-debug")&&console.log("SendUpdates.await")}async _updateStrategy(e,t,r){switch(this._strategy?.destroy(),e.type){case"feature":this._strategy=new Rl(this._source,this._attributeStore);break;case"binning":this._strategy=await Bc.create(e,t,this._source,this._attributeStore);break;case"cluster":this._strategy=await tl.create(this._connection,e,t,this._source,this._attributeStore)}for(const e of r)this._strategy.onSubscribe(e)}async _updateSortKey(e,t){if(this._sortInfo=(0,R.mG)(this._sortInfo?.computed),null!=t){const r=t.byRenderer?null:await e.createComputedField(t);this._sortInfo={...t,computed:r}}}_invalidate(){this._strategy&&this._strategy.invalidate()}async _process(e){const t=e.subscription;if((0,n.c)("esri-2d-update-debug")){const r=t.tile;console.debug(`Version[${this._version}] Tile[${r.key.id}, end=${e.end}] Processor._process`)}await this._fetchResources(e),(0,a.wp)(t.signal);const r=await this._write(e,t.tile.arcadeEvaluationOptions),s=t.tile.tileInfoView.tileInfo.isWrappable,{message:i,transferList:o}=r.serialize(s),c=e.createMessage(i,this._version,this._attributeStore.epoch);if((0,a.wp)(t.signal),await this._connection.container.onMessage(c,{signal:t.signal,transferList:o}),(0,n.c)("esri-2d-update-debug")){const r=t.tile;console.debug(`Version[${this._version}] Tile[${r.key.id}, end=${e.end}] Processor._process.await`)}}async _fetchResources(e){await this._fetchMatcherResources(e),await this._fetchWriterResources(e)}async _fetchMatcherResources(e){if(e.reader)return this._factory.enqueueMatcherRequests(this._proxy,e.reader)}async _fetchWriterResources(e){if(!e.reader)return;const t=e.reader.getCursor(),r=e.subscription.tile.arcadeEvaluationOptions;for(;t.next();)this._factory.enqueueWriterRequests(this._proxy,t,r);await this._proxy.fetchEnqueuedResources()}async _write(e,t){const r=e.subscription.tile,s=e.reader?.getCursor(),i=s?.getSize()??0,n=new J(r.key.id,this._strategy.enablePixelBuffering,i);if(!s)return n;const o=r.arcadeEvaluationOptions;for(;s.next();){const e=this._getSortKeyValue(s,t);n.entityStart(s.getDisplayId(),e),this._factory.write(n,this._proxy,s,o,r.level),n.entityEnd()}return n}_getSortKeyValue(e,t){if(!this._sortInfo)return 0;const{computed:r,order:s,byRenderer:i}=this._sortInfo,n=i?this._factory.getSortKey(e,t):r?.read(e,t);return null==n||isNaN(n)?0:n*("asc"===s?-1:1)}}var Dl=r(2600),Ul=r(32848);class Bl{static from(e){let t=0,r=0,s=0;return e.forEach((e=>{const i=e._readGeometry();i&&(r+=i.isPoint?1:i.lengths.reduce(((e,t)=>e+t),0),s+=i.isPoint?1:i.lengths.length,t+=1)})),new Bl(t,r,s)}constructor(e,t,r){this.featureCount=e,this.vertexCount=t,this.ringCount=r}toJSON(){return{featureCount:this.featureCount,ringCount:this.featureCount,vertexCount:this.featureCount}}}var Ll=r(25228);class Gl{static fromSchema(e,t){return new Gl(function(e,t){const{service:r}=e,s=r.orderByFields??t.objectIdField+" ASC",i={returnCentroid:"esriGeometryPolygon"===t.geometryType,returnGeometry:!0,timeReferenceUnknownClient:t.timeReferenceUnknownClient??void 0,outSpatialReference:V.c.fromJSON(e.mutable.dataFilter.outSpatialReference),orderByFields:[s],where:e.mutable.dataFilter.definitionExpression??"1=1",outFields:e.mutable.availableFields};if("feature"===e.type){const{gdbVersion:t,historicMoment:r,timeExtent:s}=e.mutable.dataFilter;return{...i,gdbVersion:t,historicMoment:r?new Date(r):null,timeExtent:s?Ll.c.fromJSON(s):null,outFields:e.mutable.availableFields}}return i}(e,t),e.mutable.dataFilter.customParameters,t.geometryType,e.service.queryMetadata.capabilities)}constructor(e,t,r,s){this._queryParams=e,this._customParameters=t,this._geometryType=r,this._capabilities=s}get pageSize(){if(null==this._capabilities)throw new Error("InternalError: Service does not support paged queries");const{query:e}=this._capabilities,t=e.supportsMaxRecordCountFactor?4:null,r=(e.maxRecordCount??8e3)*(t??1);return Math.min(8e3,r)}updateFields(e){this._queryParams.outFields=e}createPatchFieldsQuery(e,t){const r=e.clone();if("*"===this._queryParams.outFields[0]){if("*"===(r.outFields??[])[0])return null;r.outFields=this._queryParams.outFields}else{const e=new Set(this._queryParams.outFields),s=[];for(const r of e)t.has(r)||s.push(r);if(0===s.length)return null;r.outFields=s}return r.returnGeometry=!1,r.returnCentroid=!1,r.quantizationParameters=null,r.cacheHint=!0,{inner:r,customParameters:this._customParameters}}createQuery(e={}){if(!this._queryParams)throw new Error("InternalError: queryInfo should be defined");return{inner:new _c.c({...this._queryParams,...e}),customParameters:this._customParameters}}createTileQuery(e,t){if(null==this._capabilities)throw new Error("InternalError: Service does not support tile queries");const r=this.createQuery(t),s=r.inner;return s.quantizationParameters=t.quantizationParameters??e.getQuantizationParameters(),s.resultType="tile",s.geometry=e.extent,this._capabilities.query.supportsQuantization?"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset=e.resolution*(0,n.c)("feature-polyline-generalization-factor")):"esriGeometryPolyline"!==this._geometryType&&"esriGeometryPolygon"!==this._geometryType||(s.maxAllowableOffset=e.resolution,"esriGeometryPolyline"===this._geometryType&&(s.maxAllowableOffset*=(0,n.c)("feature-polyline-generalization-factor"))),s.defaultSpatialReferenceEnabled=this._capabilities.query.supportsDefaultSpatialReference,s.compactGeometryEnabled=this._capabilities.query.supportsCompactGeometry,this._capabilities.query.supportsMaxRecordCountFactor&&(s.maxRecordCountFactor=4),r}createPagedTileQuery(e,t){const r=this.pageSize;return this.createTileQuery(e,{start:r*t,num:r,returnExceededLimitFeatures:!0})}createPagedQuery(e){const t=this.pageSize;return this.createQuery({start:t*e,num:t,returnExceededLimitFeatures:!0,maxRecordCountFactor:4})}}let zl=class extends E.c{constructor(e){super(),this._connection=e,this._enabledEventTypes=new Set,this._updateInfo={websocket:0,client:0},this._lastTime=performance.now(),this.addHandles([(0,l.aE)((()=>this._strategy?.connectionStatus??"disconnected"),(e=>{this._layerView.setProperty({propertyName:"pipelineConnectionStatus",value:e})}),{initial:!0}),(0,l.aE)((()=>this._strategy?.errorString||null),(e=>this._layerView.setProperty({propertyName:"pipelineErrorString",value:e})),{initial:!0})])}destroy(){this._strategy=null,this.removeAllHandles()}get _layerView(){return this._connection.layerView}set strategy(e){null==this._strategy&&this._resetUpdateInfo(performance.now());const t="event-handles";this.removeHandles(t),null!=e&&this.addHandles([e.events.on("data-received",(e=>this._onFeature(e))),e.events.on("message-received",(e=>this._onWebSocketMessage(e))),e.events.on("features-updated",(e=>this._onUpdate(e))),e.events.on("tick",(()=>this._onTick()))],t),this._strategy=e}updateCustomParameters(e){null!=e&&this._strategy?.updateCustomParameters(e)}sendMessageToSocket(e){this._strategy?.sendMessageToSocket(e)}sendMessageToClient(e){this._strategy?.sendMessageToClient(e)}enableEvent(e,t){t?this._enabledEventTypes.add(e):this._enabledEventTypes.delete(e)}disconnect(){this._strategy?.disconnect()}connect(){this._strategy?.connect()}clear(){this._strategy?.clear()}_onWebSocketMessage(e){this._enabledEventTypes.has("message-received")&&this._layerView.emitEvent({name:"message-received",event:e})}_onFeature(e){this._updateInfo.websocket++,this._enabledEventTypes.has("data-received")&&this._layerView.emitEvent({name:"data-received",event:{attributes:e.attributes,centroid:e.centroid,geometry:e.geometry}})}_onUpdate(e){this._updateInfo.client+=e}_onTick(){const e=performance.now(),t=e-this._lastTime;if(t>2500){const r=Math.round(this._updateInfo.client/(t/1e3)),s=Math.round(this._updateInfo.websocket/(t/1e3));this._resetUpdateInfo(e),this._layerView.emitEvent({name:"update-rate",event:{client:r,websocket:s}})}}_resetUpdateInfo(e){this._lastTime=e,this._updateInfo.client=0,this._updateInfo.websocket=0}};(0,I._)([(0,A.qq)()],zl.prototype,"_strategy",void 0),zl=(0,I._)([(0,C.c)("esri.views.2d.layers.features.sources.StreamMessenger")],zl);class Vl{constructor(e){this._store=e,this._controller=new AbortController}destroy(){this._controller.abort()}get _options(){return{signal:this._controller.signal}}async queryOverride(e){throw new Error("InternalError: LoadStrategy does not support fetching")}}var ql=r(46448),Hl=r(42736),Wl=r(96248),Yl=r(91232),Xl=r(58580);const jl=268435455;class $l{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 Kl=268435455,Ql=128e3,Zl={small:{delta:new Int32Array(128),decoded:new Int32Array(128)},large:{delta:new Int32Array(Ql),decoded:new Int32Array(Ql)}};function Jl(e){return e<=Zl.small.delta.length?Zl.small:(e<=Zl.large.delta.length||(Zl.large.delta=new Int32Array(Math.round(1.25*e)),Zl.large.decoded=new Int32Array(Math.round(1.25*e))),Zl.large)}function eu(e){for(;e.next();){if(1===e.tag())return e.getMessage();e.skip()}return null}function tu(e,t,r,s,i,n){return.5*Math.abs(e*s+r*n+i*t-e*n-r*t-i*s)}function ru(e,t,r,s){return 0==e*s-r*t&&e*r+t*s>0}class su extends kc{static fromBuffer(e,t,r=!1){const i=t.geometryType,n=function(e){try{const t=2,r=new Yl.c(new Uint8Array(e),new DataView(e));for(;r.next();){if(r.tag()===t)return eu(r.getMessage());r.skip()}}catch(e){const t=new s.c("query:parsing-pbf","Error while parsing FeatureSet PBF payload",{error:e});M.c.getLogger("esri.view.2d.layers.features.support.FeatureSetReaderPBF").error(t)}return null}(e),o=function(e,t,r=!1){const i=e.asUnsafe(),n=i.pos(),o=new $l;let a=0,c=0,l=null,u=null,h=null,d=!1;const _=[];for(;i.next();)switch(i.tag()){case 1:l=i.getString();break;case 3:u=i.getString();break;case 12:h=i.processMessage(Xl.UH);break;case 9:if(o.exceededTransferLimit=i.getBool(),o.exceededTransferLimit){o.offsets.geometry=r?new Float64Array(8e3):new Int32Array(8e3),o.centroid=r?new Float64Array(16e3):new Int32Array(16e3);for(let e=0;e<o.centroid.length;e++)o.centroid[e]=jl}break;case 13:{const e=i.processMessage(Xl.gD);e.index=a++,_.push(e);break}case 15:{const e=i.getLength(),s=i.pos()+e;if(!o.exceededTransferLimit){const e=o.offsets.geometry,t=o.centroid;e.push(0),t.push(jl),t.push(jl)}!d&&o.exceededTransferLimit&&(d=!0,o.offsets.attributes=r?new Float64Array(8e3*a):new Uint32Array(8e3*a));let n=c*a;for(;i.pos()<s&&i.next();)switch(i.tag()){case 1:{d?o.offsets.attributes[n++]=i.pos():o.offsets.attributes.push(i.pos());const e=i.getLength();i.skipLen(e);break}case 2:if(t){const e=i.getLength(),t=i.pos()+e;for(;i.pos()<t&&i.next();)switch(i.tag()){case 3:{i.getUInt32();const e=i.getSInt64(),t=i.getSInt64();o.centroid[2*c]=e,o.centroid[2*c+1]=t;break}default:i.skip()}}else{o.offsets.geometry[c]=i.pos();const e=i.getLength();o.vertexCount+=e,i.skipLen(e)}break;case 4:{const e=i.getLength(),t=i.pos()+e;for(;i.pos()<t&&i.next();)switch(i.tag()){case 3:{i.getUInt32();const e=i.getSInt64(),t=i.getSInt64();o.centroid[2*c]=e,o.centroid[2*c+1]=t;break}default:i.skip()}break}default:i.skip()}c++,o.hasFeatures=!0;break}default:i.skip()}const p=l||u;if(!p)throw new s.c("FeatureSet has no objectId or globalId field name");return o.fields=new q.c(_),o.featureCount=c,o.fieldCount=a,o.objectIdFieldIndex=o.fields.get(p)?.index,o.transform=h,o.displayIds=new Uint32Array(o.featureCount),o.groupIds=new Uint16Array(o.featureCount),i.move(n),o}(n,"esriGeometryPoint"===i,r);return new su(n,o,t)}constructor(e,t,r){super(r),this._hasNext=!1,this._isPoints=!1,this._featureIndex=-1,this._featureOffset=0,this._cache={area:0,unquantGeometry:void 0,geometry:void 0,centroid:void 0,legacyFeature:void 0,optFeature:void 0},this._geometryType=r.geometryType,this._reader=e,this._header=t,this._hasNext=t.hasFeatures,this._isPoints="esriGeometryPoint"===r.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(e){this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0,this._featureIndex=e}getAttributeHash(){let e="";for(const t of this._header.fields.fields)e+=this._readAttributeAtIndex(t.index)+".";return e}getObjectId(){return this._readAttributeAtIndex(this._header.objectIdFieldIndex)}getDisplayId(){return this._header.displayIds[this._featureIndex]}setDisplayId(e){this._header.displayIds[this._featureIndex]=e}readGeometryArea(){return this._cache.area||this._readGeometry(!0),this._cache.area}copy(){const e=this._reader.clone(),t=new su(e,this._header,this.metadata);return this.copyInto(t),t}next(){for(this._cache.area=0,this._cache.unquantGeometry=void 0,this._cache.geometry=void 0,this._cache.centroid=void 0,this._cache.legacyFeature=void 0,this._cache.optFeature=void 0;++this._featureIndex<this._size&&!this._getExists(););return this._featureIndex<this._size}_readX(){return this._header.centroid[2*this._featureIndex]}_readY(){return this._header.centroid[2*this._featureIndex+1]}_readServerCentroid(){const e=this._header.centroid[2*this._featureIndex],t=this._header.centroid[2*this._featureIndex+1];return e===Kl?null:new me.c([],[e,t])}_readGeometry(e=!1){if(void 0===this._cache.geometry){let t=null;if(this._isPoints){if(this._header.centroid[2*this._featureIndex]===Kl)return null;const e=this._header.centroid[2*this._featureIndex],r=this._header.centroid[2*this._featureIndex+1];t=new me.c([],[e,r])}else{const r=this._header.offsets.geometry[this._featureIndex],s=this._reader;if(0===r)return null;s.move(r);try{t=e?this._parseGeometryForDisplay(s):this._parseGeometry(s)}catch(e){return console.error("Failed to parse geometry!",e),null}}return 0===t?.coords.length&&(t=null),this._cache.geometry=t,t}return this._cache.geometry}_readAttribute(e,t){const r=this._header.fields.get(e);if(null==r)return;let s=this._readAttributeAtIndex(r.index);"esriFieldTypeTimestampOffset"===this.fields.get(e)?.type&&(s=this.parseTimestampOffset(s));const i=this._header.fields.isDateField(r.name);return t?null==s?s:i?new Date(s):s:s}_readAttributes(){const e={};for(const t of this._header.fields.fields)e[t.name]=this._readAttributeAtIndex(t.index);return e}copyInto(e){super.copyInto(e),e._featureIndex=this._featureIndex,e._featureOffset=this._featureOffset,e._hasNext=this._hasNext}_readAttributeAtIndex(e){const t=this._header.offsets.attributes[this._featureIndex*this._header.fieldCount+e],r=this._reader;return r.move(t),function(e){const t=e.getLength(),r=e.pos()+t;for(;e.pos()<r&&e.next();)switch(e.tag()){case 1:return e.getString();case 2:return e.getFloat();case 3:return e.getDouble();case 4:return e.getSInt32();case 5:return e.getUInt32();case 6:return e.getInt64();case 7:return e.getUInt64();case 8:return e.getSInt64();case 9:return e.getBool();default:return e.skip(),null}return null}(r)}_readGeometryDeltaDecoded(e=!1){if(void 0===this._cache.unquantGeometry){const t=this._readGeometry(e);if(!t)return this._cache.unquantGeometry=void 0,null;if(!this.getInTransform())return this._cache.unquantGeometry=t,t;const r=Jl(t.coords.length).decoded,s=t.clone(r),i=s.coords;let n=0;for(const e of s.lengths){for(let t=1;t<e;t++){const e=2*(n+t),r=2*(n+t-1);i[e]+=i[r],i[e+1]+=i[r+1]}n+=e}return this._cache.unquantGeometry=s,s}return this._cache.unquantGeometry}_parseGeometry(e){const t=e.asUnsafe(),r=t.getLength(),s=t.pos()+r,i=[],n=[];for(;t.pos()<s&&t.next();)switch(t.tag()){case 2:{const e=t.getUInt32(),r=t.pos()+e;for(;t.pos()<r;)n.push(t.getUInt32());break}case 3:{const e=t.getUInt32(),r=t.pos()+e;for(i.push(t.getSInt64()),i.push(t.getSInt64()),this.hasZ&&t.getSInt64(),this.hasM&&t.getSInt64();t.pos()<r;)i.push(t.getSInt64()),i.push(t.getSInt64()),this.hasZ&&t.getSInt64(),this.hasM&&t.getSInt64();break}default:t.skip()}return new me.c(n,i)}_parseGeometryForDisplay(e){const t=e.asUnsafe(),r=t.getLength(),s=t.pos()+r,i=[],n=[];let o=0,a=0,c=null,l=0;const u="esriGeometryPolygon"===this.geometryType;for(;t.pos()<s&&t.next();)switch(t.tag()){case 2:{const e=t.getUInt32(),r=t.pos()+e;for(;t.pos()<r;){const e=t.getUInt32();i.push(e),o+=e}c=Jl(2*o).delta;break}case 3:{t.getUInt32();const e=2+(this.hasZ?1:0)+(this.hasM?1:0);(0,R.EN)(c);for(const r of i)if(a+e*r>c.length)for(let e=0;e<r;e++)t.getSInt32(),t.getSInt32(),this.hasZ&&t.getSInt32(),this.hasM&&t.getSInt32();else if(u){const e=this.getAreaSimplificationThreshold(r,this._header.vertexCount);let s=2,i=1;const o=!1;let u=t.getSInt32(),h=t.getSInt32();c[a++]=u,c[a++]=h,this.hasZ&&t.getSInt32(),this.hasM&&t.getSInt32();let d=t.getSInt32(),_=t.getSInt32();for(this.hasZ&&t.getSInt32(),this.hasM&&t.getSInt32();s<r;){let r=t.getSInt32(),n=t.getSInt32();this.hasZ&&t.getSInt32(),this.hasM&&t.getSInt32();const o=u+d,p=h+_;tu(u,h,o,p,o+r,p+n)>=e?(l+=-.5*(o-u)*(p+h),i>1&&ru(c[a-2],c[a-1],d,_)?(c[a-2]+=d,c[a-1]+=_):(c[a++]=d,c[a++]=_,i++),u=o,h=p):(r+=d,n+=_),d=r,_=n,s++}i<3||o?a-=2*i:(l+=-.5*(u+d-u)*(h+_+h),ru(c[a-2],c[a-1],d,_)?(c[a-2]+=d,c[a-1]+=_,n.push(i)):(c[a++]=d,c[a++]=_,n.push(++i)))}else{let e=0,s=t.getSInt32(),i=t.getSInt32();this.hasZ&&t.getSInt32(),this.hasM&&t.getSInt32(),c[a++]=s,c[a++]=i,e+=1;for(let n=1;n<r;n++){const r=t.getSInt32(),o=t.getSInt32(),u=s+r,h=i+o;l+=-.5*(u-s)*(h+i),this.hasZ&&t.getSInt32(),this.hasM&&t.getSInt32(),n>2&&ru(c[a-2],c[a-1],r,o)?(c[a-2]+=r,c[a-1]+=o):(c[a++]=r,c[a++]=o,e+=1),s=u,i=h}n.push(e)}break}default:t.skip()}return this._cache.area=l,n.length?new me.c(n,c):null}}class iu{constructor(e,t){this.service=e,this._metadata=t}destroy(){}}class nu extends iu{constructor(e,t){super(e,t),this._portsOpen=async function(e){const t=new ql.c;return await t.open(e,{}),t}(e.source).then((e=>this.client=e))}destroy(){this.client.close(),this.client=null}async executeQuery(e,t){await this._portsOpen;const r=await this.client.invoke("queryFeatures",e.toJSON(),t);return Dc.fromFeatureSet(r,this._metadata)}}class ou extends iu{async executeQuery(e,t){const{data:r}=await(0,Ul.u_)(this.service.source,e,t),s=!e.quantizationParameters;return su.fromBuffer(r,this._metadata,s)}}class au extends iu{async executeQuery(e,t){const{source:r,queryMetadata:s}=this.service,i=s.capabilities;if(null!=e.quantizationParameters&&!i.query.supportsQuantization){const s=e.clone(),i=(0,Hl.eE)(s.quantizationParameters);s.quantizationParameters=null;const{data:n}=await(0,Ul.EL)(r,s,this._metadata.spatialReference,t),o=(0,Fa.ui)(n,this._metadata.objectIdField);return(0,Fa.m)(i,o),Dc.fromOptimizedFeatureSet(o,this._metadata)}const{data:n}=await(0,Ul.EL)(r,e,this._metadata.spatialReference,t);return"esriGeometryPoint"===this._metadata.geometryType&&(n.features=n.features?.filter((e=>{if(null!=e.geometry){const t=e.geometry;return Number.isFinite(t.x)&&Number.isFinite(t.y)}return!0}))),Dc.fromFeatureSet(n,this._metadata)}}class cu extends iu{async executeQuery(e,t){const{capabilities:r}=this.service.queryMetadata;if(e.quantizationParameters&&!r.query.supportsQuantization){const r=e.clone(),s=(0,Hl.eE)(r.quantizationParameters);r.quantizationParameters=null;const i=await(0,Wl.wB)(this.service.source,e,t);return(0,Fa.m)(s,i),Dc.fromOptimizedFeatureSet(i,this._metadata)}const s=await(0,Wl.wB)(this.service.source,e,t);return Dc.fromOptimizedFeatureSet(s,this._metadata)}}class lu extends Vl{constructor(e,t,r,s,i){super(r),this._serviceInfo=e,this._queryInfo=t,this._metadata=s,this._eventLog=i,this._queue=new N.K({concurrency:8,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters};return this._adapter.executeQuery(e.query.inner,t)}}),this._adapter=function(e,t){switch(e.type){case"memory":return new nu(e,t);case"ogc":return new cu(e,t);case"feature-service":return e.queryMetadata.capabilities.query.supportsFormatPBF&&(0,n.c)("featurelayer-pbf")?new ou(e,t):new au(e,t)}}(e,s)}async updateFields(e){this._queryInfo.updateFields(e);const t=Array.from(this._store.chunks()).map((async e=>{const t=_c.c.fromJSON(e.queryInfo.queryJSON);if(t)try{return await this._tryUpdateFields(e.reader,t),null}catch(e){return e}})),r=(await Promise.all(t)).filter((e=>e));if(r.length)throw new s.c("featurelayer-query","Encountered errors when downloading fields",{errors:r})}async queryOverride({edits:e}){const t=[],r=[];for(const s of e.removed)null!=s.objectId&&-1!==s.objectId?t.push(s.objectId):r.push(s.globalId);r.length&&t.push(...this._mapGlobalIdsToObjectIds(r));const s=e.addOrModified.map((({objectId:e})=>e)),i=this._queryInfo.createQuery({objectIds:s});return{reader:await this._fetch(i),removed:t}}_mapGlobalIdsToObjectIds(e){const t=new Set(e),r=this._metadata.globalIdField;if(null==r)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const s=[];return this._store.forEachUnsafe((e=>{const i=e.readAttribute(r);t.has(i)&&s.push(e.getObjectId())})),s}async _fetch(e,t){const r=await this._enqueue(e,t);return await this._tryUpdateFields(r,e.inner),r}async _tryUpdateFields(e,t){const r=this._queryInfo.createPatchFieldsQuery(t,e.fields);if(!r)return;const s=await this._enqueue(r,this._options);e.joinAttributes(s)}async _enqueue(e,t){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}class uu extends lu{constructor(){super(...arguments),this._chunksById=new Map}unload(e){this._removeChunks(e.tile)}_addChunk(e){const t=e.tile.id;this._chunksById.has(t)||this._chunksById.set(t,[]);const r=e.size();(r||e.first||e.end)&&((0,n.c)("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] ATileLoadStrategy.addChunk [count=${r}]`),this._chunksById.get(t).push(e),this._store.insert(e))}_removeChunks(e){const t=this._chunksById.get(e.key.id)??[];for(const r of t)(0,n.c)("esri-2d-update-debug")&&console.debug(`Tile[${e.key.id}] Chunk[${r.chunkId}] ATileLoadStrategy.removeChunk`),this._store.remove(r);this._chunksById.delete(e.key.id)}}class hu extends vl{constructor(e,t,r,s,i,n){super(),this._reader=e,this._queryJSON=t,this._tile=r,this._sourceTile=s,this._sourceTileDepth=i,this._end=n,this.chunkId=`${this._tile.key.id}.${this._sourceTile?.key.id}${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(e){return this._tile.key.id===e.key.id?this.reader:null}}class du{constructor(e,t){this.subscription=e,this._tileIdToResult=new Map,this._controller=new AbortController,(0,a.wD)(e.options,(()=>this._controller.abort())),(0,a.wD)(t,(()=>this._controller.abort()))}get(e){return this._tileIdToResult.get(e)}set(e,t){this._tileIdToResult.set(e,t)}get options(){return{signal:this._controller.signal}}}class _u extends uu{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(e){this._loadStates.has(e.key.id)||this._loadStates.set(e.key.id,new du(e,this._options));const t=this._loadStates.get(e.key.id);let r;try{for await(const r of this._fetchChunkInfos(t,e.tile,0)){const{queryJSON:t,reader:s,sourceTile:i,sourceTileDepth:n,tile:o}=r,c=new hu(s,t,o,i,n,!1);(0,a.wp)(e.options),this._addChunk(c)}}catch(e){r=e}const s=new hu(Dc.empty(this._metadata),null,e.tile,null,-1,!0);if(this._addChunk(s),r)throw r}unload(e){super.unload(e),this._loadStates.delete(e.key.id)}async*_fetchChunkInfos(e,t,r){let s=e.get(t.id);const i=!!s;if(s||(s=await this._fetchChunkInfo(e,t,r),e.set(t.id,s)),s.reader.exceededTransferLimit&&r<(0,n.c)("featurelayer-query-max-depth"))for(const s of t.createChildTiles())yield*this._fetchChunkInfos(e,s,r+1);else i||(yield s)}async _fetchChunkInfo(e,t,r){const s=e.subscription.tile.getQuantizationParameters(),i=this._queryInfo.createTileQuery(t,{returnExceededLimitFeatures:!1,quantizationParameters:s});return{reader:await this._fetch(i,e.subscription.options),queryJSON:i.inner.toJSON(),tile:e.subscription.tile,sourceTile:t,sourceTileDepth:r}}}class pu extends vl{constructor(e,t,r,s,i){super(),this._reader=e,this._queryJSON=t,this._tile=r,this._page=s,this._end=i,this.chunkId=`${this._tile.key.id}.${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(e){return this._tile.key.id===e.key.id?this.reader:null}}class fu{constructor(e,t){this.subscription=e,this._pages=new Set,this._controller=new AbortController,this._done=!1,(0,a.wD)(e.options,(()=>this._controller.abort())),(0,a.wD)(t,(()=>this._controller.abort()))}resetAbortController(){this._controller=new AbortController}get pageStart(){let e=-1;for(const t of this._pages.values())e=Math.max(e,t);return e+1}get done(){return this._done}get options(){return{signal:this._controller.signal}}add(e,t){this._pages.add(e),this._done=this._done||t}}class mu extends uu{constructor(){super(...arguments),this._loadStates=new Map}get about(){return{willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}async load(e){this._loadStates.has(e.key.id)||this._loadStates.set(e.key.id,new fu(e,this._options));const t=this._loadStates.get(e.key.id);let r;t.resetAbortController();try{await this._fetchPages(t)}catch(e){r=e}const s=new pu(Dc.empty(this._metadata),null,e.tile,-1,!0);if((0,a.wv)(t.options)||this._addChunk(s),r)throw r}unload(e){super.unload(e),this._loadStates.delete(e.key.id)}async _fetchPages(e){let t=0,r=e.pageStart,s=1;for(;t<20&&!e.done;){const i=[];for(let t=0;t<s;t++)i.push(this._fetchChunk(e,r++));const n=await Promise.all(i);for(const t of n)(0!==t.size()||t.first)&&(e.add(t.page,!t.reader.exceededTransferLimit),(0,a.wp)(e.options),this._addChunk(t));t++,s=Math.min(s+1,4)}}async _fetchChunk(e,t){const r=e.subscription.tile,s=this._queryInfo.createPagedTileQuery(r,t),i=await this._fetch(s,e.options);return new pu(i,s.inner.toJSON(),r,t,!1)}}class gu extends vl{constructor(e,t,r,s){super(),this._reader=e,this._queryJSON=t,this._page=r,this._end=s,this.chunkId=`${this._page}${this.end?"e":""}`}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(e){const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class yu extends lu{constructor(e,t,r,s,i,n){super(e,t,r,i,n),this._random=new c.c(1e3),this._promise=this._downloadPages(s)}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(e){return this._promise}unload(e){}async _downloadPages(e){const t=Math.ceil(e/this._queryInfo.pageSize),r=Array.from({length:t},((e,t)=>t)).sort(((e,t)=>this._random.getInt()-this._random.getInt())),i=await Promise.all(r.map((e=>this._downloadPage(e)))),n=new gu(Dc.empty(this._metadata),null,-1,!0);this._store.insert(n);const o=i.filter((e=>e));if(o.length)throw new s.c("featurelayer-query","Encountered errors when downloading data",{errors:o})}async _downloadPage(e){try{const t=this._queryInfo.createPagedQuery(e),r=await this._fetch(t,this._options),s=new gu(r,t.inner.toJSON(),e,!1);return(0,a.wp)(this._options),this._store.insert(s),null}catch(e){return e}}}class xu{constructor(e){this.size=0,this._start=0,this.maxSize=e,this._buffer=new Array(e)}get entries(){return this._buffer}enqueue(e){if(this.size===this.maxSize){const t=this._buffer[this._start];return this._buffer[this._start]=e,this._start=(this._start+1)%this.maxSize,t}return this._buffer[(this._start+this.size++)%this.maxSize]=e,null}dequeue(){if(0===this.size)return null;const e=this._buffer[this._start];return this._buffer[this._start]=null,this.size--,this._start=(this._start+1)%this.maxSize,e}peek(){return 0===this.size?null:this._buffer[this._start]}find(e){if(0===this.size)return null;for(const t of this._buffer)if(null!=t&&e(t))return t;return null}clear(e){let t=this.dequeue();for(;null!=t;)e&&e(t),t=this.dequeue()}}const bu="__esri_timestamp__";class Tu{constructor(e,t,r,s,i=128){this._trackIdToObservations=new Map,this._idCounter=0,this._lastPurge=performance.now(),this._addOrUpdated=new Map,this._removed=[],this._maxAge=0,this._timeInfo=r,this._purgeOptions=s,this.store=e,this.objectIdField=t,this.purgeInterval=i,this._useGeneratedIds="__esri_stream_id__"===this.objectIdField}removeById(e){this._removed.push(e)}removeByTrackId(e){const t=this._trackIdToObservations.get(e);if(t)for(const e of t.entries)this._removed.push(e)}add(e){if(this._useGeneratedIds){const t=this._nextId();e.attributes[this.objectIdField]=t,e.objectId=t}else e.objectId=e.attributes[this.objectIdField];const t=e.objectId;if(this._addOrUpdated.set(t,e),this._maxAge=Math.max(this._maxAge,e.attributes[this._timeInfo.startTimeField]),!this._timeInfo.trackIdField)return null==this._trackIdLessObservations&&(this._trackIdLessObservations=new xu(1e5)),void this._trackIdLessObservations.enqueue(t);const r=e.attributes[this._timeInfo.trackIdField];if(!this._trackIdToObservations.has(r)){const e=null!=this._purgeOptions?.maxObservations?this._purgeOptions.maxObservations:1e3,t=(0,Go.qk)(e,0,1e3);this._trackIdToObservations.set(r,new xu(t))}const s=this._trackIdToObservations.get(r),i=s?.enqueue(t);null!=i&&(this._addOrUpdated.has(i)?this._addOrUpdated.delete(i):this._removed.push(i))}checkForUpdates(){const e=this._getToAdd(),t=this._getToRemove(),r=performance.now();r-this._lastPurge>=this.purgeInterval&&(this._purge(r),this._lastPurge=r);const s=[];if(null!=t)for(const e of t){const t=this.store.removeById(e);null!=t&&s.push(t)}const i=[];if(null!=e){const s=new Set(t??[]);for(const t of e)s.has(t.objectId)||(t.attributes[bu]=r,this.store.add(t),i.push(t))}(i.length||s?.length)&&this.store.update(i,s)}_getToAdd(){if(!this._addOrUpdated.size)return null;const e=new Array(this._addOrUpdated.size);let t=0;return this._addOrUpdated.forEach((r=>e[t++]=r)),this._addOrUpdated.clear(),e}_getToRemove(){const e=this._removed;return this._removed.length?(this._removed=[],e):null}_nextId(){const e=this._idCounter;return this._idCounter=(this._idCounter+1)%4294967294+1,e}_purge(e){const t=this._purgeOptions;null!=t&&(this._purgeSomeByDisplayCount(t),this._purgeByAge(t),this._purgeByAgeReceived(e,t),this._purgeTracks())}_purgeSomeByDisplayCount(e){if(!e.displayCount)return;let t=this.store.size;if(t>e.displayCount){if(this._timeInfo.trackIdField)for(const r of this._trackIdToObservations.values())if(t>e.displayCount&&r.size){const e=r.dequeue();this._removed.push(e),t--}if(null!=this._trackIdLessObservations){let r=t-e.displayCount;for(;r-- >0;){const e=this._trackIdLessObservations.dequeue();null!=e&&this._removed.push(e)}}}}_purgeByAge(e){const t=this._timeInfo?.startTimeField;if(!e.age||!t)return;const r=60*e.age*1e3,s=this._maxAge-r;this.store.forEach((e=>{e.attributes[t]<s&&this._removed.push(e.objectId)}))}_purgeByAgeReceived(e,t){if(!t.ageReceived)return;const r=e-60*t.ageReceived*1e3;this.store.forEach((e=>{e.attributes[bu]<r&&this._removed.push(e.objectId)}))}_purgeTracks(){this._trackIdToObservations.forEach(((e,t)=>{0===e.size&&this._trackIdToObservations.delete(t)}))}}var wu=r(57006);let Su=class extends E.c{constructor(e){super(e)}get connectionStatus(){return this.connection?.connectionStatus}get errorString(){return this.connection?.errorString}};(0,I._)([(0,A.qq)()],Su.prototype,"connection",void 0),(0,I._)([(0,A.qq)()],Su.prototype,"connectionStatus",null),(0,I._)([(0,A.qq)()],Su.prototype,"errorString",null),Su=(0,I._)([(0,C.c)("esri.views.2d.layers.features.sources.StreamConnectionState")],Su);class vu{constructor(e,t){this._metadata=e,this._onUpdate=t,this._objectIdToFeature=new Map}get size(){return this._objectIdToFeature.size}get reader(){return Dc.fromFeatures([...this._objectIdToFeature.values()],this._metadata)}add(e){this._objectIdToFeature.set(e.objectId,e)}forEach(e){this._objectIdToFeature.forEach(e)}removeById(e){const t=this._objectIdToFeature.get(e);return t?(this._objectIdToFeature.delete(e),t):null}clear(){this._objectIdToFeature=new Map}update(e,t){this._onUpdate(e?.length??0)}}class Iu extends vl{constructor(e){super(),this._reader=e,this.chunkId="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(e){const t=this.queryFeaturesInBounds(e.bounds);return t.setTransformForDisplay(e.transform),t}}class Eu extends Vl{constructor(e,t,r,s,i){super(r),this._service=e,this._dataFilter=t,this._streamOptions=s,this._metadata=i,this._connectionState=new Su,this.events=new Oa.c;const{objectIdField:n,timeInfo:o}=this._metadata,{purgeOptions:a}=t;this._stagingStore=new vu(this._metadata,(e=>this.events.emit("features-updated",e))),this._manager=new Tu(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(){this._manager.checkForUpdates(),this._chunk&&this._store.remove(this._chunk),this._chunk=new Iu(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick")}async updateFields(e){throw new Error("Updating available fields not supported for StreamLayer")}async load(e){}unload(e){}disconnect(){this._connection=(0,R.mG)(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:e,spatialReference:t}=this._metadata,{maxReconnectionAttempts:r,maxReconnectionInterval:s,geometryDefinition:n,definitionExpression:o,customParameters:a}=this._dataFilter;this._connection=(0,wu.createConnection)(this._service.source,t,this._streamOptions.outSR,e,o,n,r,s,a),this._handlesGroup=(0,i.Ip)([this._connection.on("data-received",(e=>this._onFeature(e))),this._connection.on("message-received",(e=>this._onWebSocketMessage(e)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear()}updateCustomParameters(e){this._connection?.updateCustomParameters(e)}sendMessageToSocket(e){this._connection?.sendMessageToSocket(e)}sendMessageToClient(e){this._connection?.sendMessageToClient(e)}_onWebSocketMessage(e){if("type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this.clear()}this.events.emit("message-received",e)}_onFeature(e){try{this._manager.add(e),this.events.emit("data-received",e)}catch(e){}}}class Ru{constructor(e){this._onChange=e,this._chunks=new Map,this._overrideChunk=new Il,this._chunksToRemove=[],this.events=new Oa.c,this.featureAdapter=new pc}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear()}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e){(0,n.c)("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){(0,n.c)("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyOverrides(e){this._overrideChunk.applyOverrides(e);for(const e of this._chunks.values())e.reader.removeIds(this._overrideChunk.overridenIds),e.invalidate()}forEach(e){const t=new Set;for(const r of this.chunks()){const s=r.reader.getCursor();for(;s.next();){const r=s.getObjectId();t.has(r)||(e(s.copy()),t.add(r))}}}forEachUnsafe(e){const t=new Set;for(const r of this.chunks()){const s=r.reader.getCursor();for(;s.next();){const r=s.getObjectId();t.has(r)||(e(s),t.add(r))}}}forEachInBounds(e,t){const r=new Set;for(const s of this.chunks()){const i=s.queryFeaturesInBounds(e);for(;i.next();){const e=i.getObjectId();r.has(e)||(t(i.copy()),r.add(e))}}}forEachBounds(e,t){const r=(0,ka.Su)();for(const s of e)s.getBounds(r)&&t(r)}}var Au=r(23964),Mu=r(60936);let Cu=class extends E.c{constructor(e){super(e),this.debugName="",this._updatingHandles=new Mu.A,this._idToUpdatingState=new Au.c}get updating(){const e=this._updatingHandles.updating||Array.from(this._idToUpdatingState.values()).some((e=>e));if((0,n.c)("esri-2d-log-updating")){const t=Array.from(this._idToUpdatingState.entries()).map((([e,t])=>`-> ${e}: ${t}`)).join("\n");console.log(`${this.debugName}: Updating: ${e}\n-> Handles: ${this._updatingHandles.updating}\n${t}`)}return e}addUpdateTracking(e,t){const r=(0,l.aE)((()=>t.updating),(t=>this._idToUpdatingState.set(e,t)),{sync:!0});this.addHandles(r)}addPromise(e){return this._updatingHandles.addPromise(e)}};(0,I._)([(0,A.qq)({constructOnly:!0})],Cu.prototype,"debugName",void 0),(0,I._)([(0,A.qq)({readOnly:!0})],Cu.prototype,"updating",null),Cu=(0,I._)([(0,C.c)("esri.view.2d.layers.support.UpdateTracking2D")],Cu);class Fu{constructor(e,t,r,s){this._aggregateAdapter=e,this._subscriptions=t,this._onChange=r,this._connection=s,this._updateTracking=new Cu({debugName:"FeatureSource"}),this._store=new Ru(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}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 service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return Bl.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,r=this._metadata;this._queryEngine=new Ua.U({featureStore:this._store,fieldsIndex:r.fieldsIndex,geometryType:r.geometryType,objectIdField:r.objectIdField,hasM:!1,hasZ:!1,spatialReference:e.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:r.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._eventLog.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise((0,a.jO)(this._strategy?.load(e)))}onUnsubscribe(e){this._eventLog.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}getOverride(e){return this._updateTracking.addPromise(this._doGetOverride(e))}applyOverride(e){this._store.applyOverrides(e)}async update(e,t){const r=e.source,s=(0,z.qq)(this._schema?.mutable,r.mutable);if(!s)return!1;if((0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:s}),this._schema=r,this._metadata=new mc(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),(0,z.mQ)(s,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===r.type&&(0,z.mQ)(s,"availableFields")&&!await this._queryLastEditDateChanged()){this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(r.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(e){this._eventLog.onEvent({type:"updateFieldsError",error:e})}return!1}return!(!(0,z.Go)(s,"dataFilter")&&!(0,z.Go)(s,"sourceRefreshVersion")||(await this._updateStrategy(t),0))}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new zl(this._connection))}async _doGetOverride(e){return this._strategy.queryOverride(e)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const e=this._schema.service.source,t={...e.query,f:"json"},r=(await(0,Dl.c)(e.path,{query:t,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e=this.service,t="isSourceHosted"in e&&e.isSourceHosted,r=Array.isArray(e.source),s=e.source&&"collection"in e.source,i=t||r||s;if("stream"===this._schema.type){const e=new Eu(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}const n=Gl.fromSchema(this._schema,this._metadata),o=await this._supportSnapshotMode(this._schema,n);return o?new yu(this._schema.service,n,this._store,o.featureCount,this.metadata,this._eventLog):i?new mu(this._schema.service,n,this._store,this.metadata,this._eventLog):new _u(this._schema.service,n,this._store,this.metadata,this._eventLog)}async _updateStrategy(e){const t=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,(0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const s=Array.from(this._subscriptions.values());if(!s.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const i=Promise.all(s.map((e=>this._strategy.load(e).then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(e){(0,a.Az)(e)}this._eventLog.onEvent({type:"updateStrategyEnd"}),(0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:r}=e.service,s=r.snapshotInfo;if(!s||!s.supportsSnapshotMinThreshold||!s.snapshotCountThresholds)return null;const i=e.service.source,n=t.createQuery();n.inner.orderByFields=[],n.inner.returnGeometry=!1;const o=(await(0,Ul.WE)(i,n.inner,{query:n.customParameters})).data.count,{min:a,max:c}=s.snapshotCountThresholds;return o<=a||s.supportsSnapshotMaxThreshold&&o<c?{featureCount:o}:null}}var Nu=r(44980);class Pu{constructor(e,t){this._handles=new Nu.c,this._abortController=new AbortController,this._resolver=(0,a.qG)(),this._isDone=!1,this._aborted=!1,this.tile=e,this._version=t,this._handles.add([])}destroy(){this.pause(),this._handles.destroy()}get key(){return this.tile.key}get version(){return this._version}set version(e){this._version=e}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 Ou=r(29624),ku=r(95247),Du=r(87636);class Uu{constructor(e,t){this.key=new _.c(0,0,0,0),this.bounds=(0,B.Su)(),this.objectIds=new Set,this.key.set(t);const r=e.getLODInfoAt(this.key);this.tileInfoView=e,this.tileInfoView.getTileBounds(this.bounds,this.key,!0),this.resolution=r.resolution,this.scale=r.scale,this.level=r.level}get lod(){return this.tileInfoView.getLODInfoAt(this.key)}get id(){return this.key.id}get extent(){return ku.c.fromBounds(this.bounds,this.tileInfoView.tileInfo.spatialReference)}get transform(){return{originPosition:"upperLeft",scale:[this.resolution,this.resolution],translate:[this.bounds[0],this.bounds[3]]}}get arcadeEvaluationOptions(){return{$view:{scale:this.scale}}}createChildTiles(){const e=this.key.getChildKeys(),t=Ou.c.acquire();for(let r=0;r<e.length;r++)t[r]=new Uu(this.tileInfoView,e[r]);return t}getQuantizationParameters(){return Du.c.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 Bu{constructor(e){this.edit=e,this.resolver=(0,a.qG)()}}class Lu{constructor(e,t){this.schema=e,this.version=t,this.resolver=(0,a.qG)()}}class Gu{constructor(){this._aggregateAdapter={getFeatureObjectIds:e=>this._processor.getFeatureObjectIdsForAggregate(e)},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._editState=null,this._tileInfoView=null}onDetach(){this.destroy(),this._initialize(this._connection)}_initialize(e){this._source=new Fu(this._aggregateAdapter,this._subscriptions,(()=>this._requestUpdate()),e),this._processor=new kl(e,this._source),this._handles=(0,i.Ip)([(0,l.aE)((()=>this._source.updateTracking.updating),(()=>{this._requestUpdate(),this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})}))])}set remoteClient(e){this._connection=new G(e),this._initialize(this._connection)}get features(){const e=this._source.queryEngine;if(!e)throw new s.c("no-queryEngine","No query engine defined");return e}get aggregates(){const e=this._processor.aggregateQueryEngine;if(!e)throw new s.c("no-queryEngine","No aggregate query engine defined");return e}get processor(){return this._processor}get streamMessenger(){return this._source.streamMessenger}getDisplayFeatures(e){return this._processor.getDisplayFeatures(e)}async updateSchema(e,t){return(0,n.c)("esri-2d-update-debug")&&this._updateSchemaState&&console.error("InternalError: Schema already updating"),this._updateSchemaState=new Lu(e,t),this._requestUpdate(),this._updateSchemaState.resolver.promise}updateSubscriptions(e){this._updateSubscriptionRequests.push(e),this._requestUpdate()}updateHighlight(e){this._updateHighlightRequests.push(e),this._requestUpdate()}async onEdits(e){if(null!=this._editState)throw new s.c("InternalError - Already processing an edit");this._editState=new Bu(e);const t=this._editState.resolver.promise;return this._requestUpdate(),t}queryStatistics(){return this._source.statistics.toJSON()}async queryVisibleFeatures(e,t){return this.features.executeQuery(e,t)}async queryHeatmapStatistics(e){const t=Math.round((0,u.im)(e.radius));let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const i="string"==typeof e.fieldOffset,n=e.fieldOffset??0,o=Array.from(this._subscriptions.values()),a=this._source.chunks(),c=t**2,l=3/(Math.PI*c),h=2*t,d=Math.ceil(L.gT/h);for(const t of o){const o=t.tile,u=new Float64Array(d*d);for(const t of a){const r=t.getTileReader(o);if(!r)continue;const s=r.getCursor();for(;s.next();){let t=1;if(null!=e.field){const r=s.readAttribute(e.field);t=i?-1*+r:+r+n}const r=s.readXForDisplay()/h,o=s.readYForDisplay()/h,a=Math.floor(r),_=Math.floor(o);if(a<0||_<0||a>=d||_>=d)continue;const p=((.5+a-r)*h)**2+((.5+_-o)*h)**2;if(p>c)continue;const f=t*(l*(1-p/c)**2);u[_+a*d]+=f}}for(let e=0;e<u.length;e++)r=Math.min(r,u[e]),s=Math.max(s,u[e])}return{max:s,min:r}}async getSampleFeatures(e){const t=this._source.chunks();if(t.reduce(((e,t)=>e+t.size()),0)<=e.minFeatureCount){if(!this._source.updateTracking.updating){const e=[];return this._source.store.forEachUnsafe((t=>e.push(t.readLegacyFeatureWorldSpace()))),e}return null}const r=new Set,s=[],i=t.map((e=>e.reader.getCursor())),n=new c.c,o=3*e.sampleSize;for(let a=0;a<o&&s.length<e.sampleSize;a++){const e=i[n.getIntRange(0,t.length-1)];if(0===e.getSize())continue;const o=n.getIntRange(0,e.getSize()-1);e.setIndex(o);const a=e.getObjectId();r.has(a)||(r.add(a),s.push(e.readLegacyFeatureWorldSpace()))}return s.length>=e.sampleSize?s:null}_requestUpdate(){this._updateRequested||(this._updateRequested=!0,(0,o.o)((()=>this._scheduleNextUpdate())))}_scheduleNextUpdate(){this._updateRequested&&(this._ongoingUpdate||(this._ongoingUpdate=this._doUpdate().finally((()=>{this._ongoingUpdate=null,this._scheduleNextUpdate()})),this._updateRequested=!1))}_subscribe(e){const t=e.tileId;if(this._subscriptions.has(t)){const r=this._subscriptions.get(t);return void(r.paused&&((0,n.c)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.resume`),r.resume(),r.version=e.version,this._source.onResume(r)))}(0,n.c)("esri-2d-update-debug")&&console.debug(`Tile[${t}] Pipeline.subscribe`);const r=new Uu(this._tileInfoView,t),s=new Pu(r,e.version);this._subscriptions.set(t,s),this._source.onSubscribe(s),this._processor.onSubscribe(s)}_unsubscribe(e){const t=this._subscriptions.get(e);t&&((0,n.c)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.unsubscribe`),this._source.onUnsubscribe(t),this._processor.onUnsubscribe(t),this._subscriptions.delete(t.key.id),t.destroy())}_pauseSubscription(e){const t=this._subscriptions.get(e);t&&((0,n.c)("esri-2d-update-debug")&&console.debug(`Tile[${e}] Pipeline.pause`),t.pause())}async _doUpdate(){if((0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateStart"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0}),this._updateSubscriptionRequests.length){const e=this._updateSubscriptionRequests;this._updateSubscriptionRequests=[];for(const t of e)this._doUpdateSubscriptions(t)}const e=this._updateSchemaState;if(this._updateSchemaState=null,null!=e){const{schema:t,version:r}=e;await this._doUpdateSchema(t,r)}const t=this._editState;if(this._editState=null,null!=t){(0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline.applyEditOverride",t.edit);const e=await this._source.getOverride(t.edit);await this._processor.applyOverride(e),(0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline.endEditOverride",t.edit)}if(this._updateHighlightRequests.length){const e=this._updateHighlightRequests;this._updateHighlightRequests=[];for(const t of e)this._processor.updateHighlight(t)}const r=this._source.cleanupRemovedChunks();this._processor.removeChunks(r);try{this._subscriptions.size&&((0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksStart"),await this._processor.updateChunks(),(0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline.updateChunksEnd"))}catch(e){(0,a.Az)(e)}null!=t&&t.resolver.resolve(),null!=e&&e.resolver.resolve(),this._updateRequested?((0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline._doUpdateEnd [updateRequested=true]"),await this._connection.layerView.setUpdating({data:this._source.updateTracking.updating,pipeline:!0})):((0,n.c)("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(e,t){if((0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateStart`,{schema:e}),!this._tileInfoView){const t=h.c.fromJSON(e.source.tileInfoJSON);this._tileInfoView=new v(t)}const r={tileInfo:this._tileInfoView?.tileInfo};try{const s=await this._source.update(e,t),i=Array.from(this._subscriptions.values());await this._processor.update(e,t,r,s,i)}catch(e){console.error(e)}(0,n.c)("esri-2d-update-debug")&&console.debug(`Version[${t}] Pipeline.updateEnd`)}_doUpdateSubscriptions(e){if((0,n.c)("esri-2d-update-debug")&&console.debug("Pipeline.updateSubscriptions",e),!this._tileInfoView){const t=h.c.fromJSON(e.tileInfoJSON);this._tileInfoView=new v(t)}for(const t of e.subscribe)this._subscribe(t);for(const t of e.unsubscribe)this._unsubscribe(t);if((0,n.c)("featurelayer-query-pausing-enabled"))for(const t of e.pause)this._pauseSubscription(t)}}},53680:(e,t,r)=>{r.d(t,{c:()=>i});var s=r(69752);class i{static getId(e,t,r,s){return"object"==typeof e?`${e.level}/${e.row}/${e.col}/${e.world}`:`${e}/${t}/${r}/${s}`}constructor(e,t,r,s){this.set(e,t,r,s)}get key(){return this}get id(){return this.toString()}set id(e){this.set(e)}get hash(){const e=4095&this.row,t=4095&this.col,r=63&this.level;return(3&this.world)<<30|t<<22|e<<8|r}acquire(e,t,r,s){this.set(e,t,r,s)}contains(e){const t=e.level-this.level;return t>=0&&this.row===e.row>>t&&this.col===e.col>>t&&this.world===e.world}containsChild(e){const t=e.level-this.level;return t>0&&this.row===e.row>>t&&this.col===e.col>>t&&this.world===e.world}equals(e){return this.level===e.level&&this.row===e.row&&this.col===e.col&&this.world===e.world}clone(){return new i(this)}release(){this.level=0,this.row=0,this.col=0,this.world=0}set(e,t,r,s){if(null==e)this.level=0,this.row=0,this.col=0,this.world=0;else if("object"==typeof e)this.level=e.level||0,this.row=e.row||0,this.col=e.col||0,this.world=e.world||0;else if("string"==typeof e){const[t,r,s,i]=e.split("/");this.level=parseFloat(t),this.row=parseFloat(r),this.col=parseFloat(s),this.world=parseFloat(i)}else this.level=+e,this.row=+t,this.col=+r,this.world=+s||0;return this}toString(){return`${this.level}/${this.row}/${this.col}/${this.world}`}getParentKey(){return this.level<=0?null:new i(this.level-1,this.row>>1,this.col>>1,this.world)}getNeighborId(e,t){return`${this.level}/${this.row+t}/${this.col+e}/${this.world}`}getChildKeys(){const e=this.level+1,t=this.row<<1,r=this.col<<1,s=this.world;return[new i(e,t,r,s),new i(e,t,r+1,s),new i(e,t+1,r,s),new i(e,t+1,r+1,s)]}compareRowMajor(e){return this.row<e.row?-1:this.row>e.row?1:this.col<e.col?-1:this.col>e.col?1:0}}i.pool=new s.c(i,null,null,25,50)},75040:(e,t,r)=>{var s;r.d(t,{u:()=>s}),function(e){e[e.Pass=0]="Pass",e[e.Draw=1]="Draw"}(s||(s={}))},90736:(e,t,r)=>{r.d(t,{If:()=>n,Uc:()=>i}),r(85256),r(74784),(0,r(37008).Su)();class s{constructor(e){this.message=e}toString(){return`AssertException: ${this.message}`}}function i(e,t){if(!e){t=t||"Assertion";const e=new Error(t).stack;throw new s(`${t} at ${e}`)}}function n(e,t,r,s){let i,n=(r[0]-e[0])/t[0],o=(s[0]-e[0])/t[0];n>o&&(i=n,n=o,o=i);let a=(r[1]-e[1])/t[1],c=(s[1]-e[1])/t[1];if(a>c&&(i=a,a=c,c=i),n>c||a>o)return!1;a>n&&(n=a),c<o&&(o=c);let l=(r[2]-e[2])/t[2],u=(s[2]-e[2])/t[2];return l>u&&(i=l,l=u,u=i),!(n>u||l>o||(u<o&&(o=u),o<0))}},27064:(e,t,r)=>{r.d(t,{K:()=>u});var s=r(70680),i=r(10860),n=r(54792),o=r(23964),a=r(66168),c=r(52888);class l{constructor(e,t){this.item=e,this.controller=t,this.promise=null}}class u{constructor(e){this._schedule=null,this._task=null,this._deferreds=new o.c,this._controllers=new o.c,this._processingItems=new o.c,this._pausedSignal=(0,c.O)(!1),this.concurrency=1,e.concurrency&&(this.concurrency=e.concurrency),this._queue=new n.c(e.peeker),this.process=e.process;const t=e.scheduler;e.priority&&t&&(this._task=t.registerTask(e.priority,this))}destroy(){this.clear(),this._schedule=(0,s.oR)(this._schedule),this._task=(0,s.oR)(this._task)}get updating(){return!!this._task?.updating||this.running}get length(){return this._processingItems.size+this._queue.length}abort(e){const t=this._controllers.get(e);t&&t.abort()}clear(){this._queue.clear();const e=[];this._controllers.forEach((t=>e.push(t))),this._controllers.clear(),e.forEach((e=>e.abort())),this._processingItems.clear(),this._cancelNext()}forEach(e){this._deferreds.forEach(((t,r)=>e(r)))}get(e){const t=this._deferreds.get(e);return t?t.promise:void 0}isOngoing(e){return this._processingItems.has(e)}has(e){return this._deferreds.has(e)}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(e,t){const r=this.get(e);if(r)return r;const s=new AbortController;let n=null;t&&(n=(0,i.wD)(t,(()=>s.abort())));const o=()=>{a.remove(),null!=n&&n.remove(),this._removeItem(e),this._queue.remove(e),this._scheduleNext()},a=(0,i.Ij)(s.signal,(()=>{const t=this._processingItems.get(e);t&&t.controller.abort(),o(),c.reject((0,i.Uh)())})),c=(0,i.qG)();return this._deferreds.set(e,c),this._controllers.set(e,s),c.promise.then(o,o),this._queue.push(e),this._scheduleNext(),c.promise}last(){return this._queue.last()}lastPromise(){const e=this.last();return e?this.get(e):null}peek(){return this._queue.peek()}popLast(){const e=this._queue.popLast();return e&&(this._deferreds.get(e)?.reject((0,i.Uh)("Removed from queue")),this._removeItem(e)),e}reset(){const e=[];this._processingItems.forEach((t=>e.push(t))),this._processingItems.clear();for(const t of e)this._queue.push(t.item),t.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const e=[];for(;this._queue.length;)e.push(this._queue.pop());return this.clear(),e}get running(){return!this._pausedSignal.value&&this._queue.length>0&&this._processingItems.size<this.concurrency}runTask(e){for(;!e.done&&this._queue.length>0&&this._processingItems.size<this.concurrency;)this._process(this._queue.pop()),e.madeProgress()}_removeItem(e){this._deferreds.delete(e),this._controllers.delete(e),this._processingItems.delete(e)}_scheduleNext(){this._task||this._pausedSignal.value||this._schedule||(this._schedule=(0,a.Ow)((()=>{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(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).resolve(t))}_processError(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).reject(t))}_canProcessFulfillment(e){return!!this._deferreds.get(e.item)&&this._processingItems.get(e.item)===e}_process(e){if(null==e)return;let t;const r=new AbortController,s=new l(e,r);this._processingItems.set(e,s);try{t=this.process(e,r.signal)}catch(e){this._processError(s,e)}(0,i.eW)(t)?(s.promise=t,t.then((e=>this._processResult(s,e)),(e=>this._processError(s,e)))):this._processResult(s,t)}get test(){return{update:e=>this.runTask(e)}}}},39104:(e,t,r)=>{var s;r.d(t,{A:()=>s}),function(e){e[e.Texture=0]="Texture",e[e.RenderBuffer=1]="RenderBuffer"}(s||(s={}))},22184:(e,t,r)=>{r.d(t,{w:()=>l});var s=r(20744),i=(r(9456),r(94460)),n=r(77800),o=r(39104),a=r(51576);class c extends a.O{constructor(e,t){switch(super(),this.context=e,Object.assign(this,t),this.internalFormat){case n.UV.R16F:case n.UV.R16I:case n.UV.R16UI:case n.UV.R32F:case n.UV.R32I:case n.UV.R32UI:case n.UV.R8_SNORM:case n.UV.R8:case n.UV.R8I:case n.UV.R8UI:this.pixelFormat=n.Id.RED}}static validate(e,t){return new c(e,t)}}let l=class e{constructor(e,t=null,r=null){if(this.type=o.A.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,r=t;else{const r=c.validate(e,t);if(!r)throw new s.c("Texture descriptor invalid");this._descriptor=r}this._descriptor.target===n.c5.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return(0,a.k)(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._glName&&this._descriptor.context.instanceCounter.decrement(n.y4.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,t){const r=this._descriptor;if(r.width!==e||r.height!==t){if(this._wasImmutablyAllocated)throw new s.c("Immutable textures can't be resized!");r.width=e,r.height=t,this._descriptor.target===n.c5.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(e=null){for(let t=n.c5.TEXTURE_CUBE_MAP_POSITIVE_X;t<=n.c5.TEXTURE_CUBE_MAP_NEGATIVE_Z;t++)this._setData(e,t)}setData(e){this._setData(e)}_setData(t,r){if(!this._descriptor.context?.gl)return;const o=this._descriptor.context.gl;(0,i.m_)(o),this._glName||(this._glName=o.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(n.y4.Texture,this)),void 0===t&&(t=null);const a=this._descriptor,c=r??a.target,l=f(c);null===t&&(a.width=a.width||4,a.height=a.height||4,l&&(a.depth=a.depth??1));const g=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),u(a),this._configurePixelStorage(),(0,i.m_)(o);const y=this._deriveInternalFormat();if(p(t)){let e="width"in t?t.width:t.codedWidth,r="height"in t?t.height:t.codedHeight;const s=1;t instanceof HTMLVideoElement&&(e=t.videoWidth,r=t.videoHeight),a.width&&a.height,l&&a.depth,a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(c,y,a.hasMipmap,e,r,s),this._texImage(c,0,y,e,r,s,t),(0,i.m_)(o),a.hasMipmap&&this.generateMipmap(),a.width||(a.width=e),a.height||(a.height=r),l&&!a.depth&&(a.depth=s)}else{const{width:e,height:r,depth:u}=a;if(null==e||null==r)throw new s.c("Width and height must be specified!");if(l&&null==u)throw new s.c("Depth must be specified!");if(a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(c,y,a.hasMipmap,e,r,u),_(t)){const i=t.levels,l=m(c,e,r,u),h=Math.min(l-1,i.length-1);o.texParameteri(a.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,h);const d=y;if(!(d in n.sr))throw new s.c("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((e,t,r,s)=>{const n=i[Math.min(e,i.length-1)];this._compressedTexImage(c,e,d,t,r,s,n)}),h)}else this._texImage(c,0,y,e,r,u,t),(0,i.m_)(o),a.hasMipmap&&this.generateMipmap()}h(o,this._descriptor),d(o,this._descriptor),function(e,t){const r=e.capabilities.textureFilterAnisotropic;r&&e.gl.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}(this._descriptor.context,this._descriptor),(0,i.m_)(o),this._descriptor.context.bindTexture(g,e.TEXTURE_UNIT_FOR_UPDATES)}updateData(t,r,i,n,o,a,c=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const l=this._descriptor,u=this._deriveInternalFormat(),{context:h,pixelFormat:d,dataType:f,target:m,isImmutable:g}=l;if(g&&!this._wasImmutablyAllocated)throw new s.c("Cannot update immutable texture before allocation!");const y=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||i<0||n>l.width||o>l.height||r+n>l.width||i+o>l.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:x}=h;c&&x.pixelStorei(x.UNPACK_SKIP_ROWS,c),p(a)?x.texSubImage2D(m,t,r,i,n,o,d,f,a):_(a)?x.compressedTexSubImage2D(m,t,r,i,n,o,u,a.levels[t]):x.texSubImage2D(m,t,r,i,n,o,d,f,a),c&&x.pixelStorei(x.UNPACK_SKIP_ROWS,0),h.bindTexture(y,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(t,r,i,n,o,a,c,l){l||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const u=this._descriptor,h=this._deriveInternalFormat(),{context:d,pixelFormat:p,dataType:m,isImmutable:g,target:y}=u;if(g&&!this._wasImmutablyAllocated)throw new s.c("Cannot update immutable texture before allocation!");f(y)||console.warn("Attempting to set 3D texture data on a non-3D texture");const x=d.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);d.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||i<0||n<0||o>u.width||a>u.height||c>u.depth||r+o>u.width||i+a>u.height||n+c>u.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:b}=d;if(_(l))l=l.levels[t],b.compressedTexSubImage3D(y,t,r,i,n,o,a,c,h,l);else{const e=l;b.texSubImage3D(y,t,r,i,n,o,a,c,p,m,e)}d.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const t=this._descriptor;if(!t.hasMipmap){if(this._wasImmutablyAllocated)throw new s.c("Cannot add mipmaps to immutable texture after allocation");t.hasMipmap=!0,this._samplingModeDirty=!0,u(t)}t.samplingMode===n.Ud.LINEAR?(this._samplingModeDirty=!0,t.samplingMode=n.Ud.LINEAR_MIPMAP_NEAREST):t.samplingMode===n.Ud.NEAREST&&(this._samplingModeDirty=!0,t.samplingMode=n.Ud.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(t.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}setSamplingMode(e){e!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=e,this._samplingModeDirty=!0)}setWrapMode(e){e!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=e,u(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const e=this._descriptor,t=e.context.gl;this._samplingModeDirty&&(h(t,e),this._samplingModeDirty=!1),this._wrapModeDirty&&(d(t,e),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===n.Id.DEPTH_STENCIL&&(this._descriptor.internalFormat=n.Id.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case n.OK.FLOAT:switch(this._descriptor.pixelFormat){case n.Id.RGBA:return this._descriptor.internalFormat=n.UV.RGBA32F;case n.Id.RGB:return this._descriptor.internalFormat=n.UV.RGB32F;default:throw new s.c("Unable to derive format")}case n.OK.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case n.Id.RGBA:return this._descriptor.internalFormat=n.UV.RGBA8;case n.Id.RGB:return this._descriptor.internalFormat=n.UV.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===n.Id.DEPTH_STENCIL?n.Id.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const e=this._descriptor.context.gl,{unpackAlignment:t,flipped:r,preMultiplyAlpha:s}=this._descriptor;e.pixelStorei(e.UNPACK_ALIGNMENT,t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r?1:0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s?1:0)}_texStorage(e,t,r,i,o,a){const{gl:c}=this._descriptor.context;if(!(t in n.UV))throw new s.c("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?m(e,i,o,a):1;if(f(e)){if(null==a)throw new s.c("Missing depth dimension for 3D texture upload");c.texStorage3D(e,l,t,i,o,a)}else c.texStorage2D(e,l,t,i,o);this._wasImmutablyAllocated=!0}_texImage(e,t,r,i,n,o,a){const c=this._descriptor.context.gl,l=f(e),{isImmutable:u,pixelFormat:h,dataType:d}=this._descriptor;if(u){if(null!=a){const r=a;if(l){if(null==o)throw new s.c("Missing depth dimension for 3D texture upload");c.texSubImage3D(e,t,0,0,0,i,n,o,h,d,r)}else c.texSubImage2D(e,t,0,0,i,n,h,d,r)}}else{const u=a;if(l){if(null==o)throw new s.c("Missing depth dimension for 3D texture upload");c.texImage3D(e,t,r,i,n,o,0,h,d,u)}else c.texImage2D(e,t,r,i,n,0,h,d,u)}}_compressedTexImage(e,t,r,i,n,o,a){const c=this._descriptor.context.gl,l=f(e);if(this._descriptor.isImmutable){if(null!=a)if(l){if(null==o)throw new s.c("Missing depth dimension for 3D texture upload");c.compressedTexSubImage3D(e,t,0,0,0,i,n,o,r,a)}else c.compressedTexSubImage2D(e,t,0,0,i,n,r,a)}else if(l){if(null==o)throw new s.c("Missing depth dimension for 3D texture upload");c.compressedTexImage3D(e,t,r,i,n,o,0,a)}else c.compressedTexImage2D(e,t,r,i,n,0,a)}_forEachMipmapLevel(e,t=1/0){let{width:r,height:i,depth:o,hasMipmap:a,target:c}=this._descriptor;const l=c===n.c5.TEXTURE_3D;if(null==r||null==i||l&&null==o)throw new s.c("Missing texture dimensions for mipmap calculation");for(let s=0;e(s,r,i,o),a&&(1!==r||1!==i||l&&1!==o)&&!(s>=t);++s)r=Math.max(1,r>>1),i=Math.max(1,i>>1),l&&(o=Math.max(1,o>>1))}};function u(e){(null!=e.width&&e.width<0||null!=e.height&&e.height<0||null!=e.depth&&e.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function h(e,t){let r=t.samplingMode,s=t.samplingMode;r===n.Ud.LINEAR_MIPMAP_NEAREST||r===n.Ud.LINEAR_MIPMAP_LINEAR?(r=n.Ud.LINEAR,t.hasMipmap||(s=n.Ud.LINEAR)):r!==n.Ud.NEAREST_MIPMAP_NEAREST&&r!==n.Ud.NEAREST_MIPMAP_LINEAR||(r=n.Ud.NEAREST,t.hasMipmap||(s=n.Ud.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,r),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,s)}function d(e,t){"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}function _(e){return null!=e&&"type"in e&&"compressed"===e.type}function p(e){return null!=e&&!_(e)&&!function(e){return null!=e&&"byteLength"in e}(e)}function f(e){return e===n.c5.TEXTURE_3D||e===n.c5.TEXTURE_2D_ARRAY}function m(e,t,r,s=1){let i=Math.max(t,r);return e===n.c5.TEXTURE_3D&&(i=Math.max(i,s)),Math.round(Math.log(i)/Math.LN2)+1}l.TEXTURE_UNIT_FOR_UPDATES=0},51576:(e,t,r)=>{r.d(t,{O:()=>n,k:()=>o});var s=r(77800),i=r(97684);class n{constructor(e=0,t=e){this.width=e,this.height=t,this.target=s.c5.TEXTURE_2D,this.pixelFormat=s.Id.RGBA,this.dataType=s.OK.UNSIGNED_BYTE,this.samplingMode=s.Ud.LINEAR,this.wrapMode=s.Qz.REPEAT,this.maxAnisotropy=1,this.flipped=!1,this.hasMipmap=!1,this.isOpaque=!1,this.unpackAlignment=4,this.preMultiplyAlpha=!1,this.depth=1,this.isImmutable=!1}}function o(e){return e.width<=0||e.height<=0?0:Math.round(e.width*e.height*(e.hasMipmap?4/3:1)*(null==e.internalFormat?4:(0,i.O4)(e.internalFormat)))}},97684:(e,t,r)=>{r.d(t,{O4:()=>i}),r(9456),r(94460);var s=r(77800);function i(e){switch(e){case s.Id.ALPHA:case s.Id.LUMINANCE:case s.Id.RED:case s.Id.RED_INTEGER:case s.UV.R8:case s.UV.R8I:case s.UV.R8UI:case s.UV.R8_SNORM:case s.Qb.STENCIL_INDEX8:return 1;case s.Id.LUMINANCE_ALPHA:case s.Id.RG:case s.Id.RG_INTEGER:case s.UV.RGBA4:case s.UV.R16F:case s.UV.R16I:case s.UV.R16UI:case s.UV.RG8:case s.UV.RG8I:case s.UV.RG8UI:case s.UV.RG8_SNORM:case s.UV.RGB565:case s.UV.RGB5_A1:case s.Qb.DEPTH_COMPONENT16:return 2;case s.Id.DEPTH_COMPONENT:case s.Id.RGB:case s.Id.RGB_INTEGER:case s.UV.RGB8:case s.UV.RGB8I:case s.UV.RGB8UI:case s.UV.RGB8_SNORM:case s.UV.SRGB8:case s.Qb.DEPTH_COMPONENT24:return 3;case s.Id.DEPTH_STENCIL:case s.Id.DEPTH24_STENCIL8:case s.Id.RGBA:case s.Id.RGBA_INTEGER:case s.UV.RGBA8:case s.UV.R32F:case s.UV.R11F_G11F_B10F:case s.UV.RG16F:case s.UV.R32I:case s.UV.R32UI:case s.UV.RG16I:case s.UV.RG16UI:case s.UV.RGBA8I:case s.UV.RGBA8UI:case s.UV.RGBA8_SNORM:case s.UV.SRGB8_ALPHA8:case s.UV.RGB9_E5:case s.UV.RGB10_A2UI:case s.UV.RGB10_A2:case s.Qb.DEPTH_STENCIL:case s.Qb.DEPTH_COMPONENT32F:case s.Qb.DEPTH24_STENCIL8:return 4;case s.Qb.DEPTH32F_STENCIL8:return 5;case s.UV.RGB16F:case s.UV.RGB16I:case s.UV.RGB16UI:return 6;case s.UV.RG32F:case s.UV.RG32I:case s.UV.RG32UI:case s.UV.RGBA16F:case s.UV.RGBA16I:case s.UV.RGBA16UI:return 8;case s.UV.RGB32F:case s.UV.RGB32I:case s.UV.RGB32UI:return 12;case s.UV.RGBA32F:case s.UV.RGBA32I:case s.UV.RGBA32UI:return 16;case s.sr.COMPRESSED_RGB_S3TC_DXT1_EXT:case s.sr.COMPRESSED_RGBA_S3TC_DXT1_EXT:return.5;case s.sr.COMPRESSED_RGBA_S3TC_DXT3_EXT:case s.sr.COMPRESSED_RGBA_S3TC_DXT5_EXT:return 1;case s.sr.COMPRESSED_R11_EAC:case s.sr.COMPRESSED_SIGNED_R11_EAC:case s.sr.COMPRESSED_RGB8_ETC2:case s.sr.COMPRESSED_SRGB8_ETC2:case s.sr.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:case s.sr.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:return.5;case s.sr.COMPRESSED_RG11_EAC:case s.sr.COMPRESSED_SIGNED_RG11_EAC:case s.sr.COMPRESSED_RGBA8_ETC2_EAC:case s.sr.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:return 1}return 0}r(2944)},94460:(e,t,r)=>{r.d(t,{E5:()=>l,gv:()=>c,m_:()=>u});var s=r(20744),i=r(9456),n=r(66360);const o=()=>n.c.getLogger("esri.views.webgl.checkWebGLError"),a=!!(0,i.c)("enable-feature:webgl-debug");function c(){return a}function l(){return a}function u(e){if(c()){const t=e.getError();if(t){const r=function(e,t){switch(t){case e.INVALID_ENUM:return"Invalid Enum. An unacceptable value has been specified for an enumerated argument.";case e.INVALID_VALUE:return"Invalid Value. A numeric argument is out of range.";case e.INVALID_OPERATION:return"Invalid Operation. The specified command is not allowed for the current state.";case e.INVALID_FRAMEBUFFER_OPERATION:return"Invalid Framebuffer operation. The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it.";case e.OUT_OF_MEMORY:return"Out of memory. Not enough memory is left to execute the command.";case e.CONTEXT_LOST_WEBGL:return"WebGL context has been lost";default:return"Unknown error"}}(e,t),i=(new Error).stack;o().error(new s.c("webgl-error","WebGL error occurred",{message:r,stack:i}))}}}},77800:(e,t,r)=>{var s,i,n,o,a,c,l,u,h,d,_,p,f,m,g,y,x,b,T,w,S,v,I;r.d(t,{Ck:()=>u,GE:()=>E,Gs:()=>T,Id:()=>m,K:()=>a,OK:()=>y,QD:()=>d,Qb:()=>x,Qx:()=>v,Qz:()=>p,SC:()=>c,UV:()=>g,Ud:()=>_,Uf:()=>i,YT:()=>o,_m:()=>b,c5:()=>f,et:()=>h,kl:()=>w,sl:()=>s,sr:()=>R,vs:()=>l,w$:()=>n,y4:()=>S}),function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT"}(s||(s={})),function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(i||(i={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA"}(n||(n={})),function(e){e[e.ADD=32774]="ADD",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.SUBTRACT=32778]="SUBTRACT",e[e.REVERSE_SUBTRACT=32779]="REVERSE_SUBTRACT"}(o||(o={})),function(e){e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER"}(a||(a={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(c||(c={})),function(e){e[e.CW=2304]="CW",e[e.CCW=2305]="CCW"}(l||(l={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT"}(u||(u={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(h||(h={})),function(e){e[e.ZERO=0]="ZERO",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP"}(d||(d={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(_||(_={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.REPEAT=10497]="REPEAT",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(p||(p={})),function(e){e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY"}(f||(f={})),function(e){e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.RED=6403]="RED",e[e.RG=33319]="RG",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER"}(m||(m={})),function(e){e[e.RGBA4=32854]="RGBA4",e[e.R16F=33325]="R16F",e[e.RG16F=33327]="RG16F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.R32F=33326]="R32F",e[e.RG32F=33328]="RG32F",e[e.RGBA32F=34836]="RGBA32F",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB5_A1=32855]="RGB5_A1",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.RGB16F=34843]="RGB16F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.RGB565=36194]="RGB565",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2=32857]="RGB10_A2",e[e.RGB10_A2UI=36975]="RGB10_A2UI"}(g||(g={})),function(e){e[e.FLOAT=5126]="FLOAT",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.INT=5124]="INT",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV"}(y||(y={})),function(e){e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8"}(x||(x={})),function(e){e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.STATIC_READ=35045]="STATIC_READ",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.STREAM_COPY=35042]="STREAM_COPY"}(b||(b={})),function(e){e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER"}(T||(T={})),function(e){e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER"}(w||(w={})),function(e){e[e.Texture=0]="Texture",e[e.BufferObject=1]="BufferObject",e[e.VertexArrayObject=2]="VertexArrayObject",e[e.Shader=3]="Shader",e[e.Program=4]="Program",e[e.FramebufferObject=5]="FramebufferObject",e[e.Renderbuffer=6]="Renderbuffer",e[e.TransformFeedback=7]="TransformFeedback",e[e.Sync=8]="Sync",e[e.UNCOUNTED=9]="UNCOUNTED",e[e.LinesOfCode=9]="LinesOfCode",e[e.Uniform=10]="Uniform",e[e.COUNT=11]="COUNT"}(S||(S={})),function(e){e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15"}(v||(v={})),function(e){e[e.NONE=0]="NONE",e[e.BACK=1029]="BACK"}(I||(I={}));const E=33306;var R,A,M,C,F,N,P;!function(e){e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"}(R||(R={})),function(e){e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT=5124]="INT",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY"}(A||(A={})),function(e){e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS"}(M||(M={})),function(e){e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED"}(C||(C={})),function(e){e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED"}(F||(F={})),function(e){e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE"}(N||(N={})),function(e){e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT"}(P||(P={}))},2944:(e,t,r)=>{r(77800)}}]);