chunk-R5LRKX5A.js 3.5 KB

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