123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- import {
- De,
- F2 as F,
- I,
- K,
- Y,
- Z,
- _,
- ae,
- e,
- je,
- le,
- re,
- t,
- t2,
- te,
- w,
- z
- } from "./chunk-FT2BCPUP.js";
- import {
- p
- } from "./chunk-6T6G6LCQ.js";
- // node_modules/@arcgis/core/arcade/Dictionary.js
- function w2(t3, s = false) {
- if (null == t3)
- return null;
- if (Z(t3))
- return re(t3);
- if (_(t3))
- return le(t3);
- if (w(t3))
- return K(t3);
- if (z(t3))
- return ae(t3);
- if (Y(t3)) {
- const i2 = [];
- for (const e2 of t3)
- i2.push(w2(e2, s));
- return i2;
- }
- const i = new J();
- i.immutable = false;
- for (const e2 of Object.keys(t3)) {
- const n = t3[e2];
- void 0 !== n && i.setField(e2, w2(n, s));
- }
- return i.immutable = s, i;
- }
- var J = class {
- constructor(t3) {
- this.declaredClass = "esri.arcade.Dictionary", this.attributes = null, this.plain = false, this.immutable = true, this.attributes = t3 instanceof J ? t3.attributes : t3 != null ? t3 : {};
- }
- field(i) {
- const e2 = i.toLowerCase(), n = this.attributes[i];
- if (void 0 !== n)
- return n;
- for (const t3 in this.attributes)
- if (t3.toLowerCase() === e2)
- return this.attributes[t3];
- throw new t(null, e.FieldNotFound, null, { key: i });
- }
- setField(i, n) {
- if (this.immutable)
- throw new t(null, e.Immutable, null);
- if (F(n))
- throw new t(null, e.NoFunctionInDictionary, null);
- const r = i.toLowerCase();
- if (void 0 === this.attributes[i]) {
- for (const t3 in this.attributes)
- if (t3.toLowerCase() === r)
- return void (this.attributes[t3] = n);
- this.attributes[i] = n;
- } else
- this.attributes[i] = n;
- }
- hasField(t3) {
- const s = t3.toLowerCase();
- if (void 0 !== this.attributes[t3])
- return true;
- for (const i in this.attributes)
- if (i.toLowerCase() === s)
- return true;
- return false;
- }
- keys() {
- let t3 = [];
- for (const s in this.attributes)
- t3.push(s);
- return t3 = t3.sort(), t3;
- }
- castToText(t3 = false) {
- let s = "";
- for (const e2 in this.attributes) {
- "" !== s && (s += ",");
- const u = this.attributes[e2];
- 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));
- }
- return "{" + s + "}";
- }
- static convertObjectToArcadeDictionary(t3, s = true) {
- const i = new J();
- i.immutable = false;
- for (const e2 in t3) {
- const s2 = t3[e2];
- void 0 !== s2 && i.setField(e2.toString(), w2(s2));
- }
- return i.immutable = s, i;
- }
- static convertJsonToArcade(t3, s = false) {
- return w2(t3, s);
- }
- castAsJson(t3 = null) {
- const s = {};
- for (let i in this.attributes) {
- const e2 = this.attributes[i];
- void 0 !== e2 && ((t3 == null ? void 0 : t3.keyTranslate) && (i = t3.keyTranslate(i)), s[i] = De(e2, t3));
- }
- return s;
- }
- async castDictionaryValueAsJsonAsync(t3, s, i, e2 = null, n) {
- const r = await je(i, e2, n);
- return t3[s] = r, r;
- }
- async castAsJsonAsync(t3 = null, s = null) {
- const i = {}, e2 = [];
- for (let n in this.attributes) {
- const r = this.attributes[n];
- (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)));
- }
- return e2.length > 0 && await Promise.all(e2), i;
- }
- };
- export {
- J
- };
- //# sourceMappingURL=chunk-PLCWBBQ4.js.map
|