chunk-PLCWBBQ4.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. import {
  2. De,
  3. F2 as F,
  4. I,
  5. K,
  6. Y,
  7. Z,
  8. _,
  9. ae,
  10. e,
  11. je,
  12. le,
  13. re,
  14. t,
  15. t2,
  16. te,
  17. w,
  18. z
  19. } from "./chunk-FT2BCPUP.js";
  20. import {
  21. p
  22. } from "./chunk-6T6G6LCQ.js";
  23. // node_modules/@arcgis/core/arcade/Dictionary.js
  24. function w2(t3, s = false) {
  25. if (null == t3)
  26. return null;
  27. if (Z(t3))
  28. return re(t3);
  29. if (_(t3))
  30. return le(t3);
  31. if (w(t3))
  32. return K(t3);
  33. if (z(t3))
  34. return ae(t3);
  35. if (Y(t3)) {
  36. const i2 = [];
  37. for (const e2 of t3)
  38. i2.push(w2(e2, s));
  39. return i2;
  40. }
  41. const i = new J();
  42. i.immutable = false;
  43. for (const e2 of Object.keys(t3)) {
  44. const n = t3[e2];
  45. void 0 !== n && i.setField(e2, w2(n, s));
  46. }
  47. return i.immutable = s, i;
  48. }
  49. var J = class {
  50. constructor(t3) {
  51. this.declaredClass = "esri.arcade.Dictionary", this.attributes = null, this.plain = false, this.immutable = true, this.attributes = t3 instanceof J ? t3.attributes : t3 != null ? t3 : {};
  52. }
  53. field(i) {
  54. const e2 = i.toLowerCase(), n = this.attributes[i];
  55. if (void 0 !== n)
  56. return n;
  57. for (const t3 in this.attributes)
  58. if (t3.toLowerCase() === e2)
  59. return this.attributes[t3];
  60. throw new t(null, e.FieldNotFound, null, { key: i });
  61. }
  62. setField(i, n) {
  63. if (this.immutable)
  64. throw new t(null, e.Immutable, null);
  65. if (F(n))
  66. throw new t(null, e.NoFunctionInDictionary, null);
  67. const r = i.toLowerCase();
  68. if (void 0 === this.attributes[i]) {
  69. for (const t3 in this.attributes)
  70. if (t3.toLowerCase() === r)
  71. return void (this.attributes[t3] = n);
  72. this.attributes[i] = n;
  73. } else
  74. this.attributes[i] = n;
  75. }
  76. hasField(t3) {
  77. const s = t3.toLowerCase();
  78. if (void 0 !== this.attributes[t3])
  79. return true;
  80. for (const i in this.attributes)
  81. if (i.toLowerCase() === s)
  82. return true;
  83. return false;
  84. }
  85. keys() {
  86. let t3 = [];
  87. for (const s in this.attributes)
  88. t3.push(s);
  89. return t3 = t3.sort(), t3;
  90. }
  91. castToText(t3 = false) {
  92. let s = "";
  93. for (const e2 in this.attributes) {
  94. "" !== s && (s += ",");
  95. const u = this.attributes[e2];
  96. null == u ? s += JSON.stringify(e2) + ":null" : _(u) || Z(u) || w(u) ? s += JSON.stringify(e2) + ":" + JSON.stringify(u) : u instanceof p ? s += JSON.stringify(e2) + ":" + te(u) : u instanceof t2 || u instanceof Array ? s += JSON.stringify(e2) + ":" + te(u, null, t3) : u instanceof Date ? s += t3 ? JSON.stringify(e2) + ":" + JSON.stringify(u.getTime()) : JSON.stringify(e2) + ":" + JSON.stringify(u) : null !== u && "object" == typeof u && void 0 !== u.castToText && (s += JSON.stringify(e2) + ":" + u.castToText(t3));
  97. }
  98. return "{" + s + "}";
  99. }
  100. static convertObjectToArcadeDictionary(t3, s = true) {
  101. const i = new J();
  102. i.immutable = false;
  103. for (const e2 in t3) {
  104. const s2 = t3[e2];
  105. void 0 !== s2 && i.setField(e2.toString(), w2(s2));
  106. }
  107. return i.immutable = s, i;
  108. }
  109. static convertJsonToArcade(t3, s = false) {
  110. return w2(t3, s);
  111. }
  112. castAsJson(t3 = null) {
  113. const s = {};
  114. for (let i in this.attributes) {
  115. const e2 = this.attributes[i];
  116. void 0 !== e2 && ((t3 == null ? void 0 : t3.keyTranslate) && (i = t3.keyTranslate(i)), s[i] = De(e2, t3));
  117. }
  118. return s;
  119. }
  120. async castDictionaryValueAsJsonAsync(t3, s, i, e2 = null, n) {
  121. const r = await je(i, e2, n);
  122. return t3[s] = r, r;
  123. }
  124. async castAsJsonAsync(t3 = null, s = null) {
  125. const i = {}, e2 = [];
  126. for (let n in this.attributes) {
  127. const r = this.attributes[n];
  128. (s == null ? void 0 : s.keyTranslate) && (n = s.keyTranslate(n)), void 0 !== r && (I(r) || r instanceof p || r instanceof Date ? i[n] = De(r, s) : e2.push(this.castDictionaryValueAsJsonAsync(i, n, r, t3, s)));
  129. }
  130. return e2.length > 0 && await Promise.all(e2), i;
  131. }
  132. };
  133. export {
  134. J
  135. };
  136. //# sourceMappingURL=chunk-PLCWBBQ4.js.map