/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
const l = {
  hideChildren: "hide-children"
}, b = ["label", "description", "metadata"], g = 10, h = 2;
function m({
  exclusive: e,
  visible: t,
  visibilityAppearance: i
}) {
  const r = i === "checkbox";
  return t ? e ? "circle-f" : r ? "check-square-f" : "view-visible" : e ? "circle" : r ? "square" : "view-hide";
}
function L({
  connectionStatus: e,
  publishing: t
}) {
  return e ? e === "connected" ? "beacon" : "offline" : t ? "square" : "bullet-point";
}
function v(e) {
  return e?.listMode === l.hideChildren;
}
function S(e) {
  e?.removeMany(e.filter((t) => t?.destroyed));
}
function u(e) {
  if (!(!e || "type" in e && e.type === "wmts"))
    return "sublayers" in e ? "sublayers" : "layers" in e ? "layers" : void 0;
}
function C(e, t, i) {
  e && (e.filterPredicate = t ? (r) => {
    const n = p(r, i);
    return n ? t(n) : !1;
  } : void 0);
}
function x(e) {
  const t = (e?.layer && d(e.layer) ? e.layer.layer : void 0) ?? e?.layer;
  return t ? t.type === "catalog" ? !1 : f(t) ?? !0 : !1;
}
function c(e, t) {
  e?.sort((i, r) => {
    const n = "uid" in i && i.uid ? t.indexOf(i.uid) : -1, a = "uid" in r && r.uid ? t.indexOf(r.uid) : -1;
    return n > a ? -1 : n < a ? 1 : 0;
  });
}
function I(e, t) {
  const i = e?.layer;
  if (!i)
    return;
  const r = u(i);
  if (!r)
    return;
  let n;
  r === "layers" && "layers" in i ? n = i.layers : r === "sublayers" && "sublayers" in i && (n = i.sublayers), c(n, t);
}
function d(e) {
  return e != null && "layer" in e && e.layer != null;
}
function f(e) {
  const t = y(e);
  return t != null && "supportsDynamicLayers" in t ? t.supportsDynamicLayers : void 0;
}
function y(e) {
  return e && "capabilities" in e && e.capabilities != null && "exportMap" in e.capabilities ? e.capabilities.exportMap : void 0;
}
function p(e, t) {
  if (e?.tagName.toLowerCase() === "calcite-list-item")
    return e.value;
  const i = e?.getAttribute("data-item") ?? e?.querySelector("calcite-list-item")?.getAttribute("data-item");
  return i && t ? t.find((r) => r.uid === i) ?? null : null;
}
function N(e) {
  return e?.getAttribute("data-layer-type") ?? null;
}
function O(e) {
  const { children: t, error: i } = e, r = "incompatible" in e ? e.incompatible : !1;
  return !!t?.filter((n) => !n.hidden).length && !i && !r;
}
function D(e) {
  for (const t of e)
    for (const i of t)
      if (i.type === "button" || i.type === "toggle")
        return i;
}
function M(e, t) {
  const i = e.parent, r = e.layer;
  if (r?.type !== "map-image" || !r.sourceJSON || !i)
    return !1;
  const n = r.sourceJSON.layers;
  if (!n)
    return !1;
  const a = n.find((s) => e.id === s.id), o = t === "footprints" ? "Feature Layer" : "Catalog Dynamic Group Layer";
  return a?.type !== o ? !1 : n.find((s) => s.id === i.id)?.type === "Catalog Layer";
}
export {
  N as a,
  g as b,
  c,
  I as d,
  b as e,
  L as f,
  p as g,
  m as h,
  d as i,
  M as j,
  v as k,
  O as l,
  h as m,
  x as n,
  D as o,
  S as r,
  C as s
};
