text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.importCodePlugin = void 0;
  const createImportCodeBlockRule_1 = require("./createImportCodeBlockRule");
  const resolveImportCode_1 = require("./resolveImportCode");
  const importCodePlugin = (md, options = {}) => {
      // add import_code block rule
      md.block.ruler.before('fence', 'import_code', (0, createImportCodeBlockRule_1.createImportCodeBlockRule)(options), {
          alt: ['paragraph', 'reference', 'blockquote', 'list'],
      });
      // add import_code renderer rule
      md.renderer.rules.import_code = (tokens, idx, options, env, slf) => {
          const token = tokens[idx];
          // use imported code as token content
          const { importFilePath, importCode } = (0, resolveImportCode_1.resolveImportCode)(token.meta, env);
          token.content = importCode;
          // extract imported files to env
          if (importFilePath) {
              const importedFiles = env.importedFiles || (env.importedFiles = []);
              importedFiles.push(importFilePath);
          }
          // render the import_code token as a fence token
          return md.renderer.rules.fence(tokens, idx, options, env, slf);
      };
  };
  exports.importCodePlugin = importCodePlugin;
  