(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-57e02c98"],{"2cad":function(e,t,r){"use strict";r.d(t,"a",(function(){return g})),r.d(t,"b",(function(){return p})),r.d(t,"c",(function(){return f})),r.d(t,"d",(function(){return y})),r.d(t,"e",(function(){return _}));var i=r("8d60"),s=r("8549"),a=r("4f73"),n=r("64fc"),l=r("853c"),o=r("07c7d"),u=r("f4cc"),d=r("66a2"),h=r("5996");class c{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class f extends c{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 c{constructor(e,t,r){super(Object(l["c"])(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=r}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:Object(o["g"])(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class _ extends c{constructor(e,t,r){super(e),this.codefield=t,this.lkp=r,this.reverseLkp={};for(const i in r)this.reverseLkp[r[i]]=i;this.sqlRewritable=!0}rewriteSql(e,t){const r=this.evaluateNodeToWhereClause(e.parseTree,l["a"].Standardised,this.field.name,this.codefield instanceof d["WhereClause"]?Object(o["i"])(this.codefield,l["a"].Standardised):this.codefield,e.parameters);return r.indexOf(_.BADNESS)>=0?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:d["WhereClause"].create(r,t._parent.getFieldsIndex())}}evaluateNodeToWhereClause(e,t,r=null,i=null,s){let a,n,l,u;switch(e.type){case"interval":return Object(o["b"])(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 a=0;a":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 Object(o["d"])(e.value,t);case"number":return e.value.toString();case"current_time":return Object(o["e"])("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 Object(o["k"])(e.name,i,t)}}throw new Error("Unsupported sql syntax "+e.type)}extractValue(e){return this.codefield instanceof d["WhereClause"]?this.reverseLkp[this.codefield.calculateValueCompiled(e)]:this.reverseLkp[e.attributes[this.codefield]]}}_.BADNESS="_!!!_BAD_LKP_!!!!";class y extends c{constructor(e,t){super(e),this.sql=t}rewriteSql(e,t){return{rewritten:!0,where:Object(o["g"])(e,this.field.name,Object(o["i"])(this.sql,l["a"].Standardised),t.getFieldsIndex())}}extractValue(e){return this.sql.calculateValueCompiled(e)}}class g extends a["a"]{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 h["a"]({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=l["m"].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 n["a"](t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset)):Object(u["t"])(this._wset)}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,r,a){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,a).then(()=>this._getFeatures(e,t,r,a));let d=0;for(let i=e._lastFetchedIndex;i=o)));i++);if(0===l.length)return Object(u["t"])("success");e=new n["a"]([],l,e._ordered,null);const h=Math.min(l.length,r);return this._parent._getFeatures(e,-1,h,a).then(()=>{this._checkCancelled(a);const e=[];for(let t=0;t0&&(i=i.replaceFields(e))}return null!==r?null!==this._extraFilter&&(r=Object(o["a"])(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===a?new n["a"](e._candidates.slice(0).concat(e._known.slice(0)),[],!0===u&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new n["a"](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===Object(o["h"])(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,a,n){let l=!1,d=this._reformulateWithoutAdaptions(t);return l=d.cannot,t=d.where,d=this._reformulateWithoutAdaptions(s),l=l||d.cannot,null!==(s=d.where)?null!==this._extraFilter&&(s=Object(o["a"])(this._extraFilter,s)):s=this._extraFilter,!0===l?null===s&&""===r&&null===i?this._manualStat(e,t,a,n):Object(u["t"])({calculated:!1}):this._parent._stat(e,t,r,i,s,a,n).then(l=>!1===l.calculated?null===s&&""===r&&null===i?this._manualStat(e,t,a,n):{calculated:!1}:l)}_canDoAggregates(e,t,r,i,s){if(null===this._parent)return Object(u["t"])(!1);for(let l=0;l{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then(()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}},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=n["a"].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 n["b"].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)):Object(o["t"])(this._wset)}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new i["a"]({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}_getFilteredSet(e,t,r,i,s){let u="",d=!1;if(null!==i&&(u=i.constructClause(),d=!0),this.isTable()&&t&&null!==e&&""!==e){const e=new a["a"]([],[],!0,null);return Object(o["t"])(e)}const h=new f["a"];return h.where=null===r?null===t?"1=1":"":Object(l["i"])(r,n["a"].Standardised),h.spatialRelationship=this._makeRelationshipEnum(e),h.outSpatialReference=this.spatialReference,h.orderByFields=""!==u?u.split(","):null,h.geometry=null===t?null:t,h.returnGeometry=!0,h.relationParameter=this._makeRelationshipParam(e),this._layer.queryFeatures(h).then(e=>{if(null===e)return new a["a"]([],[],d,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 a["a"]([],t,d,null)})}_makeRelationshipEnum(e){if(e.indexOf("esriSpatialRelRelation")>=0)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.indexOf("esriSpatialRelRelation")>=0?e.split(":")[1]:""}_queryAllFeatures(){if(this._wset)return Object(o["t"])(this._wset);const e=new f["a"];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 a["a"]([],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 a["a"]([],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;sr)));s++);return 0===i.length?Object(o["t"])("success"):Object(o["s"])(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e){return Object(o["t"])(e)}_stat(){return Object(o["t"])({calculated:!1})}_canDoAggregates(){return Object(o["t"])(!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 u of e.layerDefinition.types)s.push(h["a"].fromJSON(u));let a=e.layerDefinition.geometryType;void 0===a&&(a=e.featureSet.geometryType||"");let n=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 a=[];for(let r=0;r1===e.features.length?e.features[0]:null)}getOwningSystemUrl(){return Object(o["t"])("")}getIdentityUser(){return Object(o["t"])("")}}},"5db9":function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var i=r("89da"),s=r("4f73"),a=r("64fc"),n=r("96af"),l=r("f4cc");class o extends s["a"]{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)):Object(l["t"])(this._wset)}manualOrderSet(e,t){return this.getIdColumnDictionary(e,[],-1,t).then(e=>{this._orderbyclause.order(e);const t=new a["a"]([],[],!0,null);for(let r=0;rthis.getIdColumnDictionary(e,t,r,s));let n=r+1;const l=[];for(;n{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?Object(i["y"])(this._refineSetBlock(e,this._maxProcessingRate(),s)).then(()=>(this._checkCancelled(s),this.getIdColumnDictionary(e,t,r,s))):Object(l["t"])(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 Object(l["s"])(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 a["a"](e._candidates.slice(0),e._known.slice(0),e._ordered,this._clonePageDefinition(e.pagesDefinition));let n=!0;return e._candidates.length>0&&(n=!1),!1===i._ordered?this.manualOrderSet(i,s).then(e=>(!1===n&&(null===t&&null===r||(e=new a["a"](e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e)):i})}static registerAction(){s["a"]._featuresetFunctions.orderBy=function(e){return""===e?this:new o({parentfeatureset:this,orderbyclause:new n["a"](e)})}}}},"60fd":function(e,t,r){"use strict";r.d(t,"a",(function(){return l}));var i=r("4f73"),s=r("64fc"),a=r("853c"),n=r("f4cc");class l extends i["a"]{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["a"](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)):Object(n["t"])(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===a["b"].NotInFeatureSet)return t;const r=this._idstates[e];return r===a["b"].InFeatureSet||r===a["b"].NotInFeatureSet?r:t===a["b"].InFeatureSet&&void 0===r?this._countedinthis._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),Object(n["t"])("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 a=[],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]&&a.push(t);let o=0;for(let s=e._lastFetchedIndex;sl)));s++);if(0===a.length)return Object(n["t"])("success");const u=new s["a"]([],a,!1,null),d=Math.min(a.length,r);return this._parent._getFeatures(u,-1,d,i).then(()=>{for(let e=0;ethis._getSet(a)).then(e=>new s["a"](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 n=0;n=this._topnum)break}else if(l===a["b"].NotInFeatureSet)null===i?i={start:n,end:n}:i.end===n-1?i.end=n:(s.push(i),i={start:n,end:n}),r+=1;else if(l===a["b"].Unknown)break;if(r>=t)break}null!==i&&s.push(i);for(let a=s.length-1;a>=0;a--)e._candidates.splice(s[a].start,s[a].end-s[a].start+1);this._setKnownLength(e)>this._topnum&&(e._known=e._known.slice(0,this._topnum)),this._setKnownLength(e)>=this._topnum&&(e._candidates=[])}_stat(){return Object(n["t"])({calculated:!1})}_canDoAggregates(){return Object(n["t"])(!1)}static registerAction(){i["a"]._featuresetFunctions.top=function(e){return new l({parentfeatureset:this,topnum:e})}}}},"7efa":function(e,t,r){"use strict";r.d(t,"a",(function(){return m})),r.d(t,"b",(function(){return i}));const i={Base64:0,Hex:1,String:2,Raw:3},s=8,a=(1<>16)+(t>>16)+(r>>16)<<16|65535&r}function l(e){const t=[];for(let r=0,i=e.length*s;r>5]|=(e.charCodeAt(r/s)&a)<>5]>>>r%32&a));return t.join("")}function u(e){const t="0123456789abcdef",r=[];for(let i=0,s=4*e.length;i>2]>>i%4*8+4&15)+t.charAt(e[i>>2]>>i%4*8&15));return r.join("")}function d(e){const t="=",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=[];for(let s=0,a=4*e.length;s>2]>>s%4*8&255)<<16|(e[s+1>>2]>>(s+1)%4*8&255)<<8|e[s+2>>2]>>(s+2)%4*8&255;for(let n=0;n<4;n++)8*s+6*n>32*e.length?i.push(t):i.push(r.charAt(a>>6*(3-n)&63))}return i.join("")}function h(e,t){return e<>>32-t}function c(e,t,r,i,s,a){return n(h(n(n(t,e),n(i,a)),s),r)}function f(e,t,r,i,s,a,n){return c(t&r|~t&i,e,t,s,a,n)}function p(e,t,r,i,s,a,n){return c(t&i|r&~i,e,t,s,a,n)}function _(e,t,r,i,s,a,n){return c(t^r^i,e,t,s,a,n)}function y(e,t,r,i,s,a,n){return c(r^(t|~i),e,t,s,a,n)}function g(e,t){e[t>>5]|=128<>>9<<4)]=t;let r=1732584193,i=-271733879,s=-1732584194,a=271733878;for(let l=0;l{for(let r=0;rthis._parent._getFilteredSet("",null,this._whereclause,null,e)).then(t=>(this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new s["a"](t._candidates.slice(0).concat(t._known.slice(0)),[],t._ordered,this._clonePageDefinition(t.pagesDefinition)):this._wset=new s["a"](t._candidates.slice(0),t._known.slice(0),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset)):Object(l["t"])(this._wset)}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);return t===a["b"].NotInFeatureSet?t:(t=this._idstates[e],void 0===t?a["b"].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 Object(l["o"])(t)?t:Object(l["t"])(t)}catch(t){return Object(l["s"])(t)}return Object(l["t"])(this.executeWhereClause(e))}_fetchAndRefineFeatures(e,t,r){const i=new s["a"]([],e,!1,null),n=Math.min(t,e.length);return this._parent._getFeatures(i,-1,n,r).then(()=>{if(this._checkCancelled(r),null==this._whereClauseFunction){for(let t=0;t{for(let i=0;ithis._parent._getFilteredSet(e,t,r,i,a)).then(e=>{let t;return this._checkCancelled(a),t=null!==this._whereClauseFunction?new s["a"](e._candidates.slice(0).concat(e._known.slice(0)),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)):new s["a"](e._candidates.slice(0),e._known.slice(0),e._ordered,this._clonePageDefinition(e.pagesDefinition)),t})}_stat(e,t,r,i,s,a,o){if(null!==this._whereClauseFunction)return null===s&&""===r&&null===i?this._manualStat(e,t,a,o):Object(l["t"])({calculated:!1});let u=this._whereclause;return null!==s&&null!==this._whereclause&&(u=Object(n["a"])(this._whereclause,s)),this._parent._stat(e,t,r,i,u,a,o).then(n=>!1===n.calculated?null===s&&""===r&&null===i?this._manualStat(e,t,a,o):{calculated:!1}:n)}_canDoAggregates(e,t,r,i,s){return null!==this._whereClauseFunction?Object(l["t"])(!1):(null!==s?null!==this._whereclause&&(s=Object(n["a"])(this._whereclause,s)):s=this._whereclause,null===this._parent?Object(l["t"])(!1):this._parent._canDoAggregates(e,t,r,i,s))}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,a,o){return null===this._parent?Object(l["s"])(new Error("Should never be called")):(null!==s?null!==this._whereclause&&(s=Object(n["a"])(this._whereclause,s)):s=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(e,t,r,i,s,a,o))}static registerAction(){i["a"]._featuresetFunctions.filter=function(e){if("function"==typeof e)return new d({parentfeatureset:this,whereclause:e});let t=null;return e instanceof o["WhereClause"]&&(t=e),new d({parentfeatureset:this,whereclause:t})}}}},e335:function(e,t,r){"use strict";r.r(t),r.d(t,"constructAssociationMetaDataFeatureSetFromUrl",(function(){return re})),r.d(t,"constructFeatureSet",(function(){return Y})),r.d(t,"constructFeatureSetFromPortalItem",(function(){return he})),r.d(t,"constructFeatureSetFromRelationship",(function(){return ie})),r.d(t,"constructFeatureSetFromUrl",(function(){return X})),r.d(t,"convertToFeatureSet",(function(){return de})),r.d(t,"createFeatureSetCollectionFromMap",(function(){return ne})),r.d(t,"createFeatureSetCollectionFromService",(function(){return le})),r.d(t,"getPortal",(function(){return oe})),r.d(t,"initialiseMetaDataCache",(function(){return Z})),r.d(t,"lookupUser",(function(){return ue}));var i=r("f7be"),s=r("2eab"),a=r("94dc"),n=r("9c2d"),l=r("8d60"),o=r("89da"),u=r("2cad"),d=r("5db9"),h=r("4f73"),c=r("64fc"),f=r("96af"),p=r("853c"),_=r("07c7d"),y=r("b1dc"),g=r("66a2");function m(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(Object(_["j"])(e.parseTree.args.value[0],p["a"].Standardised,e.parameters),e.fieldsIndex);return{name:e.parseTree.name,expr:t}}return null}class b{clone(){const e=new b;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 b;i.field=e;const s=g["WhereClause"].create(t,r),a=m(s);if(null===a)throw new Error("Invalid Statistic Function");const n=a.name.toUpperCase().trim();if("MIN"===n){if(i.typeofstat="MIN",i.workingexpr=a.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("MAX"===n){if(i.typeofstat="MAX",i.workingexpr=a.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("COUNT"===n)i.typeofstat="COUNT",i.workingexpr=a.expr;else if("STDEV"===n){if(i.typeofstat="STDDEV",i.workingexpr=a.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("SUM"===n){if(i.typeofstat="SUM",i.workingexpr=a.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("MEAN"===n){if(i.typeofstat="AVG",i.workingexpr=a.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else if("AVG"===n){if(i.typeofstat="AVG",i.workingexpr=a.expr,null===s)throw new Error("Invalid Statistic Function Parameters")}else{if("VAR"!==n)throw new Error("Invalid Statistic Function");if(i.typeofstat="VAR",i.workingexpr=a.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"}}}var F=r("7efa"),w=r("f4cc"),S=r("5996"),I=r("a1f3"),O=r("80b7");function C(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 j extends h["a"]{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)):Object(w["t"])(this._wset)}_isInFeatureSet(){return p["b"].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 O["a"]([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t0)for(const a of this._parent.fields)this._adaptedFields.push(new u["c"](a));for(let a=0;athis._getFeatures(e,t,r,i)):Object(w["t"])("success")}_getFilteredSet(e,t,r,i,s){if(""!==e)return Object(w["t"])(new c["a"]([],[],!0,null));let a=null;const l={ordered:!1,nowhereclause:!1};return this._ensureLoaded().then(()=>{if(null!==r)for(let e=0;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),a=!0===l.nowhereclause?new c["a"](e._candidates.slice(0).concat(e._known.slice(0)),[],!0===l.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)):new c["a"](e._candidates.slice(0),e._known.slice(0),!0===l.ordered&&e._ordered,this._clonePageDefinition(e.pagesDefinition)),a))}let t=this._parent;if(this._adaptedFields.length>0&&(t=new u["a"]({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===l.nowhereclause)a=new c["a"](["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new d["a"]({parentfeatureset:t,orderbyclause:new f["a"](this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=t;if(null!==r){let t=null;r&&(t=this._reformulateWhereClauseWithoutGroupByFields(r)),e=new n["a"]({parentfeatureset:e,whereclause:t})}a=new c["a"](["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new d["a"]({parentfeatureset:e,orderbyclause:new f["a"](this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return a})}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=Object(_["g"])(e,t.tofieldname,Object(_["i"])(t.workingexpr,p["a"].Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=Object(_["g"])(e,t.tofieldname,Object(_["i"])(t.expression,p["a"].Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const r of this._decodedGroupbyfield)r.tofieldname!==r.name&&t.push({field:r.tofieldname,newfield:r.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{if(!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery))return this._expandPagedSet(e,this._maxQuery,0,0,r).then(()=>this._refineSetBlock(e,t,r));this._checkCancelled(r);e._candidates.length;return this._refineKnowns(e,t),e._candidates.length,e._candidates.length,Object(w["t"])(e)}catch(i){return Object(w["s"])(i)}}_expandPagedSet(e,t,r,i,s){return this._expandPagedSetFeatureSet(e,t,r,i,s)}_getPhysicalPage(e,t,r){return!0===e.pagesDefinition.aggregatefeaturesetpagedefinition?Object(w["d"])((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["a"](e)}return e.length})}_sequentialGetPhysicalItem(e,t,r,i){return Object(w["d"])((s,a)=>{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,a=>{null===a?s(i.length):(t-=1,s(this._sequentialGetPhysicalItem(e,t,r,i)))},a)})}_nextAggregateItem(e,t,r,i,s,a){try{Object(o["y"])(e.pagesDefinition.internal.iterator.next()).then(n=>{if(null===n)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(n);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[n],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:[n],id:l},void s(r)}e.pagesDefinition.internal.workingItem.features.push(n)}this._nextAggregateItem(e,t,r,i,s,a)}},a)}catch(n){a(n)}}_calculateFieldStat(e,t,r){const i=[];for(let s=0;s{try{if(!0===this._layer.loaded)return this._initialiseFeatureSet(),void e(this);this._layer.when().then(()=>{try{this._initialiseFeatureSet(),e(this)}catch(r){t(r)}},t),this._layer.load()}catch(r){t(r)}})),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["a"].StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=p["a"].Standardised)):null!=e&&(e>=10.5&&(this._databaseType=p["a"].StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=p["a"].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["b"].InFeatureSet}_refineSetBlock(e){return Object(w["t"])(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)):Object(w["t"])(this._wset)}_runDatabaseProbe(e){return Object(w["d"])((t,r)=>{try{this._ensureLoaded().then(()=>{try{const i=new P["a"];i.where=e.replace("OBJECTID",this._layer.objectIdField),this._layer.queryObjectIds(i).then(()=>{t(!0)},()=>{try{t(!1)}catch(e){r(e)}})}catch(i){r(i)}})}catch(i){r(i)}})}_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"},Object(E["executeQueryPBF"])(this._layer.parsedUrl,e,new B["b"]({})).then(e=>q["default"].fromJSON(Object(T["k"])(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?L["a"]:"executeForCount"===t?N["a"]:A["a"],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(a=>{if(this.isTable()&&t&&null!==e&&""!==e)return new c["a"]([],[],!0,null);if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,i,s);let n="",l=!1;null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=i.constructClause(),l=!0);const o=new P["a"];return o.where=null===r?null===t?"1=1":"":Object(_["i"])(r,a),this._requestStandardised&&(o.sqlFormat="standard"),o.spatialRelationship=this._makeRelationshipEnum(e),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==n?n.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 c["a"]([],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 a="",n=!1;return null!==i&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=i.constructClause(),n=!0),this.databaseType().then(i=>{let l=null===r?null===t?"1=1":"":Object(_["i"])(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&&ud)})}catch(a){return Object(w["s"])(a)}}_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,a=new P["a"];return this._requestStandardised&&(a.sqlFormat="standard"),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference,this.executeQuery(a,"execute").then(a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return"done";for(let t=0;t-1)return t;let r=!1;for(const i of t)if(i.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=this._maxProcessingRate()-1))break}if(n>=r&&0===s.length)break}if(0===s.length)return Object(w["t"])("success");try{const e=new P["a"];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 Object(w["s"])(new Error(e.error));for(let t=0;tthis.databaseType()).then(u=>{let d=r.parseTree.column;for(let e=0;e{if(this._checkCancelled(o),!u.hasOwnProperty("features"))return Object(w["s"])(new Error("Unnexected Result querying statistics from layer"));let h=!1;for(let e=0;e=n)break}return 0===u.features.length?l:u.features.length===this._layer.capabilities.query.maxRecordCount&&l.length({calculated:!0,result:e})):l})})}_distinctStat(e,t,r,i,s,a,n){return this._getDistinctPages(0,e,t,r,i,s,a,[],n).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 P["a"];if(this._requestStandardised&&(s.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===i?null===r?"1=1":"":Object(_["i"])(i,e);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),s.where=a,s.where=a,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,a,n){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===Object(_["c"])(t)&&!1===l||!1===t.isStandardized?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):"distinct"===e?!1===u?""!==r||null!==s?{calculated:!1}:this._manualStat(e,t,a,n):this._distinctStat(e,t,r,i,s,a,n):this.databaseType().then(a=>{if(this.isTable()&&i&&null!==r&&""!==r)return{calculated:!0,result:null};const n=new P["a"];this._requestStandardised&&(n.sqlFormat="standard");let l=null===s?null===i?"1=1":"":Object(_["i"])(s,a);this._layer.definitionExpression&&this._useDefinitionExpression&&(l=""!==l?"(("+this._layer.definitionExpression+") AND ("+l+"))":this._layer.definitionExpression),n.where=l,n.spatialRelationship=this._makeRelationshipEnum(r),n.relationParameter=this._makeRelationshipParam(r),n.geometry=null===i?null:i;const o=new U["a"];o.statisticType=Object(y["c"])(e),o.onStatisticField=Object(_["i"])(t,a),o.outStatisticFieldName="ARCADE_STAT_RESULT",n.returnGeometry=!1;let u="ARCADE_STAT_RESULT";return n.outStatistics=[o],this.executeQuery(n,"execute").then(e=>{if(!e.hasOwnProperty("features")||0===e.features.length)return Object(w["s"])(new Error("Unnexected Result querying statistics from layer"));let t=!1;for(let r=0;r{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=0)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.indexOf("esriSpatialRelRelation")>=0?e.split(":")[1]:""}_getAggregatePagesDataSourceDefinition(e,t,r,i,s,a,n){return this._ensureLoaded().then(()=>this.databaseType()).then(l=>{let o="",u=!1,d=!1;null!==a&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(o=a.constructClause(),d=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(d=!1,u=!0,o=this._layer.objectIdField);const h=[];for(let e=0;e"+e.pagesDefinition.internal.lastMaxId.toString()+")":e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString());const i=e.pagesDefinition.internal.lastRetrieved,s=i,a=e.pagesDefinition.internal.lastPage,n=new P["a"];return this._requestStandardised&&(n.sqlFormat="standard"),n.where=t,n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields,n.outStatistics=e.pagesDefinition.outStatistics,n.geometry=e.pagesDefinition.geometry,n.groupByFieldsForStatistics=e.pagesDefinition.groupByFieldsForStatistics,n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.returnGeometry=e.pagesDefinition.returnGeometry,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,this.isTable()&&n.geometry&&n.spatialRelationship?Object(w["t"])([]):this.executeQuery(n,"execute").then(t=>{if(this._checkCancelled(r),!t.hasOwnProperty("features"))return Object(w["s"])(new Error("Unnexected Result querying aggregates from layer"));const n=[];if(e.pagesDefinition.internal.lastPage!==a)return[];for(let r=0;r0||r&&r>0)&&(a.size=[t&&t>0?t:0,r&&r>0?r:t+1]),i&&i.length>0&&(a.attachmentTypes=i),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:a,method:"attachments"}),this._layer.queryAttachments(a).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 a=null;s&&t.exifInfo&&(a=W["a"].convertJsonToArcade(t.exifInfo,!0)),r.push(new R["a"](t.id,t.name,t.contentType,t.size,i,a))}),r})}return Object(w["t"])([])}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"}),Object(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,a=[];for(const t of i.relatedRecords){t.geometry&&(t.geometry.spatialReference=e);const r=new l["a"]({geometry:t.geometry?Object(x["a"])(t.geometry):null,attributes:t.attributes});a.push(r)}t[s]={features:a,exceededTransferLimit:!0===r.exceededTransferLimit}}}return t}return Object(w["s"])("Invalid Request")})}getFeatureByObjectId(e,t){const r=new P["a"];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"}),Object(L["a"])(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["b"])?void 0:e.findCredential(this._layer.url);return t?t.userId:null})}getOwningSystemUrl(){return this.load().then(()=>{var e;const t=null==(e=i["b"])?void 0:e.findServerInfo(this._layer.url);if(t)return Object(w["t"])(t.owningSystemUrl);let r=this._layer.url;const a=r.toLowerCase().indexOf("/rest/services");return r=a>-1?r.substring(0,a):r,r?(r+="/rest/info",Object(w["d"])((e,t)=>{Object(s["default"])(r,{query:{f:"json"}}).then(t=>{let r="";t.data&&t.data.owningSystemUrl&&(r=t.data.owningSystemUrl),e(r)},t=>{e("")})})):Object(w["t"])("")})}getDataSourceFeatureSet(){const e=new M({layer:this._layer,spatialReference:this.spatialReference,outFields:this._overrideFields,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries,interceptor:this.featureSetQueryInterceptor});return e._useDefinitionExpression=!1,e}}var Q=r("3802");class V extends h["a"]{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["f"]}end(){return this._layer}optimisePagingFeatureQueries(){}load(){return null===this._loadPromise&&(this._loadPromise=Object(w["d"])((e,t)=>{Object(w["b"])([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["b"].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)):Object(w["t"])(this._wset)}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new l["a"]({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 c["a"]([],[],!0,null);const a=this._layer.nativeCapabilities();if(!1===a.canQueryRelated)return new c["a"]([],[],!0,null);if(a.capabilities.queryRelated&&a.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,i,s);let n="",l=!1;null!==i&&a.capabilities&&a.capabilities.queryRelated&&!0===a.capabilities.queryRelated.supportsOrderBy&&(n=i.constructClause(),l=!0);const o=new G["a"];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 d=!0;return!0===this._removeGeometry&&(d=!1),o.returnGeometry=d,this._requestStandardised&&(o.sqlFormat="standard"),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==n?n.split(","):null,a.source.queryRelatedFeatures(o).then(i=>{this._checkCancelled(s);const a=i[this._findObjectId]?i[this._findObjectId].features:[],n=[];for(let e=0;e-1)return t;let r=!1;for(const i of t)if(i.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}_getFilteredSetUsingPaging(e,t,r,i,s){try{let a="",n=!1;const l=this._layer.nativeCapabilities();return null!==i&&l&&l.capabilities.queryRelated&&!0===l.capabilities.queryRelated.supportsOrderBy&&(a=i.constructClause(),n=!0),this.databaseType().then(()=>{const i="1=1";let o=this._maxQueryRate();const u=l.capabilities.query.maxRecordCount;void 0!==u&&ue.name):["*"]);return f=new c["a"](d||h?["GETPAGES"]:[],d||h?[]:["GETPAGES"],n,{outFields:_.join(","),resultRecordCount:o,resultOffset:0,objectIds:[this._findObjectId],where:i,orderByFields:a,returnGeometry:p,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),this._expandPagedSet(f,o,0,0,s).then(()=>f)})}catch(a){return Object(w["s"])(a)}}_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,a=this._layer.nativeCapabilities(),n=new G["a"];return!0===this._requestStandardised&&(n.sqlFormat="standard"),n.relationshipId=this.relationship.id,n.objectIds=e.pagesDefinition.objectIds,n.resultOffset=e.pagesDefinition.internal.lastPage,n.resultRecordCount=e.pagesDefinition.resultRecordCount,n.outFields=e.pagesDefinition.outFields.split(","),n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference,a.source.queryRelatedFeatures(n).then(a=>{if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==s)return 0;const n=a[this._findObjectId]?a[this._findObjectId].features:[];for(let t=0;tthis._getFeatures(e,t,r,i));let n=0;for(let l=e._lastFetchedIndex;lr)))&&!(n>=r&&0===s.length);l++);return 0===s.length?Object(w["t"])("success"):Object(w["s"])(new Error("Unaccounted for Features. Not in Feature Collection"))}_refineSetBlock(e,t,r){return Object(w["t"])(e)}_stat(e,t,r,i,s,a,n){return Object(w["t"])({calculated:!1})}get gdbVersion(){return this.relatedLayer.gdbVersion}_canDoAggregates(e,t,r,i,s){return Object(w["t"])(!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 J=r("1fbd"),K=r("0224"),z=r("a7e1");function Z(){null===J["a"].applicationCache&&(J["a"].applicationCache=new J["a"])}function H(e,t){if(J["a"].applicationCache){const r=J["a"].applicationCache.getLayerInfo(e);if(r)return r.then(r=>Object(w["t"])(new k["default"]({url:e,outFields:t,sourceJSON:r})));const i=new k["default"]({url:e,outFields:t});let s=Object(w["d"])((e,t)=>{i.load().then(()=>{e(i.sourceJSON)},e=>{t(e)})});return J["a"].applicationCache&&(J["a"].applicationCache.setLayerInfo(e,s),s=s.catch(t=>{throw J["a"].applicationCache.clearLayerInfo(e),t})),s.then(()=>Object(w["t"])(i))}return Object(w["t"])(new k["default"]({url:e,outFields:t}))}function X(e,t,r,i,s,a=null){return H(e,["*"]).then(e=>Object(w["t"])(Y(e,t,r,i,s,a)))}function Y(e,t=null,r=null,i=!0,s=null,a=null){return!0===e._hasMemorySource()?new Q["a"]({layer:e,spatialReference:t,outFields:r,includeGeometry:i,lrucache:s,interceptor:a}):new M({layer:e,spatialReference:t,outFields:r,includeGeometry:i,lrucache:s,interceptor:a})}function $(e){if(null!==J["a"].applicationCache){const t=J["a"].applicationCache.getLayerInfo(e);if(null!==t)return t}let t=Object(s["default"])(e,{responseType:"json",query:{f:"json"}}).then(e=>{if(e.data){const t=e.data;return Object(w["t"])(t)}return Object(w["t"])(null)});return null!==J["a"].applicationCache&&(J["a"].applicationCache.setLayerInfo(e,t),t=t.catch(t=>{throw J["a"].applicationCache.clearLayerInfo(e),t})),t}function ee(e,t){const r="QUERYDATAELEMTS:"+t.toString()+":"+e;if(null!==J["a"].applicationCache){const e=J["a"].applicationCache.getLayerInfo(r);if(null!==e)return e}let i=Object(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!==J["a"].applicationCache&&(J["a"].applicationCache.setLayerInfo(r,i),i=i.catch(e=>{throw J["a"].applicationCache.clearLayerInfo(r),e})),i}function te(e){if(null!==J["a"].applicationCache){const t=J["a"].applicationCache.getLayerInfo(e);if(null!==t)return t}let t=Object(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=[]),Object(w["t"])(t)}return Object(w["t"])({layers:[],tables:[]})});return null!==J["a"].applicationCache&&(J["a"].applicationCache.setLayerInfo(e,t),t=t.catch(t=>{throw J["a"].applicationCache.clearLayerInfo(e),t})),t}function re(e,t){const r={metadata:null,networkId:-1,unVersion:3,terminals:[],queryelem:null,layerNameLkp:{},lkp:null};return te(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 s=i.controllerDatasetLayers.utilityNetworkLayerId;return r.networkId=s,ee(e,s).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 $(e+"/"+s).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")),X(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 ie(e,t,r,i=null,s=null,a=!0,n=null,l=null){let o=e.serviceUrl();return o?(o="/"===o.charAt(o.length-1)?o+t.relatedTableId.toString():o+"/"+t.relatedTableId.toString(),X(o,i,s,a,n,l).then(o=>new V({layer:e,relatedLayer:o,relationship:t,objectId:r,spatialReference:i,outFields:s,includeGeometry:a,lrucache:n,interceptor:l}))):null}n["a"].registerAction(),j.registerAction(),d["a"].registerAction(),v["a"].registerAction(),D["a"].registerAction();class se extends a["a"]{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=Y(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(i){return Object(w["s"])(i)}});null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let a=0;at instanceof k["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 k["default"])return this.resolvePromise(this._makeAndAddFeatureSet(i,t,r));if(i._materializedTable);else{const e=i.outFields?i:{...i,outFields:["*"]};i._materializedTable=new k["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(i){return Object(w["s"])(i)}});null===r&&(r=["*"]),r=(r=r.slice(0)).sort();const i=JSON.stringify(r);for(let a=0;at instanceof k["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 k["default"])return this.resolvePromise(this._makeAndAddFeatureSet(i,t,r));if(i._materializedTable);else{const e={...i,outFields:["*"]};i._materializedTable=new k["default"](e)}return i._materializedTable.load().then(()=>this.resolvePromise(this._makeAndAddFeatureSet(i._materializedTable,t,r)))}}return this.resolvePromise(null)}}class ae extends a["a"]{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=Y(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 te(this._url).then(e=>(this.metadata=e,e))}load(){return this._loadMetaData()}clone(){return new ae(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 s=0;s{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?H(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 s=0;s{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?H(this._url+"/"+s.id,["*"]).then(e=>this._makeAndAddFeatureSet(e,t,r)):this.resolvePromise(null)})}}function ne(e,t,r=null,i=null){return new se(e,t,r,i)}function le(e,t,r=null,i=null){return new ae(e,t,r,i)}function oe(e,t){return null===e?t:new K["a"]({url:e.field("url")})}function ue(e,t,r){return i["b"].findCredential(e.restUrl)?"loaded"===e.loadStatus&&""===t&&e.user&&e.user.sourceJSON&&!1===r?Object(w["t"])(e.user.sourceJSON):""===t?Object(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 Object(w["t"])(t)}return Object(w["t"])(null)}):Object(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:Object(w["t"])(t)}return Object(w["t"])(null)}):Object(w["t"])(null)}function de(e,t,r,i,s){if(null===e)return null;if(e instanceof k["default"]){switch(t){case"datasource":return Y(e,s,e.outFields,!0,r,i).getDataSourceFeatureSet();case"parent":case"root":return Y(e,s,e.outFields,!0,r,i)}return null}if(e instanceof h["a"])switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}function he(e,t,r,i,s,a,n,l=null){if(J["a"].applicationCache){const o=J["a"].applicationCache.getLayerInfo(e+":"+a.url);if(o)return o.then(e=>{try{const a=new k["default"]({url:Object(p["i"])(e.url)+"/"+t,outFields:["*"]});return Object(w["t"])(Y(a,r,i,s,n,l))}catch(a){return Object(w["s"])(a)}},e=>Object(w["s"])(e))}return Object(w["d"])((o,u)=>{const d=new z["default"]({id:e,portal:a}).load();J["a"].applicationCache&&J["a"].applicationCache.setLayerInfo(e+":"+a.url,d),d.then(e=>{try{const a=new k["default"]({url:Object(p["i"])(e.url)+"/"+t,outFields:["*"]});o(Y(a,r,i,s,n,l))}catch(a){u(a)}},t=>{J["a"].applicationCache&&J["a"].applicationCache.clearLayerInfo(e+":"+a.url),u(t)})})}}}]); //# sourceMappingURL=chunk-57e02c98.e3fb1b53.js.map