import { a as a2, u as u2 } from "./chunk-4D6PVVFX.js"; import { u } from "./chunk-5FHVUYVE.js"; import { Y } from "./chunk-NP2BYFXT.js"; import "./chunk-6H5PP7QI.js"; import "./chunk-HSPVIAVJ.js"; import "./chunk-XIEPNAEI.js"; import { f } from "./chunk-M5BTTMP6.js"; import "./chunk-WQJRLXWG.js"; import "./chunk-ETWBEEKL.js"; import { t as t2 } from "./chunk-XZA4MVET.js"; import "./chunk-4GGRJYTB.js"; import "./chunk-D5GG5NVO.js"; import "./chunk-USORKAIZ.js"; import "./chunk-Q34L5KZA.js"; import "./chunk-ROWZMUVJ.js"; import "./chunk-7IKYLNB5.js"; import "./chunk-P4UZNLD5.js"; import "./chunk-FYNVVMWY.js"; import "./chunk-Q52DVFYK.js"; import { s as s3, t } from "./chunk-HBMVUVZX.js"; import "./chunk-QOV6ITMI.js"; import { ln } from "./chunk-DH2OBAUC.js"; import "./chunk-TNLRDNTC.js"; import { a } from "./chunk-3ZFH4KQV.js"; import "./chunk-KUXNUNAI.js"; import { d } from "./chunk-KMAHKQ2G.js"; import "./chunk-522WBHUO.js"; import "./chunk-WNCU6BFU.js"; import "./chunk-EOSZHC5H.js"; import "./chunk-C43UE3Z5.js"; import "./chunk-NE3ESGA6.js"; import "./chunk-YIS6BAC3.js"; import "./chunk-7XXXCK2A.js"; import "./chunk-7ZIDBK7B.js"; import { P } from "./chunk-WZQZRKNH.js"; import "./chunk-LRDX4TO7.js"; import "./chunk-WDLTDV2L.js"; import "./chunk-TERAW6FT.js"; import "./chunk-N2663GRX.js"; import "./chunk-O4FY3ITT.js"; import "./chunk-JXW4QTJA.js"; import "./chunk-UXF37FQ4.js"; import "./chunk-ZOEK6QHJ.js"; import "./chunk-XNLG7T2T.js"; import "./chunk-IR4PV7VK.js"; import "./chunk-2Z6LERTI.js"; import "./chunk-OWVBLVP3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-XH7RUGVZ.js"; import "./chunk-ALDCDSPV.js"; import "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import { U } from "./chunk-VNFRAYHO.js"; import "./chunk-R5IG2D6H.js"; import { Ut, j } from "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import { y } from "./chunk-ECW2QABR.js"; import "./chunk-GCDJLKH4.js"; import { E, c, k, k2 } from "./chunk-MRJEICT6.js"; import "./chunk-Y3WMVFTW.js"; import "./chunk-SAS7RONY.js"; import "./chunk-WSRBH7BF.js"; import "./chunk-IHXECKQQ.js"; import { O, g } from "./chunk-ULGDPLM2.js"; import { s, s3 as s2 } from "./chunk-EMJ4ZSM2.js"; import "./chunk-IKP3YN53.js"; import "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/layers/graphics/sources/csv/csv.js var n = /^\s*"([\S\s]*)"\s*$/; var t3 = /""/g; var e = "\n"; var o = [",", " ", ";", "|", " "]; function* c2(n3, t4, e2) { let o3 = 0; for (; o3 <= n3.length; ) { const c3 = n3.indexOf(t4, o3), i3 = n3.substring(o3, c3 > -1 ? c3 : void 0); o3 += i3.length + t4.length, e2 && !i3.trim() || (yield i3); } } function i(n3) { const t4 = n3.includes("\r\n") ? "\r\n" : e; return c2(n3, t4, true); } function r(n3, t4) { return c2(n3, t4, false); } function f2(n3) { const t4 = n3.trim(); let e2 = 0, c3 = ""; for (const i3 of o) { const n4 = t4.split(i3).length; n4 > e2 && (e2 = n4, c3 = i3); } return c3 === "" ? null : c3; } function* l(o3, c3, i3, f3 = () => Object.create(null)) { let l3 = "", u4 = "", d3 = 0, g2 = f3(), x = 0; n: for (const h of o3) { const o4 = r(h, i3); for (const e2 of o4) if (l3 += u4 + e2, u4 = "", d3 += s4(e2), d3 % 2 == 0) { if (d3 > 0) { const e3 = n.exec(l3); if (!e3) { g2 = f3(), x = 0, l3 = "", d3 = 0; continue n; } g2[c3[x]] = e3[1].replace(t3, '"'), x++; } else g2[c3[x]] = l3, x++; l3 = "", d3 = 0; } else u4 = i3; d3 === 0 ? (yield g2, g2 = f3(), x = 0) : u4 = e; } } function s4(n3) { let t4 = 0, e2 = 0; for (e2 = n3.indexOf('"', e2); e2 >= 0; ) t4++, e2 = n3.indexOf('"', e2 + 1); return t4; } // node_modules/@arcgis/core/layers/graphics/sources/support/inferenceUtils.js function r2(e2) { const t4 = e2.map((e3) => e3.toLowerCase()); return { longitudeFieldName: e2[t4.indexOf(d2.find((e3) => t4.includes(e3)))], latitudeFieldName: e2[t4.indexOf(s5.find((e3) => t4.includes(e3)))] }; } function n2(e2, r3, n3, l3) { const o3 = [], a4 = l(e2, n3, r3), u4 = []; for (const t4 of a4) { if (u4.length === 10) break; u4.push(t4); } for (const t4 of n3) if (t4 === l3.longitudeFieldName || t4 === l3.latitudeFieldName) o3.push({ name: t4, type: "esriFieldTypeDouble", alias: t4 }); else { const e3 = i2(u4.map((e4) => e4[t4])), r4 = { name: t4, type: null, alias: t4 }; switch (e3) { case "integer": r4.type = "esriFieldTypeInteger"; break; case "double": r4.type = "esriFieldTypeDouble"; break; case "date": r4.type = "esriFieldTypeDate", r4.length = 36; break; default: r4.type = "esriFieldTypeString", r4.length = 255; } o3.push(r4); } return o3; } function i2(e2) { if (!e2.length) return "string"; const t4 = /[^+-.,0-9]/; return e2.map((e3) => { let r3 = false; if (e3 !== "") { if (t4.test(e3)) r3 = true; else { let t5 = o2(e3); if (!isNaN(t5)) return /[.,]/.test(e3) || !Number.isInteger(t5) || t5 > 214783647 || t5 < -214783648 ? "double" : "integer"; if (e3.includes("E")) { if (t5 = Number(e3), !isNaN(t5)) return "double"; if (e3.includes(",")) { if (e3 = e3.replace(",", "."), t5 = Number(e3), !isNaN(t5)) return "double"; r3 = true; } else r3 = true; } else r3 = true; } if (r3) { if (!/^[-]?\d*[.,]?\d*$/.test(e3)) { return l2(new Date(e3), e3) ? "date" : "string"; } return "string"; } return "string"; } }).reduce((e3, t5) => e3 === void 0 || e3 === t5 ? t5 : e3 === "string" || t5 === "string" ? "string" : e3 === "double" || t5 === "double" ? "double" : void 0); } function l2(e2, t4) { if (!e2 || Object.prototype.toString.call(e2) !== "[object Date]" || isNaN(e2.getTime())) return false; let r3 = true; if (!u3 && /\d+\W*$/.test(t4)) { const e3 = t4.match(/[a-zA-Z]{2,}/); if (e3) { let t5 = false, n3 = 0; for (; !t5 && n3 <= e3.length; ) t5 = !a3.test(e3[n3]), n3++; r3 = !t5; } } return r3; } var o2 = function() { const t4 = a(), r3 = new RegExp("^" + t4.regexp + "$"), n3 = new RegExp("[" + t4.group + "\\s\\xa0]", "g"), i3 = t4.factor; return (e2) => { const l3 = r3.exec(e2); if (t4.factor = i3, !l3) return NaN; let o3 = l3[1]; if (!l3[1]) { if (!l3[2]) return NaN; o3 = l3[2], t4.factor *= -1; } return o3 = o3.replace(n3, "").replace(t4.decimal, "."), +o3 * t4.factor; }; }(); var a3 = /^((jan(uary)?)|(feb(ruary)?)|(mar(ch)?)|(apr(il)?)|(may)|(jun(e)?)|(jul(y)?)|(aug(ust)?)|(sep(tember)?)|(oct(ober)?)|(nov(ember)?)|(dec(ember)?)|(am)|(pm)|(gmt)|(utc))$/i; var u3 = Number.isNaN(new Date("technology 10").getTime()); var s5 = ["lat", "latitude", "latitude83", "latdecdeg", "lat_dd", "y", "ycenter", "point-y"]; var d2 = ["lon", "lng", "long", "longitude", "longitude83", "longdecdeg", "long_dd", "x", "xcenter", "point-x"]; // node_modules/@arcgis/core/layers/graphics/sources/support/CSVSourceWorker.js var b = u2("esriGeometryPoint"); var v = ["csv"]; var D = [0, 0]; var O2 = class { constructor(e2, t4) { this.x = e2, this.y = t4; } }; var k3 = class { constructor() { this._queryEngine = null, this._snapshotFeatures = async (e2) => { const t4 = await this._fetch(e2); return this._createFeatures(t4); }; } destroy() { this._queryEngine?.destroy(), this._queryEngine = null; } async load(e2, t4 = {}) { this.loadOptions = e2; const [i3] = await Promise.all([this._fetch(t4.signal), this._checkProjection(e2?.parsingOptions?.spatialReference)]), n3 = P2(i3, e2); this.locationInfo = n3.locationInfo, this.delimiter = n3.delimiter, this._queryEngine = this._createQueryEngine(n3); const r3 = await this._createFeatures(i3); if (this._queryEngine.featureStore.addMany(r3), n3.layerDefinition.extent = this._queryEngine.fullExtent, n3.layerDefinition.timeInfo) { const { start: e3, end: t5 } = this._queryEngine.timeExtent; n3.layerDefinition.timeInfo.timeExtent = [e3, t5]; } return n3; } async applyEdits() { throw new s2("csv-layer:editing-not-supported", "applyEdits() is not supported on CSVLayer"); } async queryFeatures(e2 = {}, t4 = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQuery(e2, t4.signal); } async queryFeatureCount(e2 = {}, t4 = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForCount(e2, t4.signal); } async queryObjectIds(e2 = {}, t4 = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForIds(e2, t4.signal); } async queryExtent(e2 = {}, t4 = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForExtent(e2, t4.signal); } async querySnapping(e2, t4 = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForSnapping(e2, t4.signal); } async refresh(e2) { return this.loadOptions.customParameters = e2, this._snapshotTask?.abort(), this._snapshotTask = O(this._snapshotFeatures), this._snapshotTask.promise.then((e3) => { this._queryEngine.featureStore.clear(), e3 && this._queryEngine.featureStore.addMany(e3); }, (e3) => { this._queryEngine.featureStore.clear(), g(e3) || s.getLogger("esri.layers.CSVLayer").error(new s2("csv-layer:refresh", "An error occurred during refresh", { error: e3 })); }), await this._waitSnapshotComplete(), { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent }; } async _waitSnapshotComplete() { if (this._snapshotTask && !this._snapshotTask.finished) { try { await this._snapshotTask.promise; } catch { } return this._waitSnapshotComplete(); } } async _fetch(i3) { const { url: n3, customParameters: r3 } = this.loadOptions; if (!n3) throw new s2("csv-layer:invalid-source", "url not defined"); const o3 = j(n3); return (await U(o3.path, { query: { ...o3.query, ...r3 }, responseType: "text", signal: i3 })).data; } _createQueryEngine(e2) { const { objectIdField: t4, fields: i3, extent: n3, timeInfo: r3 } = e2.layerDefinition, s6 = new u({ geometryType: "esriGeometryPoint", hasM: false, hasZ: false }); return new Y({ fields: i3, geometryType: "esriGeometryPoint", hasM: false, hasZ: false, timeInfo: r3, objectIdField: t4, spatialReference: n3.spatialReference || { wkid: 4326 }, cacheSpatialQueries: true, featureStore: s6 }); } async _createFeatures(e2) { const { latitudeFieldName: t4, longitudeFieldName: i3 } = this.locationInfo, { objectIdField: n3, fieldsIndex: r3, spatialReference: s6 } = this._queryEngine; let o3 = []; const u4 = [], y2 = r3.fields.filter((e3) => e3.name !== n3).map((e3) => e3.name); let h = 0; const g2 = i(e2); g2.next(); const I = {}; for (const a4 of r3.fields) if (a4.type !== "esriFieldTypeOID" && a4.type !== "esriFieldTypeGlobalID") { const e3 = P(a4); e3 !== void 0 && (I[a4.name] = e3); } const E2 = l(g2, y2, this.delimiter, a2(I, n3)); for (const a4 of E2) { const e3 = this._parseCoordinateValue(a4[t4]), s7 = this._parseCoordinateValue(a4[i3]); if (s7 != null && e3 != null && !isNaN(e3) && !isNaN(s7)) { a4[t4] = e3, a4[i3] = s7; for (const e4 in a4) if (e4 !== t4 && e4 !== i3) { if (r3.isDateField(e4)) { const t5 = new Date(a4[e4]); a4[e4] = l2(t5, a4[e4]) ? t5.getTime() : null; } else if (r3.isNumericField(e4)) { const t5 = o2(a4[e4]); isNaN(t5) ? a4[e4] = null : a4[e4] = t5; } } a4[n3] = h, h++, o3.push(new O2(s7, e3)), u4.push(a4); } } if (!E({ wkid: 4326 }, s6)) if (k(s6)) for (const a4 of o3) [a4.x, a4.y] = y(a4.x, a4.y, D); else o3 = ln(t2, o3, k2.WGS84, s6, null, null); const N = []; for (let a4 = 0; a4 < o3.length; a4++) { const { x: e3, y: t5 } = o3[a4], i4 = u4[a4]; i4[n3] = a4 + 1, N.push(new s3(new t([], [e3, t5]), i4, null, i4[n3])); } return N; } _parseCoordinateValue(e2) { if (e2 == null || e2 === "") return null; let t4 = o2(e2); return (isNaN(t4) || Math.abs(t4) > 181) && (t4 = parseFloat(e2)), t4; } async _checkProjection(e2) { try { await f(c, e2); } catch { throw new s2("csv-layer:projection-not-supported", "Projection not supported"); } } }; function P2(e2, i3) { const n3 = i3.parsingOptions || {}, r3 = { delimiter: n3.delimiter, layerDefinition: null, locationInfo: { latitudeFieldName: n3.latitudeField, longitudeFieldName: n3.longitudeField } }, s6 = i(e2); let a4 = s6.next().value; if (!a4) throw new s2("csv-layer:empty-csv", "CSV is empty", { csv: e2 }); if (a4 = a4.trim(), !n3.delimiter) { const e3 = f2(a4); if (!e3) throw new s2("csv-layer:invalid-delimiter", "Unable to detect the delimiter from CSV"); r3.delimiter = e3; } const l3 = a4.split(r3.delimiter).filter((e3) => !!e3), d3 = r3.layerDefinition = { name: Ut(i3.url, v) || "csv", drawingInfo: b, geometryType: "esriGeometryPoint", objectIdField: null, fields: [], timeInfo: n3.timeInfo, extent: { xmin: Number.POSITIVE_INFINITY, ymin: Number.POSITIVE_INFINITY, xmax: Number.NEGATIVE_INFINITY, ymax: Number.NEGATIVE_INFINITY, spatialReference: n3.spatialReference || { wkid: 102100 } } }; if (!n3.latitudeField || !n3.longitudeField) { const e3 = r2(l3); if (!n3.longitudeField && !e3.longitudeFieldName || !n3.latitudeField && !e3.latitudeFieldName) throw new s2("csv-layer:location-fields-not-found", "Unable to identify latitude and longitude fields from the CSV file"); r3.locationInfo = { longitudeFieldName: n3.longitudeField || e3.longitudeFieldName, latitudeFieldName: n3.latitudeField || e3.latitudeFieldName }; } const m = n2(s6, r3.delimiter, l3, r3.locationInfo); if (n3.fields && n3.fields.length) { const e3 = new Map(); for (const t4 of n3.fields) e3.set(t4.name.toLowerCase(), t4); for (const t4 of m) { const i4 = e3.get(t4.name.toLowerCase()); if (i4) { const e4 = t4.name; Object.assign(t4, i4), t4.name = e4; } } } d3.fields = m; if (!d3.fields.some((e3) => e3.type === "esriFieldTypeOID" && (d3.objectIdField = e3.name, true))) { const e3 = { name: "__OBJECTID", alias: "__OBJECTID", type: "esriFieldTypeOID", editable: false, nullable: false }; d3.objectIdField = e3.name, d3.fields.unshift(e3); } if (d3.timeInfo) { const e3 = new d(d3.fields), t4 = d3.timeInfo; if (t4.startTimeField) { const i4 = e3.get(t4.startTimeField); i4 ? (t4.startTimeField = i4.name, i4.type = "esriFieldTypeDate") : t4.startTimeField = null; } if (t4.endTimeField) { const i4 = e3.get(t4.endTimeField); i4 ? (t4.endTimeField = i4.name, i4.type = "esriFieldTypeDate") : t4.endTimeField = null; } if (t4.trackIdField) { const i4 = e3.get(t4.trackIdField); t4.trackIdField = i4 ? i4.name : null; } t4.startTimeField || t4.endTimeField || (d3.timeInfo = null); } return r3; } export { k3 as default }; //# sourceMappingURL=CSVSourceWorker-3RM7DFJI.js.map