// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("exports ../request ./featureSetCollection ../chunks/languageUtils ./featureset/actions/AttributeFilter ./featureset/actions/GroupBy ./featureset/actions/OrderBy ./featureset/actions/SpatialFilter ./featureset/actions/Top ./featureset/sources/FeatureLayerDynamic ./featureset/sources/FeatureLayerMemory ./featureset/sources/FeatureLayerRelated ./featureset/support/cache ./featureset/support/errorsupport ./featureset/support/shared ../core/Loadable ../core/sql/WhereClause ../layers/FeatureLayer ../layers/Layer ../portal/PortalItem".split(" "), function(p,v,x,y,F,G,H,I,J,K,L,M,k,z,t,A,B,r,N,O){async function u(a,d,b){if(k.applicationCache){if(b=k.applicationCache.getLayerInfo(a))return b=await b,new r({url:a,outFields:d,sourceJSON:b});const c=new r({url:a,outFields:d});d=(async()=>{await c.load();return c.sourceJSON})();if(k.applicationCache){k.applicationCache.setLayerInfo(a,d);try{return await d,c}catch(e){throw k.applicationCache.clearLayerInfo(a),e;}}await d;return c}if(null!=b){const c=b.getCachedLayerMetadata(a);if(c)return b=await c, new r({url:a,outFields:d,sourceJSON:b});const e=new r({url:a,outFields:d});d=(async()=>{await e.load();return e.sourceJSON})();b.setCachedLayerMetadata(a,d);try{return await d,e}catch(f){throw b.removeCachedLayerMetadata(a,d),f;}}return new r({url:a,outFields:d})}async function w(a,d,b,c,e,f=null){a=await u(a,["*"],e);return l(a,d,b,c,e,f)}function l(a,d=null,b=null,c=!0,e=null,f=null){if("catalog-footprint"===a.type)return l(a.parent,d,b,c,e,f);if("subtype-sublayer"===a.type)return d=l(a.parent, d,b,c,e,f),d.filter(B.WhereClause.create(a.parent.subtypeField+"\x3d"+a.subtypeCode.toString(),a.parent.fieldsIndex,d.dateFieldsTimeZoneDefaultUTC));if(t.isSupportedSourceLayer(a))return d={layer:a,spatialReference:d,outFields:b,includeGeometry:c,lrucache:e,interceptor:f},!0===!(a.url||!a.source)?new L(d):new K(d);throw Error(`Unsupported layer type: ${a.type}`);}async function P(a){if(null!==k.applicationCache){var d=k.applicationCache.getLayerInfo(a);if(null!==d)return d}d=(async()=>{const b=await v(a, {responseType:"json",query:{f:"json"}});return b.data?b.data:null})();if(null!==k.applicationCache){k.applicationCache.setLayerInfo(a,d);try{return await d}catch(b){throw k.applicationCache.clearLayerInfo(a),b;}}return d}async function Q(a,d){const b="QUERYDATAELEMTS:"+d.toString()+":"+a;if(null!==k.applicationCache){var c=k.applicationCache.getLayerInfo(b);if(null!==c)return c}c=(async()=>{var e=await v(a+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([d.toString()]), f:"json"}});if(e.data&&(e=e.data,e.layerDataElements?.[0]))return e.layerDataElements[0];throw new z.FeatureSetError(z.FeatureSetErrorCodes.DataElementsNotFound);})();if(null!==k.applicationCache){k.applicationCache.setLayerInfo(b,c);try{return await c}catch(e){throw k.applicationCache.clearLayerInfo(b),e;}}return c}async function C(a,d){if(null!==k.applicationCache){var b=k.applicationCache.getLayerInfo(a);if(null!==b)return b}if(null!=d&&(b=d.getCachedServiceMetadata(a),null!=b))return b;b=(async()=> {var c=await v(a,{responseType:"json",query:{f:"json"}});return c.data?(c=c.data,c.layers||(c.layers=[]),c.tables||(c.tables=[]),c):{layers:[],tables:[]}})();if(null!==k.applicationCache){k.applicationCache.setLayerInfo(a,b);try{return await b}catch(c){throw k.applicationCache.clearLayerInfo(a),c;}}if(null!=d){d.setCachedServiceMetadata(a,b);try{return await b}catch(c){throw d.removeCachedServiceMetadata(a,b),c;}}return b}F.registerAction();G.registerAction();H.registerAction();I.registerAction(); J.registerAction();class R extends x{constructor(a,d=null,b=null,c=null){super();this._map=a;this._overridespref=d;this._lrucache=b;this._interceptor=c;this._instantLayers=[]}_makeAndAddFeatureSet(a,d=!0,b=null){const c=l(a,this._overridespref,null===b?["*"]:b,d,this._lrucache,this._interceptor);this._instantLayers.push({featureset:c,opitem:a,includeGeometry:d,outFields:JSON.stringify(b)});return c}async featureSetByName(a,d=!0,b=null){if(A.isLoadable(this._map)&&!this._map.loaded)return await this._map.load(), this.featureSetByName(a,d,b);null===b&&(b=["*"]);b=b.slice(0);b=b.sort();var c=JSON.stringify(b);for(let e=0;et.isSupportedLayer(e)&&e.title===a);if(null!=c)return this._makeAndAddFeatureSet(c,d,b);if(this._map.tables&&(c=this._map.tables.find(e=>e.title===a),null!=c)){if(c instanceof r)return this._makeAndAddFeatureSet(c, d,b);null==c._materializedTable&&(c._materializedTable=new r(c.outFields?c:{...c,outFields:["*"]}));await c._materializedTable.load();return this._makeAndAddFeatureSet(c._materializedTable,d,b)}return null}async featureSetById(a,d=!0,b=["*"]){if(A.isLoadable(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(a,d,b);null===b&&(b=["*"]);b=b.slice(0);b=b.sort();var c=JSON.stringify(b);for(let e=0;et.isSupportedLayer(e)&&e.id===a))return this._makeAndAddFeatureSet(c,d,b);if(this._map.tables&&(c=this._map.tables.find(e=>e.id===a),null!=c)){if(c instanceof r)return this._makeAndAddFeatureSet(c,d,b);null==c._materializedTable&&(c._materializedTable=new r({...c,outFields:["*"]}));await c._materializedTable.load();return this._makeAndAddFeatureSet(c._materializedTable,d,b)}return null}} class D extends x{constructor(a,d=null,b=null,c=null){super();this._url=a;this._overridespref=d;this._lrucache=b;this._interceptor=c;this.metadata=null;this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(a,d=!0,b=null){const c=l(a,this._overridespref,null===b?["*"]:b,d,this._lrucache);this._instantLayers.push({featureset:c,opitem:a,includeGeometry:d,outFields:JSON.stringify(b)});return c}async _loadMetaData(){const a=await C(this._url,this._lrucache);return this.metadata=a}load(){return this._loadMetaData()}clone(){return new D(this._url, this._overridespref,this._lrucache,this._interceptor)}async featureSetByName(a,d=!0,b=null){null===b&&(b=["*"]);b=b.slice(0);b=b.sort();var c=JSON.stringify(b);for(var e=0;e