/* https://blog.csdn.net/weixin_48206767/article/details/124840766 */
@import "config";

/* BEM support Func
 -------------------------- */

// inspect Returns a string representation of $value
// @debug inspect("Helvetica"); unquote('"Helvetica"')
// @debug meta.inspect(10px 20px 30px); // unquote("10px 20px 30px")
// @debug meta.inspect(("width": 200px)); // unquote('("width": 200px)')
// @debug meta.inspect(null); // unquote("null")
// @debug meta.inspect("Helvetica"); // unquote('"Helvetica"')
// str-slice 从1开始数， scss的函数都是从1开始
@function selectorToString($selector) {
  $selector: inspect($selector);
  $selector: str-slice($selector, 2, -2);
  @return $selector;
}

// 判断选择器（.el-button__body--active） 是否包含 '--' m连接符
@function containsModifier($selector) {
  $selector: selectorToString($selector);

  @if str-index($selector, $modifier-separator) {
    @return true;
  } @else {
    @return false;
  }
}

// 判断选择器（.el-button__body.is-active） 是否包含 'is'
@function containWhenFlag($selector) {
  $selector: selectorToString($selector);

  @if str-index($selector, '.' + $state-prefix) {
    @return true;
  } @else {
    @return false;
  }
}

//  判断选择器（.el-button__body:before） 是否包含伪元素（如:hover）
@function containPseudoClass($selector) {
  $selector: selectorToString($selector);

  @if str-index($selector, ':') {
    @return true;
  } @else {
    @return false;
  }
}

// 判断以上三个内容
// hit：命中 nest:嵌套
@function hitAllSpecialNestRule($selector) {

  @return containsModifier($selector) or containWhenFlag($selector) or containPseudoClass($selector);
}
