import { I, L, T } from "./chunk-2H3JYQ2D.js"; import { a as a2, f as f2, g as g2, m, w } from "./chunk-5I3CETHK.js"; import { a, i as i2, o } from "./chunk-A6WD5XTM.js"; import { u } from "./chunk-5X5UDWFV.js"; import { Y } from "./chunk-3EZOER4E.js"; import "./chunk-XCIRV7CO.js"; import "./chunk-DMVKVC5I.js"; import "./chunk-EL3V6S4N.js"; import "./chunk-NFN2M2QU.js"; import { f, g } from "./chunk-3ZJXLJLL.js"; import "./chunk-OP2HNSVZ.js"; import "./chunk-4GGDRIJK.js"; import "./chunk-MZG75XMA.js"; import "./chunk-REMBDESU.js"; import "./chunk-CKZZYAPN.js"; import "./chunk-AFVJXEUJ.js"; import "./chunk-FZSI6IGI.js"; import "./chunk-SJGY5U4Q.js"; import "./chunk-27XWQUQA.js"; import "./chunk-NX2NCBAF.js"; import { X, nt, ot, rt, tt } from "./chunk-4VZNS7N2.js"; import "./chunk-IIAN3QNN.js"; import "./chunk-VYQHMPYW.js"; import "./chunk-WXUHXYJK.js"; import "./chunk-NTERQTPO.js"; import "./chunk-EDHROVWI.js"; import "./chunk-3IRT3YKJ.js"; import "./chunk-SOSOZIX6.js"; import "./chunk-ZSW35JPD.js"; import { r as r2 } from "./chunk-DAWQAVQO.js"; import "./chunk-73AMYZFU.js"; import "./chunk-NKMX5M3L.js"; import { i } from "./chunk-QEWF7QPH.js"; import "./chunk-SQ2SY4BX.js"; import "./chunk-VLG7MMVR.js"; import "./chunk-BWATQC2Y.js"; import { M } from "./chunk-47NSA4T4.js"; import "./chunk-FUODOQDM.js"; import "./chunk-CZBRZ6SU.js"; import "./chunk-VGWC3IKZ.js"; import "./chunk-SWMSD4RP.js"; import "./chunk-UKEN2UNL.js"; import "./chunk-X4SA4ELJ.js"; import "./chunk-XJCUT65M.js"; import { j as j2 } from "./chunk-PIFOHNWC.js"; import "./chunk-ZLNEXZAN.js"; import "./chunk-ZYRIJWLX.js"; import "./chunk-RYY6632W.js"; import "./chunk-DW42UVIT.js"; import "./chunk-TJNOJH33.js"; import "./chunk-YAEIHDJH.js"; import "./chunk-OSHI574D.js"; import "./chunk-44GMIOGP.js"; import "./chunk-75U5LM2V.js"; import { c as c2 } from "./chunk-ZHRAUKVQ.js"; import "./chunk-RZK6A2GY.js"; import "./chunk-X4LLOW7U.js"; import "./chunk-Z4JTBD7M.js"; import "./chunk-HZRKBTHJ.js"; import { U } from "./chunk-5DMBXPN2.js"; import "./chunk-QANZ6BFY.js"; import "./chunk-VEGAOVMY.js"; import "./chunk-CXCDYJ5R.js"; import "./chunk-GAOW3WRZ.js"; import { E, c } from "./chunk-QCKFNSN2.js"; import "./chunk-6SOHRC7T.js"; import "./chunk-U2XHEJM7.js"; import "./chunk-SQOPWYIT.js"; import "./chunk-6KZ2LTDA.js"; import { j } from "./chunk-V6P2MAQQ.js"; import { s2 as s, s3 as s2 } from "./chunk-E5O6P5I2.js"; import "./chunk-SPWQ3AWG.js"; import "./chunk-2TIUKVZN.js"; import { r } from "./chunk-YXWMMD76.js"; import "./chunk-S5KM4IGW.js"; // node_modules/@arcgis/core/layers/graphics/sources/geojson/GeoJSONSourceWorker.js var O = { 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() { var _a; (_a = this._queryEngine) == null ? void 0 : _a.destroy(), this._queryEngine = this._fieldsIndex = this._createDefaultAttributes = null; } async load(e, t = {}) { this._loadOptions = { url: e.url, customParameters: e.customParameters }; const i3 = []; await this._checkProjection(e.spatialReference); let r3 = null; e.url && (r3 = await this._fetch(t == null ? void 0 : t.signal)); const n = L(r3, { geometryType: e.geometryType }), a3 = e.fields || n.fields || [], l = null != e.hasZ ? e.hasZ : n.hasZ, u2 = n.geometryType; let d = e.objectIdField || n.objectIdFieldName || "__OBJECTID"; const p = e.spatialReference || c; let c3 = e.timeInfo; a3 === n.fields && n.unknownFields.length > 0 && i3.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 = new r2(a3).get(d); y ? ("esriFieldTypeString" !== y.type && (y.type = "esriFieldTypeOID"), y.editable = false, y.nullable = false, d = y.name) : (y = { alias: d, name: d, type: "string" === n.objectIdFieldType ? "esriFieldTypeString" : "esriFieldTypeOID", editable: false, nullable: false }, a3.unshift(y)); const m2 = {}; for (const o2 of a3) { if (null == o2.name && (o2.name = o2.alias), null == o2.alias && (o2.alias = o2.name), !o2.name) throw new s2("geojson-layer:invalid-field-name", "field name is missing", { field: o2 }); if (!i.jsonValues.includes(o2.type)) throw new s2("geojson-layer:invalid-field-type", `invalid type for field "${o2.name}"`, { field: o2 }); if (o2.name !== y.name) { const e2 = M(o2); void 0 !== e2 && (m2[o2.name] = e2); } } this._fieldsIndex = new r2(a3); const f3 = this._fieldsIndex.requiredFields.indexOf(y); if (f3 > -1 && this._fieldsIndex.requiredFields.splice(f3, 1), c3) { if (c3.startTimeField) { const e2 = this._fieldsIndex.get(c3.startTimeField); e2 ? (c3.startTimeField = e2.name, e2.type = "esriFieldTypeDate") : c3.startTimeField = null; } if (c3.endTimeField) { const e2 = this._fieldsIndex.get(c3.endTimeField); e2 ? (c3.endTimeField = e2.name, e2.type = "esriFieldTypeDate") : c3.endTimeField = null; } if (c3.trackIdField) { const e2 = this._fieldsIndex.get(c3.trackIdField); e2 ? c3.trackIdField = e2.name : (c3.trackIdField = null, i3.push({ name: "geojson-layer:invalid-timeInfo-trackIdField", message: "trackIdField is missing", details: { timeInfo: c3 } })); } c3.startTimeField || c3.endTimeField || (i3.push({ name: "geojson-layer:invalid-timeInfo", message: "startTimeField and endTimeField are missing", details: { timeInfo: c3 } }), c3 = null); } const I2 = u2 ? o(u2) : null, j3 = { warnings: i3, featureErrors: [], layerDefinition: { ...O, drawingInfo: I2, templates: a(m2), extent: null, geometryType: u2, objectIdField: d, fields: a3, hasZ: !!l, timeInfo: c3 } }; this._queryEngine = new Y({ fields: a3, geometryType: u2, hasM: false, hasZ: l, objectIdField: d, spatialReference: p, timeInfo: c3, featureStore: new u({ geometryType: u2, hasM: false, hasZ: l }), cacheSpatialQueries: true }), this._createDefaultAttributes = i2(m2, d); const w2 = await this._createFeatures(r3); this._objectIdGenerator = this._createObjectIdGenerator(this._queryEngine, w2); const T2 = this._normalizeFeatures(w2, j3.warnings, j3.featureErrors); if (this._queryEngine.featureStore.addMany(T2), j3.layerDefinition.extent = this._queryEngine.fullExtent, j3.layerDefinition.timeInfo) { const { start: e2, end: t2 } = this._queryEngine.timeExtent; j3.layerDefinition.timeInfo.timeExtent = [e2, t2]; } return j3; } 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) { var _a; return this._loadOptions.customParameters = e, (_a = this._snapshotTask) == null ? void 0 : _a.abort(), this._snapshotTask = j2(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(), j(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: i3 } = this._queryEngine, n = I(e, { geometryType: t, hasZ: s3, objectIdField: i3 }); if (!E(this._queryEngine.spatialReference, c)) for (const a3 of n) r(a3.geometry) && (a3.geometry = nt(g(rt(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: i3 } = this._loadOptions, r3 = (await U(s3, { responseType: "json", query: { ...i3 }, signal: t })).data; return await T(r3), r3; } _normalizeFeatures(e, t, s3) { const { objectIdField: i3 } = this._queryEngine, r3 = []; for (const n of e) { const e2 = this._createDefaultAttributes(), a3 = m(this._fieldsIndex, e2, n.attributes, true, t); a3 ? s3 == null ? void 0 : s3.push(a3) : (this._assignObjectId(e2, n.attributes, true), n.attributes = e2, n.objectId = e2[i3], r3.push(n)); } return r3; } _applyEdits(e) { const { adds: t, updates: s3, deletes: i3 } = e, r3 = { addResults: [], deleteResults: [], updateResults: [], uidToObjectId: {} }; if (t && t.length && this._applyAddEdits(r3, t), s3 && s3.length && this._applyUpdateEdits(r3, s3), i3 && i3.length) { for (const e2 of i3) r3.deleteResults.push(f2(e2)); this._queryEngine.featureStore.removeManyById(i3); } return { extent: this._queryEngine.fullExtent, timeExtent: this._queryEngine.timeExtent, featureEditResults: r3 }; } _applyAddEdits(e, t) { var _a; const { addResults: s3 } = e, { geometryType: i3, hasM: n, hasZ: o2, objectIdField: l, spatialReference: u2, featureStore: d } = this._queryEngine, c3 = []; for (const p of t) { if (p.geometry && i3 !== c2(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, null != p.uid) { const t3 = p.attributes[l]; e.uidToObjectId[p.uid] = t3; } if (r(p.geometry)) { const e2 = (_a = p.geometry.spatialReference) != null ? _a : u2; p.geometry = g(g2(p.geometry, e2), e2, u2); } c3.push(p), s3.push(f2(p.attributes[l])); } } d.addMany(tt([], c3, i3, o2, n, l)); } _applyUpdateEdits({ updateResults: e }, t) { var _a; const { geometryType: s3, hasM: i3, hasZ: n, objectIdField: o2, spatialReference: l, featureStore: u2 } = this._queryEngine; for (const d of t) { const { attributes: t2, geometry: p } = d, h = t2 && t2[o2]; if (null == h) { e.push(a2(`Identifier field ${o2} missing`)); continue; } if (!u2.has(h)) { e.push(a2(`Feature with object id ${h} missing`)); continue; } const m2 = ot(u2.getFeature(h), s3, n, i3); if (r(p)) { if (s3 !== c2(p)) { e.push(a2("Incorrect geometry type.")); continue; } const t3 = (_a = p.spatialReference) != null ? _a : l; m2.geometry = g(g2(p, t3), t3, l); } if (t2) { const s4 = m(this._fieldsIndex, m2.attributes, t2); if (s4) { e.push(s4); continue; } } u2.add(X(m2, s3, n, i3, o2)), e.push(f2(h)); } } _createObjectIdGenerator(e, t) { const s3 = e.fieldsIndex.get(e.objectIdField); if ("esriFieldTypeString" === s3.type) return () => s3.name + "-" + Date.now().toString(16); let i3 = Number.NEGATIVE_INFINITY; for (const r3 of t) r3.objectId && (i3 = Math.max(i3, r3.objectId)); return i3 = Math.max(0, i3) + 1, () => i3++; } _assignObjectId(e, t, s3 = false) { const i3 = this._queryEngine.objectIdField; e[i3] = s3 && i3 in t ? t[i3] : 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-BYIRP3JE.js.map