/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
function a(e, n) {
  if (!e.map)
    return;
  const { map: t } = e;
  t.layers.includes(n) || (t.add(n), t.reorder(n, t.layers.length - 1));
}
function o(e) {
  return e != null && typeof e == "object" && "type" in e && e.type === "feature";
}
function s(e) {
  return o(e) && e?.type === "feature" && e.source?.type === "feature-layer";
}
function f(e) {
  return e != null && typeof e == "object" && "type" in e && e.type === "graphics";
}
function c(e) {
  return o(e) && s(e);
}
function p(e, n) {
  const t = n?.type === "subtype-sublayer" ? n.parent : n;
  return e.allLayerViews.find((r) => {
    const i = r.layer;
    return i === t || "sublayers" in i && i.sublayers != null && i.sublayers.includes(t);
  });
}
function u(e) {
  const n = e?.type;
  return n === "binning" || n === "cluster";
}
function d(e, n) {
  if (!c(e))
    return;
  const t = n?.graphic, r = e.featureReduction;
  if (t) {
    if (t.isAggregate) {
      const i = t.origin;
      return i && "featureReductionProvider" in i && r ? u(r) ? r : null : void 0;
    }
    return e;
  }
  return n?.checkFeatureReduction && r ? u(r) ? r : null : e;
}
export {
  a,
  p as f,
  d as g,
  f as i
};
