// Generated by ReScript, PLEASE EDIT WITH CARE


var disallowedIdentifiers = [
  "and",
  "as",
  "assert",
  "constraint",
  "else",
  "exception",
  "external",
  "false",
  "for",
  "if",
  "in",
  "include",
  "lazy",
  "let",
  "module",
  "mutable",
  "of",
  "open",
  "rec",
  "switch",
  "true",
  "try",
  "type",
  "when",
  "while",
  "with",
  "private"
];

var textRegexp = /[a-zA-Z_]/;

var legalIdentifierRegexp = /^[a-z][a-zA-Z0-9_]*$/;

function removeIllegalCharacters(input) {
  var result = "";
  for(var i = 0 ,i_finish = input.length; i < i_finish; ++i){
    var $$char = input.charAt(i);
    if (textRegexp.test($$char)) {
      result = result === "" ? $$char.toLowerCase() : result + $$char;
    } else if (textRegexp.test($$char) && result === "") {
      result = result + $$char.toLowerCase();
    }
    
  }
  return result;
}

function toReScriptSafeName(ident) {
  var isIllegalIdentifier = !legalIdentifierRegexp.test(ident) || disallowedIdentifiers.includes(ident);
  if (isIllegalIdentifier) {
    return {
            TAG: "NeedsAnnotation",
            actualName: ident,
            safeName: removeIllegalCharacters(ident)
          };
  } else {
    return {
            TAG: "Safe",
            _0: ident
          };
  }
}

export {
  toReScriptSafeName ,
}
/* No side effect */
