123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- import {
- _,
- x
- } from "./chunk-7O56JPWQ.js";
- import {
- L,
- S,
- m
- } from "./chunk-PIGRDDRG.js";
- import {
- B
- } from "./chunk-WZQZRKNH.js";
- import {
- s as s3
- } from "./chunk-LRDX4TO7.js";
- import "./chunk-UXF37FQ4.js";
- import "./chunk-ZOEK6QHJ.js";
- import "./chunk-2Z6LERTI.js";
- import "./chunk-OWVBLVP3.js";
- import "./chunk-XH7RUGVZ.js";
- import "./chunk-PDKDCAAD.js";
- import "./chunk-ECW2QABR.js";
- import "./chunk-GCDJLKH4.js";
- import "./chunk-MRJEICT6.js";
- import "./chunk-Y3WMVFTW.js";
- import "./chunk-SAS7RONY.js";
- import "./chunk-WSRBH7BF.js";
- import "./chunk-IHXECKQQ.js";
- import "./chunk-ULGDPLM2.js";
- import {
- s,
- s3 as s2
- } from "./chunk-EMJ4ZSM2.js";
- import "./chunk-IKP3YN53.js";
- import "./chunk-GZT4BVFP.js";
- import "./chunk-A5ICIBVI.js";
- // node_modules/@arcgis/core/layers/support/labelFormatUtils.js
- var s4 = s.getLogger("esri.layers.support.labelFormatUtils");
- var c = { type: "simple", evaluate: () => null };
- var f = { getAttribute: (e, r) => e.field(r) };
- async function p(r, t, a) {
- if (!r || !r.symbol)
- return c;
- const n = r.where, o = x(r), p2 = n ? await import("./WhereClause-3WNNGKYX.js") : null;
- let m2;
- if (o.type === "arcade") {
- const r2 = await s3(o.expression, a, t);
- m2 = { type: "arcade", evaluate(t2) {
- try {
- const e = r2.evaluate({ $feature: "attributes" in t2 ? r2.repurposeFeature(t2) : t2 });
- if (e != null)
- return e.toString();
- } catch (a2) {
- s4.error(new s2("arcade-expression-error", "Encountered an error when evaluating label expression for feature", { feature: t2, expression: o }));
- }
- return null;
- }, needsHydrationToEvaluate: () => _(o.expression) == null };
- } else
- m2 = { type: "simple", evaluate: (e) => o.expression.replace(/{[^}]*}/g, (r2) => {
- const a2 = r2.slice(1, -1), n2 = t.get(a2);
- if (!n2)
- return r2;
- let o2 = null;
- if ("attributes" in e) {
- e && e.attributes && (o2 = e.attributes[n2.name]);
- } else
- o2 = e.field(n2.name);
- return o2 == null ? "" : d(o2, n2);
- }) };
- if (n) {
- let r2;
- try {
- r2 = p2.WhereClause.create(n, t);
- } catch (g) {
- return s4.error(new s2("bad-where-clause", "Encountered an error when evaluating where clause, ignoring", { where: n, error: g })), c;
- }
- const a2 = m2.evaluate;
- m2.evaluate = (t2) => {
- const o2 = "attributes" in t2 ? void 0 : f;
- try {
- if (r2.testFeature(t2, o2))
- return a2(t2);
- } catch (g) {
- s4.error(new s2("bad-where-clause", "Encountered an error when evaluating where clause for feature", { where: n, feature: t2, error: g }));
- }
- return null;
- };
- }
- return m2;
- }
- function d(e, r) {
- if (e == null)
- return "";
- const l = r.domain;
- if (l) {
- if (l.type === "codedValue" || l.type === "coded-value") {
- const r2 = e;
- for (const e2 of l.codedValues)
- if (e2.code === r2)
- return e2.name;
- } else if (l.type === "range") {
- const r2 = +e, t = "range" in l ? l.range[0] : l.minValue, a = "range" in l ? l.range[1] : l.maxValue;
- if (t <= r2 && r2 <= a)
- return l.name;
- }
- }
- let i = e;
- return r.type === "date" || r.type === "esriFieldTypeDate" ? i = L(i, S("short-date")) : B(r) && (i = m(+i)), i || "";
- }
- export {
- p as createLabelFunction,
- d as formatField
- };
- //# sourceMappingURL=labelFormatUtils-UVCDII77.js.map
|