// All material copyright ESRI, All Rights Reserved, unless otherwise specified.// See https://js.arcgis.com/4.6/esri/copyright.txt for details.//>>builtdefine("require exports ../core/tsSupport/declareExtendsHelper ../core/tsSupport/decorateHelper ../core/tsSupport/paramHelper ../core/accessorSupport/decorators dojo/_base/lang ../request ./Task ./support/FeatureSet ./support/Query ../geometry ../geometry/support/jsonUtils ../geometry/support/normalizeUtils".split(" "),function(x,y,t,h,k,g,f,l,u,q,m,v,w,n){returnfunction(r){functiond(a){a=r.call(this,a)||this;a.gdbVersion=null;a.source=null;returna}t(d,r);p=d;d.queryToQueryStringParameters=function(a){vare=a.geometry;a=a.toJSON();e&&(a.geometry=JSON.stringify(e),a.geometryType=w.getJsonType(e),a.inSR=e.spatialReference.wkid||JSON.stringify(e.spatialReference));a.groupByFieldsForStatistics&&(a.groupByFieldsForStatistics=a.groupByFieldsForStatistics.join(","));a.objectIds&&(a.objectIds=a.objectIds.join(","));a.orderByFields&&(a.orderByFields=a.orderByFields.join(","));a.outFields&&(a.outFields=a.outFields.join(","));a.outSR?a.outSR=a.outSR.wkid||JSON.stringify(a.outSR):e&&(a.returnGeometry||a.returnCentroid)&&(a.outSR=a.inSR);a.returnGeometry&&deletea.returnGeometry;a.outStatistics&&(a.outStatistics=JSON.stringify(a.outStatistics));a.pixelSize&&(a.pixelSize=JSON.stringify(a.pixelSize));a.quantizationParameters&&(a.quantizationParameters=JSON.stringify(a.quantizationParameters));a.timeExtent&&(e=a.timeExtent,a.time=[null!=e.startTime?e.startTime:"null",null!=e.endTime?e.endTime:"null"],deletea.timeExtent);returna};d.prototype.execute=function(a,e){varb=this;returnthis.rawExecute(a,e).then(function(a){returnb._handleExecuteResponse(a)})};d.prototype.rawExecute=function(a,e){varb=this;returnn.normalizeCentralMeridian(a.geometry?[a.geometry]:[]).then(function(c){c=b._encode(f.mixin({},b.parsedUrl.query,{f:"json"},b._normalizeQuery(a,c&&c[0])));if(b.source){vard={source:b.source.toJSON()};c.layer=JSON.stringify(d)}b.gdbVersion&&(c.gdbVersion=b.gdbVersion);c={query:c,callbackParamName:"callback"};if(b.requestOptions||e)c=f.mixin({},b.requestOptions,e,c);returnl(b.parsedUrl.path+"/query",c)})};d.prototype.executeRelationshipQuery=function(a,e){a=this._encode(f.mixin({},this.parsedUrl.query,{f:"json"},a.toJSON()));this.gdbVersion&&(a.gdbVersion=this.gdbVersion);a={query:a,callbackParamName:"callback"};if(this.requestOptions||e)a=f.mixin({},this.requestOptions,e,a);returnl(this.parsedUrl.path+"/queryRelatedRecords",a).then(this._handleExecuteRelationshipQueryResponse)};d.prototype.executeForIds=function(a,e){varb=this;returnn.normalizeCentralMeridian(a.geometry?[a.geometry]:[]).then(function(c){c=b._encode(f.mixin({},b.parsedUrl.query,{f:"json",returnIdsOnly:!0},b._normalizeQuery(a,c&&c[0])));if(b.source){vard={source:b.source.toJSON()};c.layer=JSON.stringify(d)}b.gdbVersion&&(c.gdbVersion=b.gdbVersion);c={query:c,callbackParamName:"callback"};if(b.requestOptions||e)c=f.mixin({},b.requestOptions,e,c);returnl(b.parsedUrl.path+"/query",c)}).then(this._handleExecuteForIdsResponse)};d.prototype.executeForCount=function(a,e){varb=this;returnn.normalizeCentralMeridian(a.geometry?[a.geometry]:[]).then(function(c){c=b._encode(f.mixin({},b.parsedUrl.query,{f:"json",returnIdsOnly:!0,returnCountOnly:!0},b._normalizeQuery(a,c&&c[0])));if(b.source){vard={source:b.source.toJSON()};c.layer=JSON.stringify(d)}b.gdbVersion&&(c.gdbVersion=b.gdbVersion);c={query:c,callbackParamName:"callback"};if(b.requestOptions||e)c=f.mixin({},b.requestOptions,e,c);returnl(b.parsedUrl.path+"/query",c)}).then(this._handleExecuteForCountResponse)};d.prototype.executeForExtent=function(a,e){varb=this;returnn.normalizeCentralMeridian(a.geometry?[a.geometry]:[]).then(function(c){c=b._encode(f.mixin({},b.parsedUrl.query,{f:"json",returnExtentOnly:!0,returnCountOnly:!0},b._normalizeQuery(a,c&&c[0])));if(b.source){vard={source:b.source.toJSON()};c.layer=JSON.stringify(d)}b.gdbVersion&&(c.gdbVersion=b.gdbVersion);c={query:c,callbackParamName:"callback"};if(b.requestOptions||e)c=f.mixin({},b.requestOptions,e,c);returnl(b.parsedUrl.path+"/query",c)}).then(this._handleExecuteForExtentResponse)};d.prototype._handleExecuteResponse=function(a){returnq.fromJSON(a.data)};d.prototype._handleExecuteRelationshipQueryResponse=function(a){a=a.data;vare=a.geometryType,b=a.spatialReference,c={};a.relatedRecordGroups.forEach(function(a){vard=q.fromJSON({geometryType:e,spatialReference:b,features:a.relatedRecords});if(null!=a.objectId)c[a.objectId]=d;elsefor(varfina)a.hasOwnProperty(f)&&"relatedRecords"!==f&&(c[a[f]]=d)});returnc};d.prototype._handleExecuteForIdsResponse=function(a){returna.data.objectIds};d.prototype._handleExecuteForCountResponse=function(a){a=a.data;vard=a.features,b=a.objectIds;if(b)a=b.length;else{if(d)throwError("Unable to perform query. Please check your parameters.");a=a.count}returna};d.prototype._handleExecuteForExtentResponse=function(a){a=a.data;if(a.hasOwnProperty("extent"))a.extent=v.Extent.fromJSON(a.extent);else{if(a.features)throwError("Layer does not support extent calculation.");if(a.hasOwnProperty("count"))throwError("Layer does not support extent calculation.");}returna};d.prototype._normalizeQuery=function(a,d){d&&(a=a.clone(),a.geometry=d);returnp.queryToQueryStringParameters(a)};h([g.property()],d.prototype,"gdbVersion",void0);h([g.property()],d.prototype,"source",void0);h([k(0,g.cast(m))],d.prototype,"execute",null);h([k(0,g.cast(m))],d.prototype,"rawExecute",null);h([k(0,g.cast(m))],d.prototype,"executeForIds",null);h([k(0,g.cast(m))],d.prototype,"executeForCount",null);h([k(0,g.cast(m))],d.prototype,"executeForExtent",null);returnd=p=h([g.subclass("esri.tasks.QueryTask")],d);varp}(g.declared(u))});