chunk-WGHU7NSM.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. import {
  2. J
  3. } from "./chunk-PLCWBBQ4.js";
  4. import {
  5. De,
  6. I,
  7. Z,
  8. _,
  9. e as e2,
  10. t,
  11. t2,
  12. te,
  13. w as w2,
  14. z
  15. } from "./chunk-FT2BCPUP.js";
  16. import {
  17. rt
  18. } from "./chunk-JKFWEHNK.js";
  19. import {
  20. v
  21. } from "./chunk-RMDDCMKS.js";
  22. import {
  23. p,
  24. w
  25. } from "./chunk-6T6G6LCQ.js";
  26. import {
  27. e,
  28. r
  29. } from "./chunk-YXWMMD76.js";
  30. // node_modules/@arcgis/core/arcade/Feature.js
  31. var g = class {
  32. constructor() {
  33. this.arcadeDeclaredClass = "esri.arcade.Feature", this._optimizedGeomDefinition = null, this._geometry = null, this.attributes = null, this._layer = null, this._datesfixed = true, this.immutable = true, this._datefields = null, this.immutable = true;
  34. }
  35. static createFromGraphic(t4) {
  36. const e3 = new g();
  37. return e3._geometry = r(t4.geometry) ? t4.geometry : null, void 0 === t4.attributes || null === t4.attributes ? e3.attributes = {} : e3.attributes = t4.attributes, t4._sourceLayer ? (e3._layer = t4._sourceLayer, e3._datesfixed = false) : t4._layer ? (e3._layer = t4._layer, e3._datesfixed = false) : t4.layer && "fields" in t4.layer ? (e3._layer = t4.layer, e3._datesfixed = false) : t4.sourceLayer && "fields" in t4.sourceLayer && (e3._layer = t4.sourceLayer, e3._datesfixed = false), e3;
  38. }
  39. static createFromArcadeFeature(t4) {
  40. const e3 = new g();
  41. return e3._datesfixed = t4._datesfixed, e3.attributes = t4.attributes, e3._geometry = t4._geometry, e3._optimizedGeomDefinition = t4._optimizedGeomDefinition, t4._layer && (e3._layer = t4._layer), e3;
  42. }
  43. static createFromOptimisedFeature(t4, e3, i) {
  44. const s = new g();
  45. return s._geometry = t4.geometry ? { geometry: t4.geometry } : null, s._optimizedGeomDefinition = i, s.attributes = t4.attributes || {}, s._layer = e3, s._datesfixed = false, s;
  46. }
  47. static createFromArcadeDictionary(e3) {
  48. const i = new g();
  49. return i.attributes = e3.field("attributes"), null !== i.attributes && i.attributes instanceof J ? (i.attributes = i.attributes.attributes, null === i.attributes && (i.attributes = {})) : i.attributes = {}, i._geometry = e3.field("geometry"), null !== i._geometry && (i._geometry instanceof J ? i._geometry = g.parseGeometryFromDictionary(i._geometry) : i._geometry instanceof p || (i._geometry = null)), i;
  50. }
  51. static createFromGraphicLikeObject(t4, e3, i = null) {
  52. const s = new g();
  53. return null === e3 && (e3 = {}), s.attributes = e3, s._geometry = r(t4) ? t4 : null, s._layer = i, s._layer && (s._datesfixed = false), s;
  54. }
  55. repurposeFromGraphicLikeObject(t4, e3, i = null) {
  56. null === e3 && (e3 = {}), this.attributes = e3, this._geometry = t4 || null, this._layer = i, this._layer ? this._datesfixed = false : this._datesfixed = true;
  57. }
  58. castToText(t4 = false) {
  59. let o = "";
  60. false === this._datesfixed && this._fixDates();
  61. for (const n in this.attributes) {
  62. "" !== o && (o += ",");
  63. const l = this.attributes[n];
  64. null == l ? o += JSON.stringify(n) + ":null" : _(l) || Z(l) || w2(l) ? o += JSON.stringify(n) + ":" + JSON.stringify(l) : l instanceof p ? o += JSON.stringify(n) + ":" + te(l) : l instanceof t2 || l instanceof Array ? o += JSON.stringify(n) + ":" + te(l, null, t4) : l instanceof Date ? o += t4 ? JSON.stringify(n) + ":" + JSON.stringify(l.getTime()) : JSON.stringify(n) + ":" + JSON.stringify(l) : null !== l && "object" == typeof l && void 0 !== l.castToText && (o += JSON.stringify(n) + ":" + l.castToText(t4));
  65. }
  66. return '{"geometry":' + (null === this.geometry() ? "null" : te(this.geometry())) + ',"attributes":{' + o + "}}";
  67. }
  68. _fixDates() {
  69. if (null !== this._datefields)
  70. return this._datefields.length > 0 && this._fixDateFields(this._datefields), void (this._datesfixed = true);
  71. const t4 = [], e3 = this._layer.fields;
  72. for (let i = 0; i < e3.length; i++) {
  73. const s = e3[i], r2 = s.type;
  74. "date" !== r2 && "esriFieldTypeDate" !== r2 || t4.push(s.name);
  75. }
  76. this._datefields = t4, t4.length > 0 && this._fixDateFields(t4), this._datesfixed = true;
  77. }
  78. _fixDateFields(t4) {
  79. this.attributes = { ...this.attributes };
  80. for (let e3 = 0; e3 < t4.length; e3++) {
  81. let i = this.attributes[t4[e3]];
  82. if (null === i)
  83. ;
  84. else if (void 0 === i) {
  85. for (const s in this.attributes)
  86. if (s.toLowerCase() === t4[e3].toLowerCase()) {
  87. i = this.attributes[s], null !== i && (i instanceof Date || (this.attributes[s] = new Date(i)));
  88. break;
  89. }
  90. } else
  91. i instanceof Date || (this.attributes[t4[e3]] = new Date(i));
  92. }
  93. }
  94. geometry() {
  95. return null === this._geometry || this._geometry instanceof p || (this._optimizedGeomDefinition ? (this._geometry = e(v(rt(this._geometry, this._optimizedGeomDefinition.geometryType, this._optimizedGeomDefinition.hasZ, this._optimizedGeomDefinition.hasM))), this._geometry.spatialReference = this._optimizedGeomDefinition.spatialReference) : this._geometry = e(v(this._geometry))), this._geometry;
  96. }
  97. field(t4) {
  98. false === this._datesfixed && this._fixDates();
  99. const e3 = this.attributes[t4];
  100. if (void 0 !== e3)
  101. return e3;
  102. const i = t4.toLowerCase();
  103. for (const s in this.attributes)
  104. if (s.toLowerCase() === i)
  105. return this.attributes[s];
  106. if (this._hasFieldDefinition(i))
  107. return null;
  108. throw new t(null, e2.FieldNotFound, null, { key: t4 });
  109. }
  110. _hasFieldDefinition(t4) {
  111. if (null === this._layer)
  112. return false;
  113. for (let e3 = 0; e3 < this._layer.fields.length; e3++) {
  114. if (this._layer.fields[e3].name.toLowerCase() === t4)
  115. return true;
  116. }
  117. return false;
  118. }
  119. setField(t4, e3) {
  120. if (this.immutable)
  121. throw new t(null, e2.Immutable, null);
  122. if (false === I(e3))
  123. throw new t(null, e2.TypeNotAllowedInFeature, null);
  124. const i = t4.toLowerCase();
  125. if (void 0 === this.attributes[t4]) {
  126. for (const t5 in this.attributes)
  127. if (t5.toLowerCase() === i)
  128. return void (this.attributes[t5] = e3);
  129. this.attributes[t4] = e3;
  130. } else
  131. this.attributes[t4] = e3;
  132. }
  133. hasField(t4) {
  134. const e3 = t4.toLowerCase();
  135. if (void 0 !== this.attributes[t4])
  136. return true;
  137. for (const i in this.attributes)
  138. if (i.toLowerCase() === e3)
  139. return true;
  140. return !!this._hasFieldDefinition(e3);
  141. }
  142. keys() {
  143. let t4 = [];
  144. const e3 = {};
  145. for (const i in this.attributes)
  146. t4.push(i), e3[i.toLowerCase()] = 1;
  147. if (null !== this._layer)
  148. for (let i = 0; i < this._layer.fields.length; i++) {
  149. const s = this._layer.fields[i];
  150. 1 !== e3[s.name.toLowerCase()] && t4.push(s.name);
  151. }
  152. return t4 = t4.sort(), t4;
  153. }
  154. static parseGeometryFromDictionary(t4) {
  155. const e3 = g._convertDictionaryToJson(t4, true);
  156. return void 0 !== e3.hasm && (e3.hasM = e3.hasm, delete e3.hasm), void 0 !== e3.hasz && (e3.hasZ = e3.hasz, delete e3.hasz), void 0 !== e3.spatialreference && (e3.spatialReference = e3.spatialreference, delete e3.spatialreference), void 0 !== e3.rings && (e3.rings = this._fixPathArrays(e3.rings, true === e3.hasZ, true === e3.hasZ)), void 0 !== e3.paths && (e3.paths = this._fixPathArrays(e3.paths, true === e3.hasZ, true === e3.hasM)), void 0 !== e3.points && (e3.points = this._fixPointArrays(e3.points, true === e3.hasZ, true === e3.hasM)), v(e3);
  157. }
  158. static _fixPathArrays(t4, i, s) {
  159. const r2 = [];
  160. if (t4 instanceof Array)
  161. for (let e3 = 0; e3 < t4.length; e3++)
  162. r2.push(this._fixPointArrays(t4[e3], i, s));
  163. else if (t4 instanceof t2)
  164. for (let e3 = 0; e3 < t4.length(); e3++)
  165. r2.push(this._fixPointArrays(t4.get(e3), i, s));
  166. return r2;
  167. }
  168. static _fixPointArrays(t4, i, s) {
  169. const r2 = [];
  170. if (t4 instanceof Array)
  171. for (let a = 0; a < t4.length; a++) {
  172. const o = t4[a];
  173. o instanceof w ? i && s ? r2.push([o.x, o.y, o.z, o.m]) : i ? r2.push([o.x, o.y, o.z]) : s ? r2.push([o.x, o.y, o.m]) : r2.push([o.x, o.y]) : o instanceof t2 ? r2.push(o.toArray()) : r2.push(o);
  174. }
  175. else if (t4 instanceof t2)
  176. for (let a = 0; a < t4.length(); a++) {
  177. const o = t4.get(a);
  178. o instanceof w ? i && s ? r2.push([o.x, o.y, o.z, o.m]) : i ? r2.push([o.x, o.y, o.z]) : s ? r2.push([o.x, o.y, o.m]) : r2.push([o.x, o.y]) : o instanceof t2 ? r2.push(o.toArray()) : r2.push(o);
  179. }
  180. return r2;
  181. }
  182. static _convertDictionaryToJson(e3, i = false) {
  183. const s = {};
  184. for (const r2 in e3.attributes) {
  185. let a = e3.attributes[r2];
  186. a instanceof J && (a = g._convertDictionaryToJson(a)), i ? s[r2.toLowerCase()] = a : s[r2] = a;
  187. }
  188. return s;
  189. }
  190. static parseAttributesFromDictionary(t4) {
  191. const e3 = {};
  192. for (const i in t4.attributes) {
  193. const s = t4.attributes[i];
  194. if (!I(s))
  195. throw new t(null, e2.InvalidParameter, null);
  196. e3[i] = s;
  197. }
  198. return e3;
  199. }
  200. static fromJson(t4) {
  201. let e3 = null;
  202. null !== t4.geometry && void 0 !== t4.geometry && (e3 = v(t4.geometry));
  203. const a = {};
  204. if (null !== t4.attributes && void 0 !== t4.attributes)
  205. for (const o in t4.attributes) {
  206. const e4 = t4.attributes[o];
  207. if (null === e4)
  208. a[o] = e4;
  209. else {
  210. if (!(w2(e4) || Z(e4) || _(e4) || z(e4)))
  211. throw new t(null, e2.InvalidParameter, null);
  212. a[o] = e4;
  213. }
  214. }
  215. return g.createFromGraphicLikeObject(e3, a, null);
  216. }
  217. fullSchema() {
  218. return this._layer;
  219. }
  220. gdbVersion() {
  221. if (null === this._layer)
  222. return "";
  223. const t4 = this._layer.gdbVersion;
  224. return void 0 === t4 ? "" : "" === t4 && this._layer.capabilities && this._layer.capabilities.isVersioned ? "SDE.DEFAULT" : t4;
  225. }
  226. castAsJson(t4) {
  227. const e3 = { attributes: {}, geometry: true === (t4 == null ? void 0 : t4.keepGeometryType) ? this.geometry() : this.geometry().toJSON() };
  228. for (const i in this.attributes) {
  229. const s = this.attributes[i];
  230. void 0 !== s && (e3.attributes[i] = De(s, t4));
  231. }
  232. return e3;
  233. }
  234. async castAsJsonAsync(t4 = null, e3) {
  235. return this.castAsJson(e3);
  236. }
  237. };
  238. // node_modules/@arcgis/core/arcade/ArcadePortal.js
  239. var t3 = class extends J {
  240. constructor(s) {
  241. super(), this.declaredClass = "esri.arcade.Portal", this.immutable = false, this.setField("url", s), this.immutable = true;
  242. }
  243. };
  244. export {
  245. g,
  246. t3 as t
  247. };
  248. //# sourceMappingURL=chunk-WGHU7NSM.js.map