import { L, O as O2, T } from "./chunk-YVTH4OGO.js"; import { a as a2, f as f2, g as g3, m, w } from "./chunk-XHRYELNQ.js"; import { a, l, 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, g as g2 } from "./chunk-M5BTTMP6.js"; import "./chunk-WQJRLXWG.js"; import "./chunk-ETWBEEKL.js"; import "./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 { Q, W, ee, ne, te } from "./chunk-FYNVVMWY.js"; import "./chunk-Q52DVFYK.js"; import "./chunk-HBMVUVZX.js"; import "./chunk-QOV6ITMI.js"; import "./chunk-DH2OBAUC.js"; import "./chunk-TNLRDNTC.js"; import "./chunk-KUXNUNAI.js"; import { d } from "./chunk-KMAHKQ2G.js"; import "./chunk-522WBHUO.js"; import "./chunk-WNCU6BFU.js"; import { i } from "./chunk-F6A2QQ26.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 { v } from "./chunk-2Z6LERTI.js"; import "./chunk-OWVBLVP3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-ALDCDSPV.js"; import "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import { U } from "./chunk-VNFRAYHO.js"; import "./chunk-R5IG2D6H.js"; import "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import "./chunk-ECW2QABR.js"; import "./chunk-GCDJLKH4.js"; import { E, c } 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 { r } from "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/layers/graphics/sources/geojson/GeoJSONSourceWorker.js var O3 = { hasAttachments: false, capabilities: "query, editing, create, delete, update", useStandardizedQueries: true, supportsCoordinatesQuantization: true, supportsReturningQueryGeometry: true, advancedQueryCapabilities: { supportsQueryAttachments: false, supportsStatistics: true, supportsPercentileStatistics: true, supportsReturningGeometryCentroid: true, supportsQueryWithDistance: true, supportsDistinct: true, supportsReturningQueryExtent: true, supportsReturningGeometryProperties: false, supportsHavingClause: true, supportsOrderBy: true, supportsPagination: true, supportsQueryWithResultType: false, supportsSqlExpression: true, supportsDisjointSpatialRel: true } }; var C = class { constructor() { this._queryEngine = null, this._snapshotFeatures = async (e) => { const t = await this._fetch(e); return this._createFeatures(t); }; } destroy() { this._queryEngine?.destroy(), this._queryEngine = this._fieldsIndex = this._createDefaultAttributes = null; } async load(e, s3 = {}) { this.loadOptions = { url: e.url, customParameters: e.customParameters }; const i2 = []; await this._checkProjection(e.spatialReference); let r2 = null; e.url && (r2 = await this._fetch(s3?.signal)); const n = T(r2, { geometryType: e.geometryType }), a3 = e.fields || n.fields || [], u3 = e.hasZ != null ? e.hasZ : n.hasZ, l2 = n.geometryType, d2 = e.objectIdField || n.objectIdFieldName || "__OBJECTID", p = e.spatialReference || c; let c2 = e.timeInfo; a3 === n.fields && n.unknownFields.length > 0 && i2.push({ name: "geojson-layer:unknown-field-types", message: "Some fields types couldn't be inferred from the features and were dropped", details: { unknownFields: n.unknownFields } }); let y = a3.find((e2) => e2.name === d2); y ? (y.type !== "esriFieldTypeString" && (y.type = "esriFieldTypeOID"), y.editable = false, y.nullable = false) : (y = { alias: d2, name: d2, type: n.objectIdFieldType === "string" ? "esriFieldTypeString" : "esriFieldTypeOID", editable: false, nullable: false }, a3.unshift(y)); const m2 = {}; for (const o of a3) { if (o.name == null && (o.name = o.alias), o.alias == null && (o.alias = o.name), !o.name) throw new s2("geojson-layer:invalid-field-name", "field name is missing", { field: o }); if (!i.jsonValues.includes(o.type)) throw new s2("geojson-layer:invalid-field-type", `invalid type for field "${o.name}"`, { field: o }); if (o.name !== y.name) { const e2 = P(o); e2 !== void 0 && (m2[o.name] = e2); } } this._fieldsIndex = new d(a3); const f3 = this._fieldsIndex.requiredFields.indexOf(y); if (f3 > -1 && this._fieldsIndex.requiredFields.splice(f3, 1), c2) { if (c2.startTimeField) { const e2 = this._fieldsIndex.get(c2.startTimeField); e2 ? (c2.startTimeField = e2.name, e2.type = "esriFieldTypeDate") : c2.startTimeField = null; } if (c2.endTimeField) { const e2 = this._fieldsIndex.get(c2.endTimeField); e2 ? (c2.endTimeField = e2.name, e2.type = "esriFieldTypeDate") : c2.endTimeField = null; } if (c2.trackIdField) { const e2 = this._fieldsIndex.get(c2.trackIdField); e2 ? c2.trackIdField = e2.name : (c2.trackIdField = null, i2.push({ name: "geojson-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: c2 } })); } c2.startTimeField || c2.endTimeField || (i2.push({ name: "geojson-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing", details: { timeInfo: c2 } }), c2 = null); } const I = l2 ? u2(l2) : null, j = { warnings: i2, featureErrors: [], layerDefinition: { ...O3, drawingInfo: I, templates: l(m2), extent: null, geometryType: l2, objectIdField: d2, fields: a3, hasZ: !!u3, timeInfo: c2 } }; this._queryEngine = new Y({ fields: a3, geometryType: l2, hasM: false, hasZ: u3, objectIdField: d2, spatialReference: p, timeInfo: c2, featureStore: new u({ geometryType: l2, hasM: false, hasZ: u3 }), cacheSpatialQueries: true }), this._createDefaultAttributes = a(m2, d2); const T2 = await this._createFeatures(r2); this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, T2); const w2 = this._normalizeFeatures(T2, j.warnings, j.featureErrors); if (this._queryEngine.featureStore.addMany(w2), j.layerDefinition.extent = this._queryEngine.fullExtent, j.layerDefinition.timeInfo) { const { start: e2, end: t } = this._queryEngine.timeExtent; j.layerDefinition.timeInfo.timeExtent = [e2, t]; } return j; } async applyEdits(e) { const { spatialReference: t, geometryType: s3 } = this._queryEngine; return await Promise.all([w(t, s3), f(e.adds, t), f(e.updates, t)]), await this._waitSnapshotComplete(), this._applyEdits(e); } async queryFeatures(e = {}, t = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQuery(e, t.signal); } async queryFeatureCount(e = {}, t = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForCount(e, t.signal); } async queryObjectIds(e = {}, t = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForIds(e, t.signal); } async queryExtent(e = {}, t = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForExtent(e, t.signal); } async querySnapping(e, t = {}) { return await this._waitSnapshotComplete(), this._queryEngine.executeQueryForSnapping(e, t.signal); } async refresh(e) { return this.loadOptions.customParameters = e, this._snapshotTask?.abort(), this._snapshotTask = O(this._snapshotFeatures), this._snapshotTask.promise.then((e2) => { this._queryEngine.featureStore.clear(), this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, e2); const t = this._normalizeFeatures(e2); t && this._queryEngine.featureStore.addMany(t); }, (e2) => { this._queryEngine.featureStore.clear(), g(e2) || s.getLogger("esri.layers.GeoJSONLayer").error(new s2("geojson-layer:refresh", "An error occurred during refresh", { error: e2 })); }), await this._waitSnapshotComplete(), { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent }; } async _createFeatures(e) { const { geometryType: t, hasZ: s3, objectIdField: r2 } = this._queryEngine, n = L(e, { geometryType: t, hasZ: s3, objectIdField: r2 }); if (!E(this._queryEngine.spatialReference, c)) for (const a3 of n) r(a3.geometry) && (a3.geometry = te(g2(ne(a3.geometry, this._queryEngine.geometryType, this._queryEngine.hasZ, false), c, this._queryEngine.spatialReference))); return n; } async _waitSnapshotComplete() { if (this._snapshotTask && !this._snapshotTask.finished) { try { await this._snapshotTask.promise; } catch { } return this._waitSnapshotComplete(); } } async _fetch(t) { const { url: s3, customParameters: i2 } = this.loadOptions, r2 = (await U(s3, { responseType: "json", query: { ...i2 }, signal: t })).data; return await O2(r2), r2; } _normalizeFeatures(e, t, s3) { const { objectIdField: i2 } = this._queryEngine, r2 = []; for (const n of e) { const e2 = this._createDefaultAttributes(), a3 = m(this._fieldsIndex, e2, n.attributes, true, t); a3 ? s3?.push(a3) : (this._assignObjectId(e2, n.attributes, true), n.attributes = e2, n.objectId = e2[i2], r2.push(n)); } return r2; } _applyEdits(e) { const { adds: t, updates: s3, deletes: i2 } = e, r2 = { addResults: [], deleteResults: [], updateResults: [], uidToObjectId: {} }; if (t && t.length && this._applyAddEdits(r2, t), s3 && s3.length && this._applyUpdateEdits(r2, s3), i2 && i2.length) { for (const e2 of i2) r2.deleteResults.push(f2(e2)); this._queryEngine.featureStore.removeManyById(i2); } return { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent, featureEditResults: r2 }; } _applyAddEdits(e, t) { const { addResults: s3 } = e, { geometryType: r2, hasM: n, hasZ: o, objectIdField: u3, spatialReference: l2, featureStore: d2 } = this._queryEngine, c2 = []; for (const p of t) { if (p.geometry && r2 !== v(p.geometry)) { s3.push(a2("Incorrect geometry type.")); continue; } const t2 = this._createDefaultAttributes(), n2 = m(this._fieldsIndex, t2, p.attributes); if (n2) s3.push(n2); else { if (this._assignObjectId(t2, p.attributes), p.attributes = t2, p.uid != null) { const t3 = p.attributes[u3]; e.uidToObjectId[p.uid] = t3; } r(p.geometry) && (p.geometry = g2(g3(p.geometry, l2), p.geometry.spatialReference, l2)), c2.push(p), s3.push(f2(p.attributes[u3])); } } d2.addMany(W([], c2, r2, o, n, u3)); } _applyUpdateEdits({ updateResults: e }, t) { const { geometryType: s3, hasM: r2, hasZ: n, objectIdField: o, spatialReference: u3, featureStore: l2 } = this._queryEngine; for (const d2 of t) { const { attributes: t2, geometry: p } = d2, h = t2 && t2[o]; if (h == null) { e.push(a2(`Identifier field ${o} missing`)); continue; } if (!l2.has(h)) { e.push(a2(`Feature with object id ${h} missing`)); continue; } const m2 = ee(l2.getFeature(h), s3, n, r2); if (r(p)) { if (s3 !== v(p)) { e.push(a2("Incorrect geometry type.")); continue; } m2.geometry = g2(g3(p, u3), p.spatialReference, u3); } if (t2) { const s4 = m(this._fieldsIndex, m2.attributes, t2); if (s4) { e.push(s4); continue; } } l2.add(Q(m2, s3, n, r2, o)), e.push(f2(h)); } } _createObjectIdGenerator(e, t) { const s3 = e.fieldsIndex.get(e.objectIdField); if (s3.type === "esriFieldTypeString") return () => s3.name + "-" + Date.now().toString(16); let i2 = Number.NEGATIVE_INFINITY; for (const r2 of t) r2.objectId && (i2 = Math.max(i2, r2.objectId)); return i2 = Math.max(0, i2) + 1, () => i2++; } _assignObjectId(e, t, s3 = false) { const i2 = this._queryEngine.objectIdField; e[i2] = s3 && i2 in t ? t[i2] : this._objectIdGenerator(); } async _checkProjection(e) { try { await f(c, e); } catch { throw new s2("geojson-layer", "Projection not supported"); } } }; export { C as default }; //# sourceMappingURL=GeoJSONSourceWorker-NOAEMPL4.js.map