/* eslint-disable default-case */
import { RULESET } from 'stylis';

// A workaround to https://github.com/emotion-js/emotion/issues/2836
// to be able to use `:where` selector for styling.
export default function globalSelector(element) {
  switch (element.type) {
    case RULESET:
      element.props = element.props.map(value => {
        if (value.match(/(:where|:is)\(/)) {
          value = value.replace(/\.[^:]+(:where|:is)/, '$1');
          return value;
        }
        return value;
      });
  }
}