@arcgis/core 4.24.0-next.20220429 → 4.24.0-next.20220430

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 (52) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{3a43a2918b44781aaf85.js → 055a0ebf22a82f859474.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{3273b6be43eeb49ee842.js → 0b12ff7b2ed2838afbb8.js} +1 -1
  4. package/assets/esri/core/workers/chunks/0e25548573baf855e394.js +1 -0
  5. package/assets/esri/core/workers/chunks/{c388ac33496f004d56f3.js → 135a90ae61f3b3cae91b.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{54f9b1ab9d472bf4baca.js → 1facbda248863cf72cbd.js} +1 -1
  7. package/assets/esri/core/workers/chunks/2133499e642193f6738f.js +1 -0
  8. package/assets/esri/core/workers/chunks/{3c572629f46e5093223c.js → 30333a95dc0a44e23fb5.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{7afe89eafab00afb31f2.js → 30837d93116f0337972f.js} +1 -1
  10. package/assets/esri/core/workers/chunks/31df729c17470245288c.js +2 -0
  11. package/assets/esri/core/workers/chunks/{c0bf663240df7be68131.js.LICENSE.txt → 31df729c17470245288c.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/{e5d6f3815ecab8560404.js → 4130ea1f5a9f197168d7.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{f5855075104c12bf71d8.js → 59e341b2db44351bf557.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{73630d52768e3d932f30.js → 5a10b58533b4116115ac.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{dc193247a1980360ec4f.js → 8e98ff9404a802352037.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{863cfe35ee640bac103f.js → 94e51fe1c539df6257c2.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{cbe7e6283a427a618d4b.js → 9519a02b9b8db88a3150.js} +1 -1
  18. package/assets/esri/core/workers/chunks/a59ee7d2b98c85f27dd2.js +1 -0
  19. package/assets/esri/core/workers/chunks/{92ef9b0c61640e0ecbb4.js → a5dbab94697757c87c49.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{147d3ee9aa81d7b2b7fa.js → a6406a248b7b2ed65f35.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{ebdf61eb364ac0856f40.js → acbd0f4d72d1f5d8e4e8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/ad68fe924456d6d7d4f0.js +1 -0
  23. package/assets/esri/core/workers/chunks/b06c949fc7d08e376a5f.js +1 -0
  24. package/assets/esri/core/workers/chunks/c9b09099488d0e719dfb.js +1 -0
  25. package/assets/esri/core/workers/chunks/{4a05d0dfa73ff570e1fa.js → d15e6662d90718411d62.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{b74b9dceabbf7b1aec39.js → d16aac3461af9cee0c29.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{b9d9be39cd64f28dd478.js → d60dd3e1028f714f2258.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{cab6decfcb3f596a3837.js → d8c59b1d73650c060dfb.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{d24339b37cc9316e6d99.js → dcb6e1b33402d7fa455b.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{a8da24116180d708cf81.js → df653bca2b14dffc82d1.js} +1 -1
  31. package/chunks/index.js +1 -1
  32. package/config.js +1 -1
  33. package/interfaces.d.ts +8 -0
  34. package/layers/mixins/PortalLayer.js +1 -1
  35. package/package.json +2 -2
  36. package/request.js +1 -1
  37. package/support/revision.js +1 -1
  38. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  39. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  40. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  41. package/views/3d/terrain/PatchRenderData.js +1 -1
  42. package/views/3d/terrain/TerrainSurface.js +1 -1
  43. package/views/3d/terrain/Tile.js +1 -1
  44. package/widgets/FeatureTable/Grid/Grid.js +2 -2
  45. package/widgets/Sketch/SketchViewModel.js +1 -1
  46. package/assets/esri/core/workers/chunks/3f6b17c9d2629ed396da.js +0 -1
  47. package/assets/esri/core/workers/chunks/68d57660c7c71b82ff3c.js +0 -1
  48. package/assets/esri/core/workers/chunks/6ef8de3aa9a8d9c22161.js +0 -1
  49. package/assets/esri/core/workers/chunks/b548bf032c8af34fe155.js +0 -1
  50. package/assets/esri/core/workers/chunks/bbcae04235830debd814.js +0 -1
  51. package/assets/esri/core/workers/chunks/c0bf663240df7be68131.js +0 -2
  52. package/assets/esri/core/workers/chunks/cd9668acbe3babd2b188.js +0 -1
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8875],{28924:(e,t,r)=>{r.d(t,{Z:()=>s});var i=r(95330);class s{constructor(){this.declaredRootClass="esri.arcade.featureSetCollection",this._layerById={},this._layerByName={}}add(e,t,r){this._layerById[t]=r,this._layerByName[e]=r}featureSetByName(e,t=!0,r=["*"]){return void 0===this._layerByName[e]?this.resolvePromise(null):this.resolvePromise(this._layerByName[e])}featureSetById(e,t=!0,r=["*"]){return void 0===this._layerById[e]?this.resolvePromise(null):this.resolvePromise(this._layerById[e])}castToText(){return"object, FeatureSetCollection"}resolvePromise(e){return(0,i.DB)(e)}}},42666:(e,t,r)=>{r.r(t),r.d(t,{constructAssociationMetaDataFeatureSetFromUrl:()=>ae,constructFeatureSet:()=>se,constructFeatureSetFromPortalItem:()=>_e,constructFeatureSetFromRelationship:()=>le,constructFeatureSetFromUrl:()=>ie,convertToFeatureSet:()=>pe,createFeatureSetCollectionFromMap:()=>he,createFeatureSetCollectionFromService:()=>ce,getPortal:()=>de,initialiseMetaDataCache:()=>te,lookupUser:()=>fe});var i=r(40330),s=r(3172),n=r(28924),a=r(84328),l=r(38171),o=r(61363),u=r(70409),h=r(85065),c=r(91136),d=r(90961),f=r(3823),p=r(90658),_=r(36515),y=r(95002),g=r(41534);class m{clone(){const e=new m;return e.field=this.field,e.tofieldname=this.tofieldname,e.typeofstat=this.typeofstat,e.workingexpr=this.workingexpr,e}static parseStatField(e,t,r){const i=new m;i.field=e;const s=g.WhereClause.create(t,r),n=function(e){if("function"===e.parseTree.type){if(0===e.parseTree.args.value.length)return{name:e.parseTree.name,expr:null};if(e.parseTree.args.value.length>1)throw new Error("Statistic does not have 1 or 0 Parameters");const t=g.WhereClause.create((0,_.XF)(e.parseTree.args.value[0],p.Bj.Standardised,e.parameters),e.fieldsIndex);return{name:e.parseTree.name,expr:t}}return null}(s);if(null===n)throw new Error("Invalid Statistic Function");const a=n.name.toUpperCase().trim();if("MIN"===a){if(i.typeofstat="MIN",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("MAX"===a){if(i.typeofstat="MAX",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("COUNT"===a)i.typeofstat="COUNT",i.workingexpr=n.expr;else if("STDEV"===a){if(i.typeofstat="STDDEV",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("SUM"===a){if(i.typeofstat="SUM",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("MEAN"===a){if(i.typeofstat="AVG",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("AVG"===a){if(i.typeofstat="AVG",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else{if("VAR"!==a)throw new Error("Invalid Statistic Function");if(i.typeofstat="VAR",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}return i}toStatisticsName(){switch(this.typeofstat.toUpperCase()){case"MIN":return"min";case"MAX":return"max";case"SUM":return"sum";case"COUNT":default:return"count";case"VAR":return"var";case"STDDEV":return"stddev";case"AVG":return"avg"}}}function b(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function S(e,t,r,i,s,n){return b(function(e,t){return e<<t|e>>>32-t}(b(b(t,e),b(i,n)),s),r)}function w(e,t,r,i,s,n,a){return S(t&r|~t&i,e,t,s,n,a)}function v(e,t,r,i,s,n,a){return S(t&i|r&~i,e,t,s,n,a)}function F(e,t,r,i,s,n,a){return S(t^r^i,e,t,s,n,a)}function I(e,t,r,i,s,n,a){return S(r^(t|~i),e,t,s,n,a)}function C(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;let r=1732584193,i=-271733879,s=-1732584194,n=271733878;for(let t=0;t<e.length;t+=16){const a=r,l=i,o=s,u=n;r=w(r,i,s,n,e[t+0],7,-680876936),n=w(n,r,i,s,e[t+1],12,-389564586),s=w(s,n,r,i,e[t+2],17,606105819),i=w(i,s,n,r,e[t+3],22,-1044525330),r=w(r,i,s,n,e[t+4],7,-176418897),n=w(n,r,i,s,e[t+5],12,1200080426),s=w(s,n,r,i,e[t+6],17,-1473231341),i=w(i,s,n,r,e[t+7],22,-45705983),r=w(r,i,s,n,e[t+8],7,1770035416),n=w(n,r,i,s,e[t+9],12,-1958414417),s=w(s,n,r,i,e[t+10],17,-42063),i=w(i,s,n,r,e[t+11],22,-1990404162),r=w(r,i,s,n,e[t+12],7,1804603682),n=w(n,r,i,s,e[t+13],12,-40341101),s=w(s,n,r,i,e[t+14],17,-1502002290),i=w(i,s,n,r,e[t+15],22,1236535329),r=v(r,i,s,n,e[t+1],5,-165796510),n=v(n,r,i,s,e[t+6],9,-1069501632),s=v(s,n,r,i,e[t+11],14,643717713),i=v(i,s,n,r,e[t+0],20,-373897302),r=v(r,i,s,n,e[t+5],5,-701558691),n=v(n,r,i,s,e[t+10],9,38016083),s=v(s,n,r,i,e[t+15],14,-660478335),i=v(i,s,n,r,e[t+4],20,-405537848),r=v(r,i,s,n,e[t+9],5,568446438),n=v(n,r,i,s,e[t+14],9,-1019803690),s=v(s,n,r,i,e[t+3],14,-187363961),i=v(i,s,n,r,e[t+8],20,1163531501),r=v(r,i,s,n,e[t+13],5,-1444681467),n=v(n,r,i,s,e[t+2],9,-51403784),s=v(s,n,r,i,e[t+7],14,1735328473),i=v(i,s,n,r,e[t+12],20,-1926607734),r=F(r,i,s,n,e[t+5],4,-378558),n=F(n,r,i,s,e[t+8],11,-2022574463),s=F(s,n,r,i,e[t+11],16,1839030562),i=F(i,s,n,r,e[t+14],23,-35309556),r=F(r,i,s,n,e[t+1],4,-1530992060),n=F(n,r,i,s,e[t+4],11,1272893353),s=F(s,n,r,i,e[t+7],16,-155497632),i=F(i,s,n,r,e[t+10],23,-1094730640),r=F(r,i,s,n,e[t+13],4,681279174),n=F(n,r,i,s,e[t+0],11,-358537222),s=F(s,n,r,i,e[t+3],16,-722521979),i=F(i,s,n,r,e[t+6],23,76029189),r=F(r,i,s,n,e[t+9],4,-640364487),n=F(n,r,i,s,e[t+12],11,-421815835),s=F(s,n,r,i,e[t+15],16,530742520),i=F(i,s,n,r,e[t+2],23,-995338651),r=I(r,i,s,n,e[t+0],6,-198630844),n=I(n,r,i,s,e[t+7],10,1126891415),s=I(s,n,r,i,e[t+14],15,-1416354905),i=I(i,s,n,r,e[t+5],21,-57434055),r=I(r,i,s,n,e[t+12],6,1700485571),n=I(n,r,i,s,e[t+3],10,-1894986606),s=I(s,n,r,i,e[t+10],15,-1051523),i=I(i,s,n,r,e[t+1],21,-2054922799),r=I(r,i,s,n,e[t+8],6,1873313359),n=I(n,r,i,s,e[t+15],10,-30611744),s=I(s,n,r,i,e[t+6],15,-1560198380),i=I(i,s,n,r,e[t+13],21,1309151649),r=I(r,i,s,n,e[t+4],6,-145523070),n=I(n,r,i,s,e[t+11],10,-1120210379),s=I(s,n,r,i,e[t+2],15,718787259),i=I(i,s,n,r,e[t+9],21,-343485551),r=b(r,a),i=b(i,l),s=b(s,o),n=b(n,u)}return[r,i,s,n]}function D(e,t=1){const r=t||0,i=C(function(e){const t=[];for(let r=0,i=8*e.length;r<i;r+=8)t[r>>5]|=(255&e.charCodeAt(r/8))<<r%32;return t}(e),8*e.length);switch(r){case 3:return i;case 1:return function(e){const t="0123456789abcdef",r=[];for(let i=0,s=4*e.length;i<s;i++)r.push(t.charAt(e[i>>2]>>i%4*8+4&15)+t.charAt(e[i>>2]>>i%4*8&15));return r.join("")}(i);case 2:return function(e){const t=[];for(let r=0,i=32*e.length;r<i;r+=8)t.push(String.fromCharCode(e[r>>5]>>>r%32&255));return t.join("")}(i);case 0:return function(e){const t=[];for(let r=0,i=4*e.length;r<i;r+=3){const i=(e[r>>2]>>r%4*8&255)<<16|(e[r+1>>2]>>(r+1)%4*8&255)<<8|e[r+2>>2]>>(r+2)%4*8&255;for(let s=0;s<4;s++)8*r+6*s>32*e.length?t.push("="):t.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>6*(3-s)&63))}return t.join("")}(i)}}var x=r(95330),R=r(82971),E=r(1231),A=r(99514);function k(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class T extends c.Z{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_getSet(e){return null===this._wset?this._getFilteredSet("",null,null,null,e).then((e=>(this._wset=e,this._wset))):(0,x.DB)(this._wset)}_isInFeatureSet(){return p.dj.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,r=1;const i=this._parent?this._parent.getFieldsIndex():new A.Z([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+r.toString(),r++)}for(const e of this._config.statsfields){const t=new m;t.field=e.name,t.tofieldname=e.name,t.workingexpr=e.expression instanceof g.WhereClause?e.expression:g.WhereClause.create(e.expression,i),t.typeofstat=k(e.statistic),this._decodedStatsfield.push(t)}this._decodedGroupbyfield=[];for(const e of this._config.groupbyfields){const t={name:e.name,singlefield:null,tofieldname:e.name,expression:e.expression instanceof g.WhereClause?e.expression:g.WhereClause.create(e.expression,i)};this._decodedGroupbyfield.push(t)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=p.Qk.point,this.typeIdField="",this.types=null,this.spatialReference=new R.Z({wkid:4326});this.fields=[];const s=new m;s.field=this._nextUniqueName(e),s.tofieldname=this.objectIdField,s.workingexpr=g.WhereClause.create(this._parent.objectIdField,this._parent.getFieldsIndex()),s.typeofstat="MIN",this._decodedStatsfield.push(s);for(const t of this._decodedGroupbyfield){const r=new E.Z;if(t.name=this._nextUniqueName(e),r.name=t.tofieldname,r.alias=r.name,(0,_.y5)(t.expression)){const e=this._parent.getField((0,_.zR)(t.expression,p.Bj.Standardised));if(!e)throw new Error("Field is not present for Aggregation");t.name=e.name,t.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),r.type=e.type}else{r.type=this._convertToEsriFieldType((0,_.DT)(t.expression,this._parent.fields));const e=new E.Z;e.name=t.name,e.alias=e.name,this.phsyicalgroupbyfields.push(t.name),this._adaptedFields.push(new u.yN(e,t.expression)),this._candosimplegroupby=!1}this.fields.push(r)}if(this._adaptedFields.length>0)for(const e of this._parent.fields)this._adaptedFields.push(new u.$X(e));for(let t=0;t<this._decodedStatsfield.length;t++){const r=new E.Z;let i=null;const s=this._decodedStatsfield[t];s.field=this._nextUniqueName(e),s.tofieldname===this.objectIdField&&(this._internalObjectIdField=s.field),r.name=s.tofieldname,r.alias=r.name;const n=null!==s.workingexpr&&(0,_.y5)(s.workingexpr)?(0,_.zR)(s.workingexpr,p.Bj.Standardised):"";switch(this._decodedStatsfield[t].typeofstat){case"SUM":if(""!==n){if(i=this._parent.getField(n),!i)throw new Error("Field is not present for Aggregation");r.type=i.type}else r.type="double";break;case"MIN":case"MAX":if(""!==n){if(i=this._parent.getField(n),!i)throw new Error("Field is not present for Aggregation");r.type=i.type}else r.type="double";break;case"COUNT":r.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==n&&(i=this._parent.getField(n),!i))throw new Error("Field is not present for Aggregation");r.type="double"}this.fields.push(r)}}_canDoAggregates(){return(0,x.DB)(!1)}_getFeatures(e,t,r,i){-1!==t&&this._featureCache[t];const s=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,s)?this._expandPagedSet(e,s,0,0,i).then((()=>this._getFeatures(e,t,r,i))):(0,x.DB)("success")}_getFilteredSet(e,t,r,i,s){if(""!==e)return(0,x.DB)(new d.Z([],[],!0,null));let n=null;const l={ordered:!1,nowhereclause:!1};return this._ensureLoaded().then((()=>{if(null!==r)for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===(0,_.hq)(r,this._decodedStatsfield[e].tofieldname)){l.nowhereclause=!0,r=null;break}if(null!==i){l.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===i.scanForField(this._decodedStatsfield[e].tofieldname)){i=null,l.ordered=!1;break}if(null!==i)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===i.scanForField(e.tofieldname)){i=null,l.ordered=!1;break}}return!1===this._candosimplegroupby?(0,x.DB)(!1):this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)})).then((e=>{if(e){let e=null;r&&(e=this._reformulateWhereClauseWithoutGroupByFields(r));let t=null;return i&&(t=this._reformulateOrderClauseWithoutGroupByFields(i)),this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField).then((e=>(this._checkCancelled(s),n=!0===l.nowhereclause?new d.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===l.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new d.Z(e._candidates.slice(0),e._known.slice(0),!0===l.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),n)))}let t=this._parent;if(this._adaptedFields.length>0&&(t=new u.Xx({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===l.nowhereclause)n=new d.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new h.Z({parentfeatureset:t,orderbyclause:new f.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=t;if(null!==r){let t=null;r&&(t=this._reformulateWhereClauseWithoutGroupByFields(r)),e=new a.Z({parentfeatureset:e,whereclause:t})}n=new d.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new h.Z({parentfeatureset:e,orderbyclause:new f.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return n}))}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=(0,_.bB)(e,t.tofieldname,(0,_.zR)(t.workingexpr,p.Bj.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=(0,_.bB)(e,t.tofieldname,(0,_.zR)(t.expression,p.Bj.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const e of this._decodedGroupbyfield)e.tofieldname!==e.name&&t.push({field:e.tofieldname,newfield:e.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}_refineSetBlock(e,t,r){try{return!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery)?this._expandPagedSet(e,this._maxQuery,0,0,r).then((()=>this._refineSetBlock(e,t,r))):(this._checkCancelled(r),e._candidates.length,this._refineKnowns(e,t),e._candidates.length,e._candidates.length,(0,x.DB)(e))}catch(e){return(0,x.d1)(e)}}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getPhysicalPage(e,t,r){return!0===e.pagesDefinition.aggregatefeaturesetpagedefinition?(0,x.Ue)(((t,i)=>{this._sequentialGetPhysicalItem(e,e.pagesDefinition.resultRecordCount,r,[]).then((e=>{t(e)}),i)})):this._getAgregagtePhysicalPage(e,t,r).then((e=>{for(const t of e){const e={geometry:t.geometry,attributes:{}};for(const r of this._decodedGroupbyfield)e.attributes[r.tofieldname]=t.attributes[r.name];for(const r of this._decodedStatsfield)e.attributes[r.tofieldname]=t.attributes[r.field];this._featureCache[e.attributes[this.objectIdField]]=new l.Z(e)}return e.length}))}_sequentialGetPhysicalItem(e,t,r,i){return(0,x.Ue)(((s,n)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(r)),!0===e.pagesDefinition.internal.fullyResolved||0===t?s(i.length):this._nextAggregateItem(e,t,r,i,(n=>{null===n?s(i.length):(t-=1,s(this._sequentialGetPhysicalItem(e,t,r,i)))}),n)}))}_nextAggregateItem(e,t,r,i,s,n){try{(0,o.X)(e.pagesDefinition.internal.iterator.next()).then((a=>{if(null===a)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);i.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,s(null)}else e.pagesDefinition.internal.fullyResolved=!0,s(null);else{const l=this._generateAggregateHash(a);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[a],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const r=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return i.push(r),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(r.attributes[this.objectIdField]),t-=1,e.pagesDefinition.internal.workingItem={features:[a],id:l},void s(r)}e.pagesDefinition.internal.workingItem.features.push(a)}this._nextAggregateItem(e,t,r,i,s,n)}}),n)}catch(e){n(e)}}_calculateFieldStat(e,t,r){const i=[];for(let r=0;r<e.features.length;r++)if(null!==t.workingexpr){const s=t.workingexpr.calculateValue(e.features[r]);null!==s&&i.push(s)}else i.push(null);switch(t.typeofstat){case"MIN":r.attributes[t.tofieldname]=(0,y.tj)("min",i,-1);break;case"MAX":r.attributes[t.tofieldname]=(0,y.tj)("max",i,-1);break;case"SUM":r.attributes[t.tofieldname]=(0,y.tj)("sum",i,-1);break;case"COUNT":r.attributes[t.tofieldname]=i.length;break;case"VAR":r.attributes[t.tofieldname]=(0,y.tj)("var",i,-1);break;case"STDDEV":r.attributes[t.tofieldname]=(0,y.tj)("stddev",i,-1);break;case"AVG":r.attributes[t.tofieldname]=(0,y.tj)("avg",i,-1)}return!0}_calculateAndAppendAggregateItem(e){const t={attributes:{},geometry:null};for(const r of this._decodedGroupbyfield){const i=r.singlefield?e.features[0].attributes[r.singlefield]:r.expression.calculateValue(e.features[0]);t.attributes[r.tofieldname]=i}for(const r of this._decodedStatsfield)this._calculateFieldStat(e,r,t);const r=[];for(let i=0;i<this._decodedStatsfield.length;i++)r.push(this._calculateFieldStat(e,this._decodedStatsfield[i],t));return this._featureCache[t.attributes[this.objectIdField]]=new l.Z({attributes:t.attributes,geometry:t.geometry}),t}_generateAggregateHash(e){let t="";for(const r of this._decodedGroupbyfield){const i=r.singlefield?e.attributes[r.singlefield]:r.expression.calculateValue(e);t+=null==i?":":":"+i.toString()}return D(t,2)}_stat(){return(0,x.DB)({calculated:!1})}getFeatureByObjectId(){return(0,x.DB)(null)}static registerAction(){c.Z._featuresetFunctions.groupby=function(e,t){return new T({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}var N=r(53073),L=r(63991),P=r(80692),O=r(33955),B=r(3121),j=r(98732),Z=(r(20102),r(80442),r(10158),r(4967)),q=(r(67676),r(17452),r(67900),r(8744),r(34599)),M=r(74889),G=r(57444),U=(r(98326),r(56545),r(41818)),W=(r(66577),r(5396)),z=r(75935),V=(r(82526),r(28141),r(78760)),Q=r(58539),J=r(33586);class K extends c.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return p.tI}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){return D((0,p.hd)(e.toJSON()),2)}load(){return null===this._loadPromise&&(this._loadPromise=(0,x.Ue)(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(e){t(e)}}),t),this._layer.load()}catch(e){t(e)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=p.Bj.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=p.Bj.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=p.Bj.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=p.Bj.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return p.dj.InFeatureSet}_refineSetBlock(e){return(0,x.DB)(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):(0,x.DB)(this._wset)}_runDatabaseProbe(e){return(0,x.Ue)(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new G.Z;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(e){r(e)}}))}catch(e){r(e)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},(0,q.executeQueryPBF)(this._layer.parsedUrl,e,new V.J({})).then((e=>M.default.fromJSON((0,j.cn)(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?Z.e:"executeForCount"===t?U.P:W.G,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,s){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e)return new d.Z([],[],!0,null);if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,s);let a="",l=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=i.constructClause(),l=!0);const o=new G.Z;return o.where=null===r?null===t?"1=1":"":(0,_.zR)(r,n),this._requestStandardised&&(o.sqlFormat="standard"),o.spatialRelationship=this._makeRelationshipEnum(e),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==a?a.split(","):null,o.geometry=null===t?null:t,o.relationParameter=this._makeRelationshipParam(e),this.executeQuery(o,"executeForIds").then((e=>(null===e&&(e=[]),this._checkCancelled(s),new d.Z([],e,l,null))))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,s){try{let n="",a=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),a=!0),this.databaseType().then((i=>{let l=null===r?null===t?"1=1":"":(0,_.zR)(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression);let o=this._maxQueryRate();const u=this._layer.capabilities.query.maxRecordCount;void 0!==u&&u<o&&(o=u);let h=null;if(!0===this._pageJustIds)h=new d.Z([],["GETPAGES"],a,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:o,resultOffset:0,geometry:null===t?null:t,where:l,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);h=new d.Z([],["GETPAGES"],a,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:o,resultOffset:0,geometry:null===t?null:t,where:l,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(h,o,0,1,s).then((()=>h))}))}catch(e){return(0,x.d1)(e)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,n=new G.Z;return this._requestStandardised&&(n.sqlFormat="standard"),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference,this.executeQuery(n,"execute").then((n=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<n.features.length;t++)e.pagesDefinition.internal.set[i+t]=n.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<n.features.length;e++)this._featureCache[n.features[e].attributes[this._layer.objectIdField]]=n.features[e];return(void 0===n.exceededTransferLimit&&n.features.length!==e.pagesDefinition.resultRecordCount||!1===n.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+n.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(e){return(0,x.d1)(e)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return(0,x.DB)("success");try{const e=new G.Z;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return(0,x.d1)(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(e){return(0,x.d1)(e)}}catch(e){return(0,x.d1)(e)}}_getDistinctPages(e,t,r,i,s,n,a,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const c=new G.Z;this._requestStandardised&&(c.sqlFormat="standard");let d=null===n?null===s?"1=1":"":(0,_.zR)(n,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(d=""!==d?"(("+this._layer.definitionExpression+") AND ("+d+"))":this._layer.definitionExpression),c.where=d,c.spatialRelationship=this._makeRelationshipEnum(i),c.relationParameter=this._makeRelationshipParam(i),c.geometry=null===s?null:s,c.returnDistinctValues=!0,c.returnGeometry=!1,c.outFields=[h],this.executeQuery(c,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return(0,x.d1)(new Error("Unnexected Result querying statistics from layer"));let c=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(c=!0);break}for(let e=0;e<u.features.length;e++){if(c){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=a)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<a?this._getDistinctPages(e+u.features.length,t,r,i,s,n,a,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,n,a){return this._getDistinctPages(0,e,t,r,i,s,n,[],a).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new G.Z;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===i?null===r?"1=1":"":(0,_.zR)(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),s.where=n,s.where=n,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,n,a){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===(0,_.y5)(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,n,a):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,n,a):this._distinctStat(e,t,r,i,s,n,a):this.databaseType().then((n=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const a=new G.Z;this._requestStandardised&&(a.sqlFormat="standard");let l=null===s?null===i?"1=1":"":(0,_.zR)(s,n);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),a.where=l,a.spatialRelationship=this._makeRelationshipEnum(r),a.relationParameter=this._makeRelationshipParam(r),a.geometry=null===i?null:i;const o=new Q.Z;o.statisticType=(0,y.g3)(e),o.onStatisticField=(0,_.zR)(t,n),o.outStatisticFieldName="ARCADE_STAT_RESULT",a.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return a.outStatistics=[o],this.executeQuery(a,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return(0,x.d1)(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,n,a){return this._stats(e,t,r,i,s,n,a)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===(0,_.y5)(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,a){return this._ensureLoaded().then((()=>this.databaseType())).then((l=>{let o="",u=!1,h=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(o=n.constructClause(),h=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(h=!1,u=!0,o=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new Q.Z;r.onStatisticField=null!==t[e].workingexpr?(0,_.zR)(t[e].workingexpr,l):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===o&&(o=e.join(","));let f=this._maxQueryRate();const p=this._layer.capabilities.query.maxRecordCount;void 0!==p&&p<f&&(f=p);let y=null===s?null===i?"1=1":"":(0,_.zR)(s,l);return this._layer.definitionExpression&&this._useDefinitionExpression&&(y=""!==y?"(("+this._layer.definitionExpression+") AND ("+y+"))":this._layer.definitionExpression),new d.Z([],["GETPAGES"],h,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:u,generatedOid:a,resultRecordCount:f,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:y,orderByFields:o,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(e,t,r){try{let t=e.pagesDefinition.where;!0===e.pagesDefinition.useOIDpagination&&(t=""!==t?"("+t+") AND ("+e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString()+")":e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString());const i=e.pagesDefinition.internal.lastRetrieved,s=i,n=e.pagesDefinition.internal.lastPage,a=new G.Z;return this._requestStandardised&&(a.sqlFormat="standard"),a.where=t,a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields,a.outStatistics=e.pagesDefinition.outStatistics,a.geometry=e.pagesDefinition.geometry,a.groupByFieldsForStatistics=e.pagesDefinition.groupByFieldsForStatistics,a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.returnGeometry=e.pagesDefinition.returnGeometry,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,this.isTable()&&a.geometry&&a.spatialRelationship?(0,x.DB)([]):this.executeQuery(a,"execute").then((t=>{if(this._checkCancelled(r),!t.hasOwnProperty("features"))return(0,x.d1)(new Error("Unnexected Result querying aggregates from layer"));const a=[];if(e.pagesDefinition.internal.lastPage!==n)return[];for(let r=0;r<t.features.length;r++)e.pagesDefinition.internal.set[s+r]=t.features[r].attributes[e.pagesDefinition.generatedOid];for(let e=0;e<t.features.length;e++)a.push(new l.Z({attributes:t.features[e].attributes,geometry:null}));return!0===e.pagesDefinition.useOIDpagination?0===t.features.length?e.pagesDefinition.internal.fullyResolved=!0:e.pagesDefinition.internal.lastMaxId=t.features[t.features.length-1].attributes[e.pagesDefinition.generatedOid]:(void 0===t.exceededTransferLimit&&t.features.length!==e.pagesDefinition.resultRecordCount||!1===t.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=i+t.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,a}))}catch(e){return(0,x.d1)(e)}}static create(e,t,r,i,s){const n=new B.default({url:e,outFields:null===t?["*"]:t});return new K({layer:n,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return(0,p.US)(this._layer.parsedUrl.path)}queryAttachments(e,t,r,i,s){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:s};return(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),i&&i.length>0&&(n.attachmentTypes=i),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const r=[];return t&&t[e]&&t[e].forEach((t=>{const i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;s&&t.exifInfo&&(n=J.Z.convertJsonToArcade(t.exifInfo,!0)),r.push(new P.Z(t.id,t.name,t.contentType,t.size,i,n))})),r}))}return(0,x.DB)([])}queryRelatedFeatures(e){const t={f:"json",relationshipId:e.relationshipId.toString(),definitionExpression:e.where,outFields:e.outFields.join(","),returnGeometry:e.returnGeometry.toString()};return void 0!==e.resultOffset&&null!==e.resultOffset&&(t.resultOffset=e.resultOffset.toString()),void 0!==e.resultRecordCount&&null!==e.resultRecordCount&&(t.resultRecordCount=e.resultRecordCount.toString()),e.orderByFields&&(t.orderByFields=e.orderByFields.join(",")),e.objectIds.length>0&&(t.objectIds=e.objectIds.join(",")),e.outSpatialReference&&(t.outSR=JSON.stringify(e.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:t,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),(0,s.default)(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:t}).then((e=>{if(e.data){const t={},r=e.data;if(r&&r.relatedRecordGroups){const e=r.spatialReference;for(const i of r.relatedRecordGroups){const s=i.objectId,n=[];for(const t of i.relatedRecords){t.geometry&&(t.geometry.spatialReference=e);const r=new l.Z({geometry:t.geometry?(0,O.im)(t.geometry):null,attributes:t.attributes});n.push(r)}t[s]={features:n,exceededTransferLimit:!0===r.exceededTransferLimit}}}return t}return(0,x.d1)("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new G.Z;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),(0,Z.e)(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=i.id)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const t=null==(e=i.id)?void 0:e.findServerInfo(this._layer.url);if(t)return(0,x.DB)(t.owningSystemUrl);let r=this._layer.url;const n=r.toLowerCase().indexOf("/rest/services");return r=n>-1?r.substring(0,n):r,r?(r+="/rest/info",(0,x.Ue)(((e,t)=>{(0,s.default)(r,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):(0,x.DB)("")}))}getDataSourceFeatureSet(){const e=new K({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}var $=r(17805);class H extends c.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,this.relatedLayer=null,this.relationship=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this.relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return p.tI}end(){return this._layer}optimisePagingFeatureQueries(){}load(){return null===this._loadPromise&&(this._loadPromise=(0,x.Ue)(((e,t)=>{(0,x.$6)([this._layer.load(),this.relatedLayer.load()]).then((()=>{this._initialiseFeatureSet(),e(this)}),t)}))),this._loadPromise}nativeCapabilities(){return this.relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this.relatedLayer.geometryType,this.fields=this.relatedLayer.fields.slice(0),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this.relatedLayer.objectIdField,this.globalIdField=this.relatedLayer.globalIdField,this.hasM=this.relatedLayer.supportsM,this.hasZ=this.relatedLayer.supportsZ,this.typeIdField=this.relatedLayer.typeIdField,this.types=this.relatedLayer.types}databaseType(){return this.relatedLayer.databaseType().then((()=>(this._databaseType=this.relatedLayer._databaseType,this._databaseType)))}isTable(){return this.relatedLayer.isTable()}_isInFeatureSet(){return p.dj.InFeatureSet}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):(0,x.DB)(this._wset)}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new l.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}_getFilteredSet(e,t,r,i,s){return this.databaseType().then((()=>{if(this.isTable()&&t&&null!==e&&""!==e)return new d.Z([],[],!0,null);const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated)return new d.Z([],[],!0,null);if(n.capabilities.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,i,s);let a="",l=!1;null!==i&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(a=i.constructClause(),l=!0);const o=new z.Z;o.objectIds=[this._findObjectId];const u=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this.relatedLayer.fields?this.relatedLayer.fields.map((e=>e.name)):["*"]);o.outFields=u,o.relationshipId=this.relationship.id,o.where="1=1";let h=!0;return!0===this._removeGeometry&&(h=!1),o.returnGeometry=h,this._requestStandardised&&(o.sqlFormat="standard"),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==a?a.split(","):null,n.source.queryRelatedFeatures(o).then((i=>{this._checkCancelled(s);const n=i[this._findObjectId]?i[this._findObjectId].features:[],a=[];for(let e=0;e<n.length;e++)this._featureCache[n[e].attributes[this.relatedLayer.objectIdField]]=n[e],a.push(n[e].attributes[this.relatedLayer.objectIdField]);const o=t&&null!==e&&""!==e,u=null!=r;return new d.Z(o||u?a:[],o||u?[]:a,l,null)}))}))}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFilteredSetUsingPaging(e,t,r,i,s){try{let n="",a=!1;const l=this._layer.nativeCapabilities();return null!==i&&l&&l.capabilities.queryRelated&&!0===l.capabilities.queryRelated.supportsOrderBy&&(n=i.constructClause(),a=!0),this.databaseType().then((()=>{let i=this._maxQueryRate();const o=l.capabilities.query.maxRecordCount;void 0!==o&&o<i&&(i=o);const u=t&&null!==e&&""!==e,h=null!=r;let c=null,f=!0;!0===this._removeGeometry&&(f=!1);const p=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this.relatedLayer.fields?this.relatedLayer.fields.map((e=>e.name)):["*"]);return c=new d.Z(u||h?["GETPAGES"]:[],u||h?[]:["GETPAGES"],a,{outFields:p.join(","),resultRecordCount:i,resultOffset:0,objectIds:[this._findObjectId],where:"1=1",orderByFields:n,returnGeometry:f,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),this._expandPagedSet(c,i,0,0,s).then((()=>c))}))}catch(e){return(0,x.d1)(e)}}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,n=this._layer.nativeCapabilities(),a=new z.Z;return!0===this._requestStandardised&&(a.sqlFormat="standard"),a.relationshipId=this.relationship.id,a.objectIds=e.pagesDefinition.objectIds,a.resultOffset=e.pagesDefinition.internal.lastPage,a.resultRecordCount=e.pagesDefinition.resultRecordCount,a.outFields=e.pagesDefinition.outFields.split(","),a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,n.source.queryRelatedFeatures(a).then((n=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return 0;const a=n[this._findObjectId]?n[this._findObjectId].features:[];for(let t=0;t<a.length;t++)e.pagesDefinition.internal.set[i+t]=a[t].attributes[this.relatedLayer.objectIdField];for(let e=0;e<a.length;e++)this._featureCache[a[e].attributes[this.relatedLayer.objectIdField]]=a[e];const l=!n[this._findObjectId]||!1===n[this._findObjectId].exceededTransferLimit;return a.length!==e.pagesDefinition.resultRecordCount&&l&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,a.length}))}catch(e){return(0,x.d1)(e)}}_getFeatures(e,t,r,i){const s=[];-1!==t&&void 0===this._featureCache[t]&&s.push(t);const n=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,n))return this._expandPagedSet(e,n,0,0,i).then((()=>this._getFeatures(e,t,r,i)));let a=0;for(let i=e._lastFetchedIndex;i<e._known.length&&(a++,a<=r&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[i]&&void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&s.push(e._known[i]),s.length>r)))&&!(a>=r&&0===s.length);i++);return 0===s.length?(0,x.DB)("success"):(0,x.d1)(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e,t,r){return(0,x.DB)(e)}_stat(e,t,r,i,s,n,a){return(0,x.DB)({calculated:!1})}get gdbVersion(){return this.relatedLayer.gdbVersion}_canDoAggregates(e,t,r,i,s){return(0,x.DB)(!1)}relationshipMetaData(){return this.relatedLayer.relationshipMetaData()}serviceUrl(){return this.relatedLayer.serviceUrl()}queryAttachments(e,t,r,i,s){return this.relatedLayer.queryAttachments(e,t,r,i,s)}getFeatureByObjectId(e,t){return this.relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this.relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this.relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this.relatedLayer}}var X=r(48039),Y=r(65587),ee=r(15235);function te(){null===X.Z.applicationCache&&(X.Z.applicationCache=new X.Z)}function re(e,t){if(X.Z.applicationCache){const r=X.Z.applicationCache.getLayerInfo(e);if(r)return r.then((r=>(0,x.DB)(new B.default({url:e,outFields:t,sourceJSON:r}))));const i=new B.default({url:e,outFields:t});let s=(0,x.Ue)(((e,t)=>{i.load().then((()=>{e(i.sourceJSON)}),(e=>{t(e)}))}));return X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(e,s),s=s.catch((t=>{throw X.Z.applicationCache.clearLayerInfo(e),t}))),s.then((()=>(0,x.DB)(i)))}return(0,x.DB)(new B.default({url:e,outFields:t}))}function ie(e,t,r,i,s,n=null){return re(e,["*"]).then((e=>(0,x.DB)(se(e,t,r,i,s,n))))}function se(e,t=null,r=null,i=!0,s=null,n=null){return!0===e._hasMemorySource()?new $.Z({layer:e,spatialReference:t,outFields:r,includeGeometry:i,lrucache:s,interceptor:n}):new K({layer:e,spatialReference:t,outFields:r,includeGeometry:i,lrucache:s,interceptor:n})}function ne(e){if(null!==X.Z.applicationCache){const t=X.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}let t=(0,s.default)(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.layers||(t.layers=[]),t.tables||(t.tables=[]),(0,x.DB)(t)}return(0,x.DB)({layers:[],tables:[]})}));return null!==X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(e,t),t=t.catch((t=>{throw X.Z.applicationCache.clearLayerInfo(e),t}))),t}function ae(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return ne(e).then((i=>{if(r.metadata=i,i.controllerDatasetLayers&&void 0!==i.controllerDatasetLayers.utilityNetworkLayerId&&null!==i.controllerDatasetLayers.utilityNetworkLayerId){if(i.layers)for(const e of i.layers)r.layerNameLkp[e.id]=e.name;if(i.tables)for(const e of i.tables)r.layerNameLkp[e.id]=e.name;const n=i.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=n,function(e,t){const r="QUERYDATAELEMTS:"+t.toString()+":"+e;if(null!==X.Z.applicationCache){const e=X.Z.applicationCache.getLayerInfo(r);if(null!==e)return e}let i=(0,s.default)(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([t.toString()]),f:"json"}}).then((e=>{if(e.data){const t=e.data;if(t.layerDataElements&&t.layerDataElements[0])return t.layerDataElements[0]}throw new Error("Not Found")}));return null!==X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(r,i),i=i.catch((e=>{throw X.Z.applicationCache.clearLayerInfo(r),e}))),i}(e,n).then((i=>{if(i){r.queryelem=i,r.queryelem&&r.queryelem.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources?e.edgeSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources?e.junctionSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});return function(e){if(null!==X.Z.applicationCache){const t=X.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}let t=(0,s.default)(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return(0,x.DB)(t)}return(0,x.DB)(null)}));return null!==X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(e,t),t=t.catch((t=>{throw X.Z.applicationCache.clearLayerInfo(e),t}))),t}(e+"/"+n).then((i=>{if(i.systemLayers&&void 0!==i.systemLayers.associationsTableId&&null!==i.systemLayers.associationsTableId){const s=[];return r.unVersion>=4&&(s.push("STATUS"),s.push("PERCENTALONG")),ie(e+"/"+i.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...s],!1,null,null).then((e=>e.load())).then((e=>r.unVersion>=4?(e=e.filter(g.WhereClause.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",e.getFieldsIndex()))).load():e)).then((e=>({lkp:r.lkp,associations:e,unVersion:r.unVersion,terminals:r.terminals})))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}function le(e,t,r,i=null,s=null,n=!0,a=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),ie(o,i,s,n,a,l).then((o=>new H({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:i,outFields:s,includeGeometry:n,lrucache:a,interceptor:l})))):null}a.Z.registerAction(),T.registerAction(),h.Z.registerAction(),N.Z.registerAction(),L.Z.registerAction();class oe extends n.Z{constructor(e,t=null,r=null,i=null){super(),this._map=e,this._overridespref=t,this.lrucache=r,this.interceptor=i,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,r=null){const i=se(e,this._overridespref,null===r?["*"]:r,t,this.lrucache,this.interceptor);return this._instantLayers.push({featureset:i,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),i}featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetByName(e,t,r)}catch(e){return(0,x.d1)(e)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.title===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}const s=this._map.allLayers.find((t=>t instanceof B.default&&t.title===e));if(s)return this.resolvePromise(this._makeAndAddFeatureSet(s,t,r));if(this._map.tables){const i=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(i){if(i instanceof B.default)return this.resolvePromise(this._makeAndAddFeatureSet(i,t,r));if(i._materializedTable);else{const e=i.outFields?i:{...i,outFields:["*"]};i._materializedTable=new B.default(e)}return i._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(i._materializedTable,t,r))))}}return this.resolvePromise(null)}featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetById(e,t,r)}catch(e){return(0,x.d1)(e)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.id===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}const s=this._map.allLayers.find((t=>t instanceof B.default&&t.id===e));if(s)return this.resolvePromise(this._makeAndAddFeatureSet(s,t,r));if(this._map.tables){const i=this._map.tables.find((t=>t.id===e));if(i){if(i instanceof B.default)return this.resolvePromise(this._makeAndAddFeatureSet(i,t,r));if(i._materializedTable);else{const e={...i,outFields:["*"]};i._materializedTable=new B.default(e)}return i._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(i._materializedTable,t,r))))}}return this.resolvePromise(null)}}class ue extends n.Z{constructor(e,t=null,r=null,i=null){super(),this._url=e,this._overridespref=t,this.lrucache=r,this.interceptor=i,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,r=null){const i=se(e,this._overridespref,null===r?["*"]:r,t,this.lrucache);return this._instantLayers.push({featureset:i,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),i}_loadMetaData(){return ne(this._url).then((e=>(this.metadata=e,e)))}load(){return this._loadMetaData()}clone(){return new ue(this._url,this._overridespref,this.lrucache,this.interceptor)}featureSetByName(e,t=!0,r=null){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.title===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}return this._loadMetaData().then((i=>{let s=null;for(const t of i.layers?i.layers:[])t.name===e&&(s=t);if(!s)for(const t of i.tables?i.tables:[])t.name===e&&(s=t);return s?re(this._url+"/"+s.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}featureSetById(e,t=!0,r=["*"]){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);e=null!=e?e.toString():"";for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.id===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}return this._loadMetaData().then((i=>{let s=null;for(const t of i.layers?i.layers:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(s=t);if(!s)for(const t of i.tables?i.tables:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(s=t);return s?re(this._url+"/"+s.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}}function he(e,t,r=null,i=null){return new oe(e,t,r,i)}function ce(e,t,r=null,i=null){return new ue(e,t,r,i)}function de(e,t){return null===e?t:new Y.Z({url:e.field("url")})}function fe(e,t,r){return i.id.findCredential(e.restUrl)?"loaded"===e.loadStatus&&""===t&&e.user&&e.user.sourceJSON&&!1===r?(0,x.DB)(e.user.sourceJSON):""===t?(0,s.default)(e.restUrl+"/community/self",{responseType:"json",query:{f:"json",...!1===r?{}:{returnUserLicenseTypeExtensions:!0}}}).then((e=>{if(e.data){const t=e.data;if(t&&t.username)return(0,x.DB)(t)}return(0,x.DB)(null)})):(0,s.default)(e.restUrl+"/community/users/"+t,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.error?null:(0,x.DB)(t)}return(0,x.DB)(null)})):(0,x.DB)(null)}function pe(e,t,r,i,s){if(null===e)return null;if(e instanceof B.default){switch(t){case"datasource":return se(e,s,e.outFields,!0,r,i).getDataSourceFeatureSet();case"parent":case"root":return se(e,s,e.outFields,!0,r,i)}return null}if(e instanceof c.Z)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function _e(e,t,r,i,s,n,a,l=null){if(X.Z.applicationCache){const o=X.Z.applicationCache.getLayerInfo(e+":"+n.url);if(o)return o.then((e=>{try{const n=new B.default({url:(0,p.US)(e.url)+"/"+t,outFields:["*"]});return(0,x.DB)(se(n,r,i,s,a,l))}catch(e){return(0,x.d1)(e)}}),(e=>(0,x.d1)(e)))}return(0,x.Ue)(((o,u)=>{const h=new ee.default({id:e,portal:n}).load();X.Z.applicationCache&&X.Z.applicationCache.setLayerInfo(e+":"+n.url,h),h.then((e=>{try{const n=new B.default({url:(0,p.US)(e.url)+"/"+t,outFields:["*"]});o(se(n,r,i,s,a,l))}catch(e){u(e)}}),(t=>{X.Z.applicationCache&&X.Z.applicationCache.clearLayerInfo(e+":"+n.url),u(t)}))}))}},70409:(e,t,r)=>{r.d(t,{$X:()=>f,QP:()=>p,TO:()=>_,Xx:()=>g,yN:()=>y});var i=r(38171),s=r(77286),n=r(91136),a=r(90961),l=r(90658),o=r(36515),u=r(95330),h=r(41534),c=r(82971);class d{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class f extends d{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class p extends d{constructor(e,t,r){super((0,l.JW)(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:(0,o.bB)(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class _ extends d{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const e in r)this.reverseLkp[r[e]]=e;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,l.Bj.Standardised,this.field.name,this.codefield instanceof h.WhereClause?(0,o.zR)(this.codefield,l.Bj.Standardised):this.codefield,e.parameters);return r.includes(_.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:h.WhereClause.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,i=null,s){let n,a,l,u;switch(e.type){case"interval":return(0,o.TE)(this.evaluateNodeToWhereClause(e.value,t,r,i,s),e.qualifier,e.op);case"case_expression":{let i=" CASE ";"simple"===e.format&&(i+=this.evaluateNodeToWhereClause(e.operand,t,r,_.BADNESS,s));for(let n=0;n<e.clauses.length;n++)i+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[n].operand,t,r,_.BADNESS,s)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[n].value,t,r,_.BADNESS,s);return null!==e.else&&(i+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,_.BADNESS,s)),i+=" END ",i}case"param":{const r=s[e.value.toLowerCase()];if("string"==typeof r)return"'"+s[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'";if(r instanceof Date)return(0,o.oX)(r,t);if(r instanceof Array){const e=[];for(let i=0;i<r.length;i++)"string"==typeof r[i]?e.push("'"+r[i].toString().replace(/'/g,"''")+"'"):r[i]instanceof Date?e.push((0,o.oX)(r[i],t)):e.push(r[i].toString());return e}return r.toString()}case"expr_list":a=[];for(const n of e.value)a.push(this.evaluateNodeToWhereClause(n,t,r,i,s));return a;case"unary_expr":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,_.BADNESS,s)+" ) ";case"binary_expr":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,i,s)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,i,s)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IS NOT NULL )";case"IN":if(n=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const n=[];let a=!0;for(const t of e.right.value){if("string"!==t.type){a=!1;break}if(void 0===this.lkp[t.value]){a=!1;break}n.push(this.lkp[t.value].toString())}if(a)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+n.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,r,i,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,r,i,s),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+u+")) ";case"NOT IN":if(n=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const n=[];let a=!0;for(const t of e.right.value){if("string"!==t.type){a=!1;break}if(void 0===this.lkp[t.value]){a=!1;break}n.push(this.lkp[t.value].toString())}if(a)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+n.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,r,i,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,r,i,s),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+u+")) ";case"BETWEEN":return l=this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" BETWEEN "+l[0]+" AND "+l[1]+" ) ";case"NOTBETWEEN":return l=this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" NOT BETWEEN "+l[0]+" AND "+l[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") ";case"<>":case"=":if("column_ref"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+i+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column_ref"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+i+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") "}throw new Error("Not Supported Operator "+e.operator);case"null":return"null";case"bool":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return(0,o.oX)(e.value,t);case"number":return e.value.toString();case"current_time":return(0,o.vR)("date"===e.mode,t);case"column_ref":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+i+")":e.column;case"function":{const i=this.evaluateNodeToWhereClause(e.args,t,r,_.BADNESS,s);return(0,o.fz)(e.name,i,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof h.WhereClause?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}_.BADNESS="_!!!_BAD_LKP_!!!!";class y extends d{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:(0,o.bB)(e,this.field.name,(0,o.zR)(this.sql,l.Bj.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class g extends n.Z{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new c.Z({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.Qk.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new a.Z(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):(0,u.DB)(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,n){const l=[];-1!==t&&void 0===this._featureCache[t]&&l.push(t);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,o))return this._expandPagedSet(e,o,0,0,n).then((()=>this._getFeatures(e,t,r,n)));let h=0;for(let i=e._lastFetchedIndex;i<e._known.length&&(h++,h<=r&&(e._lastFetchedIndex+=1),!(void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&l.push(e._known[i]),l.length>=o)));i++);if(0===l.length)return(0,u.DB)("success");e=new a.Z([],l,e._ordered,null);const c=Math.min(l.length,r);return this._parent._getFeatures(e,-1,c,n).then((()=>{this._checkCancelled(n);const e=[];for(let t=0;t<c;t++){const r=this._parent._featureFromCache(l[t]);void 0!==r&&e.push({geometry:r.geometry,attributes:r.attributes,id:l[t]})}for(const t of e){const e=[];for(const r of this.adaptedFields)e[r.field.name]=r.extractValue(t);this._featureCache[t.id]=new i.Z({attributes:e,geometry:(0,s.r1)(t.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return(0,u.d1)(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,i,s){let n=!1;const l=this._reformulateWithoutAdaptions(r);n=l.cannot,r=l.where;let u=!1;if(null!==i){u=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof f)&&!0===i.scanForField(t.field.name)){if(!(t instanceof p)){i=null,u=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}i&&e.length>0&&(i=i.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=(0,o.$e)(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,i,s))).then((e=>{let t;return this._checkCancelled(s),t=!0===n?new a.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===u&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new a.Z(e._candidates.slice(0),e._known.slice(0),!0===u&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===(0,o.hq)(e,r.field.name)){const i=r.rewriteSql(e,this);if(!0!==i.rewritten){t.cannot=!0,t.where=null;break}t.where=i.where}return t}_stat(e,t,r,i,s,n,a){let l=!1,h=this._reformulateWithoutAdaptions(t);return l=h.cannot,t=h.where,h=this._reformulateWithoutAdaptions(s),l=l||h.cannot,null!==(s=h.where)?null!==this._extraFilter&&(s=(0,o.$e)(this._extraFilter,s)):s=this._extraFilter,!0===l?null===s&&""===r&&null===i?this._manualStat(e,t,n,a):(0,u.DB)({calculated:!1}):this._parent._stat(e,t,r,i,s,n,a).then((l=>!1===l.calculated?null===s&&""===r&&null===i?this._manualStat(e,t,n,a):{calculated:!1}:l))}_canDoAggregates(e,t,r,i,s){if(null===this._parent)return(0,u.DB)(!1);for(let t=0;t<e.length;t++)for(const r of this.adaptedFields)if(e[t].toLowerCase()===r.field.name.toLowerCase()&&!(r instanceof f))return(0,u.DB)(!1);const n=[];for(let e=0;e<t.length;e++){const r=t[e];if(null!==r.workingexpr){const e=this._reformulateWithoutAdaptions(r.workingexpr);if(e.cannot)return(0,u.DB)(!1);const t=r.clone();t.workingexpr=e.where,n.push(t)}else n.push(r)}const a=this._reformulateWithoutAdaptions(s);return a.cannot?(0,u.DB)(!1):(null!==(s=a.where)?null!==this._extraFilter&&(s=(0,o.$e)(this._extraFilter,s)):s=this._extraFilter,this._parent._canDoAggregates(e,n,r,i,s))}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,a){if(null===this._parent)return(0,u.d1)(new Error("Should never be called"));const l=[];for(let e=0;e<t.length;e++){const r=t[e];if(null!==r.workingexpr){const e=this._reformulateWithoutAdaptions(r.workingexpr);if(e.cannot)return(0,u.d1)(new Error("Should never be called"));const t=r.clone();t.workingexpr=e.where,l.push(t)}else l.push(r)}const h=this._reformulateWithoutAdaptions(s);return h.cannot?(0,u.d1)(new Error("Should never be called")):(null!==(s=h.where)?null!==this._extraFilter&&(s=(0,o.$e)(this._extraFilter,s)):s=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,l,r,i,s,n,a))}}},84328:(e,t,r)=>{r.d(t,{Z:()=>h});var i=r(91136),s=r(90961),n=r(90658),a=r(36515),l=r(95330),o=r(41534),u=r(82971);class h extends i.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof o.WhereClause?(this._whereclause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereclause=null)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new u.Z({wkid:4326}),this.geometryType=n.Qk.point)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._parent._getFilteredSet("",null,this._whereclause,null,e))).then((t=>(this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new s.Z(t._candidates.slice(0).concat(t._known.slice(0)),[],t._ordered,this._clonePageDefinition(t.pagesDefinition)):this._wset=new s.Z(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):(0,l.DB)(this._wset)}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===n.dj.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?n.dj.Unknown:t)}_getFeature(e,t,r){return this._parent._getFeature(e,t,r)}_getFeatures(e,t,r,i){return this._parent._getFeatures(e,t,r,i)}_featureFromCache(e){return this._parent._featureFromCache(e)}executeWhereClause(e){return this._whereclause.testFeature(e)}executeWhereClauseDeferred(e){if(null!==this._whereClauseFunction)try{const t=this._whereClauseFunction(e);return(0,l.y8)(t)?t:(0,l.DB)(t)}catch(e){return(0,l.d1)(e)}return(0,l.DB)(this.executeWhereClause(e))}_fetchAndRefineFeatures(e,t,r){const i=new s.Z([],e,!1,null),a=Math.min(t,e.length);return this._parent._getFeatures(i,-1,a,r).then((()=>{if(this._checkCancelled(r),null==this._whereClauseFunction){for(let t=0;t<a;t++){const r=this._parent._featureFromCache(e[t]);!0===this.executeWhereClause(r)?this._idstates[e[t]]=n.dj.InFeatureSet:this._idstates[e[t]]=n.dj.NotInFeatureSet}return"success"}const i=[];for(let t=0;t<a;t++){const r=this._parent._featureFromCache(e[t]);i.push(this.executeWhereClauseDeferred(r))}return(0,l.$6)(i).then((r=>{for(let i=0;i<t;i++)!0===r[i]?this._idstates[e[i]]=n.dj.InFeatureSet:this._idstates[e[i]]=n.dj.NotInFeatureSet;return"success"}))}))}_getFilteredSet(e,t,r,i,n){return null!==this._whereClauseFunction||(null!==r?null!==this._whereclause&&(r=(0,a.$e)(this._whereclause,r)):r=this._whereclause),this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,i,n))).then((e=>{let t;return this._checkCancelled(n),t=null!==this._whereClauseFunction?new s.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s.Z(e._candidates.slice(0),e._known.slice(0),e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_stat(e,t,r,i,s,n,o){if(null!==this._whereClauseFunction)return null===s&&""===r&&null===i?this._manualStat(e,t,n,o):(0,l.DB)({calculated:!1});let u=this._whereclause;return null!==s&&null!==this._whereclause&&(u=(0,a.$e)(this._whereclause,s)),this._parent._stat(e,t,r,i,u,n,o).then((a=>!1===a.calculated?null===s&&""===r&&null===i?this._manualStat(e,t,n,o):{calculated:!1}:a))}_canDoAggregates(e,t,r,i,s){return null!==this._whereClauseFunction?(0,l.DB)(!1):(null!==s?null!==this._whereclause&&(s=(0,a.$e)(this._whereclause,s)):s=this._whereclause,null===this._parent?(0,l.DB)(!1):this._parent._canDoAggregates(e,t,r,i,s))}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,o){return null===this._parent?(0,l.d1)(new Error("Should never be called")):(null!==s?null!==this._whereclause&&(s=(0,a.$e)(this._whereclause,s)):s=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,o))}static registerAction(){i.Z._featuresetFunctions.filter=function(e){if("function"==typeof e)return new h({parentfeatureset:this,whereclause:e});let t=null;return e instanceof o.WhereClause&&(t=e),new h({parentfeatureset:this,whereclause:t})}}}},85065:(e,t,r)=>{r.d(t,{Z:()=>o});var i=r(61363),s=r(91136),n=r(90961),a=r(3823),l=r(95330);class o extends s.Z{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,this._orderbyclause,e))).then((t=>(this._checkCancelled(e),this._wset=t,this._wset))):(0,l.DB)(this._wset)}manualOrderSet(e,t){return this.getIdColumnDictionary(e,[],-1,t).then((e=>{this._orderbyclause.order(e);const t=new n.Z([],[],!0,null);for(let r=0;r<e.length;r++)t._known.push(e[r].id);return t}))}getIdColumnDictionary(e,t,r,s){if(r<e._known.length-1){const n=this._maxQueryRate();if("GETPAGES"===e._known[r+1])return(0,i.X)(this._parent._expandPagedSet(e,n,0,0,s)).then((()=>this.getIdColumnDictionary(e,t,r,s)));let a=r+1;const l=[];for(;a<e._known.length&&"GETPAGES"!==e._known[a];)l.push(e._known[a]),a++;return r+=l.length,(0,i.X)(this._parent._getFeatureBatch(l,s)).then((i=>{this._checkCancelled(s);for(const e of i)t.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(e,t,r,s)}))}return e._candidates.length>0?(0,i.X)(this._refineSetBlock(e,this._maxProcessingRate(),s)).then((()=>(this._checkCancelled(s),this.getIdColumnDictionary(e,t,r,s)))):(0,l.DB)(t)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,i){return this._parent._getFeatures(e,t,r,i)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}_fetchAndRefineFeatures(){return(0,l.d1)(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,i,s){return this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,null===i?this._orderbyclause:i,s))).then((e=>{this._checkCancelled(s);const i=new n.Z(e._candidates.slice(0),e._known.slice(0),e._ordered,this._clonePageDefinition(e.pagesDefinition));let a=!0;return e._candidates.length>0&&(a=!1),!1===i._ordered?this.manualOrderSet(i,s).then((e=>(!1===a&&(null===t&&null===r||(e=new n.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e))):i}))}static registerAction(){s.Z._featuresetFunctions.orderBy=function(e){return""===e?this:new o({parentfeatureset:this,orderbyclause:new a.Z(e)})}}}},63991:(e,t,r)=>{r.d(t,{Z:()=>l});var i=r(91136),s=r(90961),n=r(90658),a=r(95330);class l extends i.Z{constructor(e){super(e),this._topnum=0,this.declaredClass="esri.arcade.featureset.actions.Top",this._countedin=0,this._maxProcessing=100,this._topnum=e.topnum,this._parent=e.parentfeatureset}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._parent._getSet(e))).then((e=>(this._wset=new s.Z(e._candidates.slice(0),e._known.slice(0),!1,this._clonePageDefinition(e.pagesDefinition)),this._setKnownLength(this._wset)>this._topnum&&(this._wset._known=this._wset._known.slice(0,this._topnum)),this._setKnownLength(this._wset)>=this._topnum&&(this._wset._candidates=[]),this._wset))):(0,a.DB)(this._wset)}_setKnownLength(e){return e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]?e._known.length-1:e._known.length}_isInFeatureSet(e){const t=this._parent._isInFeatureSet(e);if(t===n.dj.NotInFeatureSet)return t;const r=this._idstates[e];return r===n.dj.InFeatureSet||r===n.dj.NotInFeatureSet?r:t===n.dj.InFeatureSet&&void 0===r?this._countedin<this._topnum?(this._idstates[e]=n.dj.InFeatureSet,this._countedin++,n.dj.InFeatureSet):(this._idstates[e]=n.dj.NotInFeatureSet,n.dj.NotInFeatureSet):n.dj.Unknown}_expandPagedSet(e,t,r,i,s){if(null===this._parent)return(0,a.d1)(new Error("Parent Paging not implemented"));if(t>this._topnum&&(t=this._topnum),this._countedin>=this._topnum&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset){let t=e._known.length;return t>0&&"GETPAGES"===e._known[t-1]&&(e._known.length=t-1),t=e._candidates.length,t>0&&"GETPAGES"===e._candidates[t-1]&&(e._candidates.length=t-1),(0,a.DB)("success")}return this._parent._expandPagedSet(e,t,r,i,s).then((t=>(this._setKnownLength(e)>this._topnum&&(e._known.length=this._topnum),this._setKnownLength(e)>=this._topnum&&(e._candidates.length=0),t)))}_getFeatures(e,t,r,i){const n=[],l=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,l))return this._expandPagedSet(e,l,0,0,i).then((()=>this._getFeatures(e,t,r,i)));-1!==t&&void 0===this._featureCache[t]&&n.push(t);let o=0;for(let i=e._lastFetchedIndex;i<e._known.length&&(o++,o<=r&&(e._lastFetchedIndex+=1),!(void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&n.push(e._known[i]),n.length>l)));i++);if(0===n.length)return(0,a.DB)("success");const u=new s.Z([],n,!1,null),h=Math.min(n.length,r);return this._parent._getFeatures(u,-1,h,i).then((()=>{for(let e=0;e<h;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&(this._featureCache[n[e]]=t)}return"success"}))}_getFilteredSet(e,t,r,i,n){return this._ensureLoaded().then((()=>this._getSet(n))).then((e=>new s.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],!1,this._clonePageDefinition(e.pagesDefinition))))}_refineKnowns(e,t){let r=0,i=null;const s=[];for(let a=0;a<e._candidates.length;a++){const l=this._isInFeatureSet(e._candidates[a]);if(l===n.dj.InFeatureSet){if(e._known.push(e._candidates[a]),r+=1,null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(s.push(i),i={start:a,end:a}),e._known.length>=this._topnum)break}else if(l===n.dj.NotInFeatureSet)null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(s.push(i),i={start:a,end:a}),r+=1;else if(l===n.dj.Unknown)break;if(r>=t)break}null!==i&&s.push(i);for(let t=s.length-1;t>=0;t--)e._candidates.splice(s[t].start,s[t].end-s[t].start+1);this._setKnownLength(e)>this._topnum&&(e._known=e._known.slice(0,this._topnum)),this._setKnownLength(e)>=this._topnum&&(e._candidates=[])}_stat(){return(0,a.DB)({calculated:!1})}_canDoAggregates(){return(0,a.DB)(!1)}static registerAction(){i.Z._featuresetFunctions.top=function(e){return new l({parentfeatureset:this,topnum:e})}}}},17805:(e,t,r)=>{r.d(t,{Z:()=>p});var i=r(38171),s=r(91136),n=r(90961),a=r(90658),l=r(36515),o=r(95330),u=r(9361),h=r(3121),c=r(16451),d=r(1231),f=r(57444);class p extends s.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a.tI}end(){return this._layer}optimisePagingFeatureQueries(){}load(){return null===this._loadPromise&&(this._loadPromise=(0,o.Ue)(((e,t)=>{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(e){t(e)}}),t),this._layer.load()}))),this._loadPromise}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this._databaseType=a.Bj.Standardised,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}isTable(){return this._forceIsTable||this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return a.dj.InFeatureSet}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):(0,o.DB)(this._wset)}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new i.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}_getFilteredSet(e,t,r,i,s){let u="",h=!1;if(null!==i&&(u=i.constructClause(),h=!0),this.isTable()&&t&&null!==e&&""!==e){const e=new n.Z([],[],!0,null);return(0,o.DB)(e)}const c=new f.Z;return c.where=null===r?null===t?"1=1":"":(0,l.zR)(r,a.Bj.Standardised),c.spatialRelationship=this._makeRelationshipEnum(e),c.outSpatialReference=this.spatialReference,c.orderByFields=""!==u?u.split(","):null,c.geometry=null===t?null:t,c.returnGeometry=!0,c.relationParameter=this._makeRelationshipParam(e),this._layer.queryFeatures(c).then((e=>{if(null===e)return new n.Z([],[],h,null);this._checkCancelled(s);const t=[];return e.features.forEach((e=>{const r=e.attributes[this._layer.objectIdField];t.push(r),this._featureCache[r]=this._changeFeature(e)})),new n.Z([],t,h,null)}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_queryAllFeatures(){if(this._wset)return(0,o.DB)(this._wset);const e=new f.Z;return e.where="1=1",this._ensureLoaded().then((()=>{if(this._layer.source&&this._layer.source.items){const e=[];return this._layer.source.items.forEach((t=>{const r=t.attributes[this._layer.objectIdField];e.push(r),this._featureCache[r]=this._changeFeature(t)})),this._wset=new n.Z([],e,!1,null),this._wset}return this._layer.queryFeatures(e).then((e=>{const t=[];return e.features.forEach((e=>{const r=e.attributes[this._layer.objectIdField];t.push(r),this._featureCache[r]=this._changeFeature(e)})),this._wset=new n.Z([],t,!1,null),this._wset}))}))}_getFeatures(e,t,r){const i=[];-1!==t&&void 0===this._featureCache[t]&&i.push(t);for(let s=e._lastFetchedIndex;s<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[s]]&&(e._known[s]!==t&&i.push(e._known[s]),i.length>r)));s++);return 0===i.length?(0,o.DB)("success"):(0,o.d1)(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e){return(0,o.DB)(e)}_stat(){return(0,o.DB)({calculated:!1})}_canDoAggregates(){return(0,o.DB)(!1)}relationshipMetaData(){return[]}static _cloneAttr(e){const t={};for(const r in e)t[r]=e[r];return t}nativeCapabilities(){return{title:this._layer.title,canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let r=e.layerDefinition.objectIdField;const i=e.layerDefinition.typeIdField?e.layerDefinition.typeIdField:"",s=[];if(e.layerDefinition.types)for(const t of e.layerDefinition.types)s.push(c.Z.fromJSON(t));let n=e.layerDefinition.geometryType;void 0===n&&(n=e.featureSet.geometryType||"");let a=e.featureSet.features;const l=t.toJSON();if(""===r||void 0===r){let t=!1;for(const i of e.layerDefinition.fields)if("oid"===i.type||"esriFieldTypeOID"===i.type){r=i.name,t=!0;break}if(!1===t){let t="FID",i=!0,s=0;for(;i;){let r=!0;for(const i of e.layerDefinition.fields)if(i.name===t){r=!1;break}!0===r?i=!1:(s++,t="FID"+s.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const n=[];for(let r=0;r<a.length;r++)n.push({geometry:e.featureSet.features[r].geometry,attributes:e.featureSet.features[r].attributes?this._cloneAttr(e.featureSet.features[r].attributes):{}}),n[r].attributes[t]=r;a=n,r=t}}const o=[];for(const t of e.layerDefinition.fields)t instanceof d.Z?o.push(t):o.push(d.Z.fromJSON(t));let f=n;switch(f){case"esriGeometryPoint":f="point";break;case"esriGeometryPolyline":f="polyline";break;case"esriGeometryPolygon":f="polygon";break;case"esriGeometryExtent":f="extent";break;case"esriGeometryMultipoint":f="multipoint"}for(const e of a)e.geometry&&e.geometry instanceof u.Z==0&&(e.geometry.type=f,void 0===e.geometry.spatialReference&&(e.geometry.spatialReference=l));const _={outFields:["*"],source:a,fields:o,types:s,typeIdField:i,objectIdField:r,spatialReference:t};_.geometryType=f||"point";const y=new h.default(_);return new p({layer:y,spatialReference:t,isTable:null===f||""===f})}queryAttachments(){return(0,o.DB)([])}getFeatureByObjectId(e){const t=new f.Z;return t.where=this.objectIdField+"="+e.toString(),this._layer.queryFeatures(t).then((e=>1===e.features.length?e.features[0]:null))}getOwningSystemUrl(){return(0,o.DB)("")}getIdentityUser(){return(0,o.DB)("")}}},3823:(e,t,r)=>{function i(e,t){return e===t?0:null===e?-1:null===t?1:e<t?-1:1}r.d(t,{Z:()=>s});class s{constructor(e){const t=e.split(",");this._fields=[],this._directions=[];for(let e=0;e<t.length;e++){const r=t[e].match(/\S+/g);this._fields.push(r[0]),2===r.length?"asc"===r[1].toLowerCase()?this._directions.push(1):this._directions.push(0):this._directions.push(1)}}constructClause(){let e="";for(let t=0;t<this._fields.length;t++)0!==t&&(e+=","),e+=this._fields[t],1===this._directions[t]?e+=" ASC":e+=" DESC";return e}order(e){e.sort(((e,t)=>{for(let r=0;r<this._fields.length;r++){const s=this.featureValue(e.feature,this._fields[r],r),n=this.featureValue(t.feature,this._fields[r],r);let a=0;if(a=1===this._directions[r]?i(s,n):-1*i(s,n),0!==a)return a}return 0}))}scanForField(e){for(let t=0;t<this._fields.length;t++)if(this._fields[t].toLowerCase().trim()===e.toLowerCase().trim())return!0;return!1}replaceFields(e){let t="";for(let r=0;r<this._fields.length;r++){0!==r&&(t+=",");let i=this._fields[r];for(const t of e)if(i.toLowerCase()===t.field.toLowerCase()){i=t.newfield;break}t+=i,1===this._directions[r]?t+=" ASC":t+=" DESC"}return new s(t)}featureValue(e,t,r){const i=e.attributes[t];if(void 0!==i)return i;for(const i in e.attributes)if(t.toLowerCase()===i.toLowerCase())return this._fields[r]=i,e.attributes[i];return null}}},25929:(e,t,r)=>{r.d(t,{M:()=>f,f:()=>n,i:()=>c,p:()=>_,r:()=>l,t:()=>a,w:()=>o});var i=r(70586),s=r(17452);function n(e,t){const r=t&&t.url&&t.url.path;if(e&&r&&(e=(0,s.hF)(e,r,{preserveProtocolRelative:!0}),t.portalItem&&t.readResourcePaths)){const r=(0,s.PF)(e,t.portalItem.itemUrl);h.test(r)&&t.readResourcePaths.push(t.portalItem.resourceFromPath(r).path)}return d(e,t&&t.portal)}function a(e,t,r=f.YES){if(!e)return e;!(0,s.YP)(e)&&t&&t.blockedRelativeUrls&&t.blockedRelativeUrls.push(e);let i=(0,s.hF)(e);if(t){const r=t.verifyItemRelativeUrls&&t.verifyItemRelativeUrls.rootPath||t.url&&t.url.path;if(r){const n=d(r,t.portal);i=(0,s.PF)(d(i,t.portal),n,n),i!==e&&t.verifyItemRelativeUrls&&t.verifyItemRelativeUrls.writtenUrls.push(i)}}return i=function(e,t){return t&&!t.isPortal&&t.urlKey&&t.customBaseUrl?(0,s.Ie)(e,`${t.urlKey}.${t.customBaseUrl}`,t.portalHostname):e}(i,t&&t.portal),(0,s.YP)(i)&&(i=(0,s.Fv)(i)),null!=t&&t.resources&&null!=t&&t.portalItem&&!(0,s.YP)(i)&&!(0,s.HK)(i)&&r===f.YES&&t.resources.toKeep.push({resource:t.portalItem.resourceFromPath(i)}),i}function l(e,t,r){return n(e,r)}function o(e,t,r,i){const s=a(e,i);void 0!==s&&(t[r]=s)}const u=/\/items\/([^\/]+)\/resources\//,h=/^\.\/resources\//;function c(e){const t=(0,i.pC)(e)?e.match(u):null;return(0,i.pC)(t)?t[1]:null}function d(e,t){if(!t||t.isPortal||!t.urlKey||!t.customBaseUrl)return e;const r=`${t.urlKey}.${t.customBaseUrl}`,i=(0,s.TI)();return(0,s.D6)(i,`${i.scheme}://${r}`)?(0,s.Ie)(e,t.portalHostname,r):(0,s.Ie)(e,r,t.portalHostname)}var f,p;(p=f||(f={}))[p.YES=0]="YES",p[p.NO=1]="NO";const _=Object.freeze(Object.defineProperty({__proto__:null,fromJSON:n,toJSON:a,read:l,write:o,itemIdFromResourceUrl:c,get MarkKeep(){return f}},Symbol.toStringTag,{value:"Module"}))},80539:(e,t,r)=>{r.d(t,{Z:()=>k});var i,s=r(43697),n=r(3894),a=r(32448),l=r(22974),o=r(70586),u=r(71143);!function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE",e[e.MOVE=4]="MOVE"}(i||(i={}));var h,c=r(1654),d=r(5600),f=r(75215),p=r(52421),_=r(52011),y=r(58971),g=r(39020);class m{constructor(){this._observers=[]}observe(e){return this._observers.includes(e)||this._observers.push(e),new g.X(this._observers,e)}notify(){const e=this._observers.slice();for(let t=0;t<e.length;++t){const r=e[t];r.onInvalidated(),r.onCommitted()}}}const b=new u.Z(class{constructor(){this.target=null,this.cancellable=!1,this.defaultPrevented=!1,this.item=void 0,this.type=void 0}preventDefault(){this.cancellable&&(this.defaultPrevented=!0)}reset(e){this.defaultPrevented=!1,this.item=e}},void 0,(e=>{e.item=null,e.target=null,e.defaultPrevented=!1,e.cancellable=!1})),S=()=>{};function w(e){return e?e instanceof A?e.toArray():e.length?Array.prototype.slice.apply(e):[]:[]}function v(e){if(e&&e.length)return e[0]}function F(e,t,r,i){const s=Math.min(e.length-r,t.length-i);let n=0;for(;n<s&&e[r+n]===t[i+n];)n++;return n}function I(e,t,r,i){t&&t.forEach(((t,s,n)=>{e.push(t),I(e,r.call(i,t,s,n),r,i)}))}const C=new Set,D=new Set,x=new Set,R=new Map;let E=0,A=h=class extends a.Z.EventedAccessor{constructor(e){super(e),this._chgListeners=[],this._notifications=null,this._timer=null,this._observable=new m,this.length=0,this._items=[],Object.defineProperty(this,"uid",{value:E++})}static isCollection(e){return null!=e&&e instanceof h}normalizeCtorArgs(e){return e?Array.isArray(e)||e instanceof h?{items:e}:e:{}}destroy(){this.removeAll()}*[Symbol.iterator](){yield*this.items}get items(){return(0,y.it)(this._observable),this._items}set items(e){this._emitBeforeChanges(i.ADD)||(this._splice(0,this.length,w(e)),this._emitAfterChanges(i.ADD))}hasEventListener(e){return"change"===e?this._chgListeners.length>0:this._emitter.hasEventListener(e)}on(e,t){if("change"===e){const e=this._chgListeners,r={removed:!1,callback:t};return e.push(r),this._notifications&&this._notifications.push({listeners:e.slice(),items:this._items.slice(),changes:[]}),{remove(){this.remove=S,r.removed=!0,e.splice(e.indexOf(r),1)}}}return this._emitter.on(e,t)}once(e,t){const r=this.on(e,t);return{remove(){r.remove()}}}add(e,t){if((0,y.it)(this._observable),this._emitBeforeChanges(i.ADD))return this;const r=this.getNextIndex(null!=t?t:null);return this._splice(r,0,[e]),this._emitAfterChanges(i.ADD),this}addMany(e,t=this._items.length){if((0,y.it)(this._observable),!e||!e.length)return this;if(this._emitBeforeChanges(i.ADD))return this;const r=this.getNextIndex(t);return this._splice(r,0,w(e)),this._emitAfterChanges(i.ADD),this}at(e){if((0,y.it)(this._observable),(e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this._items[e]}removeAll(){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return[];const e=this._splice(0,this.length)||[];return this._emitAfterChanges(i.REMOVE),e}clone(){return(0,y.it)(this._observable),this._createNewInstance({items:this._items.map(l.d9)})}concat(...e){(0,y.it)(this._observable);const t=e.map(w);return this._createNewInstance({items:this._items.concat(...t)})}drain(e,t){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return;const r=(0,o.j0)(this._splice(0,this.length)),s=r.length;for(let i=0;i<s;i++)e.call(t,r[i],i,r);this._emitAfterChanges(i.REMOVE)}every(e,t){return(0,y.it)(this._observable),this._items.every(e,t)}filter(e,t){let r;return(0,y.it)(this._observable),r=2===arguments.length?this._items.filter(e,t):this._items.filter(e),this._createNewInstance({items:r})}find(e,t){return(0,y.it)(this._observable),this._items.find(e,t)}findIndex(e,t){return(0,y.it)(this._observable),this._items.findIndex(e,t)}flatten(e,t){(0,y.it)(this._observable);const r=[];return I(r,this,e,t),new h(r)}forEach(e,t){return(0,y.it)(this._observable),this._items.forEach(e,t)}getItemAt(e){return(0,y.it)(this._observable),this._items[e]}getNextIndex(e){(0,y.it)(this._observable);const t=this.length;return(e=null==e?t:e)<0?e=0:e>t&&(e=t),e}includes(e,t=0){return(0,y.it)(this._observable),this._items.includes(e,t)}indexOf(e,t=0){return(0,y.it)(this._observable),this._items.indexOf(e,t)}join(e=","){return(0,y.it)(this._observable),this._items.join(e)}lastIndexOf(e,t=this.length-1){return(0,y.it)(this._observable),this._items.lastIndexOf(e,t)}map(e,t){(0,y.it)(this._observable);const r=this._items.map(e,t);return new h({items:r})}reorder(e,t=this.length-1){(0,y.it)(this._observable);const r=this.indexOf(e);if(-1!==r){if(t<0?t=0:t>=this.length&&(t=this.length-1),r!==t){if(this._emitBeforeChanges(i.MOVE))return e;this._splice(r,1),this._splice(t,0,[e]),this._emitAfterChanges(i.MOVE)}return e}}pop(){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return;const e=v(this._splice(this.length-1,1));return this._emitAfterChanges(i.REMOVE),e}push(...e){return(0,y.it)(this._observable),this._emitBeforeChanges(i.ADD)||(this._splice(this.length,0,e),this._emitAfterChanges(i.ADD)),this.length}reduce(e,t){(0,y.it)(this._observable);const r=this._items;return 2===arguments.length?r.reduce(e,t):r.reduce(e)}reduceRight(e,t){(0,y.it)(this._observable);const r=this._items;return 2===arguments.length?r.reduceRight(e,t):r.reduceRight(e)}remove(e){return(0,y.it)(this._observable),this.removeAt(this.indexOf(e))}removeAt(e){if((0,y.it)(this._observable),e<0||e>=this.length||this._emitBeforeChanges(i.REMOVE))return;const t=v(this._splice(e,1));return this._emitAfterChanges(i.REMOVE),t}removeMany(e){if((0,y.it)(this._observable),!e||!e.length||this._emitBeforeChanges(i.REMOVE))return[];const t=e instanceof h?e.toArray():e,r=this._items,s=[],n=t.length;for(let e=0;e<n;e++){const i=t[e],n=r.indexOf(i);if(n>-1){const i=1+F(t,r,e+1,n+1),a=this._splice(n,i);a&&a.length>0&&s.push.apply(s,a),e+=i-1}}return this._emitAfterChanges(i.REMOVE),s}reverse(){if((0,y.it)(this._observable),this._emitBeforeChanges(i.MOVE))return this;const e=this._splice(0,this.length);return e&&(e.reverse(),this._splice(0,0,e)),this._emitAfterChanges(i.MOVE),this}shift(){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return;const e=v(this._splice(0,1));return this._emitAfterChanges(i.REMOVE),e}slice(e=0,t=this.length){return(0,y.it)(this._observable),this._createNewInstance({items:this._items.slice(e,t)})}some(e,t){return(0,y.it)(this._observable),this._items.some(e,t)}sort(e){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.MOVE))return this;const t=(0,o.j0)(this._splice(0,this.length));return arguments.length?t.sort(e):t.sort(),this._splice(0,0,t),this._emitAfterChanges(i.MOVE),this}splice(e,t,...r){(0,y.it)(this._observable);const s=(t?i.REMOVE:0)|(r.length?i.ADD:0);if(this._emitBeforeChanges(s))return[];const n=this._splice(e,t,r)||[];return this._emitAfterChanges(s),n}toArray(){return(0,y.it)(this._observable),this._items.slice()}toJSON(){return(0,y.it)(this._observable),this.toArray()}toLocaleString(){return(0,y.it)(this._observable),this._items.toLocaleString()}toString(){return(0,y.it)(this._observable),this._items.toString()}unshift(...e){return(0,y.it)(this._observable),!e.length||this._emitBeforeChanges(i.ADD)||(this._splice(0,0,e),this._emitAfterChanges(i.ADD)),this.length}_createNewInstance(e){return new this.constructor(e)}_splice(e,t,r){const i=this._items,s=this.itemType;let n,a;if(!this._notifications&&this.hasEventListener("change")&&(this._notifications=[{listeners:this._chgListeners.slice(),items:this._items.slice(),changes:[]}],this._timer&&this._timer.remove(),this._timer=(0,c.Os)((()=>this._dispatchChange()))),t){if(a=i.splice(e,t),this.hasEventListener("before-remove")){const t=b.acquire();t.target=this,t.cancellable=!0;for(let r=0,s=a.length;r<s;r++)n=a[r],t.reset(n),this.emit("before-remove",t),t.defaultPrevented&&(a.splice(r,1),i.splice(e,0,n),e+=1,r-=1,s-=1);b.release(t)}if(this.length=this._items.length,this.hasEventListener("after-remove")){const e=b.acquire();e.target=this,e.cancellable=!1;const t=a.length;for(let r=0;r<t;r++)e.reset(a[r]),this.emit("after-remove",e);b.release(e)}}if(r&&r.length){if(s){const e=[];for(const t of r){const r=s.ensureType(t);null==r&&null!=t||e.push(r)}r=e}const t=this.hasEventListener("before-add"),n=this.hasEventListener("after-add"),a=e===this.length;if(t||n){const s=b.acquire();s.target=this,s.cancellable=!0;const l=b.acquire();l.target=this,l.cancellable=!1;for(const o of r)t?(s.reset(o),this.emit("before-add",s),s.defaultPrevented||(a?i.push(o):i.splice(e++,0,o),this._set("length",i.length),n&&(l.reset(o),this.emit("after-add",l)))):(a?i.push(o):i.splice(e++,0,o),this._set("length",i.length),l.reset(o),this.emit("after-add",l));b.release(l),b.release(s)}else{if(a)for(const e of r)i.push(e);else i.splice(e,0,...r);this._set("length",i.length)}}return(r&&r.length||a&&a.length)&&this._notifyChangeEvent(r,a),a}_emitBeforeChanges(e){let t=!1;if(this.hasEventListener("before-changes")){const r=b.acquire();r.target=this,r.cancellable=!0,r.type=e,this.emit("before-changes",r),t=r.defaultPrevented,b.release(r)}return t}_emitAfterChanges(e){if(this.hasEventListener("after-changes")){const t=b.acquire();t.target=this,t.cancellable=!1,t.type=e,this.emit("after-changes",t),b.release(t)}this._observable.notify()}_notifyChangeEvent(e,t){this.hasEventListener("change")&&this._notifications&&this._notifications[this._notifications.length-1].changes.push({added:e,removed:t})}_dispatchChange(){if(this._timer&&(this._timer.remove(),this._timer=null),!this._notifications)return;const e=this._notifications;this._notifications=null;for(const t of e){const e=t.changes;C.clear(),D.clear(),x.clear();for(const{added:t,removed:r}of e){if(t)if(0===x.size&&0===D.size)for(const e of t)C.add(e);else for(const e of t)D.has(e)?(x.add(e),D.delete(e)):x.has(e)||C.add(e);if(r)if(0===x.size&&0===C.size)for(const e of r)D.add(e);else for(const e of r)C.has(e)?C.delete(e):(x.delete(e),D.add(e))}const r=n.Z.acquire();C.forEach((e=>{r.push(e)}));const i=n.Z.acquire();D.forEach((e=>{i.push(e)}));const s=this._items,a=t.items,l=n.Z.acquire();if(x.forEach((e=>{a.indexOf(e)!==s.indexOf(e)&&l.push(e)})),t.listeners&&(r.length||i.length||l.length)){const e={target:this,added:r,removed:i,moved:l},s=t.listeners.length;for(let r=0;r<s;r++){const i=t.listeners[r];i.removed||i.callback.call(this,e)}}n.Z.release(r),n.Z.release(i),n.Z.release(l)}C.clear(),D.clear(),x.clear()}};A.ofType=e=>{if(!e)return h;if(R.has(e))return R.get(e);let t=null;if("function"==typeof e)t=e.prototype.declaredClass;else if(e.base)t=e.base.prototype.declaredClass;else for(const r in e.typeMap){const i=e.typeMap[r].prototype.declaredClass;t?t+=` | ${i}`:t=i}let r=class extends h{};return(0,s._)([(0,p.c)({Type:e,ensureType:"function"==typeof e?(0,f.se)(e):(0,f.N7)(e)})],r.prototype,"itemType",void 0),r=(0,s._)([(0,_.j)(`esri.core.Collection<${t}>`)],r),R.set(e,r),r},(0,s._)([(0,d.Cb)()],A.prototype,"length",void 0),(0,s._)([(0,d.Cb)()],A.prototype,"items",null),A=h=(0,s._)([(0,_.j)("esri.core.Collection")],A);const k=A},32448:(e,t,r)=>{r.d(t,{Z:()=>o});var i=r(43697),s=r(15923),n=r(50758),a=r(52011);class l{constructor(){this._emitter=new l.EventEmitter(this)}emit(e,t){return this._emitter.emit(e,t)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}hasEventListener(e){return this._emitter.hasEventListener(e)}}!function(e){class t{constructor(e=null){this.target=e,this._listenersMap=null}clear(){this._listenersMap&&this._listenersMap.clear(),this._listenersMap=null}emit(e,t){const r=this._listenersMap&&this._listenersMap.get(e);if(!r)return!1;const i=this.target||this;return[...r].forEach((e=>{e.call(i,t)})),r.length>0}on(e,t){if(Array.isArray(e)){const r=e.map((e=>this.on(e,t)));return(0,n.AL)(r)}if(e.includes(","))throw new TypeError("Evented.on() with a comma delimited string of event types is not supported");this._listenersMap||(this._listenersMap=new Map);const r=this._listenersMap.get(e)||[];return r.push(t),this._listenersMap.set(e,r),{remove:()=>{const r=this._listenersMap&&this._listenersMap.get(e)||[],i=r.indexOf(t);i>=0&&r.splice(i,1)}}}once(e,t){const r=this.on(e,(e=>{r.remove(),t.call(null,e)}));return r}hasEventListener(e){const t=this._listenersMap&&this._listenersMap.get(e);return null!=t&&t.length>0}}e.EventEmitter=t,e.EventedMixin=e=>{let r=class extends e{constructor(){super(...arguments),this._emitter=new t}destroy(){this._emitter.clear()}emit(e,t){return this._emitter.emit(e,t)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}hasEventListener(e){return this._emitter.hasEventListener(e)}};return r=(0,i._)([(0,a.j)("esri.core.Evented")],r),r};let r=class extends s.Z{constructor(){super(...arguments),this._emitter=new l.EventEmitter(this)}destroy(){this._emitter.clear()}emit(e,t){return this._emitter.emit(e,t)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}hasEventListener(e){return this._emitter.hasEventListener(e)}};r=(0,i._)([(0,a.j)("esri.core.Evented")],r),e.EventedAccessor=r}(l||(l={}));const o=l},61247:(e,t,r)=>{r.d(t,{Z:()=>h});var i=r(43697),s=r(15923),n=r(80539),a=r(70586),l=r(5600),o=r(52011);let u=class extends s.Z{constructor(e){super(e),this._groups=new Map}destroy(){this.removeAll()}get size(){let e=0;return this._groups.forEach((t=>{e+=t.length})),e}add(e,t){if(!this._isHandle(e)&&!Array.isArray(e)&&!n.Z.isCollection(e))return this;const r=this._getOrCreateGroup(t);return Array.isArray(e)||n.Z.isCollection(e)?e.forEach((e=>this._isHandle(e)&&r.push(e))):r.push(e),this.notifyChange("size"),this}forEach(e,t){if("function"==typeof e)this._groups.forEach((t=>t.forEach(e)));else{const r=this._getGroup(e);r&&t&&r.forEach(t)}}has(e){return this._groups.has(this._ensureGroupKey(e))}remove(e){if(Array.isArray(e)||n.Z.isCollection(e))return e.forEach(this.remove,this),this;if(!this.has(e))return this;const t=this._getGroup(e);for(let e=0;e<t.length;e++)t[e].remove();return this._deleteGroup(e),this.notifyChange("size"),this}removeAll(){return this._groups.forEach((e=>{for(let t=0;t<e.length;t++)e[t].remove()})),this._groups.clear(),this.notifyChange("size"),this}_isHandle(e){return e&&!!e.remove}_getOrCreateGroup(e){if(this.has(e))return this._getGroup(e);const t=[];return this._groups.set(this._ensureGroupKey(e),t),t}_getGroup(e){return(0,a.j0)(this._groups.get(this._ensureGroupKey(e)))}_deleteGroup(e){return this._groups.delete(this._ensureGroupKey(e))}_ensureGroupKey(e){return e||"_default_"}};(0,i._)([(0,l.Cb)({readOnly:!0})],u.prototype,"size",null),u=(0,i._)([(0,o.j)("esri.core.Handles")],u);const h=u},69801:(e,t,r)=>{r.d(t,{WJ:()=>o,Xq:()=>l});var i,s,n=r(70586),a=r(44553);(s=i||(i={}))[s.ALL=0]="ALL",s[s.SOME=1]="SOME";class l{constructor(e,t,r){this._namespace=e,this._storage=t,this._removeFunc=!1,this._hit=0,this._miss=0,this._storage.register(this),this._namespace+=":",r&&(this._storage.registerRemoveFunc(this._namespace,r),this._removeFunc=!0)}destroy(){this._storage.clear(this._namespace),this._removeFunc&&this._storage.deregisterRemoveFunc(this._namespace),this._storage.deregister(this),this._storage=null}get namespace(){return this._namespace.slice(0,-1)}get hitRate(){return this._hit/(this._hit+this._miss)}get size(){return this._storage.size}get maxSize(){return this._storage.maxSize}resetHitRate(){this._hit=this._miss=0}put(e,t,r,i=0){this._storage.put(this._namespace+e,t,r,i)}get(e){const t=this._storage.get(this._namespace+e);return void 0===t?++this._miss:++this._hit,t}pop(e){const t=this._storage.pop(this._namespace+e);return void 0===t?++this._miss:++this._hit,t}updateSize(e,t,r){this._storage.updateSize(this._namespace+e,t,r)}clear(){this._storage.clear(this._namespace)}clearAll(){this._storage.clearAll()}getStats(){return this._storage.getStats()}resetStats(){this._storage.resetStats()}}class o{constructor(e=10485760){this._maxSize=e,this._db=new Map,this._size=0,this._hit=0,this._miss=0,this._removeFuncs=new a.Z,this._users=new a.Z}destroy(){this.clearAll(),this._removeFuncs.clear(),this._users.clear(),this._db=null}register(e){this._users.push(e)}deregister(e){this._users.removeUnordered(e)}registerRemoveFunc(e,t){this._removeFuncs.push([e,t])}deregisterRemoveFunc(e){this._removeFuncs.filterInPlace((t=>t[0]!==e))}get size(){return this._size}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=Math.max(e,0),this._checkSizeLimit()}put(e,t,r,s){const n=this._db.get(e);if(n&&(this._size-=n.size,this._db.delete(e),n.entry!==t&&this._notifyRemove(e,n.entry,i.ALL)),r>this._maxSize)return void this._notifyRemove(e,t,i.ALL);if(void 0===t)return void console.warn("Refusing to cache undefined entry ");if(!r||r<0)return void console.warn("Refusing to cache entry with invalid size "+r);const a=1+Math.max(s,-3)- -3;this._db.set(e,{entry:t,size:r,lifetime:a,lives:a}),this._size+=r,this._checkSizeLimit()}updateSize(e,t,r){const s=this._db.get(e);if(s&&s.entry===t){for(this._size-=s.size;r>this._maxSize;){const s=this._notifyRemove(e,t,i.SOME);if(!((0,n.pC)(s)&&s>0))return void this._db.delete(e);r=s}s.size=r,this._size+=r,this._checkSizeLimit()}}pop(e){const t=this._db.get(e);if(t)return this._size-=t.size,this._db.delete(e),++this._hit,t.entry;++this._miss}get(e){const t=this._db.get(e);if(void 0!==t)return this._db.delete(e),t.lives=t.lifetime,this._db.set(e,t),++this._hit,t.entry;++this._miss}getStats(){const e={Size:Math.round(this._size/1048576)+"/"+Math.round(this._maxSize/1048576)+"MB","Hit rate":Math.round(100*this._getHitRate())+"%",Entries:this._db.size.toString()},t={},r=new Array;this._db.forEach(((e,i)=>{const s=e.lifetime;r[s]=(r[s]||0)+e.size,this._users.forAll((r=>{const s=r.namespace;if(i.startsWith(s)){const r=t[s]||0;t[s]=r+e.size}}))}));const i={};this._users.forAll((e=>{const r=e.namespace;if(!isNaN(e.hitRate)&&e.hitRate>0){const s=t[r]||0;t[r]=s,i[r]=Math.round(100*e.hitRate)+"%"}else i[r]="0%"}));const s=Object.keys(t);s.sort(((e,r)=>t[r]-t[e])),s.forEach((r=>e[r]=Math.round(t[r]/2**20)+"MB / "+i[r]));for(let t=r.length-1;t>=0;--t){const i=r[t];i&&(e["Priority "+(t+-3-1)]=Math.round(i/this.size*100)+"%")}return e}resetStats(){this._hit=this._miss=0,this._users.forAll((e=>e.resetHitRate()))}clear(e){this._db.forEach(((t,r)=>{r.startsWith(e)&&(this._size-=t.size,this._db.delete(r),this._notifyRemove(r,t.entry,i.ALL))}))}clearAll(){this._db.forEach(((e,t)=>this._notifyRemove(t,e.entry,i.ALL))),this._size=0,this._db.clear()}_getHitRate(){return this._hit/(this._hit+this._miss)}_notifyRemove(e,t,r){let i;return this._removeFuncs.some((s=>{if(e.startsWith(s[0])){const e=s[1](t,r);return"number"==typeof e&&(i=e),!0}return!1})),i}_checkSizeLimit(){if(!(this._size<=this._maxSize))for(const[e,t]of this._db){if(this._db.delete(e),t.lives<=1){this._size-=t.size;const r=this._notifyRemove(e,t.entry,i.SOME);(0,n.pC)(r)&&r>0&&(this._size+=r,t.lives=t.lifetime,t.size=r,this._db.set(e,t))}else--t.lives,this._db.set(e,t);if(this._size<=.9*this.maxSize)return}}}},52421:(e,t,r)=>{function i(e){return(t,r)=>{t[r]=e}}r.d(t,{c:()=>i})},22862:(e,t,r)=>{r.d(t,{Hg:()=>_,V7:()=>p,uD:()=>f});var i=r(15923),s=r(80539),n=r(70586),a=r(1153);const l=["esri.Color","esri.portal.Portal","esri.symbols.support.Symbol3DAnchorPosition2D","esri.symbols.support.Symbol3DAnchorPosition3D"];function o(e){return e instanceof i.Z}function u(e){return e instanceof s.Z?Object.keys(e.items):o(e)?(0,a.vw)(e).keys():e?Object.keys(e):[]}function h(e,t){return e instanceof s.Z?e.items[t]:e[t]}function c(e){return e?e.declaredClass:null}function d(e,t){const r=e.diff;if(r&&"function"==typeof r)return r(e,t);const i=u(e),s=u(t);if(0===i.length&&0===s.length)return;if(!i.length||!s.length||function(e,t){return!(!Array.isArray(e)||!Array.isArray(t))&&e.length!==t.length}(e,t))return{type:"complete",oldValue:e,newValue:t};const a=s.filter((e=>!i.includes(e))),f=i.filter((e=>!s.includes(e))),p=i.filter((r=>s.includes(r)&&h(e,r)!==h(t,r))).concat(a,f).sort(),_=c(e);if(_&&l.includes(_)&&p.length)return{type:"complete",oldValue:e,newValue:t};let y;const g=o(e)&&o(t);for(const i of p){const s=h(e,i),a=h(t,i);let l;(g||"function"!=typeof s&&"function"!=typeof a)&&s!==a&&(null==s&&null==a||(l=r&&r[i]&&"function"==typeof r[i]?r[i](s,a):"object"==typeof s&&"object"==typeof a&&c(s)===c(a)?d(s,a):{type:"complete",oldValue:s,newValue:a},(0,n.pC)(l)&&((0,n.pC)(y)?y.diff[i]=l:y={type:"partial",diff:{[i]:l}})))}return y}function f(e,t){if((0,n.Wi)(e))return!1;const r=t.split(".");let i=e;for(const e of r){if("complete"===i.type)return!0;if("partial"!==i.type)return!1;{const t=i.diff[e];if(!t)return!1;i=t}}return!0}function p(e,t){for(const r of t)if(f(e,r))return!0;return!1}function _(e,t){if(!("function"==typeof e||"function"==typeof t||(0,n.Wi)(e)&&(0,n.Wi)(t)))return(0,n.Wi)(e)||(0,n.Wi)(t)||"object"==typeof e&&"object"==typeof t&&c(e)!==c(t)?{type:"complete",oldValue:e,newValue:t}:d(e,t)}},66643:(e,t,r)=>{r.d(t,{Ed:()=>n,UI:()=>a,mt:()=>o,q6:()=>l});var i=r(70586),s=r(95330);function n(e,t,r){return(0,s.as)(e.map(((e,i)=>t.apply(r,[e,i]))))}async function a(e,t,r){return(await(0,s.as)(e.map(((e,i)=>t.apply(r,[e,i]))))).map((e=>e.value))}async function l(e){if((0,i.Wi)(e))return{ok:!1,error:new Error("no promise provided")};try{return{ok:!0,value:await e}}catch(e){return{ok:!1,error:e}}}async function o(e){try{return{ok:!0,value:await e}}catch(e){return(0,s.r9)(e),{ok:!1,error:e}}}},17445:(e,t,r)=>{r.d(t,{N1:()=>d,YP:()=>o,Z_:()=>_,gx:()=>u,nn:()=>y,on:()=>c,tX:()=>g});var i=r(91460),s=r(50758),n=r(70586),a=r(95330),l=r(26258);function o(e,t,r={}){return h(e,t,r,f)}function u(e,t,r={}){return h(e,t,r,p)}function h(e,t,r={},i){let s=null;const a=r.once?(e,r)=>{i(e)&&((0,n.hw)(s),t(e,r))}:(e,r)=>{i(e)&&t(e,r)};if(s=(0,l.aQ)(e,a,r.sync,r.equals),r.initial){const t=e();a(t,t)}return s}function c(e,t,r,a={}){let l=null,u=null,h=null;function c(){l&&u&&(u.remove(),null==a.onListenerRemove||a.onListenerRemove(l),l=null,u=null)}function d(e){a.once&&a.once&&(0,n.hw)(h),r(e)}const f=o(e,((e,r)=>{c(),(0,i.vT)(e)&&(l=e,u=(0,i.on)(e,t,d),null==a.onListenerAdd||a.onListenerAdd(e))}),{sync:a.sync,initial:!0});return h=(0,s.kB)((()=>{f.remove(),c()})),h}function d(e,t){return function(e,t,r){if((0,a.Hc)(r))return Promise.reject((0,a.zE)());const i=e();if(null!=t&&t(i))return Promise.resolve(i);let l=null;function o(){l=(0,n.hw)(l)}return new Promise(((i,n)=>{l=(0,s.AL)([(0,a.fu)(r,(()=>{o(),n((0,a.zE)())})),h(e,(e=>{o(),i(e)}),{sync:!1,once:!0},null!=t?t:f)])}))}(e,p,t)}function f(e){return!0}function p(e){return!!e}r(87538);const _={sync:!0},y={initial:!0},g={sync:!0,initial:!0}},42033:(e,t,r)=>{r.d(t,{E:()=>s,_:()=>n});var i=r(70586);async function s(e,t){const{WhereClause:i}=await Promise.resolve().then(r.bind(r,41534));return i.create(e,t)}function n(e,t){return(0,i.pC)(e)?(0,i.pC)(t)?`(${e}) AND (${t})`:e:t}},60437:(e,t,r)=>{r.d(t,{Gv:()=>y,JR:()=>f,TC:()=>a,Tn:()=>h,Ue:()=>s,al:()=>n,cS:()=>d,dp:()=>o,fS:()=>_,op:()=>u,pp:()=>l,t8:()=>c});var i=r(70586);function s(e=g){return[e[0],e[1],e[2],e[3],e[4],e[5]]}function n(e,t,r,i,n,a,l=s()){return l[0]=e,l[1]=t,l[2]=r,l[3]=i,l[4]=n,l[5]=a,l}function a(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[3]),e[4]=Math.max(e[4],t[4]),e[5]=Math.max(e[5],t[5])}function l(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[0]),e[4]=Math.max(e[4],t[1]),e[5]=Math.max(e[5],t[2])}function o(e,t=[0,0,0]){return t[0]=function(e){return e[0]>=e[3]?0:e[3]-e[0]}(e),t[1]=function(e){return e[1]>=e[4]?0:e[4]-e[1]}(e),t[2]=function(e){return e[2]>=e[5]?0:e[5]-e[2]}(e),t}function u(e,t,r=e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r!==e&&(r[3]=e[3],r[4]=e[4],r[5]=e[5]),r}function h(e,t,r=e){return r[3]=t[0],r[4]=t[1],r[5]=t[2],r!==e&&(r[0]=e[0],r[1]=e[1],r[2]=e[2]),e}function c(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function d(e){return e?c(e,y):s(y)}function f(e,t){return e[0]=t[0],e[1]=t[1],e[2]=Number.NEGATIVE_INFINITY,e[3]=t[2],e[4]=t[3],e[5]=Number.POSITIVE_INFINITY,e}function p(e){return 6===e.length}function _(e,t,r){if((0,i.Wi)(e)||(0,i.Wi)(t))return e===t;if(!p(e)||!p(t))return!1;if(r){for(let i=0;i<e.length;i++)if(!r(e[i],t[i]))return!1}else for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}r(6570),r(24470);const y=[1/0,1/0,1/0,-1/0,-1/0,-1/0],g=[0,0,0,0,0,0];s()},24470:(e,t,r)=>{r.d(t,{Gv:()=>f,HH:()=>o,SO:()=>u,Ue:()=>n,al:()=>a,jE:()=>h,kK:()=>c,oJ:()=>l,r3:()=>d}),r(80442),r(22021);var i=r(70586),s=r(6570);function n(e=p){return[e[0],e[1],e[2],e[3]]}function a(e,t,r,i,s=n()){return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function l(e,t=n()){return t[0]=e.xmin,t[1]=e.ymin,t[2]=e.xmax,t[3]=e.ymax,t}function o(e,t){return new s.Z({xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:t})}function u(e){return function(e){return(0,i.Wi)(e)||e[0]>=e[2]?0:e[2]-e[0]}(e)*function(e){return e[1]>=e[3]?0:e[3]-e[1]}(e)}function h(e,t,r){return t>=e[0]&&r>=e[1]&&t<=e[2]&&r<=e[3]}function c(e,t){return Math.max(t[0],e[0])<=Math.min(t[2],e[2])&&Math.max(t[1],e[1])<=Math.min(t[3],e[3])}function d(e,t){return t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3]}const f=[1/0,1/0,-1/0,-1/0],p=[0,0,0,0]},82526:(e,t,r)=>{r.d(t,{aX:()=>D});var i=r(68773),s=r(20102),n=r(92604),a=r(70586),l=r(38913),o=r(58901),u=r(82971),h=r(33955);const c={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new o.Z({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:u.Z.WebMercator}),minus180Line:new o.Z({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:u.Z.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new o.Z({paths:[[[180,-180],[180,180]]],spatialReference:u.Z.WGS84}),minus180Line:new o.Z({paths:[[[-180,-180],[-180,180]]],spatialReference:u.Z.WGS84})}};function d(e,t){return Math.ceil((e-t)/(2*t))}function f(e,t){const r=p(e);for(const e of r)for(const r of e)r[0]+=t;return e}function p(e){return(0,h.oU)(e)?e.rings:e.paths}var _=r(8744),y=r(40488),g=(r(66577),r(3172)),m=r(17452);function b(e){return{geometryType:(0,h.Ji)(e[0]),geometries:e.map((e=>e.toJSON()))}}const S=n.Z.getLogger("esri.geometry.support.normalizeUtils");function w(e){return"polygon"===e[0].type}function v(e){return"polyline"===e[0].type}function F(e,t,r){if(t){const t=function(e,t){if(!(e instanceof o.Z||e instanceof l.Z)){const e="straightLineDensify: the input geometry is neither polyline nor polygon";throw S.error(e),new s.Z(e)}const r=p(e),i=[];for(const e of r){const r=[];i.push(r),r.push([e[0][0],e[0][1]]);for(let i=0;i<e.length-1;i++){const s=e[i][0],n=e[i][1],a=e[i+1][0],l=e[i+1][1],o=Math.sqrt((a-s)*(a-s)+(l-n)*(l-n)),u=(l-n)/o,h=(a-s)/o,c=o/t;if(c>1){for(let e=1;e<=c-1;e++){const i=e*t,a=h*i+s,l=u*i+n;r.push([a,l])}const e=(o+Math.floor(c-1)*t)/2,i=h*e+s,a=u*e+n;r.push([i,a])}r.push([a,l])}}return function(e){return"polygon"===e.type}(e)?new l.Z({rings:i,spatialReference:e.spatialReference}):new o.Z({paths:i,spatialReference:e.spatialReference})}(e,1e6);e=(0,y.Sx)(t,!0)}return r&&(e=f(e,r)),e}function I(e,t,r){if(Array.isArray(e)){const i=e[0];if(i>t){const r=d(i,t);e[0]=i+r*(-2*t)}else if(i<r){const t=d(i,r);e[0]=i+t*(-2*r)}}else{const i=e.x;if(i>t){const r=d(i,t);e=e.clone().offset(r*(-2*t),0)}else if(i<r){const t=d(i,r);e=e.clone().offset(t*(-2*r),0)}}return e}function C(e,t){let r=-1;for(let i=0;i<t.cutIndexes.length;i++){const s=t.cutIndexes[i],n=t.geometries[i],a=p(n);for(let e=0;e<a.length;e++){const t=a[e];t.some((r=>{if(r[0]<180)return!0;{let r=0;for(let e=0;e<t.length;e++){const i=t[e][0];r=i>r?i:r}r=Number(r.toFixed(9));const i=-360*d(r,180);for(let r=0;r<t.length;r++){const t=n.getPoint(e,r);n.setPoint(e,r,t.clone().offset(i,0))}return!0}}))}if(s===r){if(w(e))for(const t of p(n))e[s]=e[s].addRing(t);else if(v(e))for(const t of p(n))e[s]=e[s].addPath(t)}else r=s,e[s]=n}return e}async function D(e,t,r){var s;if(!Array.isArray(e))return D([e],t);t&&"string"!=typeof t&&S.warn("normalizeCentralMeridian()","The url object is deprecated, use the url string instead");const n="string"==typeof t?t:null!=(s=null==t?void 0:t.url)?s:i.Z.geometryServiceUrl;let u,p,w,v,x,R,E,A,k=0;const T=[],N=[];for(const t of e)if((0,a.Wi)(t))N.push(t);else if(u||(u=t.spatialReference,p=(0,_.C5)(u),w=u.isWebMercator,R=w?102100:4326,v=c[R].maxX,x=c[R].minX,E=c[R].plus180Line,A=c[R].minus180Line),p)if("mesh"===t.type)N.push(t);else if("point"===t.type)N.push(I(t.clone(),v,x));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map((e=>I(e,v,x))),N.push(e)}else if("extent"===t.type){const e=t.clone()._normalize(!1,!1,p);N.push(e.rings?new l.Z(e):e)}else if(t.extent){const e=t.extent,r=d(e.xmin,x)*(2*v);let i=0===r?t.clone():f(t.clone(),r);e.offset(r,0),e.intersects(E)&&e.xmax!==v?(k=e.xmax>k?e.xmax:k,i=F(i,w),T.push(i),N.push("cut")):e.intersects(A)&&e.xmin!==x?(k=e.xmax*(2*v)>k?e.xmax*(2*v):k,i=F(i,w,360),T.push(i),N.push("cut")):N.push(i)}else N.push(t.clone());else N.push(t);let L=d(k,v),P=-90;const O=L,B=new o.Z;for(;L>0;){const e=360*L-180;B.addPath([[e,P],[e,-1*P]]),P*=-1,L--}if(T.length>0&&O>0){const t=C(T,await async function(e,t,r,i){const s="string"==typeof e?(0,m.mN)(e):e,n=t[0].spatialReference,a={...i,query:{...s.query,f:"json",sr:JSON.stringify(n),target:JSON.stringify({geometryType:(0,h.Ji)(t[0]),geometries:t}),cutter:JSON.stringify(r)}},l=await(0,g.default)(s.path+"/cut",a),{cutIndexes:o,geometries:u=[]}=l.data;return{cutIndexes:o,geometries:u.map((e=>{const t=(0,h.im)(e);return t.spatialReference=n,t}))}}(n,T,B,r)),i=[],s=[];for(let r=0;r<N.length;r++){const n=N[r];if("cut"!==n)s.push(n);else{const n=t.shift(),l=e[r];(0,a.pC)(l)&&"polygon"===l.type&&l.rings&&l.rings.length>1&&n.rings.length>=l.rings.length?(i.push(n),s.push("simplify")):s.push(w?(0,y.$)(n):n)}}if(!i.length)return s;const l=await async function(e,t,r){const i="string"==typeof e?(0,m.mN)(e):e,s=t[0].spatialReference,n=(0,h.Ji)(t[0]),a={...r,query:{...i.query,f:"json",sr:s.wkid?s.wkid:JSON.stringify(s),geometries:JSON.stringify(b(t))}};return function(e,t,r){const i=(0,h.q9)(t);return e.map((e=>{const t=i.fromJSON(e);return t.spatialReference=r,t}))}((await(0,g.default)(i.path+"/simplify",a)).data,n,s)}(n,i,r),o=[];for(let e=0;e<s.length;e++){const t=s[e];"simplify"!==t?o.push(t):o.push(w?(0,y.$)(l.shift()):l.shift())}return o}const j=[];for(let e=0;e<N.length;e++){const t=N[e];if("cut"!==t)j.push(t);else{const e=T.shift();j.push(!0===w?(0,y.$)(e):e)}}return j}},69285:(e,t,r)=>{r.d(t,{k:()=>a});var i=r(70586),s=r(67900),n=r(8744);function a(e,t,r){if((0,i.Wi)(t)||(0,i.Wi)(r)||r.vcsWkid||(0,n.fS)(t,r))return null;const a=(0,s._R)(t)/(0,s._R)(r);if(1===a)return null;switch(e){case"point":case"esriGeometryPoint":return e=>function(e,t){e&&null!=e.z&&(e.z*=t)}(e,a);case"polyline":case"esriGeometryPolyline":return e=>function(e,t){if(e)for(const r of e.paths)for(const e of r)e.length>2&&(e[2]*=t)}(e,a);case"polygon":case"esriGeometryPolygon":return e=>function(e,t){if(e)for(const r of e.rings)for(const e of r)e.length>2&&(e[2]*=t)}(e,a);case"multipoint":case"esriGeometryMultipoint":return e=>function(e,t){if(e)for(const r of e.points)r.length>2&&(r[2]*=t)}(e,a);case"extent":case"esriGeometryExtent":return e=>function(e,t){e&&null!=e.zmin&&null!=e.zmax&&(e.zmin*=t,e.zmax*=t)}(e,a);default:return null}}},54295:(e,t,r)=>{r.d(t,{V:()=>a});var i=r(43697),s=r(5600),n=(r(67676),r(80442),r(75215),r(52011));const a=e=>{let t=class extends e{get apiKey(){var e;return this._isOverridden("apiKey")?this._get("apiKey"):function(e){return"portalItem"in e}(this)?null==(e=this.portalItem)?void 0:e.apiKey:null}set apiKey(e){null!=e?this._override("apiKey",e):(this._clearOverride("apiKey"),this.clear("apiKey","user"))}};return(0,i._)([(0,s.Cb)({type:String})],t.prototype,"apiKey",null),t=(0,i._)([(0,n.j)("esri.layers.mixins.APIKeyMixin")],t),t}},17287:(e,t,r)=>{r.d(t,{Y:()=>u});var i=r(43697),s=r(92604),n=r(70586),a=r(5600),l=(r(67676),r(80442),r(75215),r(52011)),o=r(66677);const u=e=>{let t=class extends e{get title(){if(this._get("title")&&"defaults"!==this.originOf("title"))return this._get("title");if(this.url){const e=(0,o.Qc)(this.url);if((0,n.pC)(e)&&e.title)return e.title}return this._get("title")||""}set title(e){this._set("title",e)}set url(e){this._set("url",(0,o.Nm)(e,s.Z.getLogger(this.declaredClass)))}};return(0,i._)([(0,a.Cb)()],t.prototype,"title",null),(0,i._)([(0,a.Cb)({type:String})],t.prototype,"url",null),t=(0,i._)([(0,l.j)("esri.layers.mixins.ArcGISService")],t),t}},16859:(e,t,r)=>{r.d(t,{I:()=>S});var i=r(43697),s=r(40330),n=r(3172),a=r(66643),l=r(20102),o=r(92604),u=r(70586),h=r(95330),c=r(17452),d=r(5600),f=(r(67676),r(80442),r(75215),r(71715)),p=r(52011),_=r(30556),y=r(65587),g=r(15235),m=r(86082);const b=o.Z.getLogger("esri.layers.mixins.PortalLayer"),S=e=>{let t=class extends e{constructor(){super(...arguments),this.resourceReferences={portalItem:null,paths:[]},this.userHasEditingPrivileges=!0}destroy(){var e;null==(e=this.portalItem)||e.destroy(),this.portalItem=null}set portalItem(e){e!==this._get("portalItem")&&(this.removeOrigin("portal-item"),this._set("portalItem",e))}readPortalItem(e,t,r){if(t.itemId)return new g.default({id:t.itemId,portal:r&&r.portal})}writePortalItem(e,t){e&&e.id&&(t.itemId=e.id)}async loadFromPortal(e,t){if(this.portalItem&&this.portalItem.id)try{const i=await r.e(8062).then(r.bind(r,18062));return(0,h.k_)(t),await i.load({instance:this,supportedTypes:e.supportedTypes,validateItem:e.validateItem,supportsData:e.supportsData},t)}catch(e){throw(0,h.D_)(e)||b.warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${e}`),e}}async finishLoadEditablePortalLayer(e){this._set("userHasEditingPrivileges",await this._fetchUserHasEditingPrivileges(e).catch((e=>((0,h.r9)(e),!0))))}async _fetchUserHasEditingPrivileges(e){const t=this.url?null==s.id?void 0:s.id.findCredential(this.url):null;if(!t)return!0;const r=w.credential===t?w.user:await this._fetchEditingUser(e);return w.credential=t,w.user=r,(0,u.Wi)(r)||null==r.privileges||r.privileges.includes("features:user:edit")}async _fetchEditingUser(e){var t,r;const i=null==(t=this.portalItem)||null==(r=t.portal)?void 0:r.user;if(i)return i;const l=s.id.findServerInfo(this.url);if(null==l||!l.owningSystemUrl)return null;const o=`${l.owningSystemUrl}/sharing/rest`,h=y.Z.getDefault();if(h&&h.loaded&&(0,c.Fv)(h.restUrl)===(0,c.Fv)(o))return h.user;const d=`${o}/community/self`,f=(0,u.pC)(e)?e.signal:null,p=await(0,a.q6)((0,n.default)(d,{authMode:"no-prompt",query:{f:"json"},signal:f}));return p.ok?m.default.fromJSON(p.value.data):null}read(e,t){t&&(t.layer=this),super.read(e,t)}write(e,t){const r=t&&t.portal,i=this.portalItem&&this.portalItem.id&&(this.portalItem.portal||y.Z.getDefault());return r&&i&&!(0,c.tm)(i.restUrl,r.restUrl)?(t.messages&&t.messages.push(new l.Z("layer:cross-portal",`The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save the scene, set the layer.portalItem to null or save the scene to the same portal as the item associated with the layer`,{layer:this})),null):super.write(e,{...t,layer:this})}};return(0,i._)([(0,d.Cb)({type:g.default})],t.prototype,"portalItem",null),(0,i._)([(0,f.r)("web-document","portalItem",["itemId"])],t.prototype,"readPortalItem",null),(0,i._)([(0,_.c)("web-document","portalItem",{itemId:{type:String}})],t.prototype,"writePortalItem",null),(0,i._)([(0,d.Cb)({clonable:!1})],t.prototype,"resourceReferences",void 0),(0,i._)([(0,d.Cb)({readOnly:!0})],t.prototype,"userHasEditingPrivileges",void 0),t=(0,i._)([(0,p.j)("esri.layers.mixins.PortalLayer")],t),t},w={credential:null,user:null}},56765:(e,t,r)=>{r.d(t,{Z:()=>h});var i,s=r(43697),n=r(80539),a=r(96674),l=r(5600),o=(r(67676),r(80442),r(75215),r(52011));let u=i=class extends a.wq{constructor(e){super(e),this.floorField=null,this.viewAllMode=!1,this.viewAllLevelIds=new n.Z}clone(){return new i({floorField:this.floorField,viewAllMode:this.viewAllMode,viewAllLevelIds:this.viewAllLevelIds})}};(0,s._)([(0,l.Cb)({type:String,json:{write:!0}})],u.prototype,"floorField",void 0),(0,s._)([(0,l.Cb)({json:{read:!1,write:!1}})],u.prototype,"viewAllMode",void 0),(0,s._)([(0,l.Cb)({json:{read:!1,write:!1}})],u.prototype,"viewAllLevelIds",void 0),u=i=(0,s._)([(0,o.j)("esri.layers.support.LayerFloorInfo")],u);const h=u},66677:(e,t,r)=>{r.d(t,{B5:()=>c,DR:()=>f,G:()=>S,M8:()=>y,Nm:()=>g,Qc:()=>d,XG:()=>m,a7:()=>_,ld:()=>p,wH:()=>b});var i=r(70586),s=r(17452),n=r(25929);const a={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer"},l=Object.values(a),o=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${l.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),u=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^\\/\\n]+)\\/(${l.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),h=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function c(e){return!!o.test(e)}function d(e){const t=(0,s.mN)(e),r=t.path.match(o)||t.path.match(u);if(!r)return null;const[,i,n,l,h]=r,c=n.indexOf("/");return{title:p(-1!==c?n.slice(c+1):n),serverType:a[l.toLowerCase()],sublayer:null!=h&&""!==h?parseInt(h,10):null,url:{path:i}}}function f(e){const t=(0,s.mN)(e).path.match(h);return t?{serviceUrl:t[1],sublayerId:Number(t[2])}:null}function p(e){return(e=e.replace(/\s*[/_]+\s*/g," "))[0].toUpperCase()+e.slice(1)}function _(e,t){const r=[];if(e){const t=d(e);(0,i.pC)(t)&&t.title&&r.push(t.title)}if(t){const e=p(t);r.push(e)}if(2===r.length){if(r[0].toLowerCase().includes(r[1].toLowerCase()))return r[0];if(r[1].toLowerCase().includes(r[0].toLowerCase()))return r[1]}return r.join(" - ")}function y(e){if(!e)return!1;const t=(e=e.toLowerCase()).includes(".arcgis.com/"),r=e.includes("//services")||e.includes("//tiles")||e.includes("//features");return t&&r}function g(e,t){return e?(0,s.Qj)((0,s.Hu)(e,t)):e}function m(e){let{url:t}=e;if(!t)return{url:t};t=(0,s.Hu)(t,e.logger);const r=(0,s.mN)(t),n=d(r.path);let a;if((0,i.pC)(n))null!=n.sublayer&&null==e.layer.layerId&&(a=n.sublayer),t=n.url.path;else if(e.nonStandardUrlAllowed){const e=f(r.path);(0,i.pC)(e)&&(t=e.serviceUrl,a=e.sublayerId)}return{url:(0,s.Qj)(t),layerId:a}}function b(e,t,r,i,a){(0,n.w)(t,i,"url",a),i.url&&null!=e.layerId&&(i.url=(0,s.v_)(i.url,r,e.layerId.toString()))}function S(e){if(!e)return!1;const t=e.toLowerCase(),r=t.includes("/services/"),i=t.includes("/mapserver/wmsserver"),s=t.includes("/imageserver/wmsserver"),n=t.includes("/wmsserver");return r&&(i||s||n)}},41818:(e,t,r)=>{r.d(t,{P:()=>a});var i=r(11282),s=r(34599),n=r(57444);async function a(e,t,r){const a=(0,i.en)(e);return(0,s.executeQueryForCount)(a,n.Z.from(t),{...r}).then((e=>e.data.count))}},5396:(e,t,r)=>{r.d(t,{G:()=>a});var i=r(11282),s=r(34599),n=r(57444);async function a(e,t,r){const a=(0,i.en)(e);return(0,s.executeQueryForIds)(a,n.Z.from(t),{...r}).then((e=>e.data.objectIds))}},4967:(e,t,r)=>{r.d(t,{F:()=>o,e:()=>l});var i=r(11282),s=r(34599),n=r(74889),a=r(57444);async function l(e,t,r){const i=await o(e,t,r);return n.default.fromJSON(i)}async function o(e,t,r){const n=(0,i.en)(e),l={...r},o=a.Z.from(t),{data:u}=await(0,s.executeQuery)(n,o,o.sourceSpatialReference,l);return u}},98326:(e,t,r)=>{r.d(t,{Z:()=>c});var i,s=r(43697),n=r(96674),a=r(5600),l=(r(67676),r(80442),r(75215)),o=r(52011);const u={1:{id:1,rotation:0,mirrored:!1},2:{id:2,rotation:0,mirrored:!0},3:{id:3,rotation:180,mirrored:!1},4:{id:4,rotation:180,mirrored:!0},5:{id:5,rotation:-90,mirrored:!0},6:{id:6,rotation:90,mirrored:!1},7:{id:7,rotation:90,mirrored:!0},8:{id:8,rotation:-90,mirrored:!1}};let h=i=class extends n.wq{constructor(e){super(e),this.contentType=null,this.exifInfo=null,this.id=null,this.globalId=null,this.keywords=null,this.name=null,this.parentGlobalId=null,this.parentObjectId=null,this.size=null,this.url=null}get orientationInfo(){const{exifInfo:e}=this,t=function(e){const{exifInfo:t,exifName:r,tagName:i}=e;if(!t||!r||!i)return null;const s=t.find((e=>e.name===r));return s?function(e){const{tagName:t,tags:r}=e;if(!r||!t)return null;const i=r.find((e=>e.name===t));return i&&i.value||null}({tagName:i,tags:s.tags}):null}({exifName:"Exif IFD0",tagName:"Orientation",exifInfo:e});return u[t]||null}clone(){return new i({contentType:this.contentType,exifInfo:this.exifInfo,id:this.id,globalId:this.globalId,keywords:this.keywords,name:this.name,parentGlobalId:this.parentGlobalId,parentObjectId:this.parentObjectId,size:this.size,url:this.url})}};(0,s._)([(0,a.Cb)({type:String})],h.prototype,"contentType",void 0),(0,s._)([(0,a.Cb)()],h.prototype,"exifInfo",void 0),(0,s._)([(0,a.Cb)({readOnly:!0})],h.prototype,"orientationInfo",null),(0,s._)([(0,a.Cb)({type:l.z8})],h.prototype,"id",void 0),(0,s._)([(0,a.Cb)({type:String})],h.prototype,"globalId",void 0),(0,s._)([(0,a.Cb)({type:String})],h.prototype,"keywords",void 0),(0,s._)([(0,a.Cb)({type:String})],h.prototype,"name",void 0),(0,s._)([(0,a.Cb)({json:{read:!1}})],h.prototype,"parentGlobalId",void 0),(0,s._)([(0,a.Cb)({json:{read:!1}})],h.prototype,"parentObjectId",void 0),(0,s._)([(0,a.Cb)({type:l.z8})],h.prototype,"size",void 0),(0,s._)([(0,a.Cb)({json:{read:!1}})],h.prototype,"url",void 0),h=i=(0,s._)([(0,o.j)("esri.layers.support.AttachmentInfo")],h);const c=h},11282:(e,t,r)=>{r.d(t,{cv:()=>l,en:()=>a,lA:()=>n});var i=r(22974),s=r(17452);function n(e,t){return t?{...t,query:{...e,...t.query}}:{query:e}}function a(e){return"string"==typeof e?(0,s.mN)(e):(0,i.d9)(e)}function l(e,t,r){const i={};for(const s in e){if("declaredClass"===s)continue;const n=e[s];if(null!=n&&"function"!=typeof n)if(Array.isArray(n)){i[s]=[];for(let e=0;e<n.length;e++)i[s][e]=l(n[e])}else if("object"==typeof n)if(n.toJSON){const e=n.toJSON(r&&r[s]);i[s]=t?e:JSON.stringify(e)}else i[s]=t?n:JSON.stringify(n);else i[s]=n}return i}},58333:(e,t,r)=>{r.d(t,{ET:()=>n,I4:()=>s,eG:()=>o,lF:()=>a,lj:()=>h,qP:()=>l,wW:()=>u});const i=[252,146,31,255],s={type:"esriSMS",style:"esriSMSCircle",size:6,color:i,outline:{type:"esriSLS",style:"esriSLSSolid",width:.75,color:[153,153,153,255]}},n={type:"esriSLS",style:"esriSLSSolid",width:.75,color:i},a={type:"esriSFS",style:"esriSFSSolid",color:[252,146,31,196],outline:{type:"esriSLS",style:"esriSLSSolid",width:.75,color:[255,255,255,191]}},l={type:"esriTS",color:[255,255,255,255],font:{family:"arial-unicode-ms",size:10,weight:"bold"},horizontalAlignment:"center",kerning:!0,haloColor:[0,0,0,255],haloSize:1,rotated:!1,text:"",xoffset:0,yoffset:0,angle:0},o={type:"esriSMS",style:"esriSMSCircle",color:[0,0,0,255],outline:null,size:10.5},u={type:"esriSLS",style:"esriSLSSolid",color:[0,0,0,255],width:1.5},h={type:"esriSFS",style:"esriSFSSolid",color:[0,0,0,255],outline:null}}}]);
1
+ "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8875],{28924:(e,t,r)=>{r.d(t,{Z:()=>s});var i=r(95330);class s{constructor(){this.declaredRootClass="esri.arcade.featureSetCollection",this._layerById={},this._layerByName={}}add(e,t,r){this._layerById[t]=r,this._layerByName[e]=r}featureSetByName(e,t=!0,r=["*"]){return void 0===this._layerByName[e]?this.resolvePromise(null):this.resolvePromise(this._layerByName[e])}featureSetById(e,t=!0,r=["*"]){return void 0===this._layerById[e]?this.resolvePromise(null):this.resolvePromise(this._layerById[e])}castToText(){return"object, FeatureSetCollection"}resolvePromise(e){return(0,i.DB)(e)}}},42666:(e,t,r)=>{r.r(t),r.d(t,{constructAssociationMetaDataFeatureSetFromUrl:()=>ae,constructFeatureSet:()=>se,constructFeatureSetFromPortalItem:()=>_e,constructFeatureSetFromRelationship:()=>le,constructFeatureSetFromUrl:()=>ie,convertToFeatureSet:()=>pe,createFeatureSetCollectionFromMap:()=>he,createFeatureSetCollectionFromService:()=>ce,getPortal:()=>de,initialiseMetaDataCache:()=>te,lookupUser:()=>fe});var i=r(40330),s=r(3172),n=r(28924),a=r(84328),l=r(38171),o=r(61363),u=r(70409),h=r(85065),c=r(91136),d=r(90961),f=r(3823),p=r(90658),_=r(36515),y=r(95002),g=r(41534);class m{clone(){const e=new m;return e.field=this.field,e.tofieldname=this.tofieldname,e.typeofstat=this.typeofstat,e.workingexpr=this.workingexpr,e}static parseStatField(e,t,r){const i=new m;i.field=e;const s=g.WhereClause.create(t,r),n=function(e){if("function"===e.parseTree.type){if(0===e.parseTree.args.value.length)return{name:e.parseTree.name,expr:null};if(e.parseTree.args.value.length>1)throw new Error("Statistic does not have 1 or 0 Parameters");const t=g.WhereClause.create((0,_.XF)(e.parseTree.args.value[0],p.Bj.Standardised,e.parameters),e.fieldsIndex);return{name:e.parseTree.name,expr:t}}return null}(s);if(null===n)throw new Error("Invalid Statistic Function");const a=n.name.toUpperCase().trim();if("MIN"===a){if(i.typeofstat="MIN",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("MAX"===a){if(i.typeofstat="MAX",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("COUNT"===a)i.typeofstat="COUNT",i.workingexpr=n.expr;else if("STDEV"===a){if(i.typeofstat="STDDEV",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("SUM"===a){if(i.typeofstat="SUM",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("MEAN"===a){if(i.typeofstat="AVG",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("AVG"===a){if(i.typeofstat="AVG",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else{if("VAR"!==a)throw new Error("Invalid Statistic Function");if(i.typeofstat="VAR",i.workingexpr=n.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}return i}toStatisticsName(){switch(this.typeofstat.toUpperCase()){case"MIN":return"min";case"MAX":return"max";case"SUM":return"sum";case"COUNT":default:return"count";case"VAR":return"var";case"STDDEV":return"stddev";case"AVG":return"avg"}}}function b(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function S(e,t,r,i,s,n){return b(function(e,t){return e<<t|e>>>32-t}(b(b(t,e),b(i,n)),s),r)}function w(e,t,r,i,s,n,a){return S(t&r|~t&i,e,t,s,n,a)}function v(e,t,r,i,s,n,a){return S(t&i|r&~i,e,t,s,n,a)}function F(e,t,r,i,s,n,a){return S(t^r^i,e,t,s,n,a)}function I(e,t,r,i,s,n,a){return S(r^(t|~i),e,t,s,n,a)}function C(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;let r=1732584193,i=-271733879,s=-1732584194,n=271733878;for(let t=0;t<e.length;t+=16){const a=r,l=i,o=s,u=n;r=w(r,i,s,n,e[t+0],7,-680876936),n=w(n,r,i,s,e[t+1],12,-389564586),s=w(s,n,r,i,e[t+2],17,606105819),i=w(i,s,n,r,e[t+3],22,-1044525330),r=w(r,i,s,n,e[t+4],7,-176418897),n=w(n,r,i,s,e[t+5],12,1200080426),s=w(s,n,r,i,e[t+6],17,-1473231341),i=w(i,s,n,r,e[t+7],22,-45705983),r=w(r,i,s,n,e[t+8],7,1770035416),n=w(n,r,i,s,e[t+9],12,-1958414417),s=w(s,n,r,i,e[t+10],17,-42063),i=w(i,s,n,r,e[t+11],22,-1990404162),r=w(r,i,s,n,e[t+12],7,1804603682),n=w(n,r,i,s,e[t+13],12,-40341101),s=w(s,n,r,i,e[t+14],17,-1502002290),i=w(i,s,n,r,e[t+15],22,1236535329),r=v(r,i,s,n,e[t+1],5,-165796510),n=v(n,r,i,s,e[t+6],9,-1069501632),s=v(s,n,r,i,e[t+11],14,643717713),i=v(i,s,n,r,e[t+0],20,-373897302),r=v(r,i,s,n,e[t+5],5,-701558691),n=v(n,r,i,s,e[t+10],9,38016083),s=v(s,n,r,i,e[t+15],14,-660478335),i=v(i,s,n,r,e[t+4],20,-405537848),r=v(r,i,s,n,e[t+9],5,568446438),n=v(n,r,i,s,e[t+14],9,-1019803690),s=v(s,n,r,i,e[t+3],14,-187363961),i=v(i,s,n,r,e[t+8],20,1163531501),r=v(r,i,s,n,e[t+13],5,-1444681467),n=v(n,r,i,s,e[t+2],9,-51403784),s=v(s,n,r,i,e[t+7],14,1735328473),i=v(i,s,n,r,e[t+12],20,-1926607734),r=F(r,i,s,n,e[t+5],4,-378558),n=F(n,r,i,s,e[t+8],11,-2022574463),s=F(s,n,r,i,e[t+11],16,1839030562),i=F(i,s,n,r,e[t+14],23,-35309556),r=F(r,i,s,n,e[t+1],4,-1530992060),n=F(n,r,i,s,e[t+4],11,1272893353),s=F(s,n,r,i,e[t+7],16,-155497632),i=F(i,s,n,r,e[t+10],23,-1094730640),r=F(r,i,s,n,e[t+13],4,681279174),n=F(n,r,i,s,e[t+0],11,-358537222),s=F(s,n,r,i,e[t+3],16,-722521979),i=F(i,s,n,r,e[t+6],23,76029189),r=F(r,i,s,n,e[t+9],4,-640364487),n=F(n,r,i,s,e[t+12],11,-421815835),s=F(s,n,r,i,e[t+15],16,530742520),i=F(i,s,n,r,e[t+2],23,-995338651),r=I(r,i,s,n,e[t+0],6,-198630844),n=I(n,r,i,s,e[t+7],10,1126891415),s=I(s,n,r,i,e[t+14],15,-1416354905),i=I(i,s,n,r,e[t+5],21,-57434055),r=I(r,i,s,n,e[t+12],6,1700485571),n=I(n,r,i,s,e[t+3],10,-1894986606),s=I(s,n,r,i,e[t+10],15,-1051523),i=I(i,s,n,r,e[t+1],21,-2054922799),r=I(r,i,s,n,e[t+8],6,1873313359),n=I(n,r,i,s,e[t+15],10,-30611744),s=I(s,n,r,i,e[t+6],15,-1560198380),i=I(i,s,n,r,e[t+13],21,1309151649),r=I(r,i,s,n,e[t+4],6,-145523070),n=I(n,r,i,s,e[t+11],10,-1120210379),s=I(s,n,r,i,e[t+2],15,718787259),i=I(i,s,n,r,e[t+9],21,-343485551),r=b(r,a),i=b(i,l),s=b(s,o),n=b(n,u)}return[r,i,s,n]}function D(e,t=1){const r=t||0,i=C(function(e){const t=[];for(let r=0,i=8*e.length;r<i;r+=8)t[r>>5]|=(255&e.charCodeAt(r/8))<<r%32;return t}(e),8*e.length);switch(r){case 3:return i;case 1:return function(e){const t="0123456789abcdef",r=[];for(let i=0,s=4*e.length;i<s;i++)r.push(t.charAt(e[i>>2]>>i%4*8+4&15)+t.charAt(e[i>>2]>>i%4*8&15));return r.join("")}(i);case 2:return function(e){const t=[];for(let r=0,i=32*e.length;r<i;r+=8)t.push(String.fromCharCode(e[r>>5]>>>r%32&255));return t.join("")}(i);case 0:return function(e){const t=[];for(let r=0,i=4*e.length;r<i;r+=3){const i=(e[r>>2]>>r%4*8&255)<<16|(e[r+1>>2]>>(r+1)%4*8&255)<<8|e[r+2>>2]>>(r+2)%4*8&255;for(let s=0;s<4;s++)8*r+6*s>32*e.length?t.push("="):t.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i>>6*(3-s)&63))}return t.join("")}(i)}}var x=r(95330),R=r(82971),E=r(1231),A=r(99514);function k(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class T extends c.Z{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}_getSet(e){return null===this._wset?this._getFilteredSet("",null,null,null,e).then((e=>(this._wset=e,this._wset))):(0,x.DB)(this._wset)}_isInFeatureSet(){return p.dj.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,r=1;const i=this._parent?this._parent.getFieldsIndex():new A.Z([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e)for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}!1===e?t=!0:(this.objectIdField="ROW__ID"+r.toString(),r++)}for(const e of this._config.statsfields){const t=new m;t.field=e.name,t.tofieldname=e.name,t.workingexpr=e.expression instanceof g.WhereClause?e.expression:g.WhereClause.create(e.expression,i),t.typeofstat=k(e.statistic),this._decodedStatsfield.push(t)}this._decodedGroupbyfield=[];for(const e of this._config.groupbyfields){const t={name:e.name,singlefield:null,tofieldname:e.name,expression:e.expression instanceof g.WhereClause?e.expression:g.WhereClause.create(e.expression,i)};this._decodedGroupbyfield.push(t)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=p.Qk.point,this.typeIdField="",this.types=null,this.spatialReference=new R.Z({wkid:4326});this.fields=[];const s=new m;s.field=this._nextUniqueName(e),s.tofieldname=this.objectIdField,s.workingexpr=g.WhereClause.create(this._parent.objectIdField,this._parent.getFieldsIndex()),s.typeofstat="MIN",this._decodedStatsfield.push(s);for(const t of this._decodedGroupbyfield){const r=new E.Z;if(t.name=this._nextUniqueName(e),r.name=t.tofieldname,r.alias=r.name,(0,_.y5)(t.expression)){const e=this._parent.getField((0,_.zR)(t.expression,p.Bj.Standardised));if(!e)throw new Error("Field is not present for Aggregation");t.name=e.name,t.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),r.type=e.type}else{r.type=this._convertToEsriFieldType((0,_.DT)(t.expression,this._parent.fields));const e=new E.Z;e.name=t.name,e.alias=e.name,this.phsyicalgroupbyfields.push(t.name),this._adaptedFields.push(new u.yN(e,t.expression)),this._candosimplegroupby=!1}this.fields.push(r)}if(this._adaptedFields.length>0)for(const e of this._parent.fields)this._adaptedFields.push(new u.$X(e));for(let t=0;t<this._decodedStatsfield.length;t++){const r=new E.Z;let i=null;const s=this._decodedStatsfield[t];s.field=this._nextUniqueName(e),s.tofieldname===this.objectIdField&&(this._internalObjectIdField=s.field),r.name=s.tofieldname,r.alias=r.name;const n=null!==s.workingexpr&&(0,_.y5)(s.workingexpr)?(0,_.zR)(s.workingexpr,p.Bj.Standardised):"";switch(this._decodedStatsfield[t].typeofstat){case"SUM":if(""!==n){if(i=this._parent.getField(n),!i)throw new Error("Field is not present for Aggregation");r.type=i.type}else r.type="double";break;case"MIN":case"MAX":if(""!==n){if(i=this._parent.getField(n),!i)throw new Error("Field is not present for Aggregation");r.type=i.type}else r.type="double";break;case"COUNT":r.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==n&&(i=this._parent.getField(n),!i))throw new Error("Field is not present for Aggregation");r.type="double"}this.fields.push(r)}}_canDoAggregates(){return(0,x.DB)(!1)}_getFeatures(e,t,r,i){-1!==t&&this._featureCache[t];const s=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,s)?this._expandPagedSet(e,s,0,0,i).then((()=>this._getFeatures(e,t,r,i))):(0,x.DB)("success")}_getFilteredSet(e,t,r,i,s){if(""!==e)return(0,x.DB)(new d.Z([],[],!0,null));let n=null;const l={ordered:!1,nowhereclause:!1};return this._ensureLoaded().then((()=>{if(null!==r)for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===(0,_.hq)(r,this._decodedStatsfield[e].tofieldname)){l.nowhereclause=!0,r=null;break}if(null!==i){l.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===i.scanForField(this._decodedStatsfield[e].tofieldname)){i=null,l.ordered=!1;break}if(null!==i)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===i.scanForField(e.tofieldname)){i=null,l.ordered=!1;break}}return!1===this._candosimplegroupby?(0,x.DB)(!1):this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)})).then((e=>{if(e){let e=null;r&&(e=this._reformulateWhereClauseWithoutGroupByFields(r));let t=null;return i&&(t=this._reformulateOrderClauseWithoutGroupByFields(i)),this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField).then((e=>(this._checkCancelled(s),n=!0===l.nowhereclause?new d.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===l.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new d.Z(e._candidates.slice(0),e._known.slice(0),!0===l.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),n)))}let t=this._parent;if(this._adaptedFields.length>0&&(t=new u.Xx({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===l.nowhereclause)n=new d.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new h.Z({parentfeatureset:t,orderbyclause:new f.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=t;if(null!==r){let t=null;r&&(t=this._reformulateWhereClauseWithoutGroupByFields(r)),e=new a.Z({parentfeatureset:e,whereclause:t})}n=new d.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new h.Z({parentfeatureset:e,orderbyclause:new f.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return n}))}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=(0,_.bB)(e,t.tofieldname,(0,_.zR)(t.workingexpr,p.Bj.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=(0,_.bB)(e,t.tofieldname,(0,_.zR)(t.expression,p.Bj.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const e of this._decodedGroupbyfield)e.tofieldname!==e.name&&t.push({field:e.tofieldname,newfield:e.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}_refineSetBlock(e,t,r){try{return!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery)?this._expandPagedSet(e,this._maxQuery,0,0,r).then((()=>this._refineSetBlock(e,t,r))):(this._checkCancelled(r),e._candidates.length,this._refineKnowns(e,t),e._candidates.length,e._candidates.length,(0,x.DB)(e))}catch(e){return(0,x.d1)(e)}}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getPhysicalPage(e,t,r){return!0===e.pagesDefinition.aggregatefeaturesetpagedefinition?(0,x.Ue)(((t,i)=>{this._sequentialGetPhysicalItem(e,e.pagesDefinition.resultRecordCount,r,[]).then((e=>{t(e)}),i)})):this._getAgregagtePhysicalPage(e,t,r).then((e=>{for(const t of e){const e={geometry:t.geometry,attributes:{}};for(const r of this._decodedGroupbyfield)e.attributes[r.tofieldname]=t.attributes[r.name];for(const r of this._decodedStatsfield)e.attributes[r.tofieldname]=t.attributes[r.field];this._featureCache[e.attributes[this.objectIdField]]=new l.Z(e)}return e.length}))}_sequentialGetPhysicalItem(e,t,r,i){return(0,x.Ue)(((s,n)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(r)),!0===e.pagesDefinition.internal.fullyResolved||0===t?s(i.length):this._nextAggregateItem(e,t,r,i,(n=>{null===n?s(i.length):(t-=1,s(this._sequentialGetPhysicalItem(e,t,r,i)))}),n)}))}_nextAggregateItem(e,t,r,i,s,n){try{(0,o.X)(e.pagesDefinition.internal.iterator.next()).then((a=>{if(null===a)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);i.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,s(null)}else e.pagesDefinition.internal.fullyResolved=!0,s(null);else{const l=this._generateAggregateHash(a);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[a],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const r=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return i.push(r),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(r.attributes[this.objectIdField]),t-=1,e.pagesDefinition.internal.workingItem={features:[a],id:l},void s(r)}e.pagesDefinition.internal.workingItem.features.push(a)}this._nextAggregateItem(e,t,r,i,s,n)}}),n)}catch(e){n(e)}}_calculateFieldStat(e,t,r){const i=[];for(let r=0;r<e.features.length;r++)if(null!==t.workingexpr){const s=t.workingexpr.calculateValue(e.features[r]);null!==s&&i.push(s)}else i.push(null);switch(t.typeofstat){case"MIN":r.attributes[t.tofieldname]=(0,y.tj)("min",i,-1);break;case"MAX":r.attributes[t.tofieldname]=(0,y.tj)("max",i,-1);break;case"SUM":r.attributes[t.tofieldname]=(0,y.tj)("sum",i,-1);break;case"COUNT":r.attributes[t.tofieldname]=i.length;break;case"VAR":r.attributes[t.tofieldname]=(0,y.tj)("var",i,-1);break;case"STDDEV":r.attributes[t.tofieldname]=(0,y.tj)("stddev",i,-1);break;case"AVG":r.attributes[t.tofieldname]=(0,y.tj)("avg",i,-1)}return!0}_calculateAndAppendAggregateItem(e){const t={attributes:{},geometry:null};for(const r of this._decodedGroupbyfield){const i=r.singlefield?e.features[0].attributes[r.singlefield]:r.expression.calculateValue(e.features[0]);t.attributes[r.tofieldname]=i}for(const r of this._decodedStatsfield)this._calculateFieldStat(e,r,t);const r=[];for(let i=0;i<this._decodedStatsfield.length;i++)r.push(this._calculateFieldStat(e,this._decodedStatsfield[i],t));return this._featureCache[t.attributes[this.objectIdField]]=new l.Z({attributes:t.attributes,geometry:t.geometry}),t}_generateAggregateHash(e){let t="";for(const r of this._decodedGroupbyfield){const i=r.singlefield?e.attributes[r.singlefield]:r.expression.calculateValue(e);t+=null==i?":":":"+i.toString()}return D(t,2)}_stat(){return(0,x.DB)({calculated:!1})}getFeatureByObjectId(){return(0,x.DB)(null)}static registerAction(){c.Z._featuresetFunctions.groupby=function(e,t){return new T({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}var N=r(53073),L=r(63991),P=r(80692),O=r(33955),B=r(3121),j=r(98732),Z=(r(20102),r(80442),r(10158),r(4967)),q=(r(67676),r(17452),r(67900),r(8744),r(34599)),M=r(74889),G=r(57444),U=(r(98326),r(56545),r(41818)),W=(r(66577),r(5396)),z=r(75935),V=(r(82526),r(28141),r(78760)),Q=r(58539),J=r(33586);class K extends c.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return p.tI}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}convertQueryToLruCacheKey(e){return D((0,p.hd)(e.toJSON()),2)}load(){return null===this._loadPromise&&(this._loadPromise=(0,x.Ue)(((e,t)=>{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(e){t(e)}}),t),this._layer.load()}catch(e){t(e)}}))),this._loadPromise}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=p.Bj.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=p.Bj.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=p.Bj.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=p.Bj.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}_isInFeatureSet(){return p.dj.InFeatureSet}_refineSetBlock(e){return(0,x.DB)(e)}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):(0,x.DB)(this._wset)}_runDatabaseProbe(e){return(0,x.Ue)(((t,r)=>{try{this._ensureLoaded().then((()=>{try{const i=new G.Z;i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then((()=>{t(!0)}),(()=>{try{t(!1)}catch(e){r(e)}}))}catch(e){r(e)}}))}catch(e){r(e)}}))}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}pbfSupportedForQuery(e){return!e.outStatistics&&this._layer&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsFormatPBF&&!0===this._layer.capabilities.query.supportsQuantizationEditMode}queryPBF(e){return e.quantizationParameters={mode:"edit"},(0,q.executeQueryPBF)(this._layer.parsedUrl,e,new V.J({})).then((e=>M.default.fromJSON((0,j.cn)(e.data)).unquantize()))}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?this._layer.gdbVersion:"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title,source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}executeQuery(e,t){const r="execute"===t?Z.e:"executeForCount"===t?U.P:W.G,i="execute"===t&&this.pbfSupportedForQuery(e);let s=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);s=this.recentlyUsedQueries.getFromCache(t),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,s),s=s.catch((e=>{throw this.recentlyUsedQueries.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===s&&(s=!0!==i?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),s}_getFilteredSet(e,t,r,i,s){return this.databaseType().then((n=>{if(this.isTable()&&t&&null!==e&&""!==e)return new d.Z([],[],!0,null);if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,s);let a="",l=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=i.constructClause(),l=!0);const o=new G.Z;return o.where=null===r?null===t?"1=1":"":(0,_.zR)(r,n),this._requestStandardised&&(o.sqlFormat="standard"),o.spatialRelationship=this._makeRelationshipEnum(e),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==a?a.split(","):null,o.geometry=null===t?null:t,o.relationParameter=this._makeRelationshipParam(e),this.executeQuery(o,"executeForIds").then((e=>(null===e&&(e=[]),this._checkCancelled(s),new d.Z([],e,l,null))))}))}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getFilteredSetUsingPaging(e,t,r,i,s){try{let n="",a=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),a=!0),this.databaseType().then((i=>{let l=null===r?null===t?"1=1":"":(0,_.zR)(r,i);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression);let o=this._maxQueryRate();const u=this._layer.capabilities.query.maxRecordCount;void 0!==u&&u<o&&(o=u);let h=null;if(!0===this._pageJustIds)h=new d.Z([],["GETPAGES"],a,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:o,resultOffset:0,geometry:null===t?null:t,where:l,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const i=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);h=new d.Z([],["GETPAGES"],a,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:i.join(","),resultRecordCount:o,resultOffset:0,geometry:null===t?null:t,where:l,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return this._expandPagedSet(h,o,0,1,s).then((()=>h))}))}catch(e){return(0,x.d1)(e)}}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,n=new G.Z;return this._requestStandardised&&(n.sqlFormat="standard"),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields.split(","),n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.geometry=e.pagesDefinition.geometry,n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference,this.executeQuery(n,"execute").then((n=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t<n.features.length;t++)e.pagesDefinition.internal.set[i+t]=n.features[t].attributes[this._layer.objectIdField];if(!1===this._pageJustIds)for(let e=0;e<n.features.length;e++)this._featureCache[n.features[e].attributes[this._layer.objectIdField]]=n.features[e];return(void 0===n.exceededTransferLimit&&n.features.length!==e.pagesDefinition.resultRecordCount||!1===n.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+n.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}))}catch(e){return(0,x.d1)(e)}}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFeatures(e,t,r,i){const s=[];try{if(-1!==t&&void 0===this._featureCache[t]&&s.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return this._expandPagedSet(e,this._maxProcessingRate(),0,0,i).then((()=>this._getFeatures(e,t,r,i)));let n=0;for(let i=e._lastFetchedIndex;i<e._known.length;i++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[i]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[i]]){const s=t._featureMap[e._known[i]];null!==s&&(r=!0,this._featureCache[e._known[i]]=s)}}if(!1===r&&(e._known[i]!==t&&s.push(e._known[i]),s.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return(0,x.DB)("success");try{const e=new G.Z;return this._requestStandardised&&(e.sqlFormat="standard"),e.objectIds=s,e.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),e.returnGeometry=!0,!0===this._removeGeometry&&(e.returnGeometry=!1),e.outSpatialReference=this.spatialReference,this.executeQuery(e,"execute").then((e=>{if(this._checkCancelled(i),void 0!==e.error)return(0,x.d1)(new Error(e.error));for(let t=0;t<e.features.length;t++)this._featureCache[e.features[t].attributes[this._layer.objectIdField]]=e.features[t];return"success"}))}catch(e){return(0,x.d1)(e)}}catch(e){return(0,x.d1)(e)}}_getDistinctPages(e,t,r,i,s,n,a,l,o){return this._ensureLoaded().then((()=>this.databaseType())).then((u=>{let h=r.parseTree.column;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name.toLowerCase()===h.toLowerCase()){h=this._layer.fields[e].name;break}const c=new G.Z;this._requestStandardised&&(c.sqlFormat="standard");let d=null===n?null===s?"1=1":"":(0,_.zR)(n,u);return this._layer.definitionExpression&&this._useDefinitionExpression&&(d=""!==d?"(("+this._layer.definitionExpression+") AND ("+d+"))":this._layer.definitionExpression),c.where=d,c.spatialRelationship=this._makeRelationshipEnum(i),c.relationParameter=this._makeRelationshipParam(i),c.geometry=null===s?null:s,c.returnDistinctValues=!0,c.returnGeometry=!1,c.outFields=[h],this.executeQuery(c,"execute").then((u=>{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return(0,x.d1)(new Error("Unnexected Result querying statistics from layer"));let c=!1;for(let e=0;e<this._layer.fields.length;e++)if(this._layer.fields[e].name===h){"date"===this._layer.fields[e].type&&(c=!0);break}for(let e=0;e<u.features.length;e++){if(c){const t=u.features[e].attributes[h];null!==t?l.push(new Date(t)):l.push(t)}else l.push(u.features[e].attributes[h]);if(l.length>=a)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length<a?this._getDistinctPages(e+u.features.length,t,r,i,s,n,a,l,o).then((e=>({calculated:!0,result:e}))):l}))}))}_distinctStat(e,t,r,i,s,n,a){return this._getDistinctPages(0,e,t,r,i,s,n,[],a).then((e=>({calculated:!0,result:e})))}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType}_countstat(e,t,r,i){return this.databaseType().then((e=>{const s=new G.Z;if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let n=null===i?null===r?"1=1":"":(0,_.zR)(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(n=""!==n?"(("+this._layer.definitionExpression+") AND ("+n+"))":this._layer.definitionExpression),s.where=n,s.where=n,s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===r?null:r,s.returnGeometry=!1,this.executeQuery(s,"executeForCount").then((e=>({calculated:!0,result:e})))}))}_stats(e,t,r,i,s,n,a){return this._ensureLoaded().then((()=>{const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;return"count"===e?u?this._countstat(e,r,i,s):{calculated:!1}:!1===o||!1===(0,_.y5)(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,n,a):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,n,a):this._distinctStat(e,t,r,i,s,n,a):this.databaseType().then((n=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const a=new G.Z;this._requestStandardised&&(a.sqlFormat="standard");let l=null===s?null===i?"1=1":"":(0,_.zR)(s,n);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),a.where=l,a.spatialRelationship=this._makeRelationshipEnum(r),a.relationParameter=this._makeRelationshipParam(r),a.geometry=null===i?null:i;const o=new Q.Z;o.statisticType=(0,y.g3)(e),o.onStatisticField=(0,_.zR)(t,n),o.outStatisticFieldName="ARCADE_STAT_RESULT",a.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return a.outStatistics=[o],this.executeQuery(a,"execute").then((e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return(0,x.d1)(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r<e.fields.length;r++)if("ARCADE_STAT_RESULT"===e.fields[r].name.toUpperCase()){u=e.fields[r].name,"date"===e.fields[r].type&&(t=!0);break}if(t){let t=e.features[0].attributes[u];return null!==t&&(t=new Date(e.features[0].attributes[u])),{calculated:!0,result:t}}return{calculated:!0,result:e.features[0].attributes[u]}}))}))}))}_stat(e,t,r,i,s,n,a){return this._stats(e,t,r,i,s,n,a)}_canDoAggregates(e,t){return this._ensureLoaded().then((()=>{let e=!1;const r=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression;if(void 0!==this._layer.capabilities&&null!==this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics&&!0===this._layer.capabilities.query.supportsOrderBy&&(e=!0),e)for(let i=0;i<t.length-1;i++)null!==t[i].workingexpr&&(!1===t[i].workingexpr.isStandardized||!1===(0,_.y5)(t[i].workingexpr)&&!1===r)&&(e=!1);return!1!==e}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,a){return this._ensureLoaded().then((()=>this.databaseType())).then((l=>{let o="",u=!1,h=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(o=n.constructClause(),h=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(h=!1,u=!0,o=this._layer.objectIdField);const c=[];for(let e=0;e<t.length;e++){const r=new Q.Z;r.onStatisticField=null!==t[e].workingexpr?(0,_.zR)(t[e].workingexpr,l):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),c.push(r)}""===o&&(o=e.join(","));let f=this._maxQueryRate();const p=this._layer.capabilities.query.maxRecordCount;void 0!==p&&p<f&&(f=p);let y=null===s?null===i?"1=1":"":(0,_.zR)(s,l);return this._layer.definitionExpression&&this._useDefinitionExpression&&(y=""!==y?"(("+this._layer.definitionExpression+") AND ("+y+"))":this._layer.definitionExpression),new d.Z([],["GETPAGES"],h,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:u,generatedOid:a,resultRecordCount:f,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:c,geometry:null===i?null:i,where:y,orderByFields:o,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}))}_getAgregagtePhysicalPage(e,t,r){try{let t=e.pagesDefinition.where;!0===e.pagesDefinition.useOIDpagination&&(t=""!==t?"("+t+") AND ("+e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString()+")":e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString());const i=e.pagesDefinition.internal.lastRetrieved,s=i,n=e.pagesDefinition.internal.lastPage,a=new G.Z;return this._requestStandardised&&(a.sqlFormat="standard"),a.where=t,a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields,a.outStatistics=e.pagesDefinition.outStatistics,a.geometry=e.pagesDefinition.geometry,a.groupByFieldsForStatistics=e.pagesDefinition.groupByFieldsForStatistics,a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.returnGeometry=e.pagesDefinition.returnGeometry,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,this.isTable()&&a.geometry&&a.spatialRelationship?(0,x.DB)([]):this.executeQuery(a,"execute").then((t=>{if(this._checkCancelled(r),!t.hasOwnProperty("features"))return(0,x.d1)(new Error("Unnexected Result querying aggregates from layer"));const a=[];if(e.pagesDefinition.internal.lastPage!==n)return[];for(let r=0;r<t.features.length;r++)e.pagesDefinition.internal.set[s+r]=t.features[r].attributes[e.pagesDefinition.generatedOid];for(let e=0;e<t.features.length;e++)a.push(new l.Z({attributes:t.features[e].attributes,geometry:null}));return!0===e.pagesDefinition.useOIDpagination?0===t.features.length?e.pagesDefinition.internal.fullyResolved=!0:e.pagesDefinition.internal.lastMaxId=t.features[t.features.length-1].attributes[e.pagesDefinition.generatedOid]:(void 0===t.exceededTransferLimit&&t.features.length!==e.pagesDefinition.resultRecordCount||!1===t.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=i+t.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,a}))}catch(e){return(0,x.d1)(e)}}static create(e,t,r,i,s){const n=new B.default({url:e,outFields:null===t?["*"]:t});return new K({layer:n,spatialReference:r,lrucache:i,interceptor:s})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return(0,p.US)(this._layer.parsedUrl.path)}queryAttachments(e,t,r,i,s){if(this._layer.capabilities.data.supportsAttachment&&this._layer.capabilities.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:s};return(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),i&&i.length>0&&(n.attachmentTypes=i),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"}),this._layer.queryAttachments(n).then((t=>{const r=[];return t&&t[e]&&t[e].forEach((t=>{const i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let n=null;s&&t.exifInfo&&(n=J.Z.convertJsonToArcade(t.exifInfo,!0)),r.push(new P.Z(t.id,t.name,t.contentType,t.size,i,n))})),r}))}return(0,x.DB)([])}queryRelatedFeatures(e){const t={f:"json",relationshipId:e.relationshipId.toString(),definitionExpression:e.where,outFields:e.outFields.join(","),returnGeometry:e.returnGeometry.toString()};return void 0!==e.resultOffset&&null!==e.resultOffset&&(t.resultOffset=e.resultOffset.toString()),void 0!==e.resultRecordCount&&null!==e.resultRecordCount&&(t.resultRecordCount=e.resultRecordCount.toString()),e.orderByFields&&(t.orderByFields=e.orderByFields.join(",")),e.objectIds.length>0&&(t.objectIds=e.objectIds.join(",")),e.outSpatialReference&&(t.outSR=JSON.stringify(e.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:t,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"}),(0,s.default)(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:t}).then((e=>{if(e.data){const t={},r=e.data;if(r&&r.relatedRecordGroups){const e=r.spatialReference;for(const i of r.relatedRecordGroups){const s=i.objectId,n=[];for(const t of i.relatedRecords){t.geometry&&(t.geometry.spatialReference=e);const r=new l.Z({geometry:t.geometry?(0,O.im)(t.geometry):null,attributes:t.attributes});n.push(r)}t[s]={features:n,exceededTransferLimit:!0===r.exceededTransferLimit}}}return t}return(0,x.d1)("Invalid Request")}))}getFeatureByObjectId(e,t){const r=new G.Z;return r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"}),(0,Z.e)(this._layer.parsedUrl.path,r).then((e=>1===e.features.length?e.features[0]:null))}getIdentityUser(){return this.load().then((()=>{var e;const t=null==(e=i.id)?void 0:e.findCredential(this._layer.url);return t?t.userId:null}))}getOwningSystemUrl(){return this.load().then((()=>{var e;const t=null==(e=i.id)?void 0:e.findServerInfo(this._layer.url);if(t)return(0,x.DB)(t.owningSystemUrl);let r=this._layer.url;const n=r.toLowerCase().indexOf("/rest/services");return r=n>-1?r.substring(0,n):r,r?(r+="/rest/info",(0,x.Ue)(((e,t)=>{(0,s.default)(r,{query:{f:"json"}}).then((t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)}),(t=>{e("")}))}))):(0,x.DB)("")}))}getDataSourceFeatureSet(){const e=new K({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}var $=r(17805);class H extends c.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,this.relatedLayer=null,this.relationship=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this.relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return p.tI}end(){return this._layer}optimisePagingFeatureQueries(){}load(){return null===this._loadPromise&&(this._loadPromise=(0,x.Ue)(((e,t)=>{(0,x.$6)([this._layer.load(),this.relatedLayer.load()]).then((()=>{this._initialiseFeatureSet(),e(this)}),t)}))),this._loadPromise}nativeCapabilities(){return this.relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this.relatedLayer.geometryType,this.fields=this.relatedLayer.fields.slice(0),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}const e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this.relatedLayer.objectIdField,this.globalIdField=this.relatedLayer.globalIdField,this.hasM=this.relatedLayer.supportsM,this.hasZ=this.relatedLayer.supportsZ,this.typeIdField=this.relatedLayer.typeIdField,this.types=this.relatedLayer.types}databaseType(){return this.relatedLayer.databaseType().then((()=>(this._databaseType=this.relatedLayer._databaseType,this._databaseType)))}isTable(){return this.relatedLayer.isTable()}_isInFeatureSet(){return p.dj.InFeatureSet}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):(0,x.DB)(this._wset)}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new l.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}_getFilteredSet(e,t,r,i,s){return this.databaseType().then((()=>{if(this.isTable()&&t&&null!==e&&""!==e)return new d.Z([],[],!0,null);const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated)return new d.Z([],[],!0,null);if(n.capabilities.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,i,s);let a="",l=!1;null!==i&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(a=i.constructClause(),l=!0);const o=new z.Z;o.objectIds=[this._findObjectId];const u=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this.relatedLayer.fields?this.relatedLayer.fields.map((e=>e.name)):["*"]);o.outFields=u,o.relationshipId=this.relationship.id,o.where="1=1";let h=!0;return!0===this._removeGeometry&&(h=!1),o.returnGeometry=h,this._requestStandardised&&(o.sqlFormat="standard"),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==a?a.split(","):null,n.source.queryRelatedFeatures(o).then((i=>{this._checkCancelled(s);const n=i[this._findObjectId]?i[this._findObjectId].features:[],a=[];for(let e=0;e<n.length;e++)this._featureCache[n[e].attributes[this.relatedLayer.objectIdField]]=n[e],a.push(n[e].attributes[this.relatedLayer.objectIdField]);const o=t&&null!==e&&""!==e,u=null!=r;return new d.Z(o||u?a:[],o||u?[]:a,l,null)}))}))}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFilteredSetUsingPaging(e,t,r,i,s){try{let n="",a=!1;const l=this._layer.nativeCapabilities();return null!==i&&l&&l.capabilities.queryRelated&&!0===l.capabilities.queryRelated.supportsOrderBy&&(n=i.constructClause(),a=!0),this.databaseType().then((()=>{let i=this._maxQueryRate();const o=l.capabilities.query.maxRecordCount;void 0!==o&&o<i&&(i=o);const u=t&&null!==e&&""!==e,h=null!=r;let c=null,f=!0;!0===this._removeGeometry&&(f=!1);const p=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this.relatedLayer.fields?this.relatedLayer.fields.map((e=>e.name)):["*"]);return c=new d.Z(u||h?["GETPAGES"]:[],u||h?[]:["GETPAGES"],a,{outFields:p.join(","),resultRecordCount:i,resultOffset:0,objectIds:[this._findObjectId],where:"1=1",orderByFields:n,returnGeometry:f,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),this._expandPagedSet(c,i,0,0,s).then((()=>c))}))}catch(e){return(0,x.d1)(e)}}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupByFieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}_getPhysicalPage(e,t,r){try{const t=e.pagesDefinition.internal.lastRetrieved,i=t,s=e.pagesDefinition.internal.lastPage,n=this._layer.nativeCapabilities(),a=new z.Z;return!0===this._requestStandardised&&(a.sqlFormat="standard"),a.relationshipId=this.relationship.id,a.objectIds=e.pagesDefinition.objectIds,a.resultOffset=e.pagesDefinition.internal.lastPage,a.resultRecordCount=e.pagesDefinition.resultRecordCount,a.outFields=e.pagesDefinition.outFields.split(","),a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,n.source.queryRelatedFeatures(a).then((n=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return 0;const a=n[this._findObjectId]?n[this._findObjectId].features:[];for(let t=0;t<a.length;t++)e.pagesDefinition.internal.set[i+t]=a[t].attributes[this.relatedLayer.objectIdField];for(let e=0;e<a.length;e++)this._featureCache[a[e].attributes[this.relatedLayer.objectIdField]]=a[e];const l=!n[this._findObjectId]||!1===n[this._findObjectId].exceededTransferLimit;return a.length!==e.pagesDefinition.resultRecordCount&&l&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=t+a.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,a.length}))}catch(e){return(0,x.d1)(e)}}_getFeatures(e,t,r,i){const s=[];-1!==t&&void 0===this._featureCache[t]&&s.push(t);const n=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,n))return this._expandPagedSet(e,n,0,0,i).then((()=>this._getFeatures(e,t,r,i)));let a=0;for(let i=e._lastFetchedIndex;i<e._known.length&&(a++,a<=r&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[i]&&void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&s.push(e._known[i]),s.length>r)))&&!(a>=r&&0===s.length);i++);return 0===s.length?(0,x.DB)("success"):(0,x.d1)(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e,t,r){return(0,x.DB)(e)}_stat(e,t,r,i,s,n,a){return(0,x.DB)({calculated:!1})}get gdbVersion(){return this.relatedLayer.gdbVersion}_canDoAggregates(e,t,r,i,s){return(0,x.DB)(!1)}relationshipMetaData(){return this.relatedLayer.relationshipMetaData()}serviceUrl(){return this.relatedLayer.serviceUrl()}queryAttachments(e,t,r,i,s){return this.relatedLayer.queryAttachments(e,t,r,i,s)}getFeatureByObjectId(e,t){return this.relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this.relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this.relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this.relatedLayer}}var X=r(48039),Y=r(65587),ee=r(15235);function te(){null===X.Z.applicationCache&&(X.Z.applicationCache=new X.Z)}function re(e,t){if(X.Z.applicationCache){const r=X.Z.applicationCache.getLayerInfo(e);if(r)return r.then((r=>(0,x.DB)(new B.default({url:e,outFields:t,sourceJSON:r}))));const i=new B.default({url:e,outFields:t});let s=(0,x.Ue)(((e,t)=>{i.load().then((()=>{e(i.sourceJSON)}),(e=>{t(e)}))}));return X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(e,s),s=s.catch((t=>{throw X.Z.applicationCache.clearLayerInfo(e),t}))),s.then((()=>(0,x.DB)(i)))}return(0,x.DB)(new B.default({url:e,outFields:t}))}function ie(e,t,r,i,s,n=null){return re(e,["*"]).then((e=>(0,x.DB)(se(e,t,r,i,s,n))))}function se(e,t=null,r=null,i=!0,s=null,n=null){return!0===e._hasMemorySource()?new $.Z({layer:e,spatialReference:t,outFields:r,includeGeometry:i,lrucache:s,interceptor:n}):new K({layer:e,spatialReference:t,outFields:r,includeGeometry:i,lrucache:s,interceptor:n})}function ne(e){if(null!==X.Z.applicationCache){const t=X.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}let t=(0,s.default)(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.layers||(t.layers=[]),t.tables||(t.tables=[]),(0,x.DB)(t)}return(0,x.DB)({layers:[],tables:[]})}));return null!==X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(e,t),t=t.catch((t=>{throw X.Z.applicationCache.clearLayerInfo(e),t}))),t}function ae(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return ne(e).then((i=>{if(r.metadata=i,i.controllerDatasetLayers&&void 0!==i.controllerDatasetLayers.utilityNetworkLayerId&&null!==i.controllerDatasetLayers.utilityNetworkLayerId){if(i.layers)for(const e of i.layers)r.layerNameLkp[e.id]=e.name;if(i.tables)for(const e of i.tables)r.layerNameLkp[e.id]=e.name;const n=i.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=n,function(e,t){const r="QUERYDATAELEMTS:"+t.toString()+":"+e;if(null!==X.Z.applicationCache){const e=X.Z.applicationCache.getLayerInfo(r);if(null!==e)return e}let i=(0,s.default)(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([t.toString()]),f:"json"}}).then((e=>{if(e.data){const t=e.data;if(t.layerDataElements&&t.layerDataElements[0])return t.layerDataElements[0]}throw new Error("Not Found")}));return null!==X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(r,i),i=i.catch((e=>{throw X.Z.applicationCache.clearLayerInfo(r),e}))),i}(e,n).then((i=>{if(i){r.queryelem=i,r.queryelem&&r.queryelem.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]);for(const e of r.queryelem.dataElement.domainNetworks){for(const t of e.edgeSources?e.edgeSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}for(const t of e.junctionSources?e.junctionSources:[]){const e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]?r.layerNameLkp[t.layerId]:null};e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(const e of r.queryelem.dataElement.terminalConfigurations)for(const t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});return function(e){if(null!==X.Z.applicationCache){const t=X.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}let t=(0,s.default)(e,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return(0,x.DB)(t)}return(0,x.DB)(null)}));return null!==X.Z.applicationCache&&(X.Z.applicationCache.setLayerInfo(e,t),t=t.catch((t=>{throw X.Z.applicationCache.clearLayerInfo(e),t}))),t}(e+"/"+n).then((i=>{if(i.systemLayers&&void 0!==i.systemLayers.associationsTableId&&null!==i.systemLayers.associationsTableId){const s=[];return r.unVersion>=4&&(s.push("STATUS"),s.push("PERCENTALONG")),ie(e+"/"+i.systemLayers.associationsTableId.toString(),t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...s],!1,null,null).then((e=>e.load())).then((e=>r.unVersion>=4?(e=e.filter(g.WhereClause.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62,63)",e.getFieldsIndex()))).load():e)).then((e=>({lkp:r.lkp,associations:e,unVersion:r.unVersion,terminals:r.terminals})))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[]}}))}function le(e,t,r,i=null,s=null,n=!0,a=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),ie(o,i,s,n,a,l).then((o=>new H({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:i,outFields:s,includeGeometry:n,lrucache:a,interceptor:l})))):null}a.Z.registerAction(),T.registerAction(),h.Z.registerAction(),N.Z.registerAction(),L.Z.registerAction();class oe extends n.Z{constructor(e,t=null,r=null,i=null){super(),this._map=e,this._overridespref=t,this.lrucache=r,this.interceptor=i,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,r=null){const i=se(e,this._overridespref,null===r?["*"]:r,t,this.lrucache,this.interceptor);return this._instantLayers.push({featureset:i,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),i}featureSetByName(e,t=!0,r=null){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetByName(e,t,r)}catch(e){return(0,x.d1)(e)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.title===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}const s=this._map.allLayers.find((t=>t instanceof B.default&&t.title===e));if(s)return this.resolvePromise(this._makeAndAddFeatureSet(s,t,r));if(this._map.tables){const i=this._map.tables.find((t=>!!(t.title&&t.title===e||t.title&&t.title===e)));if(i){if(i instanceof B.default)return this.resolvePromise(this._makeAndAddFeatureSet(i,t,r));if(i._materializedTable);else{const e=i.outFields?i:{...i,outFields:["*"]};i._materializedTable=new B.default(e)}return i._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(i._materializedTable,t,r))))}}return this.resolvePromise(null)}featureSetById(e,t=!0,r=["*"]){if(void 0!==this._map.loaded&&void 0!==this._map.load&&!1===this._map.loaded)return this._map.load().then((()=>{try{return this.featureSetById(e,t,r)}catch(e){return(0,x.d1)(e)}}));null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.id===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}const s=this._map.allLayers.find((t=>t instanceof B.default&&t.id===e));if(s)return this.resolvePromise(this._makeAndAddFeatureSet(s,t,r));if(this._map.tables){const i=this._map.tables.find((t=>t.id===e));if(i){if(i instanceof B.default)return this.resolvePromise(this._makeAndAddFeatureSet(i,t,r));if(i._materializedTable);else{const e={...i,outFields:["*"]};i._materializedTable=new B.default(e)}return i._materializedTable.load().then((()=>this.resolvePromise(this._makeAndAddFeatureSet(i._materializedTable,t,r))))}}return this.resolvePromise(null)}}class ue extends n.Z{constructor(e,t=null,r=null,i=null){super(),this._url=e,this._overridespref=t,this.lrucache=r,this.interceptor=i,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,r=null){const i=se(e,this._overridespref,null===r?["*"]:r,t,this.lrucache);return this._instantLayers.push({featureset:i,opitem:e,includeGeometry:t,outFields:JSON.stringify(r)}),i}_loadMetaData(){return ne(this._url).then((e=>(this.metadata=e,e)))}load(){return this._loadMetaData()}clone(){return new ue(this._url,this._overridespref,this.lrucache,this.interceptor)}featureSetByName(e,t=!0,r=null){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.title===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}return this._loadMetaData().then((i=>{let s=null;for(const t of i.layers?i.layers:[])t.name===e&&(s=t);if(!s)for(const t of i.tables?i.tables:[])t.name===e&&(s=t);return s?re(this._url+"/"+s.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}featureSetById(e,t=!0,r=["*"]){null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);e=null!=e?e.toString():"";for(let r=0;r<this._instantLayers.length;r++){const s=this._instantLayers[r];if(s.opitem.id===e&&s.includeGeometry===t&&s.outFields===i)return this.resolvePromise(this._instantLayers[r].featureset)}return this._loadMetaData().then((i=>{let s=null;for(const t of i.layers?i.layers:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(s=t);if(!s)for(const t of i.tables?i.tables:[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(s=t);return s?re(this._url+"/"+s.id,["*"]).then((e=>this._makeAndAddFeatureSet(e,t,r))):this.resolvePromise(null)}))}}function he(e,t,r=null,i=null){return new oe(e,t,r,i)}function ce(e,t,r=null,i=null){return new ue(e,t,r,i)}function de(e,t){return null===e?t:new Y.Z({url:e.field("url")})}function fe(e,t,r){return i.id.findCredential(e.restUrl)?"loaded"===e.loadStatus&&""===t&&e.user&&e.user.sourceJSON&&!1===r?(0,x.DB)(e.user.sourceJSON):""===t?(0,s.default)(e.restUrl+"/community/self",{responseType:"json",query:{f:"json",...!1===r?{}:{returnUserLicenseTypeExtensions:!0}}}).then((e=>{if(e.data){const t=e.data;if(t&&t.username)return(0,x.DB)(t)}return(0,x.DB)(null)})):(0,s.default)(e.restUrl+"/community/users/"+t,{responseType:"json",query:{f:"json"}}).then((e=>{if(e.data){const t=e.data;return t.error?null:(0,x.DB)(t)}return(0,x.DB)(null)})):(0,x.DB)(null)}function pe(e,t,r,i,s){if(null===e)return null;if(e instanceof B.default){switch(t){case"datasource":return se(e,s,e.outFields,!0,r,i).getDataSourceFeatureSet();case"parent":case"root":return se(e,s,e.outFields,!0,r,i)}return null}if(e instanceof c.Z)switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function _e(e,t,r,i,s,n,a,l=null){if(X.Z.applicationCache){const o=X.Z.applicationCache.getLayerInfo(e+":"+n.url);if(o)return o.then((e=>{try{const n=new B.default({url:(0,p.US)(e.url)+"/"+t,outFields:["*"]});return(0,x.DB)(se(n,r,i,s,a,l))}catch(e){return(0,x.d1)(e)}}),(e=>(0,x.d1)(e)))}return(0,x.Ue)(((o,u)=>{const h=new ee.default({id:e,portal:n}).load();X.Z.applicationCache&&X.Z.applicationCache.setLayerInfo(e+":"+n.url,h),h.then((e=>{try{const n=new B.default({url:(0,p.US)(e.url)+"/"+t,outFields:["*"]});o(se(n,r,i,s,a,l))}catch(e){u(e)}}),(t=>{X.Z.applicationCache&&X.Z.applicationCache.clearLayerInfo(e+":"+n.url),u(t)}))}))}},70409:(e,t,r)=>{r.d(t,{$X:()=>f,QP:()=>p,TO:()=>_,Xx:()=>g,yN:()=>y});var i=r(38171),s=r(77286),n=r(91136),a=r(90961),l=r(90658),o=r(36515),u=r(95330),h=r(41534),c=r(82971);class d{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class f extends d{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class p extends d{constructor(e,t,r){super((0,l.JW)(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:(0,o.bB)(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class _ extends d{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const e in r)this.reverseLkp[r[e]]=e;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,l.Bj.Standardised,this.field.name,this.codefield instanceof h.WhereClause?(0,o.zR)(this.codefield,l.Bj.Standardised):this.codefield,e.parameters);return r.includes(_.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:h.WhereClause.create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,i=null,s){let n,a,l,u;switch(e.type){case"interval":return(0,o.TE)(this.evaluateNodeToWhereClause(e.value,t,r,i,s),e.qualifier,e.op);case"case_expression":{let i=" CASE ";"simple"===e.format&&(i+=this.evaluateNodeToWhereClause(e.operand,t,r,_.BADNESS,s));for(let n=0;n<e.clauses.length;n++)i+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[n].operand,t,r,_.BADNESS,s)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[n].value,t,r,_.BADNESS,s);return null!==e.else&&(i+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,r,_.BADNESS,s)),i+=" END ",i}case"param":{const r=s[e.value.toLowerCase()];if("string"==typeof r)return"'"+s[e.value.toLowerCase()].toString().replace(/'/g,"''")+"'";if(r instanceof Date)return(0,o.oX)(r,t);if(r instanceof Array){const e=[];for(let i=0;i<r.length;i++)"string"==typeof r[i]?e.push("'"+r[i].toString().replace(/'/g,"''")+"'"):r[i]instanceof Date?e.push((0,o.oX)(r[i],t)):e.push(r[i].toString());return e}return r.toString()}case"expr_list":a=[];for(const n of e.value)a.push(this.evaluateNodeToWhereClause(n,t,r,i,s));return a;case"unary_expr":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,r,_.BADNESS,s)+" ) ";case"binary_expr":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" AND "+this.evaluateNodeToWhereClause(e.right,t,r,i,s)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" OR "+this.evaluateNodeToWhereClause(e.right,t,r,i,s)+") ";case"IS":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new Error("Unsupported RHS for IS");return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IS NOT NULL )";case"IN":if(n=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const n=[];let a=!0;for(const t of e.right.value){if("string"!==t.type){a=!1;break}if(void 0===this.lkp[t.value]){a=!1;break}n.push(this.lkp[t.value].toString())}if(a)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+n.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,r,i,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,r,i,s),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" IN ("+u+")) ";case"NOT IN":if(n=[],"expr_list"===e.right.type){if("column_ref"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){const n=[];let a=!0;for(const t of e.right.value){if("string"!==t.type){a=!1;break}if(void 0===this.lkp[t.value]){a=!1;break}n.push(this.lkp[t.value].toString())}if(a)return" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+n.join(",")+")) "}return n=this.evaluateNodeToWhereClause(e.right,t,r,i,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+n.join(",")+")) "}return u=this.evaluateNodeToWhereClause(e.right,t,r,i,s),u instanceof Array?" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+u.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,i,s)+" NOT IN ("+u+")) ";case"BETWEEN":return l=this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" BETWEEN "+l[0]+" AND "+l[1]+" ) ";case"NOTBETWEEN":return l=this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)," ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" NOT BETWEEN "+l[0]+" AND "+l[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") ";case"<>":case"=":if("column_ref"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+i+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column_ref"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+i+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":return" ("+this.evaluateNodeToWhereClause(e.left,t,r,_.BADNESS,s)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,r,_.BADNESS,s)+") "}throw new Error("Not Supported Operator "+e.operator);case"null":return"null";case"bool":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replace(/'/g,"''")+"'";case"timestamp":case"date":return(0,o.oX)(e.value,t);case"number":return e.value.toString();case"current_time":return(0,o.vR)("date"===e.mode,t);case"column_ref":return r&&r.toLowerCase()===e.column.toLowerCase()?"("+i+")":e.column;case"function":{const i=this.evaluateNodeToWhereClause(e.args,t,r,_.BADNESS,s);return(0,o.fz)(e.name,i,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof h.WhereClause?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}_.BADNESS="_!!!_BAD_LKP_!!!!";class y extends d{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:(0,o.bB)(e,this.field.name,(0,o.zR)(this.sql,l.Bj.Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class g extends n.Z{constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=null,this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}static findField(e,t){for(const r of e)if(r.name.toLowerCase()===t.toString().toLowerCase())return r;return null}_initialiseFeatureSet(){null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new c.Z({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l.Qk.point,this.typeIdField="",this.types=null),this.fields=[];for(const e of this.adaptedFields)e.postInitialization(this,this._parent),this.fields.push(e.field)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._extraFilter?this._getFilteredSet("",null,null,null,e):this._parent._getSet(e))).then((t=>(this._checkCancelled(e),this._wset=new a.Z(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):(0,u.DB)(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,n){const l=[];-1!==t&&void 0===this._featureCache[t]&&l.push(t);const o=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,o))return this._expandPagedSet(e,o,0,0,n).then((()=>this._getFeatures(e,t,r,n)));let h=0;for(let i=e._lastFetchedIndex;i<e._known.length&&(h++,h<=r&&(e._lastFetchedIndex+=1),!(void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&l.push(e._known[i]),l.length>=o)));i++);if(0===l.length)return(0,u.DB)("success");e=new a.Z([],l,e._ordered,null);const c=Math.min(l.length,r);return this._parent._getFeatures(e,-1,c,n).then((()=>{this._checkCancelled(n);const e=[];for(let t=0;t<c;t++){const r=this._parent._featureFromCache(l[t]);void 0!==r&&e.push({geometry:r.geometry,attributes:r.attributes,id:l[t]})}for(const t of e){const e=[];for(const r of this.adaptedFields)e[r.field.name]=r.extractValue(t);this._featureCache[t.id]=new i.Z({attributes:e,geometry:(0,s.r1)(t.geometry)})}return"success"}))}_fetchAndRefineFeatures(){return(0,u.d1)(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,i,s){let n=!1;const l=this._reformulateWithoutAdaptions(r);n=l.cannot,r=l.where;let u=!1;if(null!==i){u=!0;const e=[];for(const t of this.adaptedFields)if(!(t instanceof f)&&!0===i.scanForField(t.field.name)){if(!(t instanceof p)){i=null,u=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}i&&e.length>0&&(i=i.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=(0,o.$e)(this._extraFilter,r)):r=this._extraFilter,this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,i,s))).then((e=>{let t;return this._checkCancelled(s),t=!0===n?new a.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],!0===u&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new a.Z(e._candidates.slice(0),e._known.slice(0),!0===u&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_reformulateWithoutAdaptions(e){const t={cannot:!1,where:e};if(null!==e)for(const r of this.adaptedFields)if(!0===(0,o.hq)(e,r.field.name)){const i=r.rewriteSql(e,this);if(!0!==i.rewritten){t.cannot=!0,t.where=null;break}t.where=i.where}return t}_stat(e,t,r,i,s,n,a){let l=!1,h=this._reformulateWithoutAdaptions(t);return l=h.cannot,t=h.where,h=this._reformulateWithoutAdaptions(s),l=l||h.cannot,null!==(s=h.where)?null!==this._extraFilter&&(s=(0,o.$e)(this._extraFilter,s)):s=this._extraFilter,!0===l?null===s&&""===r&&null===i?this._manualStat(e,t,n,a):(0,u.DB)({calculated:!1}):this._parent._stat(e,t,r,i,s,n,a).then((l=>!1===l.calculated?null===s&&""===r&&null===i?this._manualStat(e,t,n,a):{calculated:!1}:l))}_canDoAggregates(e,t,r,i,s){if(null===this._parent)return(0,u.DB)(!1);for(let t=0;t<e.length;t++)for(const r of this.adaptedFields)if(e[t].toLowerCase()===r.field.name.toLowerCase()&&!(r instanceof f))return(0,u.DB)(!1);const n=[];for(let e=0;e<t.length;e++){const r=t[e];if(null!==r.workingexpr){const e=this._reformulateWithoutAdaptions(r.workingexpr);if(e.cannot)return(0,u.DB)(!1);const t=r.clone();t.workingexpr=e.where,n.push(t)}else n.push(r)}const a=this._reformulateWithoutAdaptions(s);return a.cannot?(0,u.DB)(!1):(null!==(s=a.where)?null!==this._extraFilter&&(s=(0,o.$e)(this._extraFilter,s)):s=this._extraFilter,this._parent._canDoAggregates(e,n,r,i,s))}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,a){if(null===this._parent)return(0,u.d1)(new Error("Should never be called"));const l=[];for(let e=0;e<t.length;e++){const r=t[e];if(null!==r.workingexpr){const e=this._reformulateWithoutAdaptions(r.workingexpr);if(e.cannot)return(0,u.d1)(new Error("Should never be called"));const t=r.clone();t.workingexpr=e.where,l.push(t)}else l.push(r)}const h=this._reformulateWithoutAdaptions(s);return h.cannot?(0,u.d1)(new Error("Should never be called")):(null!==(s=h.where)?null!==this._extraFilter&&(s=(0,o.$e)(this._extraFilter,s)):s=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,l,r,i,s,n,a))}}},84328:(e,t,r)=>{r.d(t,{Z:()=>h});var i=r(91136),s=r(90961),n=r(90658),a=r(36515),l=r(95330),o=r(41534),u=r(82971);class h extends i.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof o.WhereClause?(this._whereclause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereclause=null)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(0),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.fields=[],this.typeIdField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new u.Z({wkid:4326}),this.geometryType=n.Qk.point)}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._parent._getFilteredSet("",null,this._whereclause,null,e))).then((t=>(this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new s.Z(t._candidates.slice(0).concat(t._known.slice(0)),[],t._ordered,this._clonePageDefinition(t.pagesDefinition)):this._wset=new s.Z(t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset))):(0,l.DB)(this._wset)}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===n.dj.NotInFeatureSet?t:(t=this._idstates[e],void 0===t?n.dj.Unknown:t)}_getFeature(e,t,r){return this._parent._getFeature(e,t,r)}_getFeatures(e,t,r,i){return this._parent._getFeatures(e,t,r,i)}_featureFromCache(e){return this._parent._featureFromCache(e)}executeWhereClause(e){return this._whereclause.testFeature(e)}executeWhereClauseDeferred(e){if(null!==this._whereClauseFunction)try{const t=this._whereClauseFunction(e);return(0,l.y8)(t)?t:(0,l.DB)(t)}catch(e){return(0,l.d1)(e)}return(0,l.DB)(this.executeWhereClause(e))}_fetchAndRefineFeatures(e,t,r){const i=new s.Z([],e,!1,null),a=Math.min(t,e.length);return this._parent._getFeatures(i,-1,a,r).then((()=>{if(this._checkCancelled(r),null==this._whereClauseFunction){for(let t=0;t<a;t++){const r=this._parent._featureFromCache(e[t]);!0===this.executeWhereClause(r)?this._idstates[e[t]]=n.dj.InFeatureSet:this._idstates[e[t]]=n.dj.NotInFeatureSet}return"success"}const i=[];for(let t=0;t<a;t++){const r=this._parent._featureFromCache(e[t]);i.push(this.executeWhereClauseDeferred(r))}return(0,l.$6)(i).then((r=>{for(let i=0;i<t;i++)!0===r[i]?this._idstates[e[i]]=n.dj.InFeatureSet:this._idstates[e[i]]=n.dj.NotInFeatureSet;return"success"}))}))}_getFilteredSet(e,t,r,i,n){return null!==this._whereClauseFunction||(null!==r?null!==this._whereclause&&(r=(0,a.$e)(this._whereclause,r)):r=this._whereclause),this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,i,n))).then((e=>{let t;return this._checkCancelled(n),t=null!==this._whereClauseFunction?new s.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s.Z(e._candidates.slice(0),e._known.slice(0),e._ordered,this._clonePageDefinition(e.pagesDefinition)),t}))}_stat(e,t,r,i,s,n,o){if(null!==this._whereClauseFunction)return null===s&&""===r&&null===i?this._manualStat(e,t,n,o):(0,l.DB)({calculated:!1});let u=this._whereclause;return null!==s&&null!==this._whereclause&&(u=(0,a.$e)(this._whereclause,s)),this._parent._stat(e,t,r,i,u,n,o).then((a=>!1===a.calculated?null===s&&""===r&&null===i?this._manualStat(e,t,n,o):{calculated:!1}:a))}_canDoAggregates(e,t,r,i,s){return null!==this._whereClauseFunction?(0,l.DB)(!1):(null!==s?null!==this._whereclause&&(s=(0,a.$e)(this._whereclause,s)):s=this._whereclause,null===this._parent?(0,l.DB)(!1):this._parent._canDoAggregates(e,t,r,i,s))}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,o){return null===this._parent?(0,l.d1)(new Error("Should never be called")):(null!==s?null!==this._whereclause&&(s=(0,a.$e)(this._whereclause,s)):s=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(e,t,r,i,s,n,o))}static registerAction(){i.Z._featuresetFunctions.filter=function(e){if("function"==typeof e)return new h({parentfeatureset:this,whereclause:e});let t=null;return e instanceof o.WhereClause&&(t=e),new h({parentfeatureset:this,whereclause:t})}}}},85065:(e,t,r)=>{r.d(t,{Z:()=>o});var i=r(61363),s=r(91136),n=r(90961),a=r(3823),l=r(95330);class o extends s.Z{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,this._orderbyclause,e))).then((t=>(this._checkCancelled(e),this._wset=t,this._wset))):(0,l.DB)(this._wset)}manualOrderSet(e,t){return this.getIdColumnDictionary(e,[],-1,t).then((e=>{this._orderbyclause.order(e);const t=new n.Z([],[],!0,null);for(let r=0;r<e.length;r++)t._known.push(e[r].id);return t}))}getIdColumnDictionary(e,t,r,s){if(r<e._known.length-1){const n=this._maxQueryRate();if("GETPAGES"===e._known[r+1])return(0,i.X)(this._parent._expandPagedSet(e,n,0,0,s)).then((()=>this.getIdColumnDictionary(e,t,r,s)));let a=r+1;const l=[];for(;a<e._known.length&&"GETPAGES"!==e._known[a];)l.push(e._known[a]),a++;return r+=l.length,(0,i.X)(this._parent._getFeatureBatch(l,s)).then((i=>{this._checkCancelled(s);for(const e of i)t.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(e,t,r,s)}))}return e._candidates.length>0?(0,i.X)(this._refineSetBlock(e,this._maxProcessingRate(),s)).then((()=>(this._checkCancelled(s),this.getIdColumnDictionary(e,t,r,s)))):(0,l.DB)(t)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,i){return this._parent._getFeatures(e,t,r,i)}_featureFromCache(e){if(void 0===this._featureCache[e]){const t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}_fetchAndRefineFeatures(){return(0,l.d1)(new Error("Fetch and Refine should not be called in this featureset"))}_getFilteredSet(e,t,r,i,s){return this._ensureLoaded().then((()=>this._parent._getFilteredSet(e,t,r,null===i?this._orderbyclause:i,s))).then((e=>{this._checkCancelled(s);const i=new n.Z(e._candidates.slice(0),e._known.slice(0),e._ordered,this._clonePageDefinition(e.pagesDefinition));let a=!0;return e._candidates.length>0&&(a=!1),!1===i._ordered?this.manualOrderSet(i,s).then((e=>(!1===a&&(null===t&&null===r||(e=new n.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e))):i}))}static registerAction(){s.Z._featuresetFunctions.orderBy=function(e){return""===e?this:new o({parentfeatureset:this,orderbyclause:new a.Z(e)})}}}},63991:(e,t,r)=>{r.d(t,{Z:()=>l});var i=r(91136),s=r(90961),n=r(90658),a=r(95330);class l extends i.Z{constructor(e){super(e),this._topnum=0,this.declaredClass="esri.arcade.featureset.actions.Top",this._countedin=0,this._maxProcessing=100,this._topnum=e.topnum,this._parent=e.parentfeatureset}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._parent._getSet(e))).then((e=>(this._wset=new s.Z(e._candidates.slice(0),e._known.slice(0),!1,this._clonePageDefinition(e.pagesDefinition)),this._setKnownLength(this._wset)>this._topnum&&(this._wset._known=this._wset._known.slice(0,this._topnum)),this._setKnownLength(this._wset)>=this._topnum&&(this._wset._candidates=[]),this._wset))):(0,a.DB)(this._wset)}_setKnownLength(e){return e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]?e._known.length-1:e._known.length}_isInFeatureSet(e){const t=this._parent._isInFeatureSet(e);if(t===n.dj.NotInFeatureSet)return t;const r=this._idstates[e];return r===n.dj.InFeatureSet||r===n.dj.NotInFeatureSet?r:t===n.dj.InFeatureSet&&void 0===r?this._countedin<this._topnum?(this._idstates[e]=n.dj.InFeatureSet,this._countedin++,n.dj.InFeatureSet):(this._idstates[e]=n.dj.NotInFeatureSet,n.dj.NotInFeatureSet):n.dj.Unknown}_expandPagedSet(e,t,r,i,s){if(null===this._parent)return(0,a.d1)(new Error("Parent Paging not implemented"));if(t>this._topnum&&(t=this._topnum),this._countedin>=this._topnum&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset){let t=e._known.length;return t>0&&"GETPAGES"===e._known[t-1]&&(e._known.length=t-1),t=e._candidates.length,t>0&&"GETPAGES"===e._candidates[t-1]&&(e._candidates.length=t-1),(0,a.DB)("success")}return this._parent._expandPagedSet(e,t,r,i,s).then((t=>(this._setKnownLength(e)>this._topnum&&(e._known.length=this._topnum),this._setKnownLength(e)>=this._topnum&&(e._candidates.length=0),t)))}_getFeatures(e,t,r,i){const n=[],l=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,l))return this._expandPagedSet(e,l,0,0,i).then((()=>this._getFeatures(e,t,r,i)));-1!==t&&void 0===this._featureCache[t]&&n.push(t);let o=0;for(let i=e._lastFetchedIndex;i<e._known.length&&(o++,o<=r&&(e._lastFetchedIndex+=1),!(void 0===this._featureCache[e._known[i]]&&(e._known[i]!==t&&n.push(e._known[i]),n.length>l)));i++);if(0===n.length)return(0,a.DB)("success");const u=new s.Z([],n,!1,null),h=Math.min(n.length,r);return this._parent._getFeatures(u,-1,h,i).then((()=>{for(let e=0;e<h;e++){const t=this._parent._featureFromCache(n[e]);void 0!==t&&(this._featureCache[n[e]]=t)}return"success"}))}_getFilteredSet(e,t,r,i,n){return this._ensureLoaded().then((()=>this._getSet(n))).then((e=>new s.Z(e._candidates.slice(0).concat(e._known.slice(0)),[],!1,this._clonePageDefinition(e.pagesDefinition))))}_refineKnowns(e,t){let r=0,i=null;const s=[];for(let a=0;a<e._candidates.length;a++){const l=this._isInFeatureSet(e._candidates[a]);if(l===n.dj.InFeatureSet){if(e._known.push(e._candidates[a]),r+=1,null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(s.push(i),i={start:a,end:a}),e._known.length>=this._topnum)break}else if(l===n.dj.NotInFeatureSet)null===i?i={start:a,end:a}:i.end===a-1?i.end=a:(s.push(i),i={start:a,end:a}),r+=1;else if(l===n.dj.Unknown)break;if(r>=t)break}null!==i&&s.push(i);for(let t=s.length-1;t>=0;t--)e._candidates.splice(s[t].start,s[t].end-s[t].start+1);this._setKnownLength(e)>this._topnum&&(e._known=e._known.slice(0,this._topnum)),this._setKnownLength(e)>=this._topnum&&(e._candidates=[])}_stat(){return(0,a.DB)({calculated:!1})}_canDoAggregates(){return(0,a.DB)(!1)}static registerAction(){i.Z._featuresetFunctions.top=function(e){return new l({parentfeatureset:this,topnum:e})}}}},17805:(e,t,r)=>{r.d(t,{Z:()=>p});var i=r(38171),s=r(91136),n=r(90961),a=r(90658),l=r(36515),o=r(95330),u=r(9361),h=r(3121),c=r(16451),d=r(1231),f=r(57444);class p extends s.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return a.tI}end(){return this._layer}optimisePagingFeatureQueries(){}load(){return null===this._loadPromise&&(this._loadPromise=(0,o.Ue)(((e,t)=>{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then((()=>{try{this._initialiseFeatureSet(),e(this)}catch(e){t(e)}}),t),this._layer.load()}))),this._loadPromise}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType,this.fields=this._layer.fields.slice(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const i of this._overrideFields)if(i.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this._databaseType=a.Bj.Standardised,this.typeIdField=this._layer.typeIdField,this.types=this._layer.types}isTable(){return this._forceIsTable||this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return a.dj.InFeatureSet}_candidateIdTransform(e){return e}_getSet(e){return null===this._wset?this._ensureLoaded().then((()=>this._getFilteredSet("",null,null,null,e))).then((e=>(this._wset=e,e))):(0,o.DB)(this._wset)}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new i.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}_getFilteredSet(e,t,r,i,s){let u="",h=!1;if(null!==i&&(u=i.constructClause(),h=!0),this.isTable()&&t&&null!==e&&""!==e){const e=new n.Z([],[],!0,null);return(0,o.DB)(e)}const c=new f.Z;return c.where=null===r?null===t?"1=1":"":(0,l.zR)(r,a.Bj.Standardised),c.spatialRelationship=this._makeRelationshipEnum(e),c.outSpatialReference=this.spatialReference,c.orderByFields=""!==u?u.split(","):null,c.geometry=null===t?null:t,c.returnGeometry=!0,c.relationParameter=this._makeRelationshipParam(e),this._layer.queryFeatures(c).then((e=>{if(null===e)return new n.Z([],[],h,null);this._checkCancelled(s);const t=[];return e.features.forEach((e=>{const r=e.attributes[this._layer.objectIdField];t.push(r),this._featureCache[r]=this._changeFeature(e)})),new n.Z([],t,h,null)}))}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}_queryAllFeatures(){if(this._wset)return(0,o.DB)(this._wset);const e=new f.Z;return e.where="1=1",this._ensureLoaded().then((()=>{if(this._layer.source&&this._layer.source.items){const e=[];return this._layer.source.items.forEach((t=>{const r=t.attributes[this._layer.objectIdField];e.push(r),this._featureCache[r]=this._changeFeature(t)})),this._wset=new n.Z([],e,!1,null),this._wset}return this._layer.queryFeatures(e).then((e=>{const t=[];return e.features.forEach((e=>{const r=e.attributes[this._layer.objectIdField];t.push(r),this._featureCache[r]=this._changeFeature(e)})),this._wset=new n.Z([],t,!1,null),this._wset}))}))}_getFeatures(e,t,r){const i=[];-1!==t&&void 0===this._featureCache[t]&&i.push(t);for(let s=e._lastFetchedIndex;s<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[s]]&&(e._known[s]!==t&&i.push(e._known[s]),i.length>r)));s++);return 0===i.length?(0,o.DB)("success"):(0,o.d1)(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e){return(0,o.DB)(e)}_stat(){return(0,o.DB)({calculated:!1})}_canDoAggregates(){return(0,o.DB)(!1)}relationshipMetaData(){return[]}static _cloneAttr(e){const t={};for(const r in e)t[r]=e[r];return t}nativeCapabilities(){return{title:this._layer.title,canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let r=e.layerDefinition.objectIdField;const i=e.layerDefinition.typeIdField?e.layerDefinition.typeIdField:"",s=[];if(e.layerDefinition.types)for(const t of e.layerDefinition.types)s.push(c.Z.fromJSON(t));let n=e.layerDefinition.geometryType;void 0===n&&(n=e.featureSet.geometryType||"");let a=e.featureSet.features;const l=t.toJSON();if(""===r||void 0===r){let t=!1;for(const i of e.layerDefinition.fields)if("oid"===i.type||"esriFieldTypeOID"===i.type){r=i.name,t=!0;break}if(!1===t){let t="FID",i=!0,s=0;for(;i;){let r=!0;for(const i of e.layerDefinition.fields)if(i.name===t){r=!1;break}!0===r?i=!1:(s++,t="FID"+s.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});const n=[];for(let r=0;r<a.length;r++)n.push({geometry:e.featureSet.features[r].geometry,attributes:e.featureSet.features[r].attributes?this._cloneAttr(e.featureSet.features[r].attributes):{}}),n[r].attributes[t]=r;a=n,r=t}}const o=[];for(const t of e.layerDefinition.fields)t instanceof d.Z?o.push(t):o.push(d.Z.fromJSON(t));let f=n;switch(f){case"esriGeometryPoint":f="point";break;case"esriGeometryPolyline":f="polyline";break;case"esriGeometryPolygon":f="polygon";break;case"esriGeometryExtent":f="extent";break;case"esriGeometryMultipoint":f="multipoint"}for(const e of a)e.geometry&&e.geometry instanceof u.Z==0&&(e.geometry.type=f,void 0===e.geometry.spatialReference&&(e.geometry.spatialReference=l));const _={outFields:["*"],source:a,fields:o,types:s,typeIdField:i,objectIdField:r,spatialReference:t};_.geometryType=f||"point";const y=new h.default(_);return new p({layer:y,spatialReference:t,isTable:null===f||""===f})}queryAttachments(){return(0,o.DB)([])}getFeatureByObjectId(e){const t=new f.Z;return t.where=this.objectIdField+"="+e.toString(),this._layer.queryFeatures(t).then((e=>1===e.features.length?e.features[0]:null))}getOwningSystemUrl(){return(0,o.DB)("")}getIdentityUser(){return(0,o.DB)("")}}},3823:(e,t,r)=>{function i(e,t){return e===t?0:null===e?-1:null===t?1:e<t?-1:1}r.d(t,{Z:()=>s});class s{constructor(e){const t=e.split(",");this._fields=[],this._directions=[];for(let e=0;e<t.length;e++){const r=t[e].match(/\S+/g);this._fields.push(r[0]),2===r.length?"asc"===r[1].toLowerCase()?this._directions.push(1):this._directions.push(0):this._directions.push(1)}}constructClause(){let e="";for(let t=0;t<this._fields.length;t++)0!==t&&(e+=","),e+=this._fields[t],1===this._directions[t]?e+=" ASC":e+=" DESC";return e}order(e){e.sort(((e,t)=>{for(let r=0;r<this._fields.length;r++){const s=this.featureValue(e.feature,this._fields[r],r),n=this.featureValue(t.feature,this._fields[r],r);let a=0;if(a=1===this._directions[r]?i(s,n):-1*i(s,n),0!==a)return a}return 0}))}scanForField(e){for(let t=0;t<this._fields.length;t++)if(this._fields[t].toLowerCase().trim()===e.toLowerCase().trim())return!0;return!1}replaceFields(e){let t="";for(let r=0;r<this._fields.length;r++){0!==r&&(t+=",");let i=this._fields[r];for(const t of e)if(i.toLowerCase()===t.field.toLowerCase()){i=t.newfield;break}t+=i,1===this._directions[r]?t+=" ASC":t+=" DESC"}return new s(t)}featureValue(e,t,r){const i=e.attributes[t];if(void 0!==i)return i;for(const i in e.attributes)if(t.toLowerCase()===i.toLowerCase())return this._fields[r]=i,e.attributes[i];return null}}},25929:(e,t,r)=>{r.d(t,{M:()=>f,f:()=>n,i:()=>c,p:()=>_,r:()=>l,t:()=>a,w:()=>o});var i=r(70586),s=r(17452);function n(e,t){const r=t&&t.url&&t.url.path;if(e&&r&&(e=(0,s.hF)(e,r,{preserveProtocolRelative:!0}),t.portalItem&&t.readResourcePaths)){const r=(0,s.PF)(e,t.portalItem.itemUrl);h.test(r)&&t.readResourcePaths.push(t.portalItem.resourceFromPath(r).path)}return d(e,t&&t.portal)}function a(e,t,r=f.YES){if(!e)return e;!(0,s.YP)(e)&&t&&t.blockedRelativeUrls&&t.blockedRelativeUrls.push(e);let i=(0,s.hF)(e);if(t){const r=t.verifyItemRelativeUrls&&t.verifyItemRelativeUrls.rootPath||t.url&&t.url.path;if(r){const n=d(r,t.portal);i=(0,s.PF)(d(i,t.portal),n,n),i!==e&&t.verifyItemRelativeUrls&&t.verifyItemRelativeUrls.writtenUrls.push(i)}}return i=function(e,t){return t&&!t.isPortal&&t.urlKey&&t.customBaseUrl?(0,s.Ie)(e,`${t.urlKey}.${t.customBaseUrl}`,t.portalHostname):e}(i,t&&t.portal),(0,s.YP)(i)&&(i=(0,s.Fv)(i)),null!=t&&t.resources&&null!=t&&t.portalItem&&!(0,s.YP)(i)&&!(0,s.HK)(i)&&r===f.YES&&t.resources.toKeep.push({resource:t.portalItem.resourceFromPath(i)}),i}function l(e,t,r){return n(e,r)}function o(e,t,r,i){const s=a(e,i);void 0!==s&&(t[r]=s)}const u=/\/items\/([^\/]+)\/resources\//,h=/^\.\/resources\//;function c(e){const t=(0,i.pC)(e)?e.match(u):null;return(0,i.pC)(t)?t[1]:null}function d(e,t){if(!t||t.isPortal||!t.urlKey||!t.customBaseUrl)return e;const r=`${t.urlKey}.${t.customBaseUrl}`,i=(0,s.TI)();return(0,s.D6)(i,`${i.scheme}://${r}`)?(0,s.Ie)(e,t.portalHostname,r):(0,s.Ie)(e,r,t.portalHostname)}var f,p;(p=f||(f={}))[p.YES=0]="YES",p[p.NO=1]="NO";const _=Object.freeze(Object.defineProperty({__proto__:null,fromJSON:n,toJSON:a,read:l,write:o,itemIdFromResourceUrl:c,get MarkKeep(){return f}},Symbol.toStringTag,{value:"Module"}))},80539:(e,t,r)=>{r.d(t,{Z:()=>k});var i,s=r(43697),n=r(3894),a=r(32448),l=r(22974),o=r(70586),u=r(71143);!function(e){e[e.ADD=1]="ADD",e[e.REMOVE=2]="REMOVE",e[e.MOVE=4]="MOVE"}(i||(i={}));var h,c=r(1654),d=r(5600),f=r(75215),p=r(52421),_=r(52011),y=r(58971),g=r(39020);class m{constructor(){this._observers=[]}observe(e){return this._observers.includes(e)||this._observers.push(e),new g.X(this._observers,e)}notify(){const e=this._observers.slice();for(let t=0;t<e.length;++t){const r=e[t];r.onInvalidated(),r.onCommitted()}}}const b=new u.Z(class{constructor(){this.target=null,this.cancellable=!1,this.defaultPrevented=!1,this.item=void 0,this.type=void 0}preventDefault(){this.cancellable&&(this.defaultPrevented=!0)}reset(e){this.defaultPrevented=!1,this.item=e}},void 0,(e=>{e.item=null,e.target=null,e.defaultPrevented=!1,e.cancellable=!1})),S=()=>{};function w(e){return e?e instanceof A?e.toArray():e.length?Array.prototype.slice.apply(e):[]:[]}function v(e){if(e&&e.length)return e[0]}function F(e,t,r,i){const s=Math.min(e.length-r,t.length-i);let n=0;for(;n<s&&e[r+n]===t[i+n];)n++;return n}function I(e,t,r,i){t&&t.forEach(((t,s,n)=>{e.push(t),I(e,r.call(i,t,s,n),r,i)}))}const C=new Set,D=new Set,x=new Set,R=new Map;let E=0,A=h=class extends a.Z.EventedAccessor{constructor(e){super(e),this._chgListeners=[],this._notifications=null,this._timer=null,this._observable=new m,this.length=0,this._items=[],Object.defineProperty(this,"uid",{value:E++})}static isCollection(e){return null!=e&&e instanceof h}normalizeCtorArgs(e){return e?Array.isArray(e)||e instanceof h?{items:e}:e:{}}destroy(){this.removeAll()}*[Symbol.iterator](){yield*this.items}get items(){return(0,y.it)(this._observable),this._items}set items(e){this._emitBeforeChanges(i.ADD)||(this._splice(0,this.length,w(e)),this._emitAfterChanges(i.ADD))}hasEventListener(e){return"change"===e?this._chgListeners.length>0:this._emitter.hasEventListener(e)}on(e,t){if("change"===e){const e=this._chgListeners,r={removed:!1,callback:t};return e.push(r),this._notifications&&this._notifications.push({listeners:e.slice(),items:this._items.slice(),changes:[]}),{remove(){this.remove=S,r.removed=!0,e.splice(e.indexOf(r),1)}}}return this._emitter.on(e,t)}once(e,t){const r=this.on(e,t);return{remove(){r.remove()}}}add(e,t){if((0,y.it)(this._observable),this._emitBeforeChanges(i.ADD))return this;const r=this.getNextIndex(null!=t?t:null);return this._splice(r,0,[e]),this._emitAfterChanges(i.ADD),this}addMany(e,t=this._items.length){if((0,y.it)(this._observable),!e||!e.length)return this;if(this._emitBeforeChanges(i.ADD))return this;const r=this.getNextIndex(t);return this._splice(r,0,w(e)),this._emitAfterChanges(i.ADD),this}at(e){if((0,y.it)(this._observable),(e=Math.trunc(e)||0)<0&&(e+=this.length),!(e<0||e>=this.length))return this._items[e]}removeAll(){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return[];const e=this._splice(0,this.length)||[];return this._emitAfterChanges(i.REMOVE),e}clone(){return(0,y.it)(this._observable),this._createNewInstance({items:this._items.map(l.d9)})}concat(...e){(0,y.it)(this._observable);const t=e.map(w);return this._createNewInstance({items:this._items.concat(...t)})}drain(e,t){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return;const r=(0,o.j0)(this._splice(0,this.length)),s=r.length;for(let i=0;i<s;i++)e.call(t,r[i],i,r);this._emitAfterChanges(i.REMOVE)}every(e,t){return(0,y.it)(this._observable),this._items.every(e,t)}filter(e,t){let r;return(0,y.it)(this._observable),r=2===arguments.length?this._items.filter(e,t):this._items.filter(e),this._createNewInstance({items:r})}find(e,t){return(0,y.it)(this._observable),this._items.find(e,t)}findIndex(e,t){return(0,y.it)(this._observable),this._items.findIndex(e,t)}flatten(e,t){(0,y.it)(this._observable);const r=[];return I(r,this,e,t),new h(r)}forEach(e,t){return(0,y.it)(this._observable),this._items.forEach(e,t)}getItemAt(e){return(0,y.it)(this._observable),this._items[e]}getNextIndex(e){(0,y.it)(this._observable);const t=this.length;return(e=null==e?t:e)<0?e=0:e>t&&(e=t),e}includes(e,t=0){return(0,y.it)(this._observable),this._items.includes(e,t)}indexOf(e,t=0){return(0,y.it)(this._observable),this._items.indexOf(e,t)}join(e=","){return(0,y.it)(this._observable),this._items.join(e)}lastIndexOf(e,t=this.length-1){return(0,y.it)(this._observable),this._items.lastIndexOf(e,t)}map(e,t){(0,y.it)(this._observable);const r=this._items.map(e,t);return new h({items:r})}reorder(e,t=this.length-1){(0,y.it)(this._observable);const r=this.indexOf(e);if(-1!==r){if(t<0?t=0:t>=this.length&&(t=this.length-1),r!==t){if(this._emitBeforeChanges(i.MOVE))return e;this._splice(r,1),this._splice(t,0,[e]),this._emitAfterChanges(i.MOVE)}return e}}pop(){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return;const e=v(this._splice(this.length-1,1));return this._emitAfterChanges(i.REMOVE),e}push(...e){return(0,y.it)(this._observable),this._emitBeforeChanges(i.ADD)||(this._splice(this.length,0,e),this._emitAfterChanges(i.ADD)),this.length}reduce(e,t){(0,y.it)(this._observable);const r=this._items;return 2===arguments.length?r.reduce(e,t):r.reduce(e)}reduceRight(e,t){(0,y.it)(this._observable);const r=this._items;return 2===arguments.length?r.reduceRight(e,t):r.reduceRight(e)}remove(e){return(0,y.it)(this._observable),this.removeAt(this.indexOf(e))}removeAt(e){if((0,y.it)(this._observable),e<0||e>=this.length||this._emitBeforeChanges(i.REMOVE))return;const t=v(this._splice(e,1));return this._emitAfterChanges(i.REMOVE),t}removeMany(e){if((0,y.it)(this._observable),!e||!e.length||this._emitBeforeChanges(i.REMOVE))return[];const t=e instanceof h?e.toArray():e,r=this._items,s=[],n=t.length;for(let e=0;e<n;e++){const i=t[e],n=r.indexOf(i);if(n>-1){const i=1+F(t,r,e+1,n+1),a=this._splice(n,i);a&&a.length>0&&s.push.apply(s,a),e+=i-1}}return this._emitAfterChanges(i.REMOVE),s}reverse(){if((0,y.it)(this._observable),this._emitBeforeChanges(i.MOVE))return this;const e=this._splice(0,this.length);return e&&(e.reverse(),this._splice(0,0,e)),this._emitAfterChanges(i.MOVE),this}shift(){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.REMOVE))return;const e=v(this._splice(0,1));return this._emitAfterChanges(i.REMOVE),e}slice(e=0,t=this.length){return(0,y.it)(this._observable),this._createNewInstance({items:this._items.slice(e,t)})}some(e,t){return(0,y.it)(this._observable),this._items.some(e,t)}sort(e){if((0,y.it)(this._observable),!this.length||this._emitBeforeChanges(i.MOVE))return this;const t=(0,o.j0)(this._splice(0,this.length));return arguments.length?t.sort(e):t.sort(),this._splice(0,0,t),this._emitAfterChanges(i.MOVE),this}splice(e,t,...r){(0,y.it)(this._observable);const s=(t?i.REMOVE:0)|(r.length?i.ADD:0);if(this._emitBeforeChanges(s))return[];const n=this._splice(e,t,r)||[];return this._emitAfterChanges(s),n}toArray(){return(0,y.it)(this._observable),this._items.slice()}toJSON(){return(0,y.it)(this._observable),this.toArray()}toLocaleString(){return(0,y.it)(this._observable),this._items.toLocaleString()}toString(){return(0,y.it)(this._observable),this._items.toString()}unshift(...e){return(0,y.it)(this._observable),!e.length||this._emitBeforeChanges(i.ADD)||(this._splice(0,0,e),this._emitAfterChanges(i.ADD)),this.length}_createNewInstance(e){return new this.constructor(e)}_splice(e,t,r){const i=this._items,s=this.itemType;let n,a;if(!this._notifications&&this.hasEventListener("change")&&(this._notifications=[{listeners:this._chgListeners.slice(),items:this._items.slice(),changes:[]}],this._timer&&this._timer.remove(),this._timer=(0,c.Os)((()=>this._dispatchChange()))),t){if(a=i.splice(e,t),this.hasEventListener("before-remove")){const t=b.acquire();t.target=this,t.cancellable=!0;for(let r=0,s=a.length;r<s;r++)n=a[r],t.reset(n),this.emit("before-remove",t),t.defaultPrevented&&(a.splice(r,1),i.splice(e,0,n),e+=1,r-=1,s-=1);b.release(t)}if(this.length=this._items.length,this.hasEventListener("after-remove")){const e=b.acquire();e.target=this,e.cancellable=!1;const t=a.length;for(let r=0;r<t;r++)e.reset(a[r]),this.emit("after-remove",e);b.release(e)}}if(r&&r.length){if(s){const e=[];for(const t of r){const r=s.ensureType(t);null==r&&null!=t||e.push(r)}r=e}const t=this.hasEventListener("before-add"),n=this.hasEventListener("after-add"),a=e===this.length;if(t||n){const s=b.acquire();s.target=this,s.cancellable=!0;const l=b.acquire();l.target=this,l.cancellable=!1;for(const o of r)t?(s.reset(o),this.emit("before-add",s),s.defaultPrevented||(a?i.push(o):i.splice(e++,0,o),this._set("length",i.length),n&&(l.reset(o),this.emit("after-add",l)))):(a?i.push(o):i.splice(e++,0,o),this._set("length",i.length),l.reset(o),this.emit("after-add",l));b.release(l),b.release(s)}else{if(a)for(const e of r)i.push(e);else i.splice(e,0,...r);this._set("length",i.length)}}return(r&&r.length||a&&a.length)&&this._notifyChangeEvent(r,a),a}_emitBeforeChanges(e){let t=!1;if(this.hasEventListener("before-changes")){const r=b.acquire();r.target=this,r.cancellable=!0,r.type=e,this.emit("before-changes",r),t=r.defaultPrevented,b.release(r)}return t}_emitAfterChanges(e){if(this.hasEventListener("after-changes")){const t=b.acquire();t.target=this,t.cancellable=!1,t.type=e,this.emit("after-changes",t),b.release(t)}this._observable.notify()}_notifyChangeEvent(e,t){this.hasEventListener("change")&&this._notifications&&this._notifications[this._notifications.length-1].changes.push({added:e,removed:t})}_dispatchChange(){if(this._timer&&(this._timer.remove(),this._timer=null),!this._notifications)return;const e=this._notifications;this._notifications=null;for(const t of e){const e=t.changes;C.clear(),D.clear(),x.clear();for(const{added:t,removed:r}of e){if(t)if(0===x.size&&0===D.size)for(const e of t)C.add(e);else for(const e of t)D.has(e)?(x.add(e),D.delete(e)):x.has(e)||C.add(e);if(r)if(0===x.size&&0===C.size)for(const e of r)D.add(e);else for(const e of r)C.has(e)?C.delete(e):(x.delete(e),D.add(e))}const r=n.Z.acquire();C.forEach((e=>{r.push(e)}));const i=n.Z.acquire();D.forEach((e=>{i.push(e)}));const s=this._items,a=t.items,l=n.Z.acquire();if(x.forEach((e=>{a.indexOf(e)!==s.indexOf(e)&&l.push(e)})),t.listeners&&(r.length||i.length||l.length)){const e={target:this,added:r,removed:i,moved:l},s=t.listeners.length;for(let r=0;r<s;r++){const i=t.listeners[r];i.removed||i.callback.call(this,e)}}n.Z.release(r),n.Z.release(i),n.Z.release(l)}C.clear(),D.clear(),x.clear()}};A.ofType=e=>{if(!e)return h;if(R.has(e))return R.get(e);let t=null;if("function"==typeof e)t=e.prototype.declaredClass;else if(e.base)t=e.base.prototype.declaredClass;else for(const r in e.typeMap){const i=e.typeMap[r].prototype.declaredClass;t?t+=` | ${i}`:t=i}let r=class extends h{};return(0,s._)([(0,p.c)({Type:e,ensureType:"function"==typeof e?(0,f.se)(e):(0,f.N7)(e)})],r.prototype,"itemType",void 0),r=(0,s._)([(0,_.j)(`esri.core.Collection<${t}>`)],r),R.set(e,r),r},(0,s._)([(0,d.Cb)()],A.prototype,"length",void 0),(0,s._)([(0,d.Cb)()],A.prototype,"items",null),A=h=(0,s._)([(0,_.j)("esri.core.Collection")],A);const k=A},32448:(e,t,r)=>{r.d(t,{Z:()=>o});var i=r(43697),s=r(15923),n=r(50758),a=r(52011);class l{constructor(){this._emitter=new l.EventEmitter(this)}emit(e,t){return this._emitter.emit(e,t)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}hasEventListener(e){return this._emitter.hasEventListener(e)}}!function(e){class t{constructor(e=null){this.target=e,this._listenersMap=null}clear(){this._listenersMap&&this._listenersMap.clear(),this._listenersMap=null}emit(e,t){const r=this._listenersMap&&this._listenersMap.get(e);if(!r)return!1;const i=this.target||this;return[...r].forEach((e=>{e.call(i,t)})),r.length>0}on(e,t){if(Array.isArray(e)){const r=e.map((e=>this.on(e,t)));return(0,n.AL)(r)}if(e.includes(","))throw new TypeError("Evented.on() with a comma delimited string of event types is not supported");this._listenersMap||(this._listenersMap=new Map);const r=this._listenersMap.get(e)||[];return r.push(t),this._listenersMap.set(e,r),{remove:()=>{const r=this._listenersMap&&this._listenersMap.get(e)||[],i=r.indexOf(t);i>=0&&r.splice(i,1)}}}once(e,t){const r=this.on(e,(e=>{r.remove(),t.call(null,e)}));return r}hasEventListener(e){const t=this._listenersMap&&this._listenersMap.get(e);return null!=t&&t.length>0}}e.EventEmitter=t,e.EventedMixin=e=>{let r=class extends e{constructor(){super(...arguments),this._emitter=new t}destroy(){this._emitter.clear()}emit(e,t){return this._emitter.emit(e,t)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}hasEventListener(e){return this._emitter.hasEventListener(e)}};return r=(0,i._)([(0,a.j)("esri.core.Evented")],r),r};let r=class extends s.Z{constructor(){super(...arguments),this._emitter=new l.EventEmitter(this)}destroy(){this._emitter.clear()}emit(e,t){return this._emitter.emit(e,t)}on(e,t){return this._emitter.on(e,t)}once(e,t){return this._emitter.once(e,t)}hasEventListener(e){return this._emitter.hasEventListener(e)}};r=(0,i._)([(0,a.j)("esri.core.Evented")],r),e.EventedAccessor=r}(l||(l={}));const o=l},61247:(e,t,r)=>{r.d(t,{Z:()=>h});var i=r(43697),s=r(15923),n=r(80539),a=r(70586),l=r(5600),o=r(52011);let u=class extends s.Z{constructor(e){super(e),this._groups=new Map}destroy(){this.removeAll()}get size(){let e=0;return this._groups.forEach((t=>{e+=t.length})),e}add(e,t){if(!this._isHandle(e)&&!Array.isArray(e)&&!n.Z.isCollection(e))return this;const r=this._getOrCreateGroup(t);return Array.isArray(e)||n.Z.isCollection(e)?e.forEach((e=>this._isHandle(e)&&r.push(e))):r.push(e),this.notifyChange("size"),this}forEach(e,t){if("function"==typeof e)this._groups.forEach((t=>t.forEach(e)));else{const r=this._getGroup(e);r&&t&&r.forEach(t)}}has(e){return this._groups.has(this._ensureGroupKey(e))}remove(e){if(Array.isArray(e)||n.Z.isCollection(e))return e.forEach(this.remove,this),this;if(!this.has(e))return this;const t=this._getGroup(e);for(let e=0;e<t.length;e++)t[e].remove();return this._deleteGroup(e),this.notifyChange("size"),this}removeAll(){return this._groups.forEach((e=>{for(let t=0;t<e.length;t++)e[t].remove()})),this._groups.clear(),this.notifyChange("size"),this}_isHandle(e){return e&&!!e.remove}_getOrCreateGroup(e){if(this.has(e))return this._getGroup(e);const t=[];return this._groups.set(this._ensureGroupKey(e),t),t}_getGroup(e){return(0,a.j0)(this._groups.get(this._ensureGroupKey(e)))}_deleteGroup(e){return this._groups.delete(this._ensureGroupKey(e))}_ensureGroupKey(e){return e||"_default_"}};(0,i._)([(0,l.Cb)({readOnly:!0})],u.prototype,"size",null),u=(0,i._)([(0,o.j)("esri.core.Handles")],u);const h=u},69801:(e,t,r)=>{r.d(t,{WJ:()=>o,Xq:()=>l});var i,s,n=r(70586),a=r(44553);(s=i||(i={}))[s.ALL=0]="ALL",s[s.SOME=1]="SOME";class l{constructor(e,t,r){this._namespace=e,this._storage=t,this._removeFunc=!1,this._hit=0,this._miss=0,this._storage.register(this),this._namespace+=":",r&&(this._storage.registerRemoveFunc(this._namespace,r),this._removeFunc=!0)}destroy(){this._storage.clear(this._namespace),this._removeFunc&&this._storage.deregisterRemoveFunc(this._namespace),this._storage.deregister(this),this._storage=null}get namespace(){return this._namespace.slice(0,-1)}get hitRate(){return this._hit/(this._hit+this._miss)}get size(){return this._storage.size}get maxSize(){return this._storage.maxSize}resetHitRate(){this._hit=this._miss=0}put(e,t,r,i=0){this._storage.put(this._namespace+e,t,r,i)}get(e){const t=this._storage.get(this._namespace+e);return void 0===t?++this._miss:++this._hit,t}pop(e){const t=this._storage.pop(this._namespace+e);return void 0===t?++this._miss:++this._hit,t}updateSize(e,t,r){this._storage.updateSize(this._namespace+e,t,r)}clear(){this._storage.clear(this._namespace)}clearAll(){this._storage.clearAll()}getStats(){return this._storage.getStats()}resetStats(){this._storage.resetStats()}}class o{constructor(e=10485760){this._maxSize=e,this._db=new Map,this._size=0,this._hit=0,this._miss=0,this._removeFuncs=new a.Z,this._users=new a.Z}destroy(){this.clearAll(),this._removeFuncs.clear(),this._users.clear(),this._db=null}register(e){this._users.push(e)}deregister(e){this._users.removeUnordered(e)}registerRemoveFunc(e,t){this._removeFuncs.push([e,t])}deregisterRemoveFunc(e){this._removeFuncs.filterInPlace((t=>t[0]!==e))}get size(){return this._size}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=Math.max(e,0),this._checkSizeLimit()}put(e,t,r,s){const n=this._db.get(e);if(n&&(this._size-=n.size,this._db.delete(e),n.entry!==t&&this._notifyRemove(e,n.entry,i.ALL)),r>this._maxSize)return void this._notifyRemove(e,t,i.ALL);if(void 0===t)return void console.warn("Refusing to cache undefined entry ");if(!r||r<0)return void console.warn("Refusing to cache entry with invalid size "+r);const a=1+Math.max(s,-3)- -3;this._db.set(e,{entry:t,size:r,lifetime:a,lives:a}),this._size+=r,this._checkSizeLimit()}updateSize(e,t,r){const s=this._db.get(e);if(s&&s.entry===t){for(this._size-=s.size;r>this._maxSize;){const s=this._notifyRemove(e,t,i.SOME);if(!((0,n.pC)(s)&&s>0))return void this._db.delete(e);r=s}s.size=r,this._size+=r,this._checkSizeLimit()}}pop(e){const t=this._db.get(e);if(t)return this._size-=t.size,this._db.delete(e),++this._hit,t.entry;++this._miss}get(e){const t=this._db.get(e);if(void 0!==t)return this._db.delete(e),t.lives=t.lifetime,this._db.set(e,t),++this._hit,t.entry;++this._miss}getStats(){const e={Size:Math.round(this._size/1048576)+"/"+Math.round(this._maxSize/1048576)+"MB","Hit rate":Math.round(100*this._getHitRate())+"%",Entries:this._db.size.toString()},t={},r=new Array;this._db.forEach(((e,i)=>{const s=e.lifetime;r[s]=(r[s]||0)+e.size,this._users.forAll((r=>{const s=r.namespace;if(i.startsWith(s)){const r=t[s]||0;t[s]=r+e.size}}))}));const i={};this._users.forAll((e=>{const r=e.namespace;if(!isNaN(e.hitRate)&&e.hitRate>0){const s=t[r]||0;t[r]=s,i[r]=Math.round(100*e.hitRate)+"%"}else i[r]="0%"}));const s=Object.keys(t);s.sort(((e,r)=>t[r]-t[e])),s.forEach((r=>e[r]=Math.round(t[r]/2**20)+"MB / "+i[r]));for(let t=r.length-1;t>=0;--t){const i=r[t];i&&(e["Priority "+(t+-3-1)]=Math.round(i/this.size*100)+"%")}return e}resetStats(){this._hit=this._miss=0,this._users.forAll((e=>e.resetHitRate()))}clear(e){this._db.forEach(((t,r)=>{r.startsWith(e)&&(this._size-=t.size,this._db.delete(r),this._notifyRemove(r,t.entry,i.ALL))}))}clearAll(){this._db.forEach(((e,t)=>this._notifyRemove(t,e.entry,i.ALL))),this._size=0,this._db.clear()}_getHitRate(){return this._hit/(this._hit+this._miss)}_notifyRemove(e,t,r){let i;return this._removeFuncs.some((s=>{if(e.startsWith(s[0])){const e=s[1](t,r);return"number"==typeof e&&(i=e),!0}return!1})),i}_checkSizeLimit(){if(!(this._size<=this._maxSize))for(const[e,t]of this._db){if(this._db.delete(e),t.lives<=1){this._size-=t.size;const r=this._notifyRemove(e,t.entry,i.SOME);(0,n.pC)(r)&&r>0&&(this._size+=r,t.lives=t.lifetime,t.size=r,this._db.set(e,t))}else--t.lives,this._db.set(e,t);if(this._size<=.9*this.maxSize)return}}}},52421:(e,t,r)=>{function i(e){return(t,r)=>{t[r]=e}}r.d(t,{c:()=>i})},22862:(e,t,r)=>{r.d(t,{Hg:()=>_,V7:()=>p,uD:()=>f});var i=r(15923),s=r(80539),n=r(70586),a=r(1153);const l=["esri.Color","esri.portal.Portal","esri.symbols.support.Symbol3DAnchorPosition2D","esri.symbols.support.Symbol3DAnchorPosition3D"];function o(e){return e instanceof i.Z}function u(e){return e instanceof s.Z?Object.keys(e.items):o(e)?(0,a.vw)(e).keys():e?Object.keys(e):[]}function h(e,t){return e instanceof s.Z?e.items[t]:e[t]}function c(e){return e?e.declaredClass:null}function d(e,t){const r=e.diff;if(r&&"function"==typeof r)return r(e,t);const i=u(e),s=u(t);if(0===i.length&&0===s.length)return;if(!i.length||!s.length||function(e,t){return!(!Array.isArray(e)||!Array.isArray(t))&&e.length!==t.length}(e,t))return{type:"complete",oldValue:e,newValue:t};const a=s.filter((e=>!i.includes(e))),f=i.filter((e=>!s.includes(e))),p=i.filter((r=>s.includes(r)&&h(e,r)!==h(t,r))).concat(a,f).sort(),_=c(e);if(_&&l.includes(_)&&p.length)return{type:"complete",oldValue:e,newValue:t};let y;const g=o(e)&&o(t);for(const i of p){const s=h(e,i),a=h(t,i);let l;(g||"function"!=typeof s&&"function"!=typeof a)&&s!==a&&(null==s&&null==a||(l=r&&r[i]&&"function"==typeof r[i]?r[i](s,a):"object"==typeof s&&"object"==typeof a&&c(s)===c(a)?d(s,a):{type:"complete",oldValue:s,newValue:a},(0,n.pC)(l)&&((0,n.pC)(y)?y.diff[i]=l:y={type:"partial",diff:{[i]:l}})))}return y}function f(e,t){if((0,n.Wi)(e))return!1;const r=t.split(".");let i=e;for(const e of r){if("complete"===i.type)return!0;if("partial"!==i.type)return!1;{const t=i.diff[e];if(!t)return!1;i=t}}return!0}function p(e,t){for(const r of t)if(f(e,r))return!0;return!1}function _(e,t){if(!("function"==typeof e||"function"==typeof t||(0,n.Wi)(e)&&(0,n.Wi)(t)))return(0,n.Wi)(e)||(0,n.Wi)(t)||"object"==typeof e&&"object"==typeof t&&c(e)!==c(t)?{type:"complete",oldValue:e,newValue:t}:d(e,t)}},66643:(e,t,r)=>{r.d(t,{Ed:()=>n,UI:()=>a,mt:()=>o,q6:()=>l});var i=r(70586),s=r(95330);function n(e,t,r){return(0,s.as)(e.map(((e,i)=>t.apply(r,[e,i]))))}async function a(e,t,r){return(await(0,s.as)(e.map(((e,i)=>t.apply(r,[e,i]))))).map((e=>e.value))}async function l(e){if((0,i.Wi)(e))return{ok:!1,error:new Error("no promise provided")};try{return{ok:!0,value:await e}}catch(e){return{ok:!1,error:e}}}async function o(e){try{return{ok:!0,value:await e}}catch(e){return(0,s.r9)(e),{ok:!1,error:e}}}},17445:(e,t,r)=>{r.d(t,{N1:()=>d,YP:()=>o,Z_:()=>_,gx:()=>u,nn:()=>y,on:()=>c,tX:()=>g});var i=r(91460),s=r(50758),n=r(70586),a=r(95330),l=r(26258);function o(e,t,r={}){return h(e,t,r,f)}function u(e,t,r={}){return h(e,t,r,p)}function h(e,t,r={},i){let s=null;const a=r.once?(e,r)=>{i(e)&&((0,n.hw)(s),t(e,r))}:(e,r)=>{i(e)&&t(e,r)};if(s=(0,l.aQ)(e,a,r.sync,r.equals),r.initial){const t=e();a(t,t)}return s}function c(e,t,r,a={}){let l=null,u=null,h=null;function c(){l&&u&&(u.remove(),null==a.onListenerRemove||a.onListenerRemove(l),l=null,u=null)}function d(e){a.once&&a.once&&(0,n.hw)(h),r(e)}const f=o(e,((e,r)=>{c(),(0,i.vT)(e)&&(l=e,u=(0,i.on)(e,t,d),null==a.onListenerAdd||a.onListenerAdd(e))}),{sync:a.sync,initial:!0});return h=(0,s.kB)((()=>{f.remove(),c()})),h}function d(e,t){return function(e,t,r){if((0,a.Hc)(r))return Promise.reject((0,a.zE)());const i=e();if(null!=t&&t(i))return Promise.resolve(i);let l=null;function o(){l=(0,n.hw)(l)}return new Promise(((i,n)=>{l=(0,s.AL)([(0,a.fu)(r,(()=>{o(),n((0,a.zE)())})),h(e,(e=>{o(),i(e)}),{sync:!1,once:!0},null!=t?t:f)])}))}(e,p,t)}function f(e){return!0}function p(e){return!!e}r(87538);const _={sync:!0},y={initial:!0},g={sync:!0,initial:!0}},42033:(e,t,r)=>{r.d(t,{E:()=>s,_:()=>n});var i=r(70586);async function s(e,t){const{WhereClause:i}=await Promise.resolve().then(r.bind(r,41534));return i.create(e,t)}function n(e,t){return(0,i.pC)(e)?(0,i.pC)(t)?`(${e}) AND (${t})`:e:t}},60437:(e,t,r)=>{r.d(t,{Gv:()=>y,JR:()=>f,TC:()=>a,Tn:()=>h,Ue:()=>s,al:()=>n,cS:()=>d,dp:()=>o,fS:()=>_,op:()=>u,pp:()=>l,t8:()=>c});var i=r(70586);function s(e=g){return[e[0],e[1],e[2],e[3],e[4],e[5]]}function n(e,t,r,i,n,a,l=s()){return l[0]=e,l[1]=t,l[2]=r,l[3]=i,l[4]=n,l[5]=a,l}function a(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[3]),e[4]=Math.max(e[4],t[4]),e[5]=Math.max(e[5],t[5])}function l(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.min(e[2],t[2]),e[3]=Math.max(e[3],t[0]),e[4]=Math.max(e[4],t[1]),e[5]=Math.max(e[5],t[2])}function o(e,t=[0,0,0]){return t[0]=function(e){return e[0]>=e[3]?0:e[3]-e[0]}(e),t[1]=function(e){return e[1]>=e[4]?0:e[4]-e[1]}(e),t[2]=function(e){return e[2]>=e[5]?0:e[5]-e[2]}(e),t}function u(e,t,r=e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r!==e&&(r[3]=e[3],r[4]=e[4],r[5]=e[5]),r}function h(e,t,r=e){return r[3]=t[0],r[4]=t[1],r[5]=t[2],r!==e&&(r[0]=e[0],r[1]=e[1],r[2]=e[2]),e}function c(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e}function d(e){return e?c(e,y):s(y)}function f(e,t){return e[0]=t[0],e[1]=t[1],e[2]=Number.NEGATIVE_INFINITY,e[3]=t[2],e[4]=t[3],e[5]=Number.POSITIVE_INFINITY,e}function p(e){return 6===e.length}function _(e,t,r){if((0,i.Wi)(e)||(0,i.Wi)(t))return e===t;if(!p(e)||!p(t))return!1;if(r){for(let i=0;i<e.length;i++)if(!r(e[i],t[i]))return!1}else for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}r(6570),r(24470);const y=[1/0,1/0,1/0,-1/0,-1/0,-1/0],g=[0,0,0,0,0,0];s()},24470:(e,t,r)=>{r.d(t,{Gv:()=>f,HH:()=>o,SO:()=>u,Ue:()=>n,al:()=>a,jE:()=>h,kK:()=>c,oJ:()=>l,r3:()=>d}),r(80442),r(22021);var i=r(70586),s=r(6570);function n(e=p){return[e[0],e[1],e[2],e[3]]}function a(e,t,r,i,s=n()){return s[0]=e,s[1]=t,s[2]=r,s[3]=i,s}function l(e,t=n()){return t[0]=e.xmin,t[1]=e.ymin,t[2]=e.xmax,t[3]=e.ymax,t}function o(e,t){return new s.Z({xmin:e[0],ymin:e[1],xmax:e[2],ymax:e[3],spatialReference:t})}function u(e){return function(e){return(0,i.Wi)(e)||e[0]>=e[2]?0:e[2]-e[0]}(e)*function(e){return e[1]>=e[3]?0:e[3]-e[1]}(e)}function h(e,t,r){return t>=e[0]&&r>=e[1]&&t<=e[2]&&r<=e[3]}function c(e,t){return Math.max(t[0],e[0])<=Math.min(t[2],e[2])&&Math.max(t[1],e[1])<=Math.min(t[3],e[3])}function d(e,t){return t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3]}const f=[1/0,1/0,-1/0,-1/0],p=[0,0,0,0]},82526:(e,t,r)=>{r.d(t,{aX:()=>D});var i=r(68773),s=r(20102),n=r(92604),a=r(70586),l=r(38913),o=r(58901),u=r(82971),h=r(33955);const c={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new o.Z({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:u.Z.WebMercator}),minus180Line:new o.Z({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:u.Z.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new o.Z({paths:[[[180,-180],[180,180]]],spatialReference:u.Z.WGS84}),minus180Line:new o.Z({paths:[[[-180,-180],[-180,180]]],spatialReference:u.Z.WGS84})}};function d(e,t){return Math.ceil((e-t)/(2*t))}function f(e,t){const r=p(e);for(const e of r)for(const r of e)r[0]+=t;return e}function p(e){return(0,h.oU)(e)?e.rings:e.paths}var _=r(8744),y=r(40488),g=(r(66577),r(3172)),m=r(17452);function b(e){return{geometryType:(0,h.Ji)(e[0]),geometries:e.map((e=>e.toJSON()))}}const S=n.Z.getLogger("esri.geometry.support.normalizeUtils");function w(e){return"polygon"===e[0].type}function v(e){return"polyline"===e[0].type}function F(e,t,r){if(t){const t=function(e,t){if(!(e instanceof o.Z||e instanceof l.Z)){const e="straightLineDensify: the input geometry is neither polyline nor polygon";throw S.error(e),new s.Z(e)}const r=p(e),i=[];for(const e of r){const r=[];i.push(r),r.push([e[0][0],e[0][1]]);for(let i=0;i<e.length-1;i++){const s=e[i][0],n=e[i][1],a=e[i+1][0],l=e[i+1][1],o=Math.sqrt((a-s)*(a-s)+(l-n)*(l-n)),u=(l-n)/o,h=(a-s)/o,c=o/t;if(c>1){for(let e=1;e<=c-1;e++){const i=e*t,a=h*i+s,l=u*i+n;r.push([a,l])}const e=(o+Math.floor(c-1)*t)/2,i=h*e+s,a=u*e+n;r.push([i,a])}r.push([a,l])}}return function(e){return"polygon"===e.type}(e)?new l.Z({rings:i,spatialReference:e.spatialReference}):new o.Z({paths:i,spatialReference:e.spatialReference})}(e,1e6);e=(0,y.Sx)(t,!0)}return r&&(e=f(e,r)),e}function I(e,t,r){if(Array.isArray(e)){const i=e[0];if(i>t){const r=d(i,t);e[0]=i+r*(-2*t)}else if(i<r){const t=d(i,r);e[0]=i+t*(-2*r)}}else{const i=e.x;if(i>t){const r=d(i,t);e=e.clone().offset(r*(-2*t),0)}else if(i<r){const t=d(i,r);e=e.clone().offset(t*(-2*r),0)}}return e}function C(e,t){let r=-1;for(let i=0;i<t.cutIndexes.length;i++){const s=t.cutIndexes[i],n=t.geometries[i],a=p(n);for(let e=0;e<a.length;e++){const t=a[e];t.some((r=>{if(r[0]<180)return!0;{let r=0;for(let e=0;e<t.length;e++){const i=t[e][0];r=i>r?i:r}r=Number(r.toFixed(9));const i=-360*d(r,180);for(let r=0;r<t.length;r++){const t=n.getPoint(e,r);n.setPoint(e,r,t.clone().offset(i,0))}return!0}}))}if(s===r){if(w(e))for(const t of p(n))e[s]=e[s].addRing(t);else if(v(e))for(const t of p(n))e[s]=e[s].addPath(t)}else r=s,e[s]=n}return e}async function D(e,t,r){var s;if(!Array.isArray(e))return D([e],t);t&&"string"!=typeof t&&S.warn("normalizeCentralMeridian()","The url object is deprecated, use the url string instead");const n="string"==typeof t?t:null!=(s=null==t?void 0:t.url)?s:i.Z.geometryServiceUrl;let u,p,w,v,x,R,E,A,k=0;const T=[],N=[];for(const t of e)if((0,a.Wi)(t))N.push(t);else if(u||(u=t.spatialReference,p=(0,_.C5)(u),w=u.isWebMercator,R=w?102100:4326,v=c[R].maxX,x=c[R].minX,E=c[R].plus180Line,A=c[R].minus180Line),p)if("mesh"===t.type)N.push(t);else if("point"===t.type)N.push(I(t.clone(),v,x));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map((e=>I(e,v,x))),N.push(e)}else if("extent"===t.type){const e=t.clone()._normalize(!1,!1,p);N.push(e.rings?new l.Z(e):e)}else if(t.extent){const e=t.extent,r=d(e.xmin,x)*(2*v);let i=0===r?t.clone():f(t.clone(),r);e.offset(r,0),e.intersects(E)&&e.xmax!==v?(k=e.xmax>k?e.xmax:k,i=F(i,w),T.push(i),N.push("cut")):e.intersects(A)&&e.xmin!==x?(k=e.xmax*(2*v)>k?e.xmax*(2*v):k,i=F(i,w,360),T.push(i),N.push("cut")):N.push(i)}else N.push(t.clone());else N.push(t);let L=d(k,v),P=-90;const O=L,B=new o.Z;for(;L>0;){const e=360*L-180;B.addPath([[e,P],[e,-1*P]]),P*=-1,L--}if(T.length>0&&O>0){const t=C(T,await async function(e,t,r,i){const s="string"==typeof e?(0,m.mN)(e):e,n=t[0].spatialReference,a={...i,query:{...s.query,f:"json",sr:JSON.stringify(n),target:JSON.stringify({geometryType:(0,h.Ji)(t[0]),geometries:t}),cutter:JSON.stringify(r)}},l=await(0,g.default)(s.path+"/cut",a),{cutIndexes:o,geometries:u=[]}=l.data;return{cutIndexes:o,geometries:u.map((e=>{const t=(0,h.im)(e);return t.spatialReference=n,t}))}}(n,T,B,r)),i=[],s=[];for(let r=0;r<N.length;r++){const n=N[r];if("cut"!==n)s.push(n);else{const n=t.shift(),l=e[r];(0,a.pC)(l)&&"polygon"===l.type&&l.rings&&l.rings.length>1&&n.rings.length>=l.rings.length?(i.push(n),s.push("simplify")):s.push(w?(0,y.$)(n):n)}}if(!i.length)return s;const l=await async function(e,t,r){const i="string"==typeof e?(0,m.mN)(e):e,s=t[0].spatialReference,n=(0,h.Ji)(t[0]),a={...r,query:{...i.query,f:"json",sr:s.wkid?s.wkid:JSON.stringify(s),geometries:JSON.stringify(b(t))}};return function(e,t,r){const i=(0,h.q9)(t);return e.map((e=>{const t=i.fromJSON(e);return t.spatialReference=r,t}))}((await(0,g.default)(i.path+"/simplify",a)).data,n,s)}(n,i,r),o=[];for(let e=0;e<s.length;e++){const t=s[e];"simplify"!==t?o.push(t):o.push(w?(0,y.$)(l.shift()):l.shift())}return o}const j=[];for(let e=0;e<N.length;e++){const t=N[e];if("cut"!==t)j.push(t);else{const e=T.shift();j.push(!0===w?(0,y.$)(e):e)}}return j}},69285:(e,t,r)=>{r.d(t,{k:()=>a});var i=r(70586),s=r(67900),n=r(8744);function a(e,t,r){if((0,i.Wi)(t)||(0,i.Wi)(r)||r.vcsWkid||(0,n.fS)(t,r))return null;const a=(0,s._R)(t)/(0,s._R)(r);if(1===a)return null;switch(e){case"point":case"esriGeometryPoint":return e=>function(e,t){e&&null!=e.z&&(e.z*=t)}(e,a);case"polyline":case"esriGeometryPolyline":return e=>function(e,t){if(e)for(const r of e.paths)for(const e of r)e.length>2&&(e[2]*=t)}(e,a);case"polygon":case"esriGeometryPolygon":return e=>function(e,t){if(e)for(const r of e.rings)for(const e of r)e.length>2&&(e[2]*=t)}(e,a);case"multipoint":case"esriGeometryMultipoint":return e=>function(e,t){if(e)for(const r of e.points)r.length>2&&(r[2]*=t)}(e,a);case"extent":case"esriGeometryExtent":return e=>function(e,t){e&&null!=e.zmin&&null!=e.zmax&&(e.zmin*=t,e.zmax*=t)}(e,a);default:return null}}},54295:(e,t,r)=>{r.d(t,{V:()=>a});var i=r(43697),s=r(5600),n=(r(67676),r(80442),r(75215),r(52011));const a=e=>{let t=class extends e{get apiKey(){var e;return this._isOverridden("apiKey")?this._get("apiKey"):function(e){return"portalItem"in e}(this)?null==(e=this.portalItem)?void 0:e.apiKey:null}set apiKey(e){null!=e?this._override("apiKey",e):(this._clearOverride("apiKey"),this.clear("apiKey","user"))}};return(0,i._)([(0,s.Cb)({type:String})],t.prototype,"apiKey",null),t=(0,i._)([(0,n.j)("esri.layers.mixins.APIKeyMixin")],t),t}},17287:(e,t,r)=>{r.d(t,{Y:()=>u});var i=r(43697),s=r(92604),n=r(70586),a=r(5600),l=(r(67676),r(80442),r(75215),r(52011)),o=r(66677);const u=e=>{let t=class extends e{get title(){if(this._get("title")&&"defaults"!==this.originOf("title"))return this._get("title");if(this.url){const e=(0,o.Qc)(this.url);if((0,n.pC)(e)&&e.title)return e.title}return this._get("title")||""}set title(e){this._set("title",e)}set url(e){this._set("url",(0,o.Nm)(e,s.Z.getLogger(this.declaredClass)))}};return(0,i._)([(0,a.Cb)()],t.prototype,"title",null),(0,i._)([(0,a.Cb)({type:String})],t.prototype,"url",null),t=(0,i._)([(0,l.j)("esri.layers.mixins.ArcGISService")],t),t}},16859:(e,t,r)=>{r.d(t,{I:()=>S});var i=r(43697),s=r(40330),n=r(3172),a=r(66643),l=r(20102),o=r(92604),u=r(70586),h=r(95330),c=r(17452),d=r(5600),f=(r(67676),r(80442),r(75215),r(71715)),p=r(52011),_=r(30556),y=r(65587),g=r(15235),m=r(86082);const b=o.Z.getLogger("esri.layers.mixins.PortalLayer"),S=e=>{let t=class extends e{constructor(){super(...arguments),this.resourceReferences={portalItem:null,paths:[]},this.userHasEditingPrivileges=!0}destroy(){var e;null==(e=this.portalItem)||e.destroy(),this.portalItem=null}set portalItem(e){e!==this._get("portalItem")&&(this.removeOrigin("portal-item"),this._set("portalItem",e))}readPortalItem(e,t,r){if(t.itemId)return new g.default({id:t.itemId,portal:r&&r.portal})}writePortalItem(e,t){e&&e.id&&(t.itemId=e.id)}async loadFromPortal(e,t){if(this.portalItem&&this.portalItem.id)try{const i=await r.e(8062).then(r.bind(r,18062));return(0,h.k_)(t),await i.load({instance:this,supportedTypes:e.supportedTypes,validateItem:e.validateItem,supportsData:e.supportsData},t)}catch(e){throw(0,h.D_)(e)||b.warn(`Failed to load layer (${this.title}, ${this.id}) portal item (${this.portalItem.id})\n ${e}`),e}}async finishLoadEditablePortalLayer(e){this._set("userHasEditingPrivileges",await this._fetchUserHasEditingPrivileges(e).catch((e=>((0,h.r9)(e),!0))))}async _fetchUserHasEditingPrivileges(e){const t=this.url?null==s.id?void 0:s.id.findCredential(this.url):null;if(!t)return!0;const r=w.credential===t?w.user:await this._fetchEditingUser(e);return w.credential=t,w.user=r,(0,u.Wi)(r)||null==r.privileges||r.privileges.includes("features:user:edit")}async _fetchEditingUser(e){var t,r;const i=null==(t=this.portalItem)||null==(r=t.portal)?void 0:r.user;if(i)return i;const l=s.id.findServerInfo(this.url);if(null==l||!l.owningSystemUrl)return null;const o=`${l.owningSystemUrl}/sharing/rest`,h=y.Z.getDefault();if(h&&h.loaded&&(0,c.Fv)(h.restUrl)===(0,c.Fv)(o))return h.user;const d=`${o}/community/self`,f=(0,u.pC)(e)?e.signal:null,p=await(0,a.q6)((0,n.default)(d,{authMode:"no-prompt",query:{f:"json"},signal:f}));return p.ok?m.default.fromJSON(p.value.data):null}read(e,t){t&&(t.layer=this),super.read(e,t)}write(e,t){const r=t&&t.portal,i=this.portalItem&&this.portalItem.id&&(this.portalItem.portal||y.Z.getDefault());return r&&i&&!(0,c.tm)(i.restUrl,r.restUrl)?(t.messages&&t.messages.push(new l.Z("layer:cross-portal",`The layer '${this.title} (${this.id})' cannot be persisted because it refers to an item on a different portal than the one being saved to. To save, set layer.portalItem to null or save to the same portal as the item associated with the layer`,{layer:this})),null):super.write(e,{...t,layer:this})}};return(0,i._)([(0,d.Cb)({type:g.default})],t.prototype,"portalItem",null),(0,i._)([(0,f.r)("web-document","portalItem",["itemId"])],t.prototype,"readPortalItem",null),(0,i._)([(0,_.c)("web-document","portalItem",{itemId:{type:String}})],t.prototype,"writePortalItem",null),(0,i._)([(0,d.Cb)({clonable:!1})],t.prototype,"resourceReferences",void 0),(0,i._)([(0,d.Cb)({readOnly:!0})],t.prototype,"userHasEditingPrivileges",void 0),t=(0,i._)([(0,p.j)("esri.layers.mixins.PortalLayer")],t),t},w={credential:null,user:null}},56765:(e,t,r)=>{r.d(t,{Z:()=>h});var i,s=r(43697),n=r(80539),a=r(96674),l=r(5600),o=(r(67676),r(80442),r(75215),r(52011));let u=i=class extends a.wq{constructor(e){super(e),this.floorField=null,this.viewAllMode=!1,this.viewAllLevelIds=new n.Z}clone(){return new i({floorField:this.floorField,viewAllMode:this.viewAllMode,viewAllLevelIds:this.viewAllLevelIds})}};(0,s._)([(0,l.Cb)({type:String,json:{write:!0}})],u.prototype,"floorField",void 0),(0,s._)([(0,l.Cb)({json:{read:!1,write:!1}})],u.prototype,"viewAllMode",void 0),(0,s._)([(0,l.Cb)({json:{read:!1,write:!1}})],u.prototype,"viewAllLevelIds",void 0),u=i=(0,s._)([(0,o.j)("esri.layers.support.LayerFloorInfo")],u);const h=u},66677:(e,t,r)=>{r.d(t,{B5:()=>c,DR:()=>f,G:()=>S,M8:()=>y,Nm:()=>g,Qc:()=>d,XG:()=>m,a7:()=>_,ld:()=>p,wH:()=>b});var i=r(70586),s=r(17452),n=r(25929);const a={mapserver:"MapServer",imageserver:"ImageServer",featureserver:"FeatureServer",sceneserver:"SceneServer",streamserver:"StreamServer",vectortileserver:"VectorTileServer"},l=Object.values(a),o=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/rest\\/services\\/(.+?)\\/(${l.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),u=new RegExp(`^((?:https?:)?\\/\\/\\S+?\\/([^\\/\\n]+)\\/(${l.join("|")}))(?:\\/(?:layers\\/)?(\\d+))?`,"i"),h=/(.*?)\/(?:layers\/)?(\d+)\/?$/i;function c(e){return!!o.test(e)}function d(e){const t=(0,s.mN)(e),r=t.path.match(o)||t.path.match(u);if(!r)return null;const[,i,n,l,h]=r,c=n.indexOf("/");return{title:p(-1!==c?n.slice(c+1):n),serverType:a[l.toLowerCase()],sublayer:null!=h&&""!==h?parseInt(h,10):null,url:{path:i}}}function f(e){const t=(0,s.mN)(e).path.match(h);return t?{serviceUrl:t[1],sublayerId:Number(t[2])}:null}function p(e){return(e=e.replace(/\s*[/_]+\s*/g," "))[0].toUpperCase()+e.slice(1)}function _(e,t){const r=[];if(e){const t=d(e);(0,i.pC)(t)&&t.title&&r.push(t.title)}if(t){const e=p(t);r.push(e)}if(2===r.length){if(r[0].toLowerCase().includes(r[1].toLowerCase()))return r[0];if(r[1].toLowerCase().includes(r[0].toLowerCase()))return r[1]}return r.join(" - ")}function y(e){if(!e)return!1;const t=(e=e.toLowerCase()).includes(".arcgis.com/"),r=e.includes("//services")||e.includes("//tiles")||e.includes("//features");return t&&r}function g(e,t){return e?(0,s.Qj)((0,s.Hu)(e,t)):e}function m(e){let{url:t}=e;if(!t)return{url:t};t=(0,s.Hu)(t,e.logger);const r=(0,s.mN)(t),n=d(r.path);let a;if((0,i.pC)(n))null!=n.sublayer&&null==e.layer.layerId&&(a=n.sublayer),t=n.url.path;else if(e.nonStandardUrlAllowed){const e=f(r.path);(0,i.pC)(e)&&(t=e.serviceUrl,a=e.sublayerId)}return{url:(0,s.Qj)(t),layerId:a}}function b(e,t,r,i,a){(0,n.w)(t,i,"url",a),i.url&&null!=e.layerId&&(i.url=(0,s.v_)(i.url,r,e.layerId.toString()))}function S(e){if(!e)return!1;const t=e.toLowerCase(),r=t.includes("/services/"),i=t.includes("/mapserver/wmsserver"),s=t.includes("/imageserver/wmsserver"),n=t.includes("/wmsserver");return r&&(i||s||n)}},41818:(e,t,r)=>{r.d(t,{P:()=>a});var i=r(11282),s=r(34599),n=r(57444);async function a(e,t,r){const a=(0,i.en)(e);return(0,s.executeQueryForCount)(a,n.Z.from(t),{...r}).then((e=>e.data.count))}},5396:(e,t,r)=>{r.d(t,{G:()=>a});var i=r(11282),s=r(34599),n=r(57444);async function a(e,t,r){const a=(0,i.en)(e);return(0,s.executeQueryForIds)(a,n.Z.from(t),{...r}).then((e=>e.data.objectIds))}},4967:(e,t,r)=>{r.d(t,{F:()=>o,e:()=>l});var i=r(11282),s=r(34599),n=r(74889),a=r(57444);async function l(e,t,r){const i=await o(e,t,r);return n.default.fromJSON(i)}async function o(e,t,r){const n=(0,i.en)(e),l={...r},o=a.Z.from(t),{data:u}=await(0,s.executeQuery)(n,o,o.sourceSpatialReference,l);return u}},98326:(e,t,r)=>{r.d(t,{Z:()=>c});var i,s=r(43697),n=r(96674),a=r(5600),l=(r(67676),r(80442),r(75215)),o=r(52011);const u={1:{id:1,rotation:0,mirrored:!1},2:{id:2,rotation:0,mirrored:!0},3:{id:3,rotation:180,mirrored:!1},4:{id:4,rotation:180,mirrored:!0},5:{id:5,rotation:-90,mirrored:!0},6:{id:6,rotation:90,mirrored:!1},7:{id:7,rotation:90,mirrored:!0},8:{id:8,rotation:-90,mirrored:!1}};let h=i=class extends n.wq{constructor(e){super(e),this.contentType=null,this.exifInfo=null,this.id=null,this.globalId=null,this.keywords=null,this.name=null,this.parentGlobalId=null,this.parentObjectId=null,this.size=null,this.url=null}get orientationInfo(){const{exifInfo:e}=this,t=function(e){const{exifInfo:t,exifName:r,tagName:i}=e;if(!t||!r||!i)return null;const s=t.find((e=>e.name===r));return s?function(e){const{tagName:t,tags:r}=e;if(!r||!t)return null;const i=r.find((e=>e.name===t));return i&&i.value||null}({tagName:i,tags:s.tags}):null}({exifName:"Exif IFD0",tagName:"Orientation",exifInfo:e});return u[t]||null}clone(){return new i({contentType:this.contentType,exifInfo:this.exifInfo,id:this.id,globalId:this.globalId,keywords:this.keywords,name:this.name,parentGlobalId:this.parentGlobalId,parentObjectId:this.parentObjectId,size:this.size,url:this.url})}};(0,s._)([(0,a.Cb)({type:String})],h.prototype,"contentType",void 0),(0,s._)([(0,a.Cb)()],h.prototype,"exifInfo",void 0),(0,s._)([(0,a.Cb)({readOnly:!0})],h.prototype,"orientationInfo",null),(0,s._)([(0,a.Cb)({type:l.z8})],h.prototype,"id",void 0),(0,s._)([(0,a.Cb)({type:String})],h.prototype,"globalId",void 0),(0,s._)([(0,a.Cb)({type:String})],h.prototype,"keywords",void 0),(0,s._)([(0,a.Cb)({type:String})],h.prototype,"name",void 0),(0,s._)([(0,a.Cb)({json:{read:!1}})],h.prototype,"parentGlobalId",void 0),(0,s._)([(0,a.Cb)({json:{read:!1}})],h.prototype,"parentObjectId",void 0),(0,s._)([(0,a.Cb)({type:l.z8})],h.prototype,"size",void 0),(0,s._)([(0,a.Cb)({json:{read:!1}})],h.prototype,"url",void 0),h=i=(0,s._)([(0,o.j)("esri.layers.support.AttachmentInfo")],h);const c=h},11282:(e,t,r)=>{r.d(t,{cv:()=>l,en:()=>a,lA:()=>n});var i=r(22974),s=r(17452);function n(e,t){return t?{...t,query:{...e,...t.query}}:{query:e}}function a(e){return"string"==typeof e?(0,s.mN)(e):(0,i.d9)(e)}function l(e,t,r){const i={};for(const s in e){if("declaredClass"===s)continue;const n=e[s];if(null!=n&&"function"!=typeof n)if(Array.isArray(n)){i[s]=[];for(let e=0;e<n.length;e++)i[s][e]=l(n[e])}else if("object"==typeof n)if(n.toJSON){const e=n.toJSON(r&&r[s]);i[s]=t?e:JSON.stringify(e)}else i[s]=t?n:JSON.stringify(n);else i[s]=n}return i}},58333:(e,t,r)=>{r.d(t,{ET:()=>n,I4:()=>s,eG:()=>o,lF:()=>a,lj:()=>h,qP:()=>l,wW:()=>u});const i=[252,146,31,255],s={type:"esriSMS",style:"esriSMSCircle",size:6,color:i,outline:{type:"esriSLS",style:"esriSLSSolid",width:.75,color:[153,153,153,255]}},n={type:"esriSLS",style:"esriSLSSolid",width:.75,color:i},a={type:"esriSFS",style:"esriSFSSolid",color:[252,146,31,196],outline:{type:"esriSLS",style:"esriSLSSolid",width:.75,color:[255,255,255,191]}},l={type:"esriTS",color:[255,255,255,255],font:{family:"arial-unicode-ms",size:10,weight:"bold"},horizontalAlignment:"center",kerning:!0,haloColor:[0,0,0,255],haloSize:1,rotated:!1,text:"",xoffset:0,yoffset:0,angle:0},o={type:"esriSMS",style:"esriSMSCircle",color:[0,0,0,255],outline:null,size:10.5},u={type:"esriSLS",style:"esriSLSSolid",color:[0,0,0,255],width:1.5},h={type:"esriSFS",style:"esriSFSSolid",color:[0,0,0,255],outline:null}}}]);