import { isLegacyDescriptor } from "./descriptors";
import {
  introspectRichTextData,
  Targets
} from "@makeswift/controls";
import {
  getLinkPropControllerPageIds,
  getResponsiveColorPropControllerDataSwatchIds,
  getShadowsPropControllerDataSwatchIds,
  Types as PropControllerTypes,
  getBorderPropControllerDataSwatchIds,
  getTablePropControllerDataTableIds,
  getNavigationLinksPropControllerPageIds,
  getNavigationLinksPropControllerSwatchIds,
  getElementIDPropControllerDataElementID,
  getGridPropControllerElementChildren,
  getImagePropControllerFileIds,
  getImagesPropControllerFileIds,
  getBackgroundsPropControllerFileIds,
  getBackgroundsPropControllerSwatchIds
} from "@makeswift/prop-controllers";
import { DELETED_PROP_CONTROLLER_TYPES } from "./deleted";
function getElementChildren(descriptor, prop) {
  if (prop == null)
    return [];
  if (!isLegacyDescriptor(descriptor)) {
    return descriptor.introspect(prop, Targets.ChildrenElement);
  }
  switch (descriptor.type) {
    case PropControllerTypes.Grid:
      return getGridPropControllerElementChildren(prop);
    default:
      return [];
  }
}
function getElementId(descriptor, prop) {
  if (prop == null)
    return null;
  if (!isLegacyDescriptor(descriptor)) {
    return null;
  }
  switch (descriptor.type) {
    case PropControllerTypes.ElementID:
      return getElementIDPropControllerDataElementID(prop) ?? null;
    default:
      return null;
  }
}
function getSwatchIds(descriptor, prop) {
  if (prop == null)
    return [];
  if (!isLegacyDescriptor(descriptor)) {
    return descriptor.introspect(prop, Targets.Swatch);
  }
  switch (descriptor.type) {
    case PropControllerTypes.Backgrounds:
      return getBackgroundsPropControllerSwatchIds(prop);
    case PropControllerTypes.Border:
      return getBorderPropControllerDataSwatchIds(prop);
    case PropControllerTypes.NavigationLinks: {
      return getNavigationLinksPropControllerSwatchIds(prop);
    }
    case PropControllerTypes.ResponsiveColor:
      return getResponsiveColorPropControllerDataSwatchIds(prop);
    case PropControllerTypes.Shadows:
      return getShadowsPropControllerDataSwatchIds(prop);
    case DELETED_PROP_CONTROLLER_TYPES.RichText: {
      return introspectRichTextData(prop, Targets.Swatch);
    }
    default:
      return [];
  }
}
function getFileIds(descriptor, prop) {
  if (prop == null)
    return [];
  if (!isLegacyDescriptor(descriptor)) {
    return descriptor.introspect(prop, Targets.File);
  }
  switch (descriptor.type) {
    case PropControllerTypes.Backgrounds:
      return getBackgroundsPropControllerFileIds(prop);
    case PropControllerTypes.Image: {
      return getImagePropControllerFileIds(prop);
    }
    case PropControllerTypes.Images: {
      return getImagesPropControllerFileIds(prop);
    }
    default:
      return [];
  }
}
function getTypographyIds(descriptor, prop) {
  if (prop == null)
    return [];
  if (!isLegacyDescriptor(descriptor)) {
    return descriptor.introspect(prop, Targets.Typography);
  }
  switch (descriptor.type) {
    case DELETED_PROP_CONTROLLER_TYPES.RichText: {
      return introspectRichTextData(prop, Targets.Typography);
    }
    default:
      return [];
  }
}
function getTableIds(descriptor, prop) {
  if (prop == null)
    return [];
  if (!isLegacyDescriptor(descriptor)) {
    return descriptor.introspect(prop, Targets.Table);
  }
  switch (descriptor.type) {
    case PropControllerTypes.Table: {
      return getTablePropControllerDataTableIds(prop);
    }
    default:
      return [];
  }
}
function getPageIds(descriptor, prop) {
  if (prop == null)
    return [];
  if (!isLegacyDescriptor(descriptor)) {
    return descriptor.introspect(prop, Targets.Page);
  }
  switch (descriptor.type) {
    case PropControllerTypes.Link: {
      return getLinkPropControllerPageIds(prop);
    }
    case PropControllerTypes.NavigationLinks: {
      return getNavigationLinksPropControllerPageIds(prop);
    }
    case DELETED_PROP_CONTROLLER_TYPES.RichText: {
      return introspectRichTextData(prop, Targets.Page);
    }
    default:
      return [];
  }
}
export {
  getElementChildren,
  getElementId,
  getFileIds,
  getPageIds,
  getSwatchIds,
  getTableIds,
  getTypographyIds
};
//# sourceMappingURL=introspection.js.map