function createCodegenContext(ast, {
  mode = "function",
  prefixIdentifiers = mode === "module",
  sourceMap = false,
  filename = `template.vue.html`,
  scopeId = null,
  optimizeImports = false,
  runtimeGlobalName = `Vue`,
  runtimeModuleName = `vue`,
  ssrRuntimeModuleName = "vue/server-renderer",
  ssr = false,
  isTS = false,
  inSSR = false
}) {
  const context = {
    mode,
    prefixIdentifiers,
    sourceMap,
    filename,
    scopeId,
    optimizeImports,
    runtimeGlobalName,
    runtimeModuleName,
    ssrRuntimeModuleName,
    ssr,
    isTS,
    inSSR,
    source: ast.source,
    code: ``,
    column: 1,
    line: 1,
    offset: 0,
    indentLevel: 0,
    pure: false,
    map: void 0,
    helper(key) {
      return `_${helperNameMap[key]}`;
    },
    push(code, newlineIndex = -2 /* None */, node) {
      context.code += code;
      if (context.map) {
        if (node) {
          let name;
          if (node.type === 4 && !node.isStatic) {
            const content = node.content.replace(/^_ctx\./, "");
            if (content !== node.content && isSimpleIdentifier(content)) {
              name = content;
            }
          }
          addMapping(node.loc.start, name);
        }
        if (newlineIndex === -3 /* Unknown */) {
          advancePositionWithMutation(context, code);
        } else {
          context.offset += code.length;
          if (newlineIndex === -2 /* None */) {
            context.column += code.length;
          } else {
            if (newlineIndex === -1 /* End */) {
              newlineIndex = code.length - 1;
            }
            context.line++;
            context.column = code.length - newlineIndex;
          }
        }
        if (node && node.loc !== locStub) {
          addMapping(node.loc.end);
        }
      }
    },
    indent() {
      newline(++context.indentLevel);
    },
    deindent(withoutNewLine = false) {
      if (withoutNewLine) {
        --context.indentLevel;
      } else {
        newline(--context.indentLevel);
      }
    },
    newline() {
      newline(context.indentLevel);
    }
  };
  function newline(n) {
    context.push("\n" + `  `.repeat(n), 0 /* Start */);
  }
  function addMapping(loc, name = null) {
    const { _names, _mappings } = context.map;
    if (name !== null && !_names.has(name))
      _names.add(name);
    _mappings.add({
      originalLine: loc.line,
      originalColumn: loc.column - 1,
      // source-map column is 0 based
      generatedLine: context.line,
      generatedColumn: context.column - 1,
      source: filename,
      // @ts-expect-error it is possible to be null
      name
    });
  }
  if (sourceMap) {
    context.map = new SourceMapGenerator$6();
    context.map.setSourceContent(filename, context.source);
    context.map._sources.add(filename);
  }
  return context;
}
Returns the string representation of this source node along with a source
map.