/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../chunks/tslib.es6","../../../geometry","../../../core/has","../../../core/Loadable","../../../core/maybe","../../../core/promiseUtils","../../../core/workers/workers","../../../core/accessorSupport/decorators/property","../../../core/arrayUtils","../../../core/accessorSupport/ensureType","../../../core/accessorSupport/decorators/subclass","../../../rest/support/FeatureSet","../../../geometry/Extent"],(function(e,t,o,r,n,i,u,s,c,a,l,p,d,y,f){"use strict";e.CSVSource=function(e){function o(o){var r;return(r=e.call(this,o)||this).type="csv",r.refresh=s.debounce(function(){var e=t._asyncToGenerator((function*(e){yield r.load();const{extent:t,timeExtent:o}=yield r._connection.invoke("refresh",e);return r.sourceJSON.extent=t,o&&(r.sourceJSON.timeInfo.timeExtent=[o.start,o.end]),{dataChanged:!0,updates:{extent:r.sourceJSON.extent,timeInfo:r.sourceJSON.timeInfo}}}));return function(t){return e.apply(this,arguments)}}()),r}t._inheritsLoose(o,e);var r=o.prototype;return r.load=function(e){const t=u.isSome(e)?e.signal:null;return this.addResolvingPromise(this._startWorker(t)),Promise.resolve(this)},r.destroy=function(){var e;null==(e=this._connection)||e.close(),this._connection=null},r.openPorts=function(){var e=t._asyncToGenerator((function*(){return yield this.load(),this._connection.openPorts()}));function o(){return e.apply(this,arguments)}return o}(),r.queryFeatures=function(){var e=t._asyncToGenerator((function*(e,t={}){yield this.load(t);const o=yield this._connection.invoke("queryFeatures",e?e.toJSON():null,t);return y.fromJSON(o)}));function o(t){return e.apply(this,arguments)}return o}(),r.queryFeaturesJSON=function(){var e=t._asyncToGenerator((function*(e,t={}){return yield this.load(t),this._connection.invoke("queryFeatures",e?e.toJSON():null,t)}));function o(t){return e.apply(this,arguments)}return o}(),r.queryFeatureCount=function(){var e=t._asyncToGenerator((function*(e,t={}){return yield this.load(t),this._connection.invoke("queryFeatureCount",e?e.toJSON():null,t)}));function o(t){return e.apply(this,arguments)}return o}(),r.queryObjectIds=function(){var e=t._asyncToGenerator((function*(e,t={}){return yield this.load(t),this._connection.invoke("queryObjectIds",e?e.toJSON():null,t)}));function o(t){return e.apply(this,arguments)}return o}(),r.queryExtent=function(){var e=t._asyncToGenerator((function*(e,t={}){yield this.load(t);const o=yield this._connection.invoke("queryExtent",e?e.toJSON():null,t);return{count:o.count,extent:f.fromJSON(o.extent)}}));function o(t){return e.apply(this,arguments)}return o}(),r.querySnapping=function(){var e=t._asyncToGenerator((function*(e,t={}){return yield this.load(t),this._connection.invoke("querySnapping",e,t)}));function o(t){return e.apply(this,arguments)}return o}(),r._startWorker=function(){var e=t._asyncToGenerator((function*(e){this._connection=yield c.open("CSVSourceWorker",{strategy:n("feature-layers-workers")?"dedicated":"local",signal:e});const{url:t,delimiter:o,fields:r,latitudeField:i,longitudeField:u,spatialReference:s,timeInfo:a}=this.loadOptions,l=yield this._connection.invoke("load",{url:t,customParameters:this.customParameters,parsingOptions:{delimiter:o,fields:null==r?void 0:r.map((e=>e.toJSON())),latitudeField:i,longitudeField:u,spatialReference:null==s?void 0:s.toJSON(),timeInfo:null==a?void 0:a.toJSON()}},{signal:e});this.locationInfo=l.locationInfo,this.sourceJSON=l.layerDefinition,this.delimiter=l.delimiter}));function o(t){return e.apply(this,arguments)}return o}(),o}(i),o.__decorate([a.property()],e.CSVSource.prototype,"type",void 0),o.__decorate([a.property()],e.CSVSource.prototype,"loadOptions",void 0),o.__decorate([a.property()],e.CSVSource.prototype,"customParameters",void 0),o.__decorate([a.property()],e.CSVSource.prototype,"locationInfo",void 0),o.__decorate([a.property()],e.CSVSource.prototype,"sourceJSON",void 0),o.__decorate([a.property()],e.CSVSource.prototype,"delimiter",void 0),e.CSVSource=o.__decorate([d.subclass("esri.layers.graphics.sources.CSVSource")],e.CSVSource),Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
