{"version":3,"sources":["node_modules/@arcgis/core/rest/query/operations/query.js"],"sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.31/esri/copyright.txt for details.\n*/\nimport t from \"../../../request.js\";\nimport { urlToObject as e, join as n } from \"../../../core/urlUtils.js\";\nimport { getJsonType as r } from \"../../../geometry/support/jsonUtils.js\";\nimport { normalizeCentralMeridian as i } from \"../../../geometry/support/normalizeUtils.js\";\nimport { srToRESTValue as a } from \"../../../geometry/support/spatialReferenceUtils.js\";\nimport { mapParameters as o } from \"../../operations/urlUtils.js\";\nimport { parsePBFFeatureQuery as u } from \"./pbfQueryUtils.js\";\nimport { applyFeatureSetZUnitScaling as l } from \"./queryZScale.js\";\nconst s = \"Layer does not support extent calculation.\";\nfunction m(t, e) {\n if (e && \"extent\" === t.type) return `${t.xmin},${t.ymin},${t.xmax},${t.ymax}`;\n if (e && \"point\" === t.type) return `${t.x},${t.y}`;\n const n = t.toJSON();\n return delete n.spatialReference, JSON.stringify(n);\n}\nfunction y(t, e) {\n const n = t.geometry,\n i = t.toJSON();\n delete i.compactGeometryEnabled, delete i.defaultSpatialReferenceEnabled;\n const o = i;\n let u, l, s;\n if (null != n && (l = n.spatialReference, s = a(l), o.geometryType = r(n), o.geometry = m(n, t.compactGeometryEnabled), o.inSR = s), i.groupByFieldsForStatistics && (o.groupByFieldsForStatistics = i.groupByFieldsForStatistics.join(\",\")), i.objectIds && (o.objectIds = i.objectIds.join(\",\")), i.orderByFields && (o.orderByFields = i.orderByFields.join(\",\")), !i.outFields || !i.returnDistinctValues && (e?.returnCountOnly || e?.returnExtentOnly || e?.returnIdsOnly) ? delete o.outFields : i.outFields.includes(\"*\") ? o.outFields = \"*\" : o.outFields = i.outFields.join(\",\"), i.outSR ? (o.outSR = a(i.outSR), u = t.outSpatialReference) : n && (i.returnGeometry || i.returnCentroid) && (o.outSR = o.inSR, u = l), i.returnGeometry && delete i.returnGeometry, i.outStatistics && (o.outStatistics = JSON.stringify(i.outStatistics)), i.fullText && (o.fullText = JSON.stringify(i.fullText)), i.pixelSize && (o.pixelSize = JSON.stringify(i.pixelSize)), i.quantizationParameters && (t.defaultSpatialReferenceEnabled && null != l && null != t.quantizationParameters?.extent && l.equals(t.quantizationParameters.extent.spatialReference) && delete i.quantizationParameters.extent.spatialReference, o.quantizationParameters = JSON.stringify(i.quantizationParameters)), i.parameterValues && (o.parameterValues = JSON.stringify(i.parameterValues)), i.rangeValues && (o.rangeValues = JSON.stringify(i.rangeValues)), i.dynamicDataSource && (o.layer = JSON.stringify({\n source: i.dynamicDataSource\n }), delete i.dynamicDataSource), i.timeExtent) {\n const t = i.timeExtent,\n {\n start: e,\n end: n\n } = t;\n null == e && null == n || (o.time = e === n ? e : `${e ?? \"null\"},${n ?? \"null\"}`), delete i.timeExtent;\n }\n return t.defaultSpatialReferenceEnabled && null != l && null != u && l.equals(u) && (o.defaultSR = o.inSR, delete o.inSR, delete o.outSR), o;\n}\nasync function c(t, e, n, r) {\n const i = null != e.timeExtent && e.timeExtent.isEmpty ? {\n data: {\n features: []\n }\n } : await E(t, e, \"json\", r);\n return l(e, n, i.data), i;\n}\nasync function f(t, e, n, r) {\n if (null != e.timeExtent && e.timeExtent.isEmpty) return {\n data: n.createFeatureResult()\n };\n const i = await d(t, e, r),\n a = i;\n return a.data = u(i.data, n), a;\n}\nfunction d(t, e, n) {\n return E(t, e, \"pbf\", n);\n}\nfunction p(t, e, n) {\n return null != e.timeExtent && e.timeExtent.isEmpty ? Promise.resolve({\n data: {\n objectIds: []\n }\n }) : E(t, e, \"json\", n, {\n returnIdsOnly: !0\n });\n}\nfunction S(t, e, n) {\n return null != e.timeExtent && e.timeExtent.isEmpty ? Promise.resolve({\n data: {\n count: 0\n }\n }) : E(t, e, \"json\", n, {\n returnIdsOnly: !0,\n returnCountOnly: !0\n });\n}\nasync function x(t, e, n) {\n if (null != e.timeExtent && e.timeExtent.isEmpty) return {\n data: {\n count: 0,\n extent: null\n }\n };\n const r = await E(t, e, \"json\", n, {\n returnExtentOnly: !0,\n returnCountOnly: !0\n }),\n i = r.data;\n if (i.hasOwnProperty(\"extent\")) return r;\n if (i.features) throw new Error(s);\n if (i.hasOwnProperty(\"count\")) throw new Error(s);\n return r;\n}\nasync function E(r, a, u, l = {}, s = {}) {\n const m = \"string\" == typeof r ? e(r) : r,\n c = a.geometry ? [a.geometry] : [],\n f = await i(c, null, {\n signal: l.signal\n }),\n d = f?.[0];\n null != d && ((a = a.clone()).geometry = d);\n const p = o({\n ...m.query,\n f: u,\n ...s,\n ...y(a, s)\n });\n return t(n(m.path, g(a, s) ? \"query3d\" : \"query\"), {\n ...l,\n responseType: \"pbf\" === u ? \"array-buffer\" : \"json\",\n query: {\n ...p,\n ...l.query\n }\n });\n}\nfunction g(t, e) {\n return null != t.formatOf3DObjects && !(e.returnCountOnly || e.returnExtentOnly || e.returnIdsOnly);\n}\nexport { m as encodeGeometry, c as executeQuery, S as executeQueryForCount, x as executeQueryForExtent, p as executeQueryForIds, f as executeQueryPBF, d as executeQueryPBFBuffer, y as queryToQueryStringParameters, E as runQuery };"],"mappings":"6XAYA,IAAMA,EAAI,6CACV,SAASC,EAAEC,EAAGC,EAAG,CACf,GAAIA,GAAkBD,EAAE,OAAf,SAAqB,MAAO,GAAGA,EAAE,IAAI,IAAIA,EAAE,IAAI,IAAIA,EAAE,IAAI,IAAIA,EAAE,IAAI,GAC5E,GAAIC,GAAiBD,EAAE,OAAd,QAAoB,MAAO,GAAGA,EAAE,CAAC,IAAIA,EAAE,CAAC,GACjD,IAAME,EAAIF,EAAE,OAAO,EACnB,OAAO,OAAOE,EAAE,iBAAkB,KAAK,UAAUA,CAAC,CACpD,CACA,SAASC,EAAEH,EAAGC,EAAG,CACf,IAAMC,EAAIF,EAAE,SACVI,EAAIJ,EAAE,OAAO,EACf,OAAOI,EAAE,uBAAwB,OAAOA,EAAE,+BAC1C,IAAMC,EAAID,EACNE,EAAGC,EAAGT,EACV,GAAYI,GAA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EAAAD,EAAA,GACP,EAAE,OADK,CAEV,EAAGjB,IACAR,GACAK,EAAEY,EAAGjB,CAAC,EACV,EACD,OAAO2B,EAAEC,EAAE,EAAE,KAAMC,EAAEZ,EAAGjB,CAAC,EAAI,UAAY,OAAO,EAAG0B,EAAAD,EAAA,GAC9ChB,GAD8C,CAEjD,aAAwBD,IAAV,MAAc,eAAiB,OAC7C,MAAOiB,IAAA,GACFd,GACAF,EAAE,MAET,EAAC,CACH,GACA,SAASoB,EAAE3B,EAAGC,EAAG,CACf,OAAeD,EAAE,mBAAV,MAA+B,EAAEC,EAAE,iBAAmBA,EAAE,kBAAoBA,EAAE,cACvF","names":["s","m","t","e","n","y","i","o","u","l","c","p","r","__async","E","f","d","a","S","x","_0","_1","_2","I","R","__spreadValues","__spreadProps","U","V","g"],"x_google_ignoreList":[0]}